Fix some bugs and improve coding of minimized groupchats.
This commit is contained in:
parent
fb95530daf
commit
19df2a0f9e
|
@ -553,6 +553,7 @@ class ChatControlBase(MessageControl):
|
||||||
subject = None, old_kind = None, xhtml = None):
|
subject = None, old_kind = None, xhtml = None):
|
||||||
'''prints 'chat' type messages'''
|
'''prints 'chat' type messages'''
|
||||||
jid = self.contact.jid
|
jid = self.contact.jid
|
||||||
|
account = self.account
|
||||||
full_jid = self.get_full_jid()
|
full_jid = self.get_full_jid()
|
||||||
textview = self.conv_textview
|
textview = self.conv_textview
|
||||||
end = False
|
end = False
|
||||||
|
@ -566,24 +567,27 @@ class ChatControlBase(MessageControl):
|
||||||
return
|
return
|
||||||
if kind == 'incoming':
|
if kind == 'incoming':
|
||||||
gajim.last_message_time[self.account][full_jid] = time.time()
|
gajim.last_message_time[self.account][full_jid] = time.time()
|
||||||
if (not self.parent_win.get_active_jid() or \
|
|
||||||
full_jid != self.parent_win.get_active_jid() or \
|
if kind in ('incoming', 'incoming_queue'):
|
||||||
not self.parent_win.is_active() or not end) and \
|
|
||||||
kind in ('incoming', 'incoming_queue'):
|
|
||||||
gc_message = False
|
gc_message = False
|
||||||
if self.type_id == message_control.TYPE_GC:
|
if self.type_id == message_control.TYPE_GC:
|
||||||
gc_message = True
|
gc_message = True
|
||||||
if not gc_message or \
|
if not gc_message or \
|
||||||
(gc_message and (other_tags_for_text == ['marked'] or \
|
(gc_message and (other_tags_for_text == ['marked'] or \
|
||||||
gajim.config.get('notify_on_all_muc_messages'))):
|
gajim.config.get('notify_on_all_muc_messages'))) or \
|
||||||
|
(gc_message and \
|
||||||
|
gajim.interface.minimized_controls.has_key(account) and \
|
||||||
|
jid in gajim.interface.minimized_controls[account]):
|
||||||
# we want to have save this message in events list
|
# we want to have save this message in events list
|
||||||
# other_tags_for_text == ['marked'] --> highlighted gc message
|
# other_tags_for_text == ['marked'] --> highlighted gc message
|
||||||
type_ = 'printed_' + self.type_id
|
type_ = 'printed_' + self.type_id
|
||||||
|
event = 'message_received'
|
||||||
if gc_message:
|
if gc_message:
|
||||||
type_ = 'printed_gc_msg'
|
type_ = 'printed_gc_msg'
|
||||||
show_in_roster = notify.get_show_in_roster('message_received',
|
event = 'gc_message_received'
|
||||||
|
show_in_roster = notify.get_show_in_roster(event,
|
||||||
self.account, self.contact)
|
self.account, self.contact)
|
||||||
show_in_systray = notify.get_show_in_systray('message_received',
|
show_in_systray = notify.get_show_in_systray(event,
|
||||||
self.account, self.contact)
|
self.account, self.contact)
|
||||||
event = gajim.events.create_event(type_, None,
|
event = gajim.events.create_event(type_, None,
|
||||||
show_in_roster = show_in_roster,
|
show_in_roster = show_in_roster,
|
||||||
|
@ -593,6 +597,14 @@ class ChatControlBase(MessageControl):
|
||||||
if show_in_roster:
|
if show_in_roster:
|
||||||
gajim.interface.roster.draw_contact(self.contact.jid,
|
gajim.interface.roster.draw_contact(self.contact.jid,
|
||||||
self.account)
|
self.account)
|
||||||
|
|
||||||
|
if not self.parent_win:
|
||||||
|
return
|
||||||
|
|
||||||
|
if (not self.parent_win.get_active_jid() or \
|
||||||
|
full_jid != self.parent_win.get_active_jid() or \
|
||||||
|
not self.parent_win.is_active() or not end) and \
|
||||||
|
kind in ('incoming', 'incoming_queue'):
|
||||||
self.parent_win.redraw_tab(self)
|
self.parent_win.redraw_tab(self)
|
||||||
ctrl = gajim.interface.msg_win_mgr.get_control(full_jid, self.account)
|
ctrl = gajim.interface.msg_win_mgr.get_control(full_jid, self.account)
|
||||||
if not self.parent_win.is_active():
|
if not self.parent_win.is_active():
|
||||||
|
@ -669,8 +681,12 @@ class ChatControlBase(MessageControl):
|
||||||
|
|
||||||
win.notebook.remove_page(ctrl_page)
|
win.notebook.remove_page(ctrl_page)
|
||||||
control.unparent()
|
control.unparent()
|
||||||
|
ctrl.parent_win = None
|
||||||
|
|
||||||
|
if not gajim.interface.minimized_controls.has_key(self.account):
|
||||||
|
gajim.interface.minimized_controls[self.account] = {}
|
||||||
|
gajim.interface.minimized_controls[self.account][self.contact.jid] = ctrl
|
||||||
|
|
||||||
gajim.connections[self.account].hidden_groupchats[self.contact.jid] = ctrl
|
|
||||||
del win._controls[self.account][self.contact.jid]
|
del win._controls[self.account][self.contact.jid]
|
||||||
|
|
||||||
win.check_tabs()
|
win.check_tabs()
|
||||||
|
@ -788,6 +804,8 @@ class ChatControlBase(MessageControl):
|
||||||
if not len(gajim.events.get_events(self.account, jid, ['printed_' + type_,
|
if not len(gajim.events.get_events(self.account, jid, ['printed_' + type_,
|
||||||
type_])):
|
type_])):
|
||||||
return
|
return
|
||||||
|
if not self.parent_win:
|
||||||
|
return
|
||||||
if self.conv_textview.at_the_end() and \
|
if self.conv_textview.at_the_end() and \
|
||||||
self.parent_win.get_active_control() == self and \
|
self.parent_win.get_active_control() == self and \
|
||||||
self.parent_win.window.is_active():
|
self.parent_win.window.is_active():
|
||||||
|
|
|
@ -70,7 +70,6 @@ class Connection(ConnectionHandlers):
|
||||||
self.last_time_to_reconnect = None
|
self.last_time_to_reconnect = None
|
||||||
self.new_account_info = None
|
self.new_account_info = None
|
||||||
self.bookmarks = []
|
self.bookmarks = []
|
||||||
self.hidden_groupchats = {}
|
|
||||||
self.annotations = {}
|
self.annotations = {}
|
||||||
self.on_purpose = False
|
self.on_purpose = False
|
||||||
self.last_io = gajim.idlequeue.current_time()
|
self.last_io = gajim.idlequeue.current_time()
|
||||||
|
|
|
@ -155,9 +155,8 @@ class Events:
|
||||||
self._events[account][new_jid] = self._events[account][old_jid]
|
self._events[account][new_jid] = self._events[account][old_jid]
|
||||||
del self._events[account][old_jid]
|
del self._events[account][old_jid]
|
||||||
|
|
||||||
def get_nb_events(self, types = [], account = None, ignore_types = []):
|
def get_nb_events(self, types = [], account = None):
|
||||||
return self._get_nb_events(types = types, account = account,
|
return self._get_nb_events(types = types, account = account)
|
||||||
ignore_types = ignore_types)
|
|
||||||
|
|
||||||
def get_events(self, account, jid = None, types = []):
|
def get_events(self, account, jid = None, types = []):
|
||||||
'''if event is not specified, get all events from this jid,
|
'''if event is not specified, get all events from this jid,
|
||||||
|
@ -187,7 +186,7 @@ class Events:
|
||||||
return first_event
|
return first_event
|
||||||
|
|
||||||
def _get_nb_events(self, account = None, jid = None, attribute = None,
|
def _get_nb_events(self, account = None, jid = None, attribute = None,
|
||||||
types = [], ignore_types = []):
|
types = []):
|
||||||
'''return the number of pending events'''
|
'''return the number of pending events'''
|
||||||
nb = 0
|
nb = 0
|
||||||
if account:
|
if account:
|
||||||
|
@ -207,8 +206,6 @@ class Events:
|
||||||
for event in self._events[acct][j]:
|
for event in self._events[acct][j]:
|
||||||
if types and event.type_ not in types:
|
if types and event.type_ not in types:
|
||||||
continue
|
continue
|
||||||
if ignore_types and event.type_ in ignore_types:
|
|
||||||
continue
|
|
||||||
if not attribute or \
|
if not attribute or \
|
||||||
attribute == 'systray' and event.show_in_systray or \
|
attribute == 'systray' and event.show_in_systray or \
|
||||||
attribute == 'roster' and event.show_in_roster:
|
attribute == 'roster' and event.show_in_roster:
|
||||||
|
|
114
src/gajim.py
114
src/gajim.py
|
@ -1052,9 +1052,10 @@ class Interface:
|
||||||
show = array[1]
|
show = array[1]
|
||||||
status = array[2]
|
status = array[2]
|
||||||
|
|
||||||
|
ctrl = self.msg_win_mgr.get_control(fjid, account)
|
||||||
|
|
||||||
# print status in chat window and update status/GPG image
|
# print status in chat window and update status/GPG image
|
||||||
if self.msg_win_mgr.has_window(fjid, account):
|
if ctrl:
|
||||||
ctrl = self.msg_win_mgr.get_control(fjid, account)
|
|
||||||
contact = ctrl.contact
|
contact = ctrl.contact
|
||||||
contact.show = show
|
contact.show = show
|
||||||
contact.status = status
|
contact.status = status
|
||||||
|
@ -1066,44 +1067,42 @@ class Interface:
|
||||||
else:
|
else:
|
||||||
ctrl.print_conversation(_('%s is now %s') % (nick, uf_show),
|
ctrl.print_conversation(_('%s is now %s') % (nick, uf_show),
|
||||||
'status')
|
'status')
|
||||||
ctrl.parent_win.redraw_tab(ctrl)
|
if ctrl.parent_win:
|
||||||
|
ctrl.parent_win.redraw_tab(ctrl)
|
||||||
if self.remote_ctrl:
|
if self.remote_ctrl:
|
||||||
self.remote_ctrl.raise_signal('GCPresence', (account, array))
|
self.remote_ctrl.raise_signal('GCPresence', (account, array))
|
||||||
|
|
||||||
if room_jid in gajim.connections[account].hidden_groupchats:
|
|
||||||
my_nick = gajim.connections[account].hidden_groupchats[room_jid].nick
|
|
||||||
first = False
|
|
||||||
if not gajim.events.get_events(account, room_jid, ['change_status']):
|
|
||||||
first = True
|
|
||||||
array = array + (time.localtime(),)
|
|
||||||
event = gajim.events.create_event('change_status', array,
|
|
||||||
show_in_roster = False, show_in_systray = False)
|
|
||||||
gajim.events.add_event(account, room_jid, event)
|
|
||||||
|
|
||||||
# Change status icon if kicked or deconnected from gc
|
|
||||||
if array[3] == my_nick and array[1] in ('offline', 'error') and \
|
|
||||||
array[9] != '303':
|
|
||||||
gajim.gc_connected[account][room_jid] = False
|
|
||||||
gajim.interface.roster.draw_contact(room_jid, account)
|
|
||||||
elif array[3] == my_nick:
|
|
||||||
gajim.gc_connected[account][room_jid] = True
|
|
||||||
gajim.interface.roster.draw_contact(room_jid, account)
|
|
||||||
return
|
|
||||||
|
|
||||||
# Get the window and control for the updated status, this may be a
|
# Get the window and control for the updated status, this may be a
|
||||||
# PrivateChatControl
|
# PrivateChatControl
|
||||||
control = self.msg_win_mgr.get_control(room_jid, account)
|
control = self.msg_win_mgr.get_control(room_jid, account)
|
||||||
|
if not control and \
|
||||||
|
self.minimized_controls.has_key(account) and \
|
||||||
|
room_jid in self.minimized_controls[account]:
|
||||||
|
control = self.minimized_controls[account][room_jid]
|
||||||
|
|
||||||
if control and control.type_id != message_control.TYPE_GC:
|
if control and control.type_id != message_control.TYPE_GC:
|
||||||
return
|
return
|
||||||
if control:
|
if control:
|
||||||
control.chg_contact_status(nick, show, status, array[4], array[5],
|
control.chg_contact_status(nick, show, status, array[4], array[5],
|
||||||
array[6], array[7], array[8], array[9], array[10])
|
array[6], array[7], array[8], array[9], array[10])
|
||||||
|
if not control.parent_win:
|
||||||
|
gajim.interface.roster.draw_contact(room_jid, account)
|
||||||
|
|
||||||
def handle_event_gc_msg(self, account, array):
|
def handle_event_gc_msg(self, account, array):
|
||||||
# ('GC_MSG', account, (jid, msg, time, has_timestamp, htmlmsg))
|
# ('GC_MSG', account, (jid, msg, time, has_timestamp, htmlmsg))
|
||||||
jids = array[0].split('/', 1)
|
jids = array[0].split('/', 1)
|
||||||
room_jid = jids[0]
|
room_jid = jids[0]
|
||||||
|
|
||||||
|
gc_control = self.msg_win_mgr.get_control(room_jid, account)
|
||||||
|
if not gc_control and \
|
||||||
|
self.minimized_controls.has_key(account) and \
|
||||||
|
room_jid in self.minimized_controls[account]:
|
||||||
|
gc_control = self.minimized_controls[account][room_jid]
|
||||||
|
|
||||||
|
if not gc_control:
|
||||||
|
return
|
||||||
xhtml = array[4]
|
xhtml = array[4]
|
||||||
|
|
||||||
if gajim.config.get('ignore_incoming_xhtml'):
|
if gajim.config.get('ignore_incoming_xhtml'):
|
||||||
xhtml = None
|
xhtml = None
|
||||||
if len(jids) == 1:
|
if len(jids) == 1:
|
||||||
|
@ -1113,47 +1112,13 @@ class Interface:
|
||||||
# message from someone
|
# message from someone
|
||||||
nick = jids[1]
|
nick = jids[1]
|
||||||
|
|
||||||
if room_jid in gajim.connections[account].hidden_groupchats:
|
|
||||||
message = array[1]
|
|
||||||
tim = array[2]
|
|
||||||
first = False
|
|
||||||
|
|
||||||
if not gajim.events.get_events(account, room_jid, ['gc_msg',
|
|
||||||
'gc_chat']):
|
|
||||||
first = True
|
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(
|
|
||||||
account, room_jid)
|
|
||||||
advanced_notif_num = notify.get_advanced_notification\
|
|
||||||
('message_received', account, contact)
|
|
||||||
ctrl = gajim.connections[account].hidden_groupchats[room_jid]
|
|
||||||
|
|
||||||
type_event = 'gc_msg'
|
|
||||||
do_popup = False
|
|
||||||
is_history = False
|
|
||||||
show_in_systray = False
|
|
||||||
show_in_roster = True
|
|
||||||
if not array[3] and ctrl.needs_visual_notification(message):
|
|
||||||
do_popup = True
|
|
||||||
show_in_systray = True
|
|
||||||
if array[3] or nick == '':
|
|
||||||
is_history = True
|
|
||||||
type_event = 'gc_history'
|
|
||||||
show_in_roster = False
|
|
||||||
if not array[3]:
|
|
||||||
notify.notify('new_gc_message', room_jid, account, [do_popup,
|
|
||||||
first, nick, message, is_history], advanced_notif_num)
|
|
||||||
event = gajim.events.create_event(type_event, (nick, array[1],
|
|
||||||
array[2], array[3], xhtml), show_in_roster = show_in_roster,
|
|
||||||
show_in_systray = show_in_systray)
|
|
||||||
gajim.events.add_event(account, room_jid, event)
|
|
||||||
gajim.interface.roster.draw_contact(room_jid, account)
|
|
||||||
gajim.interface.roster.show_title()
|
|
||||||
return
|
|
||||||
|
|
||||||
gc_control = self.msg_win_mgr.get_control(room_jid, account)
|
|
||||||
if not gc_control:
|
|
||||||
return
|
|
||||||
gc_control.on_message(nick, array[1], array[2], array[3], xhtml)
|
gc_control.on_message(nick, array[1], array[2], array[3], xhtml)
|
||||||
|
|
||||||
|
contact = gajim.contacts.\
|
||||||
|
get_contact_with_highest_priority(account, room_jid)
|
||||||
|
if contact:
|
||||||
|
gajim.interface.roster.draw_contact(room_jid, account)
|
||||||
|
|
||||||
if self.remote_ctrl:
|
if self.remote_ctrl:
|
||||||
self.remote_ctrl.raise_signal('GCMessage', (account, array))
|
self.remote_ctrl.raise_signal('GCMessage', (account, array))
|
||||||
|
|
||||||
|
@ -1161,18 +1126,20 @@ class Interface:
|
||||||
#('GC_SUBJECT', account, (jid, subject, body, has_timestamp))
|
#('GC_SUBJECT', account, (jid, subject, body, has_timestamp))
|
||||||
jids = array[0].split('/', 1)
|
jids = array[0].split('/', 1)
|
||||||
jid = jids[0]
|
jid = jids[0]
|
||||||
if jid in gajim.connections[account].hidden_groupchats:
|
|
||||||
array = (array[0], array[1], array[2]) + (time.localtime(),)
|
|
||||||
event = gajim.events.create_event('change_subject',
|
|
||||||
array, show_in_roster = False, show_in_systray = False)
|
|
||||||
gajim.events.add_event(account, jid, event)
|
|
||||||
contact = gajim.contacts.\
|
|
||||||
get_contact_with_highest_priority(account, jid)
|
|
||||||
contact.status = array[1]
|
|
||||||
gajim.interface.roster.draw_contact(jid, account)
|
|
||||||
return
|
|
||||||
|
|
||||||
gc_control = self.msg_win_mgr.get_control(jid, account)
|
gc_control = self.msg_win_mgr.get_control(jid, account)
|
||||||
|
|
||||||
|
if not gc_control and \
|
||||||
|
self.minimized_controls.has_key(account) and \
|
||||||
|
jid in self.minimized_controls[account]:
|
||||||
|
gc_control = self.minimized_controls[account][jid]
|
||||||
|
|
||||||
|
contact = gajim.contacts.\
|
||||||
|
get_contact_with_highest_priority(account, jid)
|
||||||
|
if contact:
|
||||||
|
contact.status = array[1]
|
||||||
|
gajim.interface.roster.draw_contact(jid, account)
|
||||||
|
|
||||||
if not gc_control:
|
if not gc_control:
|
||||||
return
|
return
|
||||||
gc_control.set_subject(array[1])
|
gc_control.set_subject(array[1])
|
||||||
|
@ -2203,6 +2170,7 @@ class Interface:
|
||||||
self.emoticons_menu = None
|
self.emoticons_menu = None
|
||||||
# handler when an emoticon is clicked in emoticons_menu
|
# handler when an emoticon is clicked in emoticons_menu
|
||||||
self.emoticon_menuitem_clicked = None
|
self.emoticon_menuitem_clicked = None
|
||||||
|
self.minimized_controls = {}
|
||||||
self.default_colors = {
|
self.default_colors = {
|
||||||
'inmsgcolor': gajim.config.get('inmsgcolor'),
|
'inmsgcolor': gajim.config.get('inmsgcolor'),
|
||||||
'outmsgcolor': gajim.config.get('outmsgcolor'),
|
'outmsgcolor': gajim.config.get('outmsgcolor'),
|
||||||
|
|
|
@ -614,7 +614,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
else:
|
else:
|
||||||
kind = 'incoming'
|
kind = 'incoming'
|
||||||
# muc-specific chatstate
|
# muc-specific chatstate
|
||||||
self.parent_win.redraw_tab(self, 'newmsg')
|
if self.parent_win:
|
||||||
|
self.parent_win.redraw_tab(self, 'newmsg')
|
||||||
else:
|
else:
|
||||||
kind = 'status'
|
kind = 'status'
|
||||||
|
|
||||||
|
@ -636,7 +637,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
str(self.gc_count_nicknames_colors))
|
str(self.gc_count_nicknames_colors))
|
||||||
if highlight:
|
if highlight:
|
||||||
# muc-specific chatstate
|
# muc-specific chatstate
|
||||||
self.parent_win.redraw_tab(self, 'attention')
|
if self.parent_win:
|
||||||
|
self.parent_win.redraw_tab(self, 'attention')
|
||||||
other_tags_for_name.append('bold')
|
other_tags_for_name.append('bold')
|
||||||
other_tags_for_text.append('marked')
|
other_tags_for_text.append('marked')
|
||||||
if sound == 'received':
|
if sound == 'received':
|
||||||
|
@ -647,7 +649,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
other_tags_for_text.append('gc_nickname_color_' + \
|
other_tags_for_text.append('gc_nickname_color_' + \
|
||||||
str(self.gc_custom_colors[contact]))
|
str(self.gc_custom_colors[contact]))
|
||||||
|
|
||||||
self.check_and_possibly_add_focus_out_line()
|
if self.parent_win:
|
||||||
|
self.check_and_possibly_add_focus_out_line()
|
||||||
|
|
||||||
ChatControlBase.print_conversation_line(self, text, kind, contact, tim,
|
ChatControlBase.print_conversation_line(self, text, kind, contact, tim,
|
||||||
other_tags_for_name, [], other_tags_for_text, xhtml = xhtml)
|
other_tags_for_name, [], other_tags_for_text, xhtml = xhtml)
|
||||||
|
@ -918,7 +921,12 @@ class GroupchatControl(ChatControlBase):
|
||||||
c.status = status
|
c.status = status
|
||||||
if nick == self.nick and statusCode != '303': # We became offline
|
if nick == self.nick and statusCode != '303': # We became offline
|
||||||
self.got_disconnected()
|
self.got_disconnected()
|
||||||
self.parent_win.redraw_tab(self)
|
contact = gajim.contacts.\
|
||||||
|
get_contact_with_highest_priority(self.account, self.room_jid)
|
||||||
|
if contact:
|
||||||
|
gajim.interface.roster.draw_contact(self.room_jid, self.account)
|
||||||
|
if self.parent_win:
|
||||||
|
self.parent_win.redraw_tab(self)
|
||||||
else:
|
else:
|
||||||
iter = self.get_contact_iter(nick)
|
iter = self.get_contact_iter(nick)
|
||||||
if not iter:
|
if not iter:
|
||||||
|
@ -943,8 +951,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
c.affiliation = affiliation
|
c.affiliation = affiliation
|
||||||
c.status = status
|
c.status = status
|
||||||
self.draw_contact(nick)
|
self.draw_contact(nick)
|
||||||
|
if self.parent_win:
|
||||||
self.parent_win.redraw_tab(self)
|
self.parent_win.redraw_tab(self)
|
||||||
if (time.time() - self.room_creation) > 30 and \
|
if (time.time() - self.room_creation) > 30 and \
|
||||||
nick != self.nick and statusCode != '303':
|
nick != self.nick and statusCode != '303':
|
||||||
st = ''
|
st = ''
|
||||||
|
@ -2017,47 +2025,47 @@ class GroupchatControl(ChatControlBase):
|
||||||
else:
|
else:
|
||||||
self.revoke_owner(widget, jid)
|
self.revoke_owner(widget, jid)
|
||||||
|
|
||||||
def read_queue(self, jid, account):
|
#~ def read_queue(self, jid, account):
|
||||||
'''read queue and print messages containted in it'''
|
#~ '''read queue and print messages containted in it'''
|
||||||
events = gajim.events.get_events(account, jid)
|
#~ events = gajim.events.get_events(account, jid)
|
||||||
|
|
||||||
for event in events:
|
#~ for event in events:
|
||||||
if event.type_ == 'change_subject':
|
#~ if event.type_ == 'change_subject':
|
||||||
array = event.parameters
|
#~ array = event.parameters
|
||||||
jids = array[0].split('/', 1)
|
#~ jids = array[0].split('/', 1)
|
||||||
jid = jids[0]
|
#~ jid = jids[0]
|
||||||
self.set_subject(array[1])
|
#~ self.set_subject(array[1])
|
||||||
text = None
|
#~ text = None
|
||||||
if len(jids) > 1:
|
#~ if len(jids) > 1:
|
||||||
text = _('%s has set the subject to %s') % (jids[1], array[1])
|
#~ text = _('%s has set the subject to %s') % (jids[1], array[1])
|
||||||
elif array[2]:
|
#~ elif array[2]:
|
||||||
text = array[2]
|
#~ text = array[2]
|
||||||
if text is not None:
|
#~ if text is not None:
|
||||||
self.print_conversation(text, tim = array[3])
|
#~ self.print_conversation(text, tim = array[3])
|
||||||
|
|
||||||
if event.type_ == 'change_status':
|
#~ if event.type_ == 'change_status':
|
||||||
array = event.parameters
|
#~ array = event.parameters
|
||||||
nick = array[3]
|
#~ nick = array[3]
|
||||||
if not nick:
|
#~ if not nick:
|
||||||
return
|
#~ return
|
||||||
room_jid = array[0]
|
#~ room_jid = array[0]
|
||||||
fjid = room_jid + '/' + nick
|
#~ fjid = room_jid + '/' + nick
|
||||||
show = array[1]
|
#~ show = array[1]
|
||||||
status = array[2]
|
#~ status = array[2]
|
||||||
self.chg_contact_status(nick, show, status, array[4], array[5],
|
#~ self.chg_contact_status(nick, show, status, array[4], array[5],
|
||||||
array[6], array[7], array[8], array[9], array[10], array[11])
|
#~ array[6], array[7], array[8], array[9], array[10], array[11])
|
||||||
|
|
||||||
self.parent_win.redraw_tab(self)
|
#~ self.parent_win.redraw_tab(self)
|
||||||
|
|
||||||
if event.type_ in ['gc_msg', 'gc_history']:
|
#~ if event.type_ in ['gc_msg', 'gc_history']:
|
||||||
array = event.parameters
|
#~ array = event.parameters
|
||||||
kind = array[0]
|
#~ kind = array[0]
|
||||||
if kind == 'error' or kind == 'status':
|
#~ if kind == 'error' or kind == 'status':
|
||||||
kind = 'info'
|
#~ kind = 'info'
|
||||||
self.on_message(kind, array[1], array[2], array[3], array[4])
|
#~ self.on_message(kind, array[1], array[2], array[3], array[4])
|
||||||
|
|
||||||
gajim.events.remove_events(account, jid,
|
#~ gajim.events.remove_events(account, jid,
|
||||||
types = ['change_status', 'gc_msg', 'gc_history',
|
#~ types = ['change_status', 'gc_msg', 'gc_history',
|
||||||
'change_subject'])
|
#~ 'change_subject'])
|
||||||
gajim.interface.roster.draw_contact(jid, account)
|
#~ gajim.interface.roster.draw_contact(jid, account)
|
||||||
gajim.interface.roster.show_title()
|
#~ gajim.interface.roster.show_title()
|
||||||
|
|
|
@ -42,6 +42,8 @@ except ImportError:
|
||||||
|
|
||||||
def get_show_in_roster(event, account, contact):
|
def get_show_in_roster(event, account, contact):
|
||||||
'''Return True if this event must be shown in roster, else False'''
|
'''Return True if this event must be shown in roster, else False'''
|
||||||
|
if event == 'gc_message_received':
|
||||||
|
return True
|
||||||
num = get_advanced_notification(event, account, contact)
|
num = get_advanced_notification(event, account, contact)
|
||||||
if num != None:
|
if num != None:
|
||||||
if gajim.config.get_per('notifications', str(num), 'roster') == 'yes':
|
if gajim.config.get_per('notifications', str(num), 'roster') == 'yes':
|
||||||
|
@ -153,25 +155,10 @@ def notify(event, jid, account, parameters, advanced_notif_num = None):
|
||||||
is_first_message = parameters[1]
|
is_first_message = parameters[1]
|
||||||
nickname = parameters[2]
|
nickname = parameters[2]
|
||||||
message = parameters[3]
|
message = parameters[3]
|
||||||
if is_first_message and helpers.allow_sound_notification(
|
|
||||||
'first_message_received', advanced_notif_num):
|
|
||||||
do_sound = True
|
|
||||||
elif not is_first_message and helpers.allow_sound_notification(
|
|
||||||
'next_message_received', advanced_notif_num):
|
|
||||||
do_sound = True
|
|
||||||
if helpers.allow_showing_notification(account, 'notify_on_new_message',
|
if helpers.allow_showing_notification(account, 'notify_on_new_message',
|
||||||
advanced_notif_num, is_first_message):
|
advanced_notif_num, is_first_message):
|
||||||
do_popup = True
|
do_popup = True
|
||||||
elif event == 'new_gc_message':
|
if is_first_message and helpers.allow_sound_notification(
|
||||||
message_type = 'gc_msg'
|
|
||||||
do_popup = parameters[0]
|
|
||||||
is_first_message = parameters[1]
|
|
||||||
nickname = parameters[2]
|
|
||||||
message = parameters[3]
|
|
||||||
is_history = parameters[4]
|
|
||||||
if is_history:
|
|
||||||
pass
|
|
||||||
elif is_first_message and helpers.allow_sound_notification(
|
|
||||||
'first_message_received', advanced_notif_num):
|
'first_message_received', advanced_notif_num):
|
||||||
do_sound = True
|
do_sound = True
|
||||||
elif not is_first_message and helpers.allow_sound_notification(
|
elif not is_first_message and helpers.allow_sound_notification(
|
||||||
|
@ -260,19 +247,6 @@ def notify(event, jid, account, parameters, advanced_notif_num = None):
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
||||||
popup(event_type, jid, account, message_type,
|
popup(event_type, jid, account, message_type,
|
||||||
path_to_image = path, title = title, text = text)
|
path_to_image = path, title = title, text = text)
|
||||||
elif event == 'new_gc_message':
|
|
||||||
event_type = _('New Groupchat Message')
|
|
||||||
room_jid = jid
|
|
||||||
name = gajim.connections[account].hidden_groupchats[room_jid].name
|
|
||||||
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
|
||||||
'gc_invitation.png')
|
|
||||||
title = _('New Message on %s') % name
|
|
||||||
text = _('%(nickname)s: %(message)s') % {'nickname': nickname,
|
|
||||||
'message': message}
|
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
|
||||||
popup(event_type, jid, account, message_type,
|
|
||||||
path_to_image = path, title = title, text = text)
|
|
||||||
|
|
||||||
|
|
||||||
if do_sound:
|
if do_sound:
|
||||||
snd_file = None
|
snd_file = None
|
||||||
|
@ -462,8 +436,6 @@ class DesktopNotification:
|
||||||
ntype = 'presence.status'
|
ntype = 'presence.status'
|
||||||
elif event_type == _('Connection Failed'):
|
elif event_type == _('Connection Failed'):
|
||||||
ntype = 'connection.failed'
|
ntype = 'connection.failed'
|
||||||
elif event_type == _('New Groupchat Message'):
|
|
||||||
ntype = 'im'
|
|
||||||
else:
|
else:
|
||||||
# default failsafe values
|
# default failsafe values
|
||||||
self.path_to_image = os.path.abspath(
|
self.path_to_image = os.path.abspath(
|
||||||
|
|
|
@ -728,7 +728,8 @@ class RosterWindow:
|
||||||
win.set_active_tab(room_jid, account)
|
win.set_active_tab(room_jid, account)
|
||||||
dialogs.ErrorDialog(_('You are already in group chat %s') % room_jid)
|
dialogs.ErrorDialog(_('You are already in group chat %s') % room_jid)
|
||||||
return
|
return
|
||||||
if gajim.connections[account].hidden_groupchats.has_key(room_jid):
|
if gajim.interface.minimized_controls.has_key(account) and \
|
||||||
|
room_jid in gajim.interface.minimized_controls[account]:
|
||||||
self.on_groupchat_maximized(None, room_jid, account)
|
self.on_groupchat_maximized(None, room_jid, account)
|
||||||
return
|
return
|
||||||
invisible_show = gajim.SHOW_LIST.index('invisible')
|
invisible_show = gajim.SHOW_LIST.index('invisible')
|
||||||
|
@ -739,7 +740,11 @@ class RosterWindow:
|
||||||
if minimize:
|
if minimize:
|
||||||
contact = gajim.contacts.create_contact(jid = room_jid, name = nick)
|
contact = gajim.contacts.create_contact(jid = room_jid, name = nick)
|
||||||
gc_control = GroupchatControl(None, contact, account)
|
gc_control = GroupchatControl(None, contact, account)
|
||||||
gajim.connections[account].hidden_groupchats[room_jid] = gc_control
|
|
||||||
|
if not gajim.interface.minimized_controls.has_key(account):
|
||||||
|
gajim.interface.minimized_controls[account] = {}
|
||||||
|
gajim.interface.minimized_controls[account][room_jid] = gc_control
|
||||||
|
|
||||||
self.add_groupchat_to_roster(account, room_jid)
|
self.add_groupchat_to_roster(account, room_jid)
|
||||||
gajim.connections[account].join_gc(nick, room_jid, password)
|
gajim.connections[account].join_gc(nick, room_jid, password)
|
||||||
if password:
|
if password:
|
||||||
|
@ -2401,7 +2406,13 @@ class RosterWindow:
|
||||||
|
|
||||||
def on_groupchat_maximized(self, widget, jid, account):
|
def on_groupchat_maximized(self, widget, jid, account):
|
||||||
'''When a groupshat is maximised'''
|
'''When a groupshat is maximised'''
|
||||||
ctrl = gajim.connections[account].hidden_groupchats[jid]
|
if not gajim.interface.minimized_controls.has_key(account):
|
||||||
|
return
|
||||||
|
if not gajim.interface.minimized_controls[account].has_key(jid):
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
ctrl = gajim.interface.minimized_controls[account][jid]
|
||||||
mw = gajim.interface.msg_win_mgr.get_window(ctrl.contact.jid, ctrl.account)
|
mw = gajim.interface.msg_win_mgr.get_window(ctrl.contact.jid, ctrl.account)
|
||||||
if not mw:
|
if not mw:
|
||||||
mw = gajim.interface.msg_win_mgr.create_window(ctrl.contact, \
|
mw = gajim.interface.msg_win_mgr.create_window(ctrl.contact, \
|
||||||
|
@ -2410,12 +2421,12 @@ class RosterWindow:
|
||||||
mw.new_tab(ctrl)
|
mw.new_tab(ctrl)
|
||||||
mw.set_active_tab(jid, account)
|
mw.set_active_tab(jid, account)
|
||||||
mw.window.present()
|
mw.window.present()
|
||||||
ctrl.read_queue(jid, account)
|
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||||
self.remove_contact(contact, account)
|
self.remove_contact(contact, account)
|
||||||
gajim.contacts.remove_contact(account, contact)
|
gajim.contacts.remove_contact(account, contact)
|
||||||
self.draw_group(_('Groupchats'), account)
|
self.draw_group(_('Groupchats'), account)
|
||||||
del gajim.connections[account].hidden_groupchats[jid]
|
del gajim.interface.minimized_controls[account][jid]
|
||||||
|
|
||||||
def make_group_menu(self, event, iter):
|
def make_group_menu(self, event, iter):
|
||||||
'''Make group's popup menu'''
|
'''Make group's popup menu'''
|
||||||
|
@ -3177,8 +3188,11 @@ class RosterWindow:
|
||||||
else:
|
else:
|
||||||
gajim.connections[account].change_status(status, txt, auto)
|
gajim.connections[account].change_status(status, txt, auto)
|
||||||
|
|
||||||
|
if not gajim.interface.minimized_controls.has_key(account):
|
||||||
|
gajim.interface.minimized_controls[account] = {}
|
||||||
for gc_control in gajim.interface.msg_win_mgr.get_controls(
|
for gc_control in gajim.interface.msg_win_mgr.get_controls(
|
||||||
message_control.TYPE_GC):
|
message_control.TYPE_GC) + \
|
||||||
|
gajim.interface.minimized_controls[account].values():
|
||||||
if gc_control.account == account:
|
if gc_control.account == account:
|
||||||
if gajim.gc_connected[account][gc_control.room_jid]:
|
if gajim.gc_connected[account][gc_control.room_jid]:
|
||||||
gajim.connections[account].send_gc_status(gc_control.nick,
|
gajim.connections[account].send_gc_status(gc_control.nick,
|
||||||
|
@ -3786,8 +3800,7 @@ class RosterWindow:
|
||||||
# check if we have unread or recent mesages
|
# check if we have unread or recent mesages
|
||||||
unread = False
|
unread = False
|
||||||
recent = False
|
recent = False
|
||||||
if gajim.events.get_nb_events(ignore_types = ['gc_history',
|
if gajim.events.get_nb_events() > 0:
|
||||||
'change_status', 'change_subject']) > 0:
|
|
||||||
unread = True
|
unread = True
|
||||||
for win in gajim.interface.msg_win_mgr.windows():
|
for win in gajim.interface.msg_win_mgr.windows():
|
||||||
unrd = 0
|
unrd = 0
|
||||||
|
@ -3908,7 +3921,8 @@ class RosterWindow:
|
||||||
self.tree.collapse_row(path)
|
self.tree.collapse_row(path)
|
||||||
else:
|
else:
|
||||||
self.tree.expand_row(path, False)
|
self.tree.expand_row(path, False)
|
||||||
elif gajim.connections[account].hidden_groupchats.has_key(jid):
|
elif gajim.interface.minimized_controls.has_key(account) and \
|
||||||
|
gajim.interface.minimized_controls[account].has_key(jid):
|
||||||
self.on_groupchat_maximized(None, jid, account)
|
self.on_groupchat_maximized(None, jid, account)
|
||||||
else:
|
else:
|
||||||
first_ev = gajim.events.get_first_event(account, jid)
|
first_ev = gajim.events.get_first_event(account, jid)
|
||||||
|
|
|
@ -412,8 +412,9 @@ class RosterTooltip(NotificationAreaTooltip):
|
||||||
if self.account and prim_contact.jid in gajim.connections[
|
if self.account and prim_contact.jid in gajim.connections[
|
||||||
self.account].blocked_contacts:
|
self.account].blocked_contacts:
|
||||||
name_markup += _(' [blocked]')
|
name_markup += _(' [blocked]')
|
||||||
if self.account and gajim.connections[self.account].\
|
if self.account and \
|
||||||
hidden_groupchats.has_key(prim_contact.jid):
|
gajim.interface.minimized_controls.has_key(self.account) and \
|
||||||
|
prim_contact.jid in gajim.interface.minimized_controls[self.account]:
|
||||||
name_markup += _(' [minimized]')
|
name_markup += _(' [minimized]')
|
||||||
properties.append((name_markup, None))
|
properties.append((name_markup, None))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue