[thorstenp] fix unused variables

This commit is contained in:
Yann Leboulanger 2008-10-20 21:17:48 +00:00
parent 297a81325b
commit f801a50260
50 changed files with 215 additions and 270 deletions

View File

@ -294,7 +294,7 @@ class ChatControlBase(MessageControl):
if lang: if lang:
self.msg_textview.lang = lang self.msg_textview.lang = lang
spell.set_language(lang) spell.set_language(lang)
except (gobject.GError, RuntimeError), msg: except (gobject.GError, RuntimeError):
dialogs.AspellDictError(lang) dialogs.AspellDictError(lang)
self.conv_textview.tv.show() self.conv_textview.tv.show()
self._paint_banner() self._paint_banner()
@ -434,7 +434,6 @@ class ChatControlBase(MessageControl):
def show_emoticons_menu(self): def show_emoticons_menu(self):
if not gajim.config.get('emoticons_theme'): if not gajim.config.get('emoticons_theme'):
return return
msg_tv = self.msg_textview
def set_emoticons_menu_position(w, msg_tv = self.msg_textview): def set_emoticons_menu_position(w, msg_tv = self.msg_textview):
window = msg_tv.get_window(gtk.TEXT_WINDOW_WIDGET) window = msg_tv.get_window(gtk.TEXT_WINDOW_WIDGET)
# get the window position # get the window position
@ -448,7 +447,7 @@ class ChatControlBase(MessageControl):
cursor.x, cursor.y) cursor.x, cursor.y)
x = origin[0] + cursor[0] x = origin[0] + cursor[0]
y = origin[1] + size[1] y = origin[1] + size[1]
menu_width, menu_height = gajim.interface.emoticons_menu.size_request() menu_height = gajim.interface.emoticons_menu.size_request()[1]
#FIXME: get_line_count is not so good #FIXME: get_line_count is not so good
#get the iter of cursor, then tv.get_line_yrange #get the iter of cursor, then tv.get_line_yrange
# so we know in which y we are typing (not how many lines we have # so we know in which y we are typing (not how many lines we have
@ -1119,7 +1118,7 @@ class ChatControl(ChatControlBase):
if session: if session:
# Don't use previous session if we want to a specific resource # Don't use previous session if we want to a specific resource
# and it's not the same # and it's not the same
j, r = gajim.get_room_and_nick_from_fjid(str(session.jid)) r = gajim.get_room_and_nick_from_fjid(str(session.jid))[1]
if resource and resource != r: if resource and resource != r:
session = None session = None
@ -1425,7 +1424,6 @@ class ChatControl(ChatControlBase):
banner_name_label = self.xml.get_widget('banner_name_label') banner_name_label = self.xml.get_widget('banner_name_label')
banner_name_tooltip = gtk.Tooltips() banner_name_tooltip = gtk.Tooltips()
banner_eventbox = self.xml.get_widget('banner_eventbox')
name = contact.get_shown_name() name = contact.get_shown_name()
if self.resource: if self.resource:
@ -1827,7 +1825,6 @@ class ChatControl(ChatControlBase):
if contact is set to print_queue: it is incomming from queue if contact is set to print_queue: it is incomming from queue
if contact is not set: it's an incomming message''' if contact is not set: it's an incomming message'''
contact = self.contact contact = self.contact
jid = contact.jid
if frm == 'status': if frm == 'status':
if not gajim.config.get('print_status_in_chats'): if not gajim.config.get('print_status_in_chats'):
@ -2215,7 +2212,7 @@ class ChatControl(ChatControlBase):
def on_cancel(): def on_cancel():
on_no(self) on_no(self)
dialog = dialogs.ConfirmationDialog( dialogs.ConfirmationDialog(
# %s is being replaced in the code with JID # %s is being replaced in the code with JID
_('You just received a new message from "%s"') % self.contact.jid, _('You just received a new message from "%s"') % self.contact.jid,
_('If you close this tab and you have history disabled, '\ _('If you close this tab and you have history disabled, '\
@ -2306,7 +2303,6 @@ class ChatControl(ChatControlBase):
path = treeview.get_selection().get_selected_rows()[1][0] path = treeview.get_selection().get_selected_rows()[1][0]
iter = model.get_iter(path) iter = model.get_iter(path)
type = model[iter][2] type = model[iter][2]
account = model[iter][4].decode('utf-8')
if type != 'contact': # source is not a contact if type != 'contact': # source is not a contact
return return
dropped_jid = data.decode('utf-8') dropped_jid = data.decode('utf-8')

View File

@ -71,7 +71,7 @@ class AdHocCommand:
' bad-request')) ' bad-request'))
def cancel(self, request): def cancel(self, request):
response, cmd = self.buildResponse(request, status = 'canceled') response = self.buildResponse(request, status = 'canceled')[0]
self.connection.connection.send(response) self.connection.connection.send(response)
return False # finish the session return False # finish the session

View File

@ -415,7 +415,6 @@ class Connection(ConnectionHandlers):
if data: if data:
hostname = data['hostname'] hostname = data['hostname']
usessl = data['usessl']
self.try_connecting_for_foo_secs = 45 self.try_connecting_for_foo_secs = 45
p = data['proxy'] p = data['proxy']
use_srv = True use_srv = True
@ -961,7 +960,6 @@ class Connection(ConnectionHandlers):
sshow = helpers.get_xmpp_show(show) sshow = helpers.get_xmpp_show(show)
if not msg: if not msg:
msg = '' msg = ''
keyID = gajim.config.get_per('accounts', self.name, 'keyid')
if show == 'offline': if show == 'offline':
p = common.xmpp.Presence(typ = 'unavailable', to = jid) p = common.xmpp.Presence(typ = 'unavailable', to = jid)
p = self.add_sha(p, False) p = self.add_sha(p, False)
@ -985,7 +983,6 @@ class Connection(ConnectionHandlers):
sshow = helpers.get_xmpp_show(show) sshow = helpers.get_xmpp_show(show)
if not msg: if not msg:
msg = '' msg = ''
keyID = gajim.config.get_per('accounts', self.name, 'keyid')
sign_msg = False sign_msg = False
if not auto and not show == 'offline': if not auto and not show == 'offline':
sign_msg = True sign_msg = True
@ -1399,7 +1396,7 @@ class Connection(ConnectionHandlers):
return return
iq = common.xmpp.Iq(typ='get') iq = common.xmpp.Iq(typ='get')
iq2 = iq.addChild(name='query', namespace=common.xmpp.NS_PRIVATE) iq2 = iq.addChild(name='query', namespace=common.xmpp.NS_PRIVATE)
iq3 = iq2.addChild(name='gajim', namespace='gajim:prefs') iq2.addChild(name='gajim', namespace='gajim:prefs')
self.connection.send(iq) self.connection.send(iq)
def get_bookmarks(self): def get_bookmarks(self):
@ -1429,11 +1426,11 @@ class Connection(ConnectionHandlers):
# Note: need to handle both None and '' as empty # Note: need to handle both None and '' as empty
# thus shouldn't use "is not None" # thus shouldn't use "is not None"
if bm.get('nick', None): if bm.get('nick', None):
iq5 = iq4.setTagData('nick', bm['nick']) iq4.setTagData('nick', bm['nick'])
if bm.get('password', None): if bm.get('password', None):
iq5 = iq4.setTagData('password', bm['password']) iq4.setTagData('password', bm['password'])
if bm.get('print_status', None): if bm.get('print_status', None):
iq5 = iq4.setTagData('print_status', bm['print_status']) iq4.setTagData('print_status', bm['print_status'])
self.connection.send(iq) self.connection.send(iq)
def get_annotations(self): def get_annotations(self):
@ -1704,7 +1701,7 @@ class Connection(ConnectionHandlers):
if gajim.account_is_connected(self.name): if gajim.account_is_connected(self.name):
hostname = gajim.config.get_per('accounts', self.name, 'hostname') hostname = gajim.config.get_per('accounts', self.name, 'hostname')
iq = common.xmpp.Iq(typ = 'set', to = hostname) iq = common.xmpp.Iq(typ = 'set', to = hostname)
q = iq.setTag(common.xmpp.NS_REGISTER + ' query').setTag('remove') iq.setTag(common.xmpp.NS_REGISTER + ' query').setTag('remove')
con.send(iq) con.send(iq)
on_remove_success(True) on_remove_success(True)
return return

View File

@ -764,7 +764,6 @@ class ConnectionDisco:
if node: if node:
q.setAttr('node', node) q.setAttr('node', node)
q.addChild('identity', attrs = gajim.gajim_identity) q.addChild('identity', attrs = gajim.gajim_identity)
extension = None
if node and node.find('#') != -1: if node and node.find('#') != -1:
extension = node[node.index('#') + 1:] extension = node[node.index('#') + 1:]
client_version = 'http://gajim.org#' + gajim.caps_hash[self.name] client_version = 'http://gajim.org#' + gajim.caps_hash[self.name]
@ -980,7 +979,7 @@ class ConnectionVcard:
j = gajim.get_jid_from_account(self.name) j = gajim.get_jid_from_account(self.name)
self.awaiting_answers[id] = (VCARD_ARRIVED, j, groupchat_jid) self.awaiting_answers[id] = (VCARD_ARRIVED, j, groupchat_jid)
if groupchat_jid: if groupchat_jid:
room_jid, nick = gajim.get_room_and_nick_from_fjid(groupchat_jid) room_jid = gajim.get_room_and_nick_from_fjid(groupchat_jid)[0]
if not room_jid in self.room_jids: if not room_jid in self.room_jids:
self.room_jids.append(room_jid) self.room_jids.append(room_jid)
self.groupchat_jids[id] = groupchat_jid self.groupchat_jids[id] = groupchat_jid
@ -1389,6 +1388,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
try: try:
idle.init() idle.init()
except Exception: except Exception:
global HAS_IDLE
HAS_IDLE = False HAS_IDLE = False
self.gmail_last_tid = None self.gmail_last_tid = None

View File

@ -847,7 +847,6 @@ def sanitize_filename(filename):
.replace('*', '_').replace('<', '_').replace('>', '_') .replace('*', '_').replace('<', '_').replace('>', '_')
# 48 is the limit # 48 is the limit
if len(filename) > 48: if len(filename) > 48:
extension = filename.split('.')[-1]
filename = filename[0:48] filename = filename[0:48]
return filename return filename
@ -1027,7 +1026,7 @@ def get_notification_icon_tooltip_dict():
def get_notification_icon_tooltip_text(): def get_notification_icon_tooltip_text():
text = None text = None
# How many events must there be before they're shown summarized, not per-user # How many events must there be before they're shown summarized, not per-user
max_ungrouped_events = 10 # max_ungrouped_events = 10
# Character which should be used to indent in the tooltip. # Character which should be used to indent in the tooltip.
indent_with = ' ' indent_with = ' '

View File

@ -178,7 +178,7 @@ class Logger:
and after that all okay''' and after that all okay'''
if jid.find('/') > -1: if jid.find('/') > -1:
possible_room_jid, possible_nick = jid.split('/', 1) possible_room_jid = jid.split('/', 1)[1]
return self.jid_is_room_jid(possible_room_jid) return self.jid_is_room_jid(possible_room_jid)
else: else:
# it's not a full jid, so it's not a pm one # it's not a full jid, so it's not a pm one
@ -466,7 +466,6 @@ class Logger:
and are already logged but pending to be viewed, and are already logged but pending to be viewed,
returns a list of tupples containg time, kind, message, returns a list of tupples containg time, kind, message,
list with empty tupple if nothing found to meet our demands''' list with empty tupple if nothing found to meet our demands'''
jid_id = self.get_jid_id(jid)
where_sql = self._build_contact_where(account, jid) where_sql = self._build_contact_where(account, jid)
now = int(float(time.time())) now = int(float(time.time()))
@ -504,7 +503,6 @@ class Logger:
'''returns contact_name, time, kind, show, message '''returns contact_name, time, kind, show, message
for each row in a list of tupples, for each row in a list of tupples,
returns list with empty tupple if we found nothing to meet our demands''' returns list with empty tupple if we found nothing to meet our demands'''
jid_id = self.get_jid_id(jid)
where_sql = self._build_contact_where(account, jid) where_sql = self._build_contact_where(account, jid)
start_of_day = self.get_unix_time_from_date(year, month, day) start_of_day = self.get_unix_time_from_date(year, month, day)
@ -525,7 +523,6 @@ class Logger:
'''returns contact_name, time, kind, show, message '''returns contact_name, time, kind, show, message
for each row in a list of tupples, for each row in a list of tupples,
returns list with empty tupple if we found nothing to meet our demands''' returns list with empty tupple if we found nothing to meet our demands'''
jid_id = self.get_jid_id(jid)
if False: #query.startswith('SELECT '): # it's SQL query (FIXME) if False: #query.startswith('SELECT '): # it's SQL query (FIXME)
try: try:
@ -548,7 +545,6 @@ class Logger:
def get_days_with_logs(self, jid, year, month, max_day, account): def get_days_with_logs(self, jid, year, month, max_day, account):
'''returns the list of days that have logs (not status messages)''' '''returns the list of days that have logs (not status messages)'''
jid_id = self.get_jid_id(jid)
days_with_logs = [] days_with_logs = []
where_sql = self._build_contact_where(account, jid) where_sql = self._build_contact_where(account, jid)

View File

@ -268,7 +268,7 @@ class IdleCommand(IdleObject):
def pollin(self): def pollin(self):
try: try:
res = self.pipe.read() res = self.pipe.read()
except Exception, e: except Exception:
res = '' res = ''
if res == '': if res == '':
return self.pollend() return self.pollend()

View File

@ -264,7 +264,7 @@ class OptionsParser:
) )
con.commit() con.commit()
gajim.logger.init_vars() gajim.logger.init_vars()
except sqlite.OperationalError, e: except sqlite.OperationalError:
pass pass
con.close() con.close()
@ -336,7 +336,7 @@ class OptionsParser:
''' '''
) )
con.commit() con.commit()
except sqlite.OperationalError, e: except sqlite.OperationalError:
pass pass
con.close() con.close()
gajim.config.set('version', '0.10.1.3') gajim.config.set('version', '0.10.1.3')
@ -457,7 +457,7 @@ class OptionsParser:
''' '''
) )
con.commit() con.commit()
except sqlite.OperationalError, e: except sqlite.OperationalError:
pass pass
con.close() con.close()
gajim.config.set('version', '0.11.1.3') gajim.config.set('version', '0.11.1.3')
@ -499,7 +499,7 @@ class OptionsParser:
''' '''
) )
con.commit() con.commit()
except sqlite.OperationalError, e: except sqlite.OperationalError:
pass pass
con.close() con.close()
gajim.config.set('version', '0.11.1.5') gajim.config.set('version', '0.11.1.5')
@ -535,7 +535,7 @@ class OptionsParser:
''' '''
) )
con.commit() con.commit()
except sqlite.OperationalError, e: except sqlite.OperationalError:
pass pass
con.close() con.close()
gajim.config.set('version', '0.11.4.1') gajim.config.set('version', '0.11.4.1')
@ -572,7 +572,7 @@ class OptionsParser:
''' '''
) )
con.commit() con.commit()
except sqlite.OperationalError, e: except sqlite.OperationalError:
pass pass
con.close() con.close()
gajim.config.set('version', '0.11.4.3') gajim.config.set('version', '0.11.4.3')
@ -586,7 +586,7 @@ class OptionsParser:
try: try:
cur.executescript('DROP TABLE caps_cache;') cur.executescript('DROP TABLE caps_cache;')
con.commit() con.commit()
except sqlite.OperationalError, e: except sqlite.OperationalError:
pass pass
try: try:
cur.executescript( cur.executescript(

View File

@ -67,7 +67,7 @@ class GnomePasswordStorage(PasswordStorage):
if conf is None: if conf is None:
return None return None
try: try:
unused, auth_token = conf.split('gnomekeyring:') auth_token = conf.split('gnomekeyring:')[1]
auth_token = int(auth_token) auth_token = int(auth_token)
except ValueError: except ValueError:
password = conf password = conf

View File

@ -169,7 +169,7 @@ def user_mood(items, name, jid):
if 'text' in acc.mood: if 'text' in acc.mood:
del acc.mood['text'] del acc.mood['text']
(user, resource) = gajim.get_room_and_nick_from_fjid(jid) user = gajim.get_room_and_nick_from_fjid(jid)[0]
for contact in gajim.contacts.get_contacts(name, user): for contact in gajim.contacts.get_contacts(name, user):
if has_child: if has_child:
if 'mood' in contact.mood: if 'mood' in contact.mood:
@ -255,7 +255,7 @@ def user_tune(items, name, jid):
if 'length' in acc.tune: if 'length' in acc.tune:
del acc.tune['length'] del acc.tune['length']
(user, resource) = gajim.get_room_and_nick_from_fjid(jid) user = gajim.get_room_and_nick_from_fjid(jid)[0]
for contact in gajim.contacts.get_contacts(name, user): for contact in gajim.contacts.get_contacts(name, user):
if has_child: if has_child:
if 'artist' in contact.tune: if 'artist' in contact.tune:
@ -344,7 +344,7 @@ def user_activity(items, name, jid):
if 'text' in acc.activity: if 'text' in acc.activity:
del acc.activity['text'] del acc.activity['text']
(user, resource) = gajim.get_room_and_nick_from_fjid(jid) user = gajim.get_room_and_nick_from_fjid(jid)[0]
for contact in gajim.contacts.get_contacts(name, user): for contact in gajim.contacts.get_contacts(name, user):
if has_child: if has_child:
if 'activity' in contact.activity: if 'activity' in contact.activity:
@ -491,7 +491,7 @@ def user_retract_nickname(account):
gajim.connections[account].send_pb_retract('', xmpp.NS_NICK, '0') gajim.connections[account].send_pb_retract('', xmpp.NS_NICK, '0')
def delete_pep(jid, name): def delete_pep(jid, name):
(user, resource) = gajim.get_room_and_nick_from_fjid(jid) user = gajim.get_room_and_nick_from_fjid(jid)[0]
if jid == gajim.get_jid_from_account(name): if jid == gajim.get_jid_from_account(name):
acc = gajim.connections[name] acc = gajim.connections[name]

View File

@ -279,7 +279,7 @@ class HostTester(Socks5, IdleObject):
self._send = self._sock.send self._send = self._sock.send
self._recv = self._sock.recv self._recv = self._sock.recv
except Exception, ee: except Exception, ee:
(errnum, errstr) = ee errnum = ee[0]
# 56 is for freebsd # 56 is for freebsd
if errnum in (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK): if errnum in (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK):
# still trying to connect # still trying to connect
@ -391,7 +391,7 @@ class ReceiverTester(Socks5, IdleObject):
self._send = self._sock.send self._send = self._sock.send
self._recv = self._sock.recv self._recv = self._sock.recv
except Exception, ee: except Exception, ee:
(errnum, errstr) = ee errnum = ee[0]
# 56 is for freebsd # 56 is for freebsd
if errnum in (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK): if errnum in (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK):
# still trying to connect # still trying to connect

View File

@ -87,6 +87,7 @@ class SleepyWindows:
class SleepyUnix: class SleepyUnix:
def __init__(self, away_interval = 60, xa_interval = 120): def __init__(self, away_interval = 60, xa_interval = 120):
global SUPPORTED
self.away_interval = away_interval self.away_interval = away_interval
self.xa_interval = xa_interval self.xa_interval = xa_interval
self.state = STATE_AWAKE # assume we are awake self.state = STATE_AWAKE # assume we are awake

View File

@ -421,7 +421,7 @@ class Socks5:
received = '' received = ''
try: try:
add = self._recv(64) add = self._recv(64)
except Exception, e: except Exception:
add='' add=''
received +=add received +=add
if len(add) == 0: if len(add) == 0:
@ -431,8 +431,8 @@ class Socks5:
def send_raw(self,raw_data): def send_raw(self,raw_data):
''' Writes raw outgoing data. ''' ''' Writes raw outgoing data. '''
try: try:
lenn = self._send(raw_data) self._send(raw_data)
except Exception, e: except Exception:
self.disconnect() self.disconnect()
return len(raw_data) return len(raw_data)
@ -512,7 +512,7 @@ class Socks5:
fd = self.get_fd() fd = self.get_fd()
try: try:
buff = self._recv(MAX_BUFF_LEN) buff = self._recv(MAX_BUFF_LEN)
except Exception, e: except Exception:
buff = '' buff = ''
current_time = self.idlequeue.current_time() current_time = self.idlequeue.current_time()
self.file_props['elapsed-time'] += current_time - \ self.file_props['elapsed-time'] += current_time - \
@ -576,7 +576,7 @@ class Socks5:
mechanisms ''' mechanisms '''
auth_mechanisms = [] auth_mechanisms = []
try: try:
ver, num_auth = struct.unpack('!BB', buff[:2]) num_auth = struct.unpack('!BB', buff[:2])[1]
for i in xrange(num_auth): for i in xrange(num_auth):
mechanism, = struct.unpack('!B', buff[1 + i]) mechanism, = struct.unpack('!B', buff[1 + i])
auth_mechanisms.append(mechanism) auth_mechanisms.append(mechanism)
@ -605,8 +605,7 @@ class Socks5:
def _parse_request_buff(self, buff): def _parse_request_buff(self, buff):
try: # don't trust on what comes from the outside try: # don't trust on what comes from the outside
version, req_type, reserved, host_type, = \ req_type, host_type = struct.unpack('!xBxB', buff[:4])
struct.unpack('!BBBB', buff[:4])
if host_type == 0x01: if host_type == 0x01:
host_arr = struct.unpack('!iiii', buff[4:8]) host_arr = struct.unpack('!iiii', buff[4:8])
host, = '.'.join(str(s) for s in host_arr) host, = '.'.join(str(s) for s in host_arr)
@ -768,7 +767,7 @@ class Socks5Sender(Socks5, IdleObject):
return -1 # invalid auth methods received return -1 # invalid auth methods received
elif self.state == 3: # get next request elif self.state == 3: # get next request
buff = self.receive() buff = self.receive()
(req_type, self.sha_msg, port) = self._parse_request_buff(buff) req_type, self.sha_msg = self._parse_request_buff(buff)[:2]
if req_type != 0x01: if req_type != 0x01:
return -1 # request is not of type 'connect' return -1 # request is not of type 'connect'
self.state += 1 # go to the next step self.state += 1 # go to the next step
@ -976,7 +975,7 @@ class Socks5Receiver(Socks5, IdleObject):
self._send=self._sock.send self._send=self._sock.send
self._recv=self._sock.recv self._recv=self._sock.recv
except Exception, ee: except Exception, ee:
(errnum, errstr) = ee errnum = ee[0]
self.connect_timeout += 1 self.connect_timeout += 1
if errnum == 111 or self.connect_timeout > 1000: if errnum == 111 or self.connect_timeout > 1000:
self.queue._connection_refused(self.streamhost, self.queue._connection_refused(self.streamhost,
@ -1021,8 +1020,8 @@ class Socks5Receiver(Socks5, IdleObject):
sub_buff = buff[:4] sub_buff = buff[:4]
if len(sub_buff) < 4: if len(sub_buff) < 4:
return None return None
version, command, rsvd, address_type = struct.unpack('!BBBB', buff[:4]) version, address_type = struct.unpack('!BxxB', buff[:4])
addrlen, address, port = 0, 0, 0 addrlen = 0
if address_type == 0x03: if address_type == 0x03:
addrlen = ord(buff[4]) addrlen = ord(buff[4])
address = struct.unpack('!%ds' % addrlen, buff[5:addrlen + 5]) address = struct.unpack('!%ds' % addrlen, buff[5:addrlen + 5])

View File

@ -28,6 +28,7 @@ from common import gajim
from common import xmpp from common import xmpp
from common import exceptions from common import exceptions
import itertools
import random import random
import string import string
@ -91,8 +92,8 @@ class StanzaSession(object):
return any_removed return any_removed
def generate_thread_id(self): def generate_thread_id(self):
return ''.join([random.choice(string.ascii_letters) for x in xrange(0, return ''.join([f(string.ascii_letters) for f in itertools.repeat(
32)]) random.choice, 32)])
def send(self, msg): def send(self, msg):
if self.thread_id: if self.thread_id:
@ -386,10 +387,9 @@ class EncryptedStanzaSession(StanzaSession):
parsed = xmpp.Node(node='<node>' + plaintext + '</node>') parsed = xmpp.Node(node='<node>' + plaintext + '</node>')
if self.negotiated['recv_pubkey'] == 'hash': if self.negotiated['recv_pubkey'] == 'hash':
fingerprint = parsed.getTagData('fingerprint') # fingerprint = parsed.getTagData('fingerprint')
# XXX find stored pubkey or terminate session # XXX find stored pubkey or terminate session
raise 'unimplemented' raise NotImplementedError()
else: else:
if self.negotiated['sign_algs'] == (XmlDsig + 'rsa-sha256'): if self.negotiated['sign_algs'] == (XmlDsig + 'rsa-sha256'):
keyvalue = parsed.getTag(name='RSAKeyValue', namespace=XmlDsig) keyvalue = parsed.getTag(name='RSAKeyValue', namespace=XmlDsig)
@ -771,7 +771,7 @@ class EncryptedStanzaSession(StanzaSession):
else: else:
srses = secrets.secrets().retained_secrets(self.conn.name, srses = secrets.secrets().retained_secrets(self.conn.name,
self.jid.getStripped()) self.jid.getStripped())
rshashes = [self.hmac(self.n_s, rs) for (rs,v) in srses] rshashes = [self.hmac(self.n_s, rs[0]) for rs in srses]
if not rshashes: if not rshashes:
# we've never spoken before, but we'll pretend we have # we've never spoken before, but we'll pretend we have
@ -838,7 +838,7 @@ class EncryptedStanzaSession(StanzaSession):
rshashes = [base64.b64decode(rshash) for rshash in form.getField( rshashes = [base64.b64decode(rshash) for rshash in form.getField(
'rshashes').getValues()] 'rshashes').getValues()]
for (secret, verified) in srses: for secret in (s[0] for s in srses):
if self.hmac(self.n_o, secret) in rshashes: if self.hmac(self.n_o, secret) in rshashes:
srs = secret srs = secret
break break
@ -889,7 +889,7 @@ class EncryptedStanzaSession(StanzaSession):
srshash = base64.b64decode(form['srshash']) srshash = base64.b64decode(form['srshash'])
for (secret, verified) in srses: for secret in (s[0] for s in srses):
if self.hmac(secret, 'Shared Retained Secret') == srshash: if self.hmac(secret, 'Shared Retained Secret') == srshash:
srs = secret srs = secret
break break

View File

@ -61,8 +61,14 @@ class NonSASL(PlugIn):
token=query.getTagData('token') token=query.getTagData('token')
seq=query.getTagData('sequence') seq=query.getTagData('sequence')
self.DEBUG("Performing zero-k authentication",'ok') self.DEBUG("Performing zero-k authentication",'ok')
hash = sha.new(sha.new(self.password).hexdigest()+token).hexdigest()
for foo in xrange(int(seq)): hash = sha.new(hash).hexdigest() def hasher(s):
return sha.new(s).hexdigest()
def hash_n_times(s, count):
return count and hasher(hash_n_times(s, count-1)) or s
hash = hash_n_times(hasher(hasher(self.password)+token), int(seq))
query.setTagData('hash',hash) query.setTagData('hash',hash)
method='0k' method='0k'
else: else:
@ -182,10 +188,8 @@ class SASL(PlugIn):
resp['username']=self.username resp['username']=self.username
resp['realm']=self._owner.Server resp['realm']=self._owner.Server
resp['nonce']=chal['nonce'] resp['nonce']=chal['nonce']
cnonce='' resp['cnonce'] = ''.join("%x" % randint(0, 2**28) for randint in
for i in range(7): itertools.repeat(random.randint, 7))
cnonce+=hex(int(random.random()*65536*4096))[2:]
resp['cnonce']=cnonce
resp['nc']=('00000001') resp['nc']=('00000001')
resp['qop']='auth' resp['qop']='auth'
resp['digest-uri']='xmpp/'+self._owner.Server resp['digest-uri']='xmpp/'+self._owner.Server
@ -305,4 +309,4 @@ class ComponentBind(PlugIn):
self.DEBUG('Binding failed: timeout expired.','error') self.DEBUG('Binding failed: timeout expired.','error')
return '' return ''
# vim: se ts=3: # vim: se ts=3:

View File

@ -20,7 +20,11 @@ Can be used both for client and transport authentication.
from protocol import * from protocol import *
from auth import * from auth import *
from client import PlugIn from client import PlugIn
import sha,base64,random,dispatcher_nb import sha
import base64
import random
import itertools
import dispatcher_nb
try: try:
import kerberos import kerberos
@ -141,8 +145,8 @@ class SASL(PlugIn):
self._owner.RegisterHandler('failure', self.SASLHandler, xmlns=NS_SASL) self._owner.RegisterHandler('failure', self.SASLHandler, xmlns=NS_SASL)
self._owner.RegisterHandler('success', self.SASLHandler, xmlns=NS_SASL) self._owner.RegisterHandler('success', self.SASLHandler, xmlns=NS_SASL)
if "GSSAPI" in mecs and have_kerberos: if "GSSAPI" in mecs and have_kerberos:
rc, self.gss_vc = kerberos.authGSSClientInit('xmpp@' + self.gss_vc = kerberos.authGSSClientInit(
self._owner.Server) 'xmpp@' + self._owner.Server)[1]
response = kerberos.authGSSClientResponse(self.gss_vc) response = kerberos.authGSSClientResponse(self.gss_vc)
node=Node('auth',attrs={'xmlns': NS_SASL, 'mechanism': 'GSSAPI'}, node=Node('auth',attrs={'xmlns': NS_SASL, 'mechanism': 'GSSAPI'},
payload=(response or "")) payload=(response or ""))
@ -223,10 +227,8 @@ class SASL(PlugIn):
else: else:
resp['realm'] = self._owner.Server resp['realm'] = self._owner.Server
resp['nonce']=chal['nonce'] resp['nonce']=chal['nonce']
cnonce='' resp['cnonce'] = ''.join("%x" % randint(0, 2**28) for randint in
for i in range(7): itertools.repeat(random.randint, 7))
cnonce += hex(int(random.random() * 65536 * 4096))[2:]
resp['cnonce'] = cnonce
resp['nc'] = ('00000001') resp['nc'] = ('00000001')
resp['qop'] = 'auth' resp['qop'] = 'auth'
resp['digest-uri'] = 'xmpp/'+self._owner.Server resp['digest-uri'] = 'xmpp/'+self._owner.Server
@ -277,7 +279,7 @@ class NonBlockingNonSASL(PlugIn):
self.DEBUG('Querying server about possible auth methods', 'start') self.DEBUG('Querying server about possible auth methods', 'start')
self.owner = owner self.owner = owner
resp = owner.Dispatcher.SendAndWaitForResponse( owner.Dispatcher.SendAndWaitForResponse(
Iq('get', NS_AUTH, payload=[Node('username', payload=[self.user])]), func=self._on_username Iq('get', NS_AUTH, payload=[Node('username', payload=[self.user])]), func=self._on_username
) )
@ -301,9 +303,14 @@ class NonBlockingNonSASL(PlugIn):
token=query.getTagData('token') token=query.getTagData('token')
seq=query.getTagData('sequence') seq=query.getTagData('sequence')
self.DEBUG("Performing zero-k authentication",'ok') self.DEBUG("Performing zero-k authentication",'ok')
hash = sha.new(sha.new(self.password).hexdigest()+token).hexdigest()
for foo in xrange(int(seq)): def hasher(s):
hash = sha.new(hash).hexdigest() return sha.new(s).hexdigest()
def hash_n_times(s, count):
return count and hasher(hash_n_times(s, count-1)) or s
hash = hash_n_times(hasher(hasher(self.password) + token), int(seq))
query.setTagData('hash',hash) query.setTagData('hash',hash)
self._method='0k' self._method='0k'
else: else:
@ -375,7 +382,7 @@ class NonBlockingBind(Bind):
self._resource = [] self._resource = []
self._owner.onreceive(None) self._owner.onreceive(None)
resp=self._owner.Dispatcher.SendAndWaitForResponse( self._owner.Dispatcher.SendAndWaitForResponse(
Protocol('iq',typ='set', Protocol('iq',typ='set',
payload=[Node('bind', attrs={'xmlns':NS_BIND}, payload=self._resource)]), payload=[Node('bind', attrs={'xmlns':NS_BIND}, payload=self._resource)]),
func=self._on_bound) func=self._on_bound)

View File

@ -26,6 +26,8 @@ automatically called when user requests some node of your disco tree.
from dispatcher import * from dispatcher import *
from client import PlugIn from client import PlugIn
DBG_BROWSER = "Browser"
class Browser(PlugIn): class Browser(PlugIn):
""" WARNING! This class is for components only. It will not work in client mode! """ WARNING! This class is for components only. It will not work in client mode!
@ -80,7 +82,7 @@ class Browser(PlugIn):
def __init__(self): def __init__(self):
"""Initialises internal variables. Used internally.""" """Initialises internal variables. Used internally."""
PlugIn.__init__(self) PlugIn.__init__(self)
DBG_LINE='browser' self.DBG_LINE = DBG_BROWSER
self._exported_methods=[] self._exported_methods=[]
self._handlers={'':{}} self._handlers={'':{}}
@ -89,6 +91,7 @@ class Browser(PlugIn):
Used internally.""" Used internally."""
owner.RegisterHandler('iq',self._DiscoveryHandler,typ='get',ns=NS_DISCO_INFO) owner.RegisterHandler('iq',self._DiscoveryHandler,typ='get',ns=NS_DISCO_INFO)
owner.RegisterHandler('iq',self._DiscoveryHandler,typ='get',ns=NS_DISCO_ITEMS) owner.RegisterHandler('iq',self._DiscoveryHandler,typ='get',ns=NS_DISCO_ITEMS)
owner.debug_flags.append(DBG_BROWSER)
def plugout(self): def plugout(self):
""" Unregisters browser's iq handlers from your application dispatcher instance. """ Unregisters browser's iq handlers from your application dispatcher instance.
@ -215,4 +218,4 @@ class Browser(PlugIn):
conn.send(rep) conn.send(rep)
raise NodeProcessed raise NodeProcessed
# vim: se ts=3: # vim: se ts=3:

View File

@ -35,6 +35,8 @@ import math
from protocol import * from protocol import *
from client import PlugIn from client import PlugIn
DBG_COMMANDS = 'commands'
class Commands(PlugIn): class Commands(PlugIn):
"""Commands is an ancestor of PlugIn and can be attached to any session. """Commands is an ancestor of PlugIn and can be attached to any session.
@ -47,7 +49,7 @@ class Commands(PlugIn):
def __init__(self, browser): def __init__(self, browser):
"""Initialises class and sets up local variables""" """Initialises class and sets up local variables"""
PlugIn.__init__(self) PlugIn.__init__(self)
DBG_LINE='commands' self.DBG_LINE = DBG_COMMANDS
self._exported_methods=[] self._exported_methods=[]
self._handlers={'':{}} self._handlers={'':{}}
self._browser = browser self._browser = browser
@ -59,13 +61,14 @@ class Commands(PlugIn):
owner.RegisterHandler('iq',self._CommandHandler,typ='set',ns=NS_COMMANDS) owner.RegisterHandler('iq',self._CommandHandler,typ='set',ns=NS_COMMANDS)
owner.RegisterHandler('iq',self._CommandHandler,typ='get',ns=NS_COMMANDS) owner.RegisterHandler('iq',self._CommandHandler,typ='get',ns=NS_COMMANDS)
self._browser.setDiscoHandler(self._DiscoHandler,node=NS_COMMANDS,jid='') self._browser.setDiscoHandler(self._DiscoHandler,node=NS_COMMANDS,jid='')
owner.debug_flags.append(DBG_COMMANDS)
def plugout(self): def plugout(self):
"""Removes handlers from the session""" """Removes handlers from the session"""
# unPlug from the session and the disco manager # unPlug from the session and the disco manager
self._owner.UnregisterHandler('iq',self._CommandHandler,ns=NS_COMMANDS) self._owner.UnregisterHandler('iq',self._CommandHandler,ns=NS_COMMANDS)
for jid in self._handlers: for jid in self._handlers:
self._browser.delDiscoHandler(self._DiscoHandler,node=NS_COMMANDS) self._browser.delDiscoHandler(self._DiscoHandler,node=NS_COMMANDS,jid=jid)
def _CommandHandler(self,conn,request): def _CommandHandler(self,conn,request):
"""The internal method to process the routing of command execution requests""" """The internal method to process the routing of command execution requests"""
@ -194,7 +197,7 @@ class Command_Handler_Prototype(PlugIn):
def __init__(self,jid=''): def __init__(self,jid=''):
"""Set up the class""" """Set up the class"""
PlugIn.__init__(self) PlugIn.__init__(self)
DBG_LINE='command' self.DBG_LINE='command'
self.sessioncount = 0 self.sessioncount = 0
self.sessions = {} self.sessions = {}
# Disco information for command list pre-formatted as a tuple # Disco information for command list pre-formatted as a tuple

View File

@ -28,12 +28,14 @@ from client import PlugIn
DefaultTimeout=25 DefaultTimeout=25
ID=0 ID=0
DBG_DISPATCHER = 'dispatcher'
class Dispatcher(PlugIn): class Dispatcher(PlugIn):
""" Ancestor of PlugIn class. Handles XMPP stream, i.e. aware of stream headers. """ Ancestor of PlugIn class. Handles XMPP stream, i.e. aware of stream headers.
Can be plugged out/in to restart these headers (used for SASL f.e.). """ Can be plugged out/in to restart these headers (used for SASL f.e.). """
def __init__(self): def __init__(self):
PlugIn.__init__(self) PlugIn.__init__(self)
DBG_LINE='dispatcher' self.DBG_LINE = DBG_DISPATCHER
self.handlers={} self.handlers={}
self._expected={} self._expected={}
self._defaultHandler=None self._defaultHandler=None
@ -82,6 +84,7 @@ class Dispatcher(PlugIn):
self._owner.lastErr=None self._owner.lastErr=None
self._owner.lastErrCode=None self._owner.lastErrCode=None
self.StreamInit() self.StreamInit()
owner.debug_flags.append(DBG_DISPATCHER)
def plugout(self): def plugout(self):
""" Prepares instance to be destructed. """ """ Prepares instance to be destructed. """
@ -292,7 +295,6 @@ class Dispatcher(PlugIn):
for key in list: for key in list:
if key: chain = chain + self.handlers[xmlns][name][key] if key: chain = chain + self.handlers[xmlns][name][key]
output=''
if ID in session._expected: if ID in session._expected:
user=0 user=0
if isinstance(session._expected[ID], tuple): if isinstance(session._expected[ID], tuple):
@ -323,7 +325,6 @@ class Dispatcher(PlugIn):
lastErrNode, lastErr and lastErrCode are set accordingly. """ lastErrNode, lastErr and lastErrCode are set accordingly. """
if timeout is None: timeout=DefaultTimeout if timeout is None: timeout=DefaultTimeout
self._expected[ID]=None self._expected[ID]=None
has_timed_out=0
abort_time=time.time() + timeout abort_time=time.time() + timeout
self.DEBUG("Waiting for ID:%s with timeout %s..." % (ID,timeout),'wait') self.DEBUG("Waiting for ID:%s with timeout %s..." % (ID,timeout),'wait')
while not self._expected[ID]: while not self._expected[ID]:

View File

@ -37,7 +37,7 @@ class Dispatcher(PlugIn):
Can be plugged out/in to restart these headers (used for SASL f.e.). ''' Can be plugged out/in to restart these headers (used for SASL f.e.). '''
def __init__(self): def __init__(self):
PlugIn.__init__(self) PlugIn.__init__(self)
DBG_LINE='dispatcher' self.DBG_LINE='dispatcher'
self.handlers={} self.handlers={}
self._expected={} self._expected={}
self._defaultHandler=None self._defaultHandler=None
@ -334,7 +334,6 @@ class Dispatcher(PlugIn):
for key in list: for key in list:
if key: chain = chain + self.handlers[xmlns][name][key] if key: chain = chain + self.handlers[xmlns][name][key]
output=''
if ID in session._expected: if ID in session._expected:
user=0 user=0
if isinstance(session._expected[ID], tuple): if isinstance(session._expected[ID], tuple):

View File

@ -118,7 +118,6 @@ def getRegInfo(disp, host, info={}, sync=True):
disp.SendAndCallForResponse(iq, _ReceivedRegInfo, {'agent': host }) disp.SendAndCallForResponse(iq, _ReceivedRegInfo, {'agent': host })
def _ReceivedRegInfo(con, resp, agent): def _ReceivedRegInfo(con, resp, agent):
iq=Iq('get',NS_REGISTER,to=agent)
if not isResultNode(resp): if not isResultNode(resp):
error_msg = resp.getErrorMsg() error_msg = resp.getErrorMsg()
con.Event(NS_REGISTER,REGISTER_DATA_RECEIVED,(agent,None,False,error_msg)) con.Event(NS_REGISTER,REGISTER_DATA_RECEIVED,(agent,None,False,error_msg))

View File

@ -99,7 +99,8 @@ class IBB(PlugIn):
self.DEBUG('SendHandler called','info') self.DEBUG('SendHandler called','info')
for sid in self._streams.keys(): for sid in self._streams.keys():
stream=self._streams[sid] stream=self._streams[sid]
if stream['direction'][:2]=='|>': cont=1 if stream['direction'][:2]=='|>':
pass
elif stream['direction'][0]=='>': elif stream['direction'][0]=='>':
chunk=stream['fp'].read(stream['block-size']) chunk=stream['fp'].read(stream['block-size'])
if chunk: if chunk:

View File

@ -66,13 +66,15 @@ class error:
"""Serialise exception into pre-cached descriptive string.""" """Serialise exception into pre-cached descriptive string."""
return self._comment return self._comment
DBG_SOCKET = "socket"
class TCPsocket(PlugIn): class TCPsocket(PlugIn):
""" This class defines direct TCP connection method. """ """ This class defines direct TCP connection method. """
def __init__(self, server=None, use_srv=True): def __init__(self, server=None, use_srv=True):
""" Cache connection point 'server'. 'server' is the tuple of (host, port) """ Cache connection point 'server'. 'server' is the tuple of (host, port)
absolutely the same as standard tcp socket uses. """ absolutely the same as standard tcp socket uses. """
PlugIn.__init__(self) PlugIn.__init__(self)
self.DBG_LINE='socket' self.DBG_LINE = DBG_SOCKET
self._exported_methods=[self.send,self.disconnect] self._exported_methods=[self.send,self.disconnect]
self._server = server self._server = server
@ -85,6 +87,7 @@ class TCPsocket(PlugIn):
if not self.connect(self._server): return if not self.connect(self._server): return
self._owner.Connection=self self._owner.Connection=self
self._owner.RegisterDisconnectHandler(self.disconnected) self._owner.RegisterDisconnectHandler(self.disconnected)
owner.debug_flags.append(DBG_SOCKET)
return 'ok' return 'ok'
def getHost(self): def getHost(self):
@ -235,7 +238,7 @@ class TLS(PlugIn):
""" """
if 'TLS' in owner.__dict__: return # Already enabled. if 'TLS' in owner.__dict__: return # Already enabled.
PlugIn.PlugIn(self,owner) PlugIn.PlugIn(self,owner)
DBG_LINE='TLS' self.DBG_LINE='TLS'
if now: return self._startSSL() if now: return self._startSSL()
if self._owner.Dispatcher.Stream.features: if self._owner.Dispatcher.Stream.features:
try: self.FeaturesHandler(self._owner.Dispatcher,self._owner.Dispatcher.Stream.features) try: self.FeaturesHandler(self._owner.Dispatcher,self._owner.Dispatcher.Stream.features)

View File

@ -38,6 +38,7 @@ import common.gajim
USE_PYOPENSSL = False USE_PYOPENSSL = False
DBG_NONBLOCKINGTLS= 'NonBlockingTLS'
try: try:
#raise ImportError("Manually disabled PyOpenSSL") #raise ImportError("Manually disabled PyOpenSSL")
import OpenSSL.SSL import OpenSSL.SSL
@ -662,6 +663,8 @@ class NonBlockingTcp(PlugIn, IdleObject):
''' Return the 'port' value that is connection is [will be] made to.''' ''' Return the 'port' value that is connection is [will be] made to.'''
return self._server[1] return self._server[1]
DBG_NONBLOCKINGTLS = "NonBlockingTLS"
class NonBlockingTLS(PlugIn): class NonBlockingTLS(PlugIn):
''' TLS connection used to encrypts already estabilished tcp connection.''' ''' TLS connection used to encrypts already estabilished tcp connection.'''
@ -680,12 +683,13 @@ class NonBlockingTLS(PlugIn):
if 'NonBlockingTLS' in owner.__dict__: if 'NonBlockingTLS' in owner.__dict__:
return # Already enabled. return # Already enabled.
PlugIn.PlugIn(self, owner) PlugIn.PlugIn(self, owner)
DBG_LINE='NonBlockingTLS' self.DBG_LINE = DBG_NONBLOCKINGTLS
owner.debug_flags.append(DBG_NONBLOCKINGTLS)
self.on_tls_start = on_tls_start self.on_tls_start = on_tls_start
if now: if now:
try: try:
res = self._startSSL() res = self._startSSL()
except Exception, e: except Exception:
log.error("PlugIn: while trying _startSSL():", exc_info=True) log.error("PlugIn: while trying _startSSL():", exc_info=True)
#traceback.print_exc() #traceback.print_exc()
self._owner.socket.pollend() self._owner.socket.pollend()
@ -860,7 +864,7 @@ class NonBlockingTLS(PlugIn):
self.DEBUG('Got starttls proceed response. Switching to TLS/SSL...','ok') self.DEBUG('Got starttls proceed response. Switching to TLS/SSL...','ok')
try: try:
self._startSSL() self._startSSL()
except Exception, e: except Exception:
log.error("StartTLSHandler:", exc_info=True) log.error("StartTLSHandler:", exc_info=True)
#traceback.print_exc() #traceback.print_exc()
self._owner.socket.pollend() self._owner.socket.pollend()
@ -1101,9 +1105,9 @@ class NBSOCKS5PROXYsocket(NonBlockingTcp):
return return
# Get the bound address/port # Get the bound address/port
elif reply[3] == "\x01": elif reply[3] == "\x01":
begin, end = 3, 7 pass # begin, end = 3, 7
elif reply[3] == "\x03": elif reply[3] == "\x03":
begin, end = 4, 4 + reply[4] pass # begin, end = 4, 4 + reply[4]
else: else:
self.DEBUG('Invalid proxy reply', 'error') self.DEBUG('Invalid proxy reply', 'error')
self._owner.disconnected() self._owner.disconnected()

View File

@ -71,7 +71,7 @@ class ZeroconfListener(IdleObject):
# will fail when port is busy, or we don't have rights to bind # will fail when port is busy, or we don't have rights to bind
try: try:
self._serv.bind((ai[4][0], self.port)) self._serv.bind((ai[4][0], self.port))
except Exception, e: except Exception:
# unable to bind, show error dialog # unable to bind, show error dialog
return None return None
self._serv.listen(socket.SOMAXCONN) self._serv.listen(socket.SOMAXCONN)
@ -158,7 +158,7 @@ class P2PClient(IdleObject):
self.conn_holder.add_connection(self, self.Server, port, self.to) self.conn_holder.add_connection(self, self.Server, port, self.to)
# count messages in queue # count messages in queue
for val in self.stanzaqueue: for val in self.stanzaqueue:
stanza, is_message = val is_message = val[1]
if is_message: if is_message:
if self.fd == -1: if self.fd == -1:
if on_not_ok: if on_not_ok:

View File

@ -76,7 +76,6 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
receiver = file_props['receiver'] receiver = file_props['receiver']
if sender is None: if sender is None:
sender = file_props['sender'] sender = file_props['sender']
proxyhosts = []
sha_str = helpers.get_auth_sha(file_props['sid'], sender, sha_str = helpers.get_auth_sha(file_props['sid'], sender,
receiver) receiver)
file_props['sha_str'] = sha_str file_props['sha_str'] = sha_str
@ -382,6 +381,7 @@ class ConnectionHandlersZeroconf(ConnectionVcard, ConnectionBytestream, connecti
try: try:
idle.init() idle.init()
except Exception: except Exception:
global HAS_IDLE
HAS_IDLE = False HAS_IDLE = False
def _messageCB(self, ip, con, msg): def _messageCB(self, ip, con, msg):

View File

@ -56,8 +56,7 @@ class Roster:
if not contact: if not contact:
return return
(service_jid, domain, interface, protocol, host, address, port, bare_jid, txt) \ host, address, port, txt = contact[4:7] + contact[8]
= contact
self._data[jid]={} self._data[jid]={}
self._data[jid]['ask'] = 'no' #? self._data[jid]['ask'] = 'no' #?

View File

@ -292,7 +292,7 @@ class Zeroconf:
return True return True
else: else:
return False return False
except dbus.DBusException, e: except dbus.DBusException:
gajim.log.debug("Can't remove service. That should not happen") gajim.log.debug("Can't remove service. That should not happen")
def browse_domain(self, interface, protocol, domain): def browse_domain(self, interface, protocol, domain):
@ -429,4 +429,4 @@ class Zeroconf:
# END Zeroconf # END Zeroconf
# vim: se ts=3: # vim: se ts=3:

View File

@ -115,7 +115,8 @@ class Zeroconf:
} }
# Split on '.' but do not split on '\.' # Split on '.' but do not split on '\.'
name, stype, protocol, domain, dummy = re.split('(?<!\\\\)\.', fullname) result = re.split('(?<!\\\\)\.', fullname)
name, protocol, domain = result[0] + result[2:4]
# Replace the escaped values # Replace the escaped values
for src, trg in escaping.items(): for src, trg in escaping.items():
@ -329,7 +330,7 @@ class Zeroconf:
try: try:
pybonjour.DNSServiceUpdateRecord(self.service_sdRef, None, 0, self.txt) pybonjour.DNSServiceUpdateRecord(self.service_sdRef, None, 0, self.txt)
except pybonjour.BonjourError, e: except pybonjour.BonjourError:
return False return False
return True return True

View File

@ -308,9 +308,6 @@ class PreferencesWindow:
self.xml.get_widget('sounds_scrolledwindow').set_sensitive(False) self.xml.get_widget('sounds_scrolledwindow').set_sensitive(False)
self.xml.get_widget('browse_sounds_hbox').set_sensitive(False) self.xml.get_widget('browse_sounds_hbox').set_sensitive(False)
# sound player
player = gajim.config.get('soundplayer')
# sounds treeview # sounds treeview
self.sound_tree = self.xml.get_widget('sounds_treeview') self.sound_tree = self.xml.get_widget('sounds_treeview')
@ -613,27 +610,25 @@ class PreferencesWindow:
helpers.update_optional_features() helpers.update_optional_features()
def apply_speller(self): def apply_speller(self):
for acct in gajim.connections: for ctrl in gajim.interface.msg_win_mgr.controls():
for ctrl in gajim.interface.msg_win_mgr.controls(): if isinstance(ctrl, chat_control.ChatControlBase):
if isinstance(ctrl, chat_control.ChatControlBase): try:
try: spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview)
spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview) except Exception:
except Exception: spell_obj = None
spell_obj = None
if not spell_obj: if not spell_obj:
gtkspell.Spell(ctrl.msg_textview) gtkspell.Spell(ctrl.msg_textview)
def remove_speller(self): def remove_speller(self):
for acct in gajim.connections: for ctrl in gajim.interface.msg_win_mgr.controls():
for ctrl in gajim.interface.msg_win_mgr.controls(): if isinstance(ctrl, chat_control.ChatControlBase):
if isinstance(ctrl, chat_control.ChatControlBase): try:
try: spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview)
spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview) except Exception:
except Exception: spell_obj = None
spell_obj = None if spell_obj:
if spell_obj: spell_obj.detach()
spell_obj.detach()
def on_speller_checkbutton_toggled(self, widget): def on_speller_checkbutton_toggled(self, widget):
active = widget.get_active() active = widget.get_active()
@ -645,7 +640,7 @@ class PreferencesWindow:
lang = gajim.LANG lang = gajim.LANG
tv = gtk.TextView() tv = gtk.TextView()
try: try:
spell = gtkspell.Spell(tv, lang) gtkspell.Spell(tv, lang)
except: except:
dialogs.ErrorDialog( dialogs.ErrorDialog(
_('Dictionary for lang %s not available') % lang, _('Dictionary for lang %s not available') % lang,
@ -1032,7 +1027,6 @@ class PreferencesWindow:
return return
buf = self.xml.get_widget('msg_textview').get_buffer() buf = self.xml.get_widget('msg_textview').get_buffer()
first_iter, end_iter = buf.get_bounds() first_iter, end_iter = buf.get_bounds()
name = model.get_value(iter, 0)
model.set_value(iter, 1, buf.get_text(first_iter, end_iter)) model.set_value(iter, 1, buf.get_text(first_iter, end_iter))
def on_msg_treeview_key_press_event(self, widget, event): def on_msg_treeview_key_press_event(self, widget, event):
@ -1690,7 +1684,7 @@ class AccountsWindow:
gajim.interface.instances[account]['remove_account'] = \ gajim.interface.instances[account]['remove_account'] = \
RemoveAccountWindow(account) RemoveAccountWindow(account)
if win_opened: if win_opened:
dialog = dialogs.ConfirmationDialog( dialogs.ConfirmationDialog(
_('You have opened chat in account %s') % account, _('You have opened chat in account %s') % account,
_('All chat and groupchat windows will be closed. Do you want to ' _('All chat and groupchat windows will be closed. Do you want to '
'continue?'), 'continue?'),
@ -1895,7 +1889,7 @@ class AccountsWindow:
def on_synchronise_contacts_button1_clicked(self, widget): def on_synchronise_contacts_button1_clicked(self, widget):
try: try:
dialog = dialogs.SynchroniseSelectAccountDialog(self.current_account) dialogs.SynchroniseSelectAccountDialog(self.current_account)
except GajimGeneralException: except GajimGeneralException:
# If we showed ErrorDialog, there will not be dialog instance # If we showed ErrorDialog, there will not be dialog instance
return return
@ -1909,7 +1903,7 @@ class AccountsWindow:
self.xml.get_widget('password_entry1').set_text(new_password) self.xml.get_widget('password_entry1').set_text(new_password)
try: try:
dialog = dialogs.ChangePasswordDialog(self.current_account, on_changed) dialogs.ChangePasswordDialog(self.current_account, on_changed)
except GajimGeneralException: except GajimGeneralException:
# if we showed ErrorDialog, there will not be dialog instance # if we showed ErrorDialog, there will not be dialog instance
return return
@ -2074,14 +2068,10 @@ class AccountsWindow:
gajim.config.set_per('accounts', self.current_account, 'keyid', gajim.config.set_per('accounts', self.current_account, 'keyid',
keyID[0]) keyID[0])
instance = dialogs.ChooseGPGKeyDialog(_('OpenPGP Key Selection'), dialogs.ChooseGPGKeyDialog(_('OpenPGP Key Selection'),
_('Choose your OpenPGP key'), secret_keys, on_key_selected) _('Choose your OpenPGP key'), secret_keys, on_key_selected)
def on_use_gpg_agent_checkbutton_toggled(self, widget): def on_use_gpg_agent_checkbutton_toggled(self, widget):
if self.current_account == gajim.ZEROCONF_ACC_NAME:
wiget_name_ext = '2'
else:
wiget_name_ext = '1'
self.on_checkbutton_toggled(widget, 'use_gpg_agent') self.on_checkbutton_toggled(widget, 'use_gpg_agent')
def on_edit_details_button1_clicked(self, widget): def on_edit_details_button1_clicked(self, widget):
@ -2471,7 +2461,7 @@ class GroupchatConfigWindow:
return return
model = self.affiliation_treeview[affiliation].get_model() model = self.affiliation_treeview[affiliation].get_model()
model.append((jid,'', '', '')) model.append((jid,'', '', ''))
instance = dialogs.InputDialog(title, prompt, ok_handler=on_ok) dialogs.InputDialog(title, prompt, ok_handler=on_ok)
def on_remove_button_clicked(self, widget, affiliation): def on_remove_button_clicked(self, widget, affiliation):
selection = self.affiliation_treeview[affiliation].get_selection() selection = self.affiliation_treeview[affiliation].get_selection()
@ -2577,7 +2567,7 @@ class RemoveAccountWindow:
gajim.connections[self.account].unregister_account( gajim.connections[self.account].unregister_account(
self._on_remove_success) self._on_remove_success)
w = dialogs.PassphraseDialog( dialogs.PassphraseDialog(
_('Password Required'), _('Password Required'),
_('Enter your password for account %s') % self.account, _('Enter your password for account %s') % self.account,
_('Save password'), ok_handler=on_ok) _('Save password'), ok_handler=on_ok)
@ -2588,7 +2578,7 @@ class RemoveAccountWindow:
self._on_remove_success(True) self._on_remove_success(True)
if gajim.connections[self.account].connected: if gajim.connections[self.account].connected:
dialog = dialogs.ConfirmationDialog( dialogs.ConfirmationDialog(
_('Account "%s" is connected to the server') % self.account, _('Account "%s" is connected to the server') % self.account,
_('If you remove it, the connection will be lost.'), _('If you remove it, the connection will be lost.'),
on_response_ok=remove) on_response_ok=remove)

View File

@ -597,7 +597,7 @@ class ConversationTextview:
def on_textview_motion_notify_event(self, widget, event): def on_textview_motion_notify_event(self, widget, event):
'''change the cursor to a hand when we are over a mail or an '''change the cursor to a hand when we are over a mail or an
url''' url'''
pointer_x, pointer_y, spam = self.tv.window.get_pointer() pointer_x, pointer_y = self.tv.window.get_pointer()[0:2]
x, y = self.tv.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, x, y = self.tv.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT,
pointer_x, pointer_y) pointer_x, pointer_y)
tags = self.tv.get_iter_at_location(x, y).get_tags() tags = self.tv.get_iter_at_location(x, y).get_tags()

View File

@ -567,7 +567,6 @@ class SingleForm(gtk.Table, object):
def on_jid_multi_remove_button_clicked(self, widget, treeview, field): def on_jid_multi_remove_button_clicked(self, widget, treeview, field):
selection = treeview.get_selection() selection = treeview.get_selection()
model = treeview.get_model()
deleted = [] deleted = []
def remove(model, path, iter_, deleted): def remove(model, path, iter_, deleted):

View File

@ -427,7 +427,6 @@ class ChangeActivityDialog:
''' '''
Return activity and messsage (None if no activity selected) Return activity and messsage (None if no activity selected)
''' '''
message = None
if self.checkbutton.get_active(): if self.checkbutton.get_active():
pep.user_send_activity(self.account, self.activity, pep.user_send_activity(self.account, self.activity,
self.subactivity, self.subactivity,
@ -651,7 +650,7 @@ class ChangeStatusMessageDialog:
self.preset_messages_dict[msg_name] = msg_text self.preset_messages_dict[msg_name] = msg_text
gajim.config.set_per('statusmsg', msg_name, 'message', gajim.config.set_per('statusmsg', msg_name, 'message',
msg_text_1l) msg_text_1l)
dlg2 = ConfirmationDialog(_('Overwrite Status Message?'), ConfirmationDialog(_('Overwrite Status Message?'),
_('This name is already used. Do you want to overwrite this ' _('This name is already used. Do you want to overwrite this '
'status message?'), on_response_ok=on_ok2) 'status message?'), on_response_ok=on_ok2)
return return
@ -1853,7 +1852,7 @@ class SynchroniseSelectAccountDialog:
return return
else: else:
try: try:
dialog = SynchroniseSelectContactsDialog(self.account, remote_account) SynchroniseSelectContactsDialog(self.account, remote_account)
except GajimGeneralException: except GajimGeneralException:
# if we showed ErrorDialog, there will not be dialog instance # if we showed ErrorDialog, there will not be dialog instance
return return
@ -2195,7 +2194,7 @@ class SingleMessageWindow:
if lang: if lang:
spell1.set_language(lang) spell1.set_language(lang)
spell2.set_language(lang) spell2.set_language(lang)
except gobject.GError, msg: except gobject.GError:
AspellDictError(lang) AspellDictError(lang)
self.prepare_widgets_for(self.action) self.prepare_widgets_for(self.action)
@ -2969,7 +2968,7 @@ class InvitationReceivedDialog:
except GajimGeneralException: except GajimGeneralException:
pass pass
dialog = YesNoDialog(pritext, sectext, on_response_yes=on_yes) YesNoDialog(pritext, sectext, on_response_yes=on_yes)
class ProgressDialog: class ProgressDialog:
def __init__(self, title_text, during_text, messages_queue): def __init__(self, title_text, during_text, messages_queue):
@ -3156,7 +3155,6 @@ class AddSpecialNotificationDialog:
self.window.destroy() self.window.destroy()
def on_listen_sound_combobox_changed(self, widget): def on_listen_sound_combobox_changed(self, widget):
model = widget.get_model()
active = widget.get_active() active = widget.get_active()
if active == 1: # user selected 'choose sound' if active == 1: # user selected 'choose sound'
def on_ok(widget, path_to_snd_file): def on_ok(widget, path_to_snd_file):
@ -3659,9 +3657,6 @@ class TransformChatToMUC:
'server_and_guests_hseparator', 'server_select_label'): 'server_and_guests_hseparator', 'server_select_label'):
self.__dict__[widget_to_add] = self.xml.get_widget(widget_to_add) self.__dict__[widget_to_add] = self.xml.get_widget(widget_to_add)
# set comboboxentry
renderer_servers = gtk.CellRendererText()
server_list = [] server_list = []
self.servers = gtk.ListStore(str) self.servers = gtk.ListStore(str)
self.server_list_comboboxentry.set_model(self.servers) self.server_list_comboboxentry.set_model(self.servers)
@ -3904,7 +3899,7 @@ class GPGInfoWindow:
'encrypt messages.') 'encrypt messages.')
image = 'security-low-big.png' image = 'security-low-big.png'
else: else:
msgenc, error = gajim.connections[account].gpg.encrypt('test', [keyID]) error = gajim.connections[account].gpg.encrypt('test', [keyID])[1]
if error: if error:
verification_status = _('''Contact's identity NOT verified''') verification_status = _('''Contact's identity NOT verified''')
info = _('GPG key is assigned to this contact, but <b>you do not ' info = _('GPG key is assigned to this contact, but <b>you do not '

View File

@ -969,7 +969,6 @@ _('This service does not contain any items to browse.'))
def _agent_info(self, jid, node, identities, features, data): def _agent_info(self, jid, node, identities, features, data):
'''Callback for when we receive info about an agent's item.''' '''Callback for when we receive info about an agent's item.'''
addr = get_agent_address(jid, node)
iter = self._find_item(jid, node) iter = self._find_item(jid, node)
if not iter: if not iter:
# Not in the treeview, stop # Not in the treeview, stop
@ -1099,7 +1098,7 @@ class ToplevelAgentBrowser(AgentBrowser):
if not props or self.tooltip.id != props[0]: if not props or self.tooltip.id != props[0]:
self.tooltip.hide_tooltip() self.tooltip.hide_tooltip()
if props: if props:
[row, col, x, y] = props row = props[0]
iter = None iter = None
try: try:
iter = self.model.get_iter(row) iter = self.model.get_iter(row)
@ -1430,7 +1429,7 @@ class ToplevelAgentBrowser(AgentBrowser):
def _find_category(self, cat, type_=None): def _find_category(self, cat, type_=None):
'''Looks up a category row and returns the iterator to it, or None.''' '''Looks up a category row and returns the iterator to it, or None.'''
cat, prio = self._friendly_category(cat, type_) cat = self._friendly_category(cat, type_)[0]
iter = self.model.get_iter_root() iter = self.model.get_iter_root()
while iter: while iter:
if self.model.get_value(iter, 3).decode('utf-8') == cat: if self.model.get_value(iter, 3).decode('utf-8') == cat:
@ -1540,7 +1539,6 @@ class ToplevelAgentBrowser(AgentBrowser):
self._expand_all() self._expand_all()
def _update_error(self, iter_, jid, node): def _update_error(self, iter_, jid, node):
addr = get_agent_address(jid, node)
self.model[iter_][4] = 2 self.model[iter_][4] = 2
self._progress += 1 self._progress += 1
self._update_progressbar() self._update_progressbar()
@ -1635,7 +1633,6 @@ class MucBrowser(AgentBrowser):
room = model[iter][1].decode('utf-8') room = model[iter][1].decode('utf-8')
if 'join_gc' not in gajim.interface.instances[self.account]: if 'join_gc' not in gajim.interface.instances[self.account]:
try: try:
room_jid = '%s@%s' % (service, room)
dialogs.JoinGroupchatWindow(self.account, service) dialogs.JoinGroupchatWindow(self.account, service)
except GajimGeneralException: except GajimGeneralException:
pass pass

View File

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

View File

@ -150,7 +150,7 @@ class FileTransfersWindow:
dialog.destroy() dialog.destroy()
if 'file-name' not in file_props: if 'file-name' not in file_props:
return return
(path, file) = os.path.split(file_props['file-name']) path = os.path.split(file_props['file-name'])[0]
if os.path.exists(path) and os.path.isdir(path): if os.path.exists(path) and os.path.isdir(path):
helpers.launch_file_manager(path) helpers.launch_file_manager(path)
self.tree.get_selection().unselect_all() self.tree.get_selection().unselect_all()
@ -276,7 +276,7 @@ _('Connection with peer cannot be established.'))
return return
(jid, resource) = contact.split('/', 1) (jid, resource) = contact.split('/', 1)
contact = gajim.contacts.create_contact(jid=jid, resource=resource) contact = gajim.contacts.create_contact(jid=jid, resource=resource)
(file_dir, file_name) = os.path.split(file_path) file_name = os.path.split(file_path)[1]
file_props = self.get_send_file_props(account, contact, file_props = self.get_send_file_props(account, contact,
file_path, file_name, file_desc) file_path, file_name, file_desc)
if file_props is None: if file_props is None:
@ -307,7 +307,7 @@ _('Connection with peer cannot be established.'))
if 'desc' in file_props: if 'desc' in file_props:
sec_text += '\n\t' + _('Description: %s') % file_props['desc'] sec_text += '\n\t' + _('Description: %s') % file_props['desc']
prim_text = _('%s wants to send you a file:') % contact.jid prim_text = _('%s wants to send you a file:') % contact.jid
dialog, dialog2 = None, None dialog = None
def on_response_ok(account, contact, file_props): def on_response_ok(account, contact, file_props):
@ -600,7 +600,7 @@ _('Connection with peer cannot be established.'))
text_labels += '<b>' + _('Recipient: ') + '</b>' text_labels += '<b>' + _('Recipient: ') + '</b>'
if file_props['type'] == 'r': if file_props['type'] == 'r':
(file_path, file_name) = os.path.split(file_props['file-name']) file_name = os.path.split(file_props['file-name'])[1]
else: else:
file_name = file_props['name'] file_name = file_props['name']
text_props = gobject.markup_escape_text(file_name) + '\n' text_props = gobject.markup_escape_text(file_name) + '\n'
@ -621,14 +621,13 @@ _('Connection with peer cannot be established.'))
def on_transfers_list_motion_notify_event(self, widget, event): def on_transfers_list_motion_notify_event(self, widget, event):
pointer = self.tree.get_pointer() pointer = self.tree.get_pointer()
orig = widget.window.get_origin()
props = widget.get_path_at_pos(int(event.x), int(event.y)) props = widget.get_path_at_pos(int(event.x), int(event.y))
self.height_diff = pointer[1] - int(event.y) self.height_diff = pointer[1] - int(event.y)
if self.tooltip.timeout > 0: if self.tooltip.timeout > 0:
if not props or self.tooltip.id != props[0]: if not props or self.tooltip.id != props[0]:
self.tooltip.hide_tooltip() self.tooltip.hide_tooltip()
if props: if props:
[row, col, x, y] = props row = props[0]
iter = None iter = None
try: try:
iter = self.model.get_iter(row) iter = self.model.get_iter(row)
@ -890,7 +889,7 @@ _('Connection with peer cannot be established.'))
self.tooltip.hide_tooltip() self.tooltip.hide_tooltip()
iter = None iter = None
try: try:
store, iter = self.tree.get_selection().get_selected() iter = self.tree.get_selection().get_selected()[1]
except TypeError: except TypeError:
self.tree.get_selection().unselect_all() self.tree.get_selection().unselect_all()
@ -908,8 +907,7 @@ _('Connection with peer cannot be established.'))
self.tooltip.hide_tooltip() self.tooltip.hide_tooltip()
path = None path = None
try: try:
path, column, x, y = self.tree.get_path_at_pos(int(event.x), path = self.tree.get_path_at_pos(int(event.x), int(event.y))[0]
int(event.y))
except TypeError: except TypeError:
self.tree.get_selection().unselect_all() self.tree.get_selection().unselect_all()
if path is None: if path is None:
@ -922,8 +920,7 @@ _('Connection with peer cannot be established.'))
self.tooltip.hide_tooltip() self.tooltip.hide_tooltip()
path, iter = None, None path, iter = None, None
try: try:
path, column, x, y = self.tree.get_path_at_pos(int(event.x), path = self.tree.get_path_at_pos(int(event.x), int(event.y))[0]
int(event.y))
except TypeError: except TypeError:
self.tree.get_selection().unselect_all() self.tree.get_selection().unselect_all()
if event.button == 3: # Right click if event.button == 3: # Right click
@ -943,7 +940,7 @@ _('Connection with peer cannot be established.'))
file_props = self.files_props[sid[0]][sid[1:]] file_props = self.files_props[sid[0]][sid[1:]]
if 'file-name' not in file_props: if 'file-name' not in file_props:
return return
(path, file) = os.path.split(file_props['file-name']) path = os.path.split(file_props['file-name'])[0]
if os.path.exists(path) and os.path.isdir(path): if os.path.exists(path) and os.path.isdir(path):
helpers.launch_file_manager(path) helpers.launch_file_manager(path)

View File

@ -111,7 +111,7 @@ def parseOpts():
try: try:
shortargs = 'hqvl:p:c:' shortargs = 'hqvl:p:c:'
longargs = 'help quiet verbose loglevel= profile= config_path=' longargs = 'help quiet verbose loglevel= profile= config_path='
opts, args = getopt.getopt(sys.argv[1:], shortargs, longargs.split()) opts = getopt.getopt(sys.argv[1:], shortargs, longargs.split())[0]
except getopt.error, msg: except getopt.error, msg:
print msg print msg
print 'for help use --help' print 'for help use --help'

View File

@ -121,7 +121,7 @@ class GajimThemesWindow:
model.clear() model.clear()
for config_theme in gajim.config.get_per('themes'): for config_theme in gajim.config.get_per('themes'):
theme = config_theme.replace('_', ' ') theme = config_theme.replace('_', ' ')
iter = model.append([theme]) model.append([theme])
def select_active_theme(self): def select_active_theme(self):
model = self.themes_tree.get_model() model = self.themes_tree.get_model()

View File

@ -990,7 +990,6 @@ class GroupchatControl(ChatControlBase):
contact in a room''' contact in a room'''
if nick is None: if nick is None:
nick = model[iter_][C_NICK].decode('utf-8') nick = model[iter_][C_NICK].decode('utf-8')
fjid = gajim.construct_fjid(self.room_jid, nick) # 'fake' jid
ctrl = self._start_private_message(nick) ctrl = self._start_private_message(nick)
if ctrl and msg: if ctrl and msg:
@ -1791,7 +1790,7 @@ class GroupchatControl(ChatControlBase):
on_minimize(self) on_minimize(self)
return return
if method == self.parent_win.CLOSE_ESC: if method == self.parent_win.CLOSE_ESC:
model, iter = self.list_treeview.get_selection().get_selected() iter = self.list_treeview.get_selection().get_selected()[1]
if iter: if iter:
self.list_treeview.get_selection().unselect_all() self.list_treeview.get_selection().unselect_all()
on_no(self) on_no(self)
@ -1820,7 +1819,7 @@ class GroupchatControl(ChatControlBase):
sectext = _('If you close this window, you will be disconnected ' sectext = _('If you close this window, you will be disconnected '
'from this group chat.') 'from this group chat.')
dialog = dialogs.ConfirmationDialogCheck(pritext, sectext, dialogs.ConfirmationDialogCheck(pritext, sectext,
_('Do _not ask me again'), on_response_ok=on_ok, _('Do _not ask me again'), on_response_ok=on_ok,
on_response_cancel=on_cancel) on_response_cancel=on_cancel)
return return
@ -1854,7 +1853,7 @@ class GroupchatControl(ChatControlBase):
# will work yet # will work yet
gajim.connections[self.account].send_gc_subject(self.room_jid, subject) gajim.connections[self.account].send_gc_subject(self.room_jid, subject)
instance = dialogs.InputTextDialog(_('Changing Subject'), dialogs.InputTextDialog(_('Changing Subject'),
_('Please specify the new subject:'), input_str=self.subject, _('Please specify the new subject:'), input_str=self.subject,
ok_handler=on_ok) ok_handler=on_ok)
@ -1886,7 +1885,7 @@ class GroupchatControl(ChatControlBase):
jid) jid)
# Ask for a reason # Ask for a reason
instance = dialogs.DubbleInputDialog(_('Destroying %s') % self.room_jid, dialogs.DubbleInputDialog(_('Destroying %s') % self.room_jid,
_('You are going to definitively destroy this room.\n' _('You are going to definitively destroy this room.\n'
'You may specify a reason below:'), 'You may specify a reason below:'),
_('You may also enter an alternate venue:'), ok_handler=on_ok) _('You may also enter an alternate venue:'), ok_handler=on_ok)
@ -1909,7 +1908,6 @@ class GroupchatControl(ChatControlBase):
path = treeview.get_selection().get_selected_rows()[1][0] path = treeview.get_selection().get_selected_rows()[1][0]
iter = model.get_iter(path) iter = model.get_iter(path)
type = model[iter][2] type = model[iter][2]
account = model[iter][4].decode('utf-8')
if type != 'contact': # source is not a contact if type != 'contact': # source is not a contact
return return
contact_jid = data.decode('utf-8') contact_jid = data.decode('utf-8')
@ -2037,7 +2035,7 @@ class GroupchatControl(ChatControlBase):
def on_list_treeview_key_press_event(self, widget, event): def on_list_treeview_key_press_event(self, widget, event):
if event.keyval == gtk.keysyms.Escape: if event.keyval == gtk.keysyms.Escape:
selection = widget.get_selection() selection = widget.get_selection()
model, iter = selection.get_selected() iter = selection.get_selected()[1]
if iter: if iter:
widget.get_selection().unselect_all() widget.get_selection().unselect_all()
return True return True
@ -2061,7 +2059,7 @@ class GroupchatControl(ChatControlBase):
'none', reason) 'none', reason)
# ask for reason # ask for reason
instance = dialogs.InputDialog(_('Kicking %s') % nick, dialogs.InputDialog(_('Kicking %s') % nick,
_('You may specify a reason below:'), ok_handler=on_ok) _('You may specify a reason below:'), ok_handler=on_ok)
def mk_menu(self, event, iter_): def mk_menu(self, event, iter_):
@ -2215,13 +2213,13 @@ class GroupchatControl(ChatControlBase):
def on_list_treeview_button_press_event(self, widget, event): def on_list_treeview_button_press_event(self, widget, event):
'''popup user's group's or agent menu''' '''popup user's group's or agent menu'''
try:
pos = widget.get_path_at_pos(int(event.x), int(event.y))
path, x = pos[0] + pos[2]
except TypeError:
widget.get_selection().unselect_all()
return
if event.button == 3: # right click if event.button == 3: # right click
try:
path, column, x, y = widget.get_path_at_pos(int(event.x),
int(event.y))
except TypeError:
widget.get_selection().unselect_all()
return
widget.get_selection().select_path(path) widget.get_selection().select_path(path)
model = widget.get_model() model = widget.get_model()
iter = model.get_iter(path) iter = model.get_iter(path)
@ -2230,12 +2228,6 @@ class GroupchatControl(ChatControlBase):
return True return True
elif event.button == 2: # middle click elif event.button == 2: # middle click
try:
path, column, x, y = widget.get_path_at_pos(int(event.x),
int(event.y))
except TypeError:
widget.get_selection().unselect_all()
return
widget.get_selection().select_path(path) widget.get_selection().select_path(path)
model = widget.get_model() model = widget.get_model()
iter = model.get_iter(path) iter = model.get_iter(path)
@ -2245,13 +2237,6 @@ class GroupchatControl(ChatControlBase):
return True return True
elif event.button == 1: # left click elif event.button == 1: # left click
try:
path, column, x, y = widget.get_path_at_pos(int(event.x),
int(event.y))
except TypeError:
widget.get_selection().unselect_all()
return
if gajim.single_click and not event.state & gtk.gdk.SHIFT_MASK: if gajim.single_click and not event.state & gtk.gdk.SHIFT_MASK:
self.on_row_activated(widget, path) self.on_row_activated(widget, path)
return True return True
@ -2365,7 +2350,7 @@ class GroupchatControl(ChatControlBase):
# to ban we know the real jid. so jid is not fakejid # to ban we know the real jid. so jid is not fakejid
nick = gajim.get_nick_from_jid(jid) nick = gajim.get_nick_from_jid(jid)
# ask for reason # ask for reason
instance = dialogs.InputDialog(_('Banning %s') % nick, dialogs.InputDialog(_('Banning %s') % nick,
_('You may specify a reason below:'), ok_handler=on_ok) _('You may specify a reason below:'), ok_handler=on_ok)
def grant_membership(self, widget, jid): def grant_membership(self, widget, jid):

View File

@ -82,7 +82,6 @@ def _info(type_, value, tb):
# on expand the details the dialog remains centered on screen # on expand the details the dialog remains centered on screen
dialog.set_position(gtk.WIN_POS_CENTER_ALWAYS) dialog.set_position(gtk.WIN_POS_CENTER_ALWAYS)
close_clicked = False
def on_dialog_response(dialog, response): def on_dialog_response(dialog, response):
if response == RESPONSE_REPORT_BUG: if response == RESPONSE_REPORT_BUG:
url = 'http://trac.gajim.org/wiki/HowToCreateATicket' url = 'http://trac.gajim.org/wiki/HowToCreateATicket'

View File

@ -97,7 +97,7 @@ def popup_emoticons_under_button(menu, button, parent_win):
x = window_x + button_x x = window_x + button_x
y = window_y + button_y y = window_y + button_y
menu_width, menu_height = menu.size_request() menu_height = menu.size_request()[1]
## should we pop down or up? ## should we pop down or up?
if (y + button.allocation.height + menu_height if (y + button.allocation.height + menu_height
@ -494,7 +494,7 @@ def file_is_locked(path_to_file):
win32con.FILE_ATTRIBUTE_NORMAL, # normal file win32con.FILE_ATTRIBUTE_NORMAL, # normal file
0 # no attr. template 0 # no attr. template
) )
except pywintypes.error, e: except pywintypes.error:
return True return True
else: # in case all went ok, close file handle (go to hell WinAPI) else: # in case all went ok, close file handle (go to hell WinAPI)
hfile.Close() hfile.Close()
@ -808,10 +808,6 @@ default_name = ''):
dialog.destroy() dialog.destroy()
def on_ok(widget): def on_ok(widget):
def on_ok2(file_path, pixbuf):
pixbuf.save(file_path, 'jpeg')
dialog.destroy()
file_path = dialog.get_filename() file_path = dialog.get_filename()
file_path = decode_filechooser_file_paths((file_path,))[0] file_path = decode_filechooser_file_paths((file_path,))[0]
if os.path.exists(file_path): if os.path.exists(file_path):

View File

@ -220,7 +220,7 @@ class HistoryManager:
def on_no(): def on_no():
gtk.main_quit() gtk.main_quit()
dialog = dialogs.YesNoDialog( dialogs.YesNoDialog(
_('Do you want to clean up the database? ' _('Do you want to clean up the database? '
'(STRONGLY NOT RECOMMENDED IF GAJIM IS RUNNING)'), '(STRONGLY NOT RECOMMENDED IF GAJIM IS RUNNING)'),
_('Normally allocated database size will not be freed, ' _('Normally allocated database size will not be freed, '
@ -296,7 +296,7 @@ class HistoryManager:
(user will see the first pm as if it was message in room's public chat) (user will see the first pm as if it was message in room's public chat)
and after that all okay''' and after that all okay'''
possible_room_jid, possible_nick = jid.split('/', 1) possible_room_jid = jid.split('/', 1)[0]
self.cur.execute('SELECT jid_id FROM jids WHERE jid = ? AND type = ?', self.cur.execute('SELECT jid_id FROM jids WHERE jid = ? AND type = ?',
(possible_room_jid, constants.JID_ROOM_TYPE)) (possible_room_jid, constants.JID_ROOM_TYPE))
@ -421,9 +421,6 @@ class HistoryManager:
xml.get_widget('delete_menuitem').connect('activate', xml.get_widget('delete_menuitem').connect('activate',
self.on_delete_menuitem_activate, widget) self.on_delete_menuitem_activate, widget)
liststore, list_of_paths = self.jids_listview.get_selection()\
.get_selected_rows()
xml.signal_autoconnect(self) xml.signal_autoconnect(self)
xml.get_widget('context_menu').popup(None, None, None, xml.get_widget('context_menu').popup(None, None, None,
event.button, event.time) event.button, event.time)

View File

@ -321,7 +321,7 @@ class HistoryWindow:
# first day of month is 1 not 0 # first day of month is 1 not 0
widget.clear_marks() widget.clear_marks()
month = gtkgui_helpers.make_gtk_month_python_month(month) month = gtkgui_helpers.make_gtk_month_python_month(month)
weekday, days_in_this_month = calendar.monthrange(year, month) days_in_this_month = calendar.monthrange(year, month)[1]
log_days = gajim.logger.get_days_with_logs(self.jid, year, log_days = gajim.logger.get_days_with_logs(self.jid, year,
month, days_in_this_month, self.account) month, days_in_this_month, self.account)
for day in log_days: for day in log_days:
@ -509,7 +509,7 @@ class HistoryWindow:
'''a row was double clicked, get date from row, and select it in calendar '''a row was double clicked, get date from row, and select it in calendar
which results to showing conversation logs for that date''' which results to showing conversation logs for that date'''
# get currently selected date # get currently selected date
cur_year, cur_month, cur_day = self.calendar.get_date() cur_year, cur_month = self.calendar.get_date()[0:2]
cur_month = gtkgui_helpers.make_gtk_month_python_month(cur_month) cur_month = gtkgui_helpers.make_gtk_month_python_month(cur_month)
model = widget.get_model() model = widget.get_model()
# make it a tupple (Y, M, D, 0, 0, 0...) # make it a tupple (Y, M, D, 0, 0, 0...)

View File

@ -1034,7 +1034,7 @@ if __name__ == '__main__':
def on_textview_motion_notify_event(widget, event): def on_textview_motion_notify_event(widget, event):
'''change the cursor to a hand when we are over a mail or an url''' '''change the cursor to a hand when we are over a mail or an url'''
global change_cursor global change_cursor
pointer_x, pointer_y, spam = htmlview.window.get_pointer() pointer_x, pointer_y = htmlview.window.get_pointer()[0:2]
x, y = htmlview.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, pointer_x, x, y = htmlview.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, pointer_x,
pointer_y) pointer_y)
tags = htmlview.get_iter_at_location(x, y).get_tags() tags = htmlview.get_iter_at_location(x, y).get_tags()
@ -1043,7 +1043,6 @@ if __name__ == '__main__':
gtk.gdk.Cursor(gtk.gdk.XTERM)) gtk.gdk.Cursor(gtk.gdk.XTERM))
change_cursor = None change_cursor = None
tag_table = htmlview.get_buffer().get_tag_table() tag_table = htmlview.get_buffer().get_tag_table()
over_line = False
for tag in tags: for tag in tags:
try: try:
if tag.is_anchor: if tag.is_anchor:

View File

@ -245,7 +245,6 @@ class IterableIPShell:
@param header: Header to be printed before output @param header: Header to be printed before output
@type header: string @type header: string
''' '''
stat = 0
if verbose or debug: print header+cmd if verbose or debug: print header+cmd
# flush stdout so we don't mangle python's buffering # flush stdout so we don't mangle python's buffering
if not debug: if not debug:

View File

@ -142,7 +142,6 @@ class MessageControl:
self.session = session self.session = session
new_key = None
if session: if session:
session.control = self session.control = self
new_key = session.thread_id new_key = session.thread_id

View File

@ -213,7 +213,6 @@ class MessageWindow(object):
self.on_delete_ok -= 1 self.on_delete_ok -= 1
# Make sure all controls are okay with being deleted # Make sure all controls are okay with being deleted
ctrl_to_minimize = []
self.on_delete_ok = self.get_nb_controls() self.on_delete_ok = self.get_nb_controls()
for ctrl in self.controls(): for ctrl in self.controls():
ctrl.allow_shutdown(self.CLOSE_CLOSE_BUTTON, on_yes, on_no, ctrl.allow_shutdown(self.CLOSE_CLOSE_BUTTON, on_yes, on_no,
@ -671,11 +670,7 @@ class MessageWindow(object):
yield ctrl yield ctrl
def get_nb_controls(self): def get_nb_controls(self):
nb_ctrl = 0 return sum(len(jid_dict) for jid_dict in self._controls.values())
for jid_dict in self._controls.values():
for ctrl in jid_dict.values():
nb_ctrl += 1
return nb_ctrl
def move_to_next_unread_tab(self, forward): def move_to_next_unread_tab(self, forward):
ind = self.notebook.get_current_page() ind = self.notebook.get_current_page()
@ -776,7 +771,7 @@ class MessageWindow(object):
selection, type_, time): selection, type_, time):
'''Reorder the tabs according to the drop position''' '''Reorder the tabs according to the drop position'''
source_page_num = int(selection.data) source_page_num = int(selection.data)
dest_page_num, to_right = self.get_tab_at_xy(x, y) dest_page_num = self.get_tab_at_xy(x, y)[0]
source_child = self.notebook.get_nth_page(source_page_num) source_child = self.notebook.get_nth_page(source_page_num)
if dest_page_num != source_page_num: if dest_page_num != source_page_num:
self.notebook.reorder_child(source_child, dest_page_num) self.notebook.reorder_child(source_child, dest_page_num)

View File

@ -521,8 +521,8 @@ class DesktopNotification:
if gajim.interface.systray_enabled and \ if gajim.interface.systray_enabled and \
gajim.config.get('attach_notifications_to_systray'): gajim.config.get('attach_notifications_to_systray'):
x, y = gajim.interface.systray.img_tray.window.get_position() x, y = gajim.interface.systray.img_tray.window.get_position()
x_, y_, width, height, depth = \ width, height = \
gajim.interface.systray.img_tray.window.get_geometry() gajim.interface.systray.img_tray.window.get_geometry()[2:4]
pos_x = x + (width / 2) pos_x = x + (width / 2)
pos_y = y + (height / 2) pos_y = y + (height / 2)
hints = {'x': pos_x, 'y': pos_y} hints = {'x': pos_x, 'y': pos_y}

View File

@ -517,7 +517,6 @@ class RosterWindow:
# Family might has changed (actual big brother not on top). # Family might has changed (actual big brother not on top).
# Remove childs first then big brother # Remove childs first then big brother
family_in_roster = False family_in_roster = False
big_brother_jid = None
for data in nearby_family: for data in nearby_family:
_account = data['account'] _account = data['account']
_jid = data['jid'] _jid = data['jid']
@ -835,7 +834,6 @@ class RosterWindow:
def remove_transport(self, jid, account): def remove_transport(self, jid, account):
'''Remove transport from roster and redraw account and group.''' '''Remove transport from roster and redraw account and group.'''
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
self.remove_contact(jid, account, force=True, backend=True) self.remove_contact(jid, account, force=True, backend=True)
return True return True
@ -1150,8 +1148,8 @@ class RosterWindow:
is_big_brother = False is_big_brother = False
have_visible_children = False have_visible_children = False
if family: if family:
nearby_family, bb_jid, bb_account = \ bb_jid, bb_account = \
self._get_nearby_family_and_big_brother(family, account) self._get_nearby_family_and_big_brother(family, account)[1:]
is_big_brother = (jid, account) == (bb_jid, bb_account) is_big_brother = (jid, account) == (bb_jid, bb_account)
iters = self._get_contact_iter(jid, account) iters = self._get_contact_iter(jid, account)
have_visible_children = iters \ have_visible_children = iters \
@ -1712,7 +1710,7 @@ class RosterWindow:
obj = bus.get_object('com.google.code.Awn', '/com/google/code/Awn') obj = bus.get_object('com.google.code.Awn', '/com/google/code/Awn')
awn = dbus.Interface(obj, 'com.google.code.Awn') awn = dbus.Interface(obj, 'com.google.code.Awn')
awn.SetTaskIconByName('Gajim', os.path.abspath(path)) awn.SetTaskIconByName('Gajim', os.path.abspath(path))
except Exception, e: except Exception:
pass pass
def music_track_changed(self, unused_listener, music_track_info, def music_track_changed(self, unused_listener, music_track_info,
@ -1724,14 +1722,10 @@ class RosterWindow:
artist = '' artist = ''
title = '' title = ''
source = '' source = ''
track = ''
length = ''
elif hasattr(music_track_info, 'paused') and music_track_info.paused == 0: elif hasattr(music_track_info, 'paused') and music_track_info.paused == 0:
artist = '' artist = ''
title = '' title = ''
source = '' source = ''
track = ''
length = ''
else: else:
artist = music_track_info.artist artist = music_track_info.artist
title = music_track_info.title title = music_track_info.title
@ -1899,7 +1893,6 @@ class RosterWindow:
self.set_connecting_state(account) self.set_connecting_state(account)
if not gajim.connections[account].password: if not gajim.connections[account].password:
passphrase = ''
text = _('Enter your password for account %s') % account text = _('Enter your password for account %s') % account
if passwords.USER_HAS_GNOMEKEYRING and \ if passwords.USER_HAS_GNOMEKEYRING and \
not passwords.USER_USES_GNOMEKEYRING: not passwords.USER_USES_GNOMEKEYRING:
@ -1913,7 +1906,7 @@ class RosterWindow:
passwords.save_password(account, passphrase) passwords.save_password(account, passphrase)
keyid = gajim.config.get_per('accounts', account, 'keyid') keyid = gajim.config.get_per('accounts', account, 'keyid')
if keyid and not gajim.connections[account].gpg: if keyid and not gajim.connections[account].gpg:
dialog = dialogs.WarningDialog(_('GPG is not usable'), dialogs.WarningDialog(_('GPG is not usable'),
_('You will be connected to %s without OpenPGP.') % \ _('You will be connected to %s without OpenPGP.') % \
account) account)
self.send_status_continue(account, status, txt, auto, to) self.send_status_continue(account, status, txt, auto, to)
@ -1926,14 +1919,14 @@ class RosterWindow:
gajim.interface.systray.change_status('offline') gajim.interface.systray.change_status('offline')
self.update_status_combobox() self.update_status_combobox()
w = dialogs.PassphraseDialog(_('Password Required'), text, dialogs.PassphraseDialog(_('Password Required'), text,
_('Save password'), ok_handler=on_ok, _('Save password'), ok_handler=on_ok,
cancel_handler=on_cancel) cancel_handler=on_cancel)
return return
keyid = gajim.config.get_per('accounts', account, 'keyid') keyid = gajim.config.get_per('accounts', account, 'keyid')
if keyid and not gajim.connections[account].gpg: if keyid and not gajim.connections[account].gpg:
dialog = dialogs.WarningDialog(_('GPG is not usable'), dialogs.WarningDialog(_('GPG is not usable'),
_('You will be connected to %s without OpenPGP.') % account) _('You will be connected to %s without OpenPGP.') % account)
self.send_status_continue(account, status, txt, auto, to) self.send_status_continue(account, status, txt, auto, to)
@ -2263,7 +2256,7 @@ class RosterWindow:
break break
if unread or recent: if unread or recent:
dialog = dialogs.ConfirmationDialog(_('You have unread messages'), dialogs.ConfirmationDialog(_('You have unread messages'),
_('Messages will only be available for reading them later if you' _('Messages will only be available for reading them later if you'
' have history enabled and contact is in your roster.'), ' have history enabled and contact is in your roster.'),
on_response_ok=(on_continue2, message)) on_response_ok=(on_continue2, message))
@ -2371,7 +2364,7 @@ class RosterWindow:
if not props or self.tooltip.id != props[0]: if not props or self.tooltip.id != props[0]:
self.tooltip.hide_tooltip() self.tooltip.hide_tooltip()
if props: if props:
[row, col, x, y] = props row = props[0]
titer = None titer = None
try: try:
titer = model.get_iter(row) titer = model.get_iter(row)
@ -2525,7 +2518,6 @@ class RosterWindow:
if msg is None: if msg is None:
# user pressed Cancel to change status message dialog # user pressed Cancel to change status message dialog
return return
model = self.modelfilter
accounts = [] accounts = []
if group is None: if group is None:
for (contact, account) in list_: for (contact, account) in list_:
@ -2568,7 +2560,6 @@ class RosterWindow:
def on_unblock(self, widget, list_, group=None): def on_unblock(self, widget, list_, group=None):
''' When clicked on the 'unblock' button in context menu. ''' ''' When clicked on the 'unblock' button in context menu. '''
model = self.modelfilter
accounts = [] accounts = []
if group is None: if group is None:
for (contact, account) in list_: for (contact, account) in list_:
@ -2640,7 +2631,6 @@ class RosterWindow:
if 'rename' in gajim.interface.instances: if 'rename' in gajim.interface.instances:
gajim.interface.instances['rename'].dialog.present() gajim.interface.instances['rename'].dialog.present()
return return
model = self.modelfilter
# account is offline, don't allow to rename # account is offline, don't allow to rename
if gajim.connections[account].connected < 2: if gajim.connections[account].connected < 2:
@ -2753,7 +2743,7 @@ class RosterWindow:
u.keyID = helpers.prepare_and_validate_gpg_keyID(account, u.keyID = helpers.prepare_and_validate_gpg_keyID(account,
contact.jid, keyID) contact.jid, keyID)
instance = dialogs.ChooseGPGKeyDialog(_('Assign OpenPGP Key'), dialogs.ChooseGPGKeyDialog(_('Assign OpenPGP Key'),
_('Select a key to apply to the contact'), public_keys, _('Select a key to apply to the contact'), public_keys,
on_key_selected, selected=keyID) on_key_selected, selected=keyID)
@ -2870,7 +2860,7 @@ class RosterWindow:
resource = None): resource = None):
''' resource parameter MUST NOT be used if more than one contact in ''' resource parameter MUST NOT be used if more than one contact in
list ''' list '''
for (contact, acct) in list_: for contact in (e[0] for e in list_):
contact_jid = contact.jid contact_jid = contact.jid
if resource: # we MUST have one contact only in list_ if resource: # we MUST have one contact only in list_
contact_jid += '/' + resource contact_jid += '/' + resource
@ -2915,10 +2905,10 @@ class RosterWindow:
helpers.launch_browser_mailer('url', url) helpers.launch_browser_mailer('url', url)
def on_change_activity_activate(self, widget, account): def on_change_activity_activate(self, widget, account):
dlg = dialogs.ChangeActivityDialog(account) dialogs.ChangeActivityDialog(account)
def on_change_mood_activate(self, widget, account): def on_change_mood_activate(self, widget, account):
dlg = dialogs.ChangeMoodDialog(account) dialogs.ChangeMoodDialog(account)
def on_change_status_message_activate(self, widget, account): def on_change_status_message_activate(self, widget, account):
show = gajim.SHOW_LIST[gajim.connections[account].connected] show = gajim.SHOW_LIST[gajim.connections[account].connected]
@ -2977,8 +2967,7 @@ class RosterWindow:
def on_roster_treeview_button_release_event(self, widget, event): def on_roster_treeview_button_release_event(self, widget, event):
try: try:
path, column, x, y = self.tree.get_path_at_pos(int(event.x), path = self.tree.get_path_at_pos(int(event.x), int(event.y))[0]
int(event.y))
except TypeError: except TypeError:
return False return False
@ -2994,8 +2983,8 @@ class RosterWindow:
# hide tooltip, no matter the button is pressed # hide tooltip, no matter the button is pressed
self.tooltip.hide_tooltip() self.tooltip.hide_tooltip()
try: try:
path, column, x, y = self.tree.get_path_at_pos(int(event.x), pos = self.tree.get_path_at_pos(int(event.x), int(event.y))
int(event.y)) path, x = pos[0] + pos[2]
except TypeError: except TypeError:
self.tree.get_selection().unselect_all() self.tree.get_selection().unselect_all()
return False return False
@ -3106,7 +3095,6 @@ class RosterWindow:
if len(list_) == 1: if len(list_) == 1:
contact = list_[0][0] contact = list_[0][0]
account = list_[0][1]
pritext = _('Contact "%s" will be removed from your roster') % \ pritext = _('Contact "%s" will be removed from your roster') % \
contact.get_shown_name() contact.get_shown_name()
if contact.sub == 'to': if contact.sub == 'to':
@ -3245,7 +3233,7 @@ class RosterWindow:
def on_cancel(): def on_cancel():
self.update_status_combobox() self.update_status_combobox()
dialog = dialogs.ConfirmationDialog( dialogs.ConfirmationDialog(
_('You are participating in one or more group chats'), _('You are participating in one or more group chats'),
_('Changing your status to invisible will result in ' _('Changing your status to invisible will result in '
'disconnection from those group chats. Are you sure you want to ' 'disconnection from those group chats. Are you sure you want to '
@ -3399,7 +3387,7 @@ class RosterWindow:
gajim.interface.msg_win_mgr.one_window_opened(): gajim.interface.msg_win_mgr.one_window_opened():
# let message window close the tab # let message window close the tab
return return
model, list_of_paths = self.tree.get_selection().get_selected_rows() list_of_paths = self.tree.get_selection().get_selected_rows()[1]
if not len(list_of_paths) and gajim.interface.systray_enabled and \ if not len(list_of_paths) and gajim.interface.systray_enabled and \
not gajim.config.get('quit_on_roster_x_button'): not gajim.config.get('quit_on_roster_x_button'):
self.tooltip.hide_tooltip() self.tooltip.hide_tooltip()
@ -3518,8 +3506,8 @@ class RosterWindow:
jid = model[titer][C_JID].decode('utf-8') jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT].decode('utf-8') account = model[titer][C_ACCOUNT].decode('utf-8')
family = gajim.contacts.get_metacontacts_family(account, jid) family = gajim.contacts.get_metacontacts_family(account, jid)
nearby_family, bb_jid, bb_account = \ nearby_family = \
self._get_nearby_family_and_big_brother(family, account) self._get_nearby_family_and_big_brother(family, account)[0]
# Redraw all brothers to show pending events # Redraw all brothers to show pending events
for data in nearby_family: for data in nearby_family:
self.draw_contact(data['jid'], data['account']) self.draw_contact(data['jid'], data['account'])
@ -3558,8 +3546,8 @@ class RosterWindow:
jid = model[titer][C_JID].decode('utf-8') jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT].decode('utf-8') account = model[titer][C_ACCOUNT].decode('utf-8')
family = gajim.contacts.get_metacontacts_family(account, jid) family = gajim.contacts.get_metacontacts_family(account, jid)
nearby_family, bb_jid, bb_account = \ nearby_family = \
self._get_nearby_family_and_big_brother(family, account) self._get_nearby_family_and_big_brother(family, account)[0]
# Redraw all brothers to show pending events # Redraw all brothers to show pending events
for data in nearby_family: for data in nearby_family:
self.draw_contact(data['jid'], data['account']) self.draw_contact(data['jid'], data['account'])
@ -3824,7 +3812,7 @@ class RosterWindow:
def drag_drop(self, treeview, context, x, y, timestamp): def drag_drop(self, treeview, context, x, y, timestamp):
target_list = treeview.drag_dest_get_target_list() target_list = treeview.drag_dest_get_target_list()
target = treeview.drag_dest_find_target(context, target_list) target = treeview.drag_dest_find_target(context, target_list)
selection = treeview.drag_get_data(context, target) treeview.drag_get_data(context, target)
context.finish(False, True) context.finish(False, True)
return True return True
@ -5400,10 +5388,11 @@ class RosterWindow:
else: else:
execute_command_menuitem.set_sensitive(False) execute_command_menuitem.set_sensitive(False)
our_jid_other_resource = None # This does nothing:
if our_jid: # our_jid_other_resource = None
# It's another resource of us, be sure to send invite to her # if our_jid:
our_jid_other_resource = contact.resource # # It's another resource of us, be sure to send invite to her
# our_jid_other_resource = contact.resource
# Else this var is useless but harmless in next connect calls # Else this var is useless but harmless in next connect calls
if gajim.capscache.is_supported(contact, NS_FILE): if gajim.capscache.is_supported(contact, NS_FILE):
@ -5764,7 +5753,6 @@ class RosterWindow:
def make_groupchat_menu(self, event, titer): def make_groupchat_menu(self, event, titer):
model = self.modelfilter model = self.modelfilter
path = model.get_path(titer)
jid = model[titer][C_JID].decode('utf-8') jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT].decode('utf-8') account = model[titer][C_ACCOUNT].decode('utf-8')
contact = gajim.contacts.get_contact_with_highest_priority(account, jid) contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
@ -6340,8 +6328,7 @@ class RosterWindow:
if not gajim.ZEROCONF_ACC_NAME in gajim.config.get_per('accounts'): if not gajim.ZEROCONF_ACC_NAME in gajim.config.get_per('accounts'):
# Create zeroconf in config file # Create zeroconf in config file
from common.zeroconf import connection_zeroconf from common.zeroconf import connection_zeroconf
zeroconf = connection_zeroconf.ConnectionZeroconf( connection_zeroconf.ConnectionZeroconf(gajim.ZEROCONF_ACC_NAME)
gajim.ZEROCONF_ACC_NAME)
if sys.platform == 'darwin': if sys.platform == 'darwin':
self.setup_for_osx() self.setup_for_osx()

View File

@ -655,7 +655,7 @@ class FileTransfersTooltip(BaseTooltip):
properties = [] properties = []
name = file_props['name'] name = file_props['name']
if file_props['type'] == 'r': if file_props['type'] == 'r':
(file_path, file_name) = os.path.split(file_props['file-name']) file_name = os.path.split(file_props['file-name'])[1]
else: else:
file_name = file_props['name'] file_name = file_props['name']
properties.append((_('Name: '), properties.append((_('Name: '),