awaiting_messages is now named awaiting events
it now contains subject of messages
This commit is contained in:
parent
6b097f465a
commit
966afbb031
|
@ -54,7 +54,10 @@ gc_connected = {} # tell if we are connected to the room or not {room_jid: True}
|
||||||
groups = {} # list of groups
|
groups = {} # list of groups
|
||||||
newly_added = {} # list of contacts that has just signed in
|
newly_added = {} # list of contacts that has just signed in
|
||||||
to_be_removed = {} # list of contacts that has just signed out
|
to_be_removed = {} # list of contacts that has just signed out
|
||||||
awaiting_messages = {} # list of messages reveived but not printed
|
awaiting_events = {} # list of messages/FT reveived but not printed
|
||||||
|
# awaiting_events[jid] = (type, (data1, data2, ...))
|
||||||
|
# if type == 'message': data = (message, subject, kind, time, encrypted)
|
||||||
|
# kind can be (incoming, error)
|
||||||
nicks = {} # list of our nick names in each account
|
nicks = {} # list of our nick names in each account
|
||||||
allow_notifications = {} # do we allow notifications for each account ?
|
allow_notifications = {} # do we allow notifications for each account ?
|
||||||
con_types = {} # type of each connection (ssl, tls, tcp, ...)
|
con_types = {} # type of each connection (ssl, tls, tcp, ...)
|
||||||
|
|
|
@ -1261,8 +1261,7 @@ _('To change the account name, you must be disconnected.')).get_response()
|
||||||
if name != self.account:
|
if name != self.account:
|
||||||
#update variables
|
#update variables
|
||||||
self.plugin.windows[name] = self.plugin.windows[self.account]
|
self.plugin.windows[name] = self.plugin.windows[self.account]
|
||||||
gajim.awaiting_messages[name] = \
|
gajim.awaiting_events[name] = gajim.awaiting_events[self.account]
|
||||||
gajim.awaiting_messages[self.account]
|
|
||||||
gajim.nicks[name] = gajim.nicks[self.account]
|
gajim.nicks[name] = gajim.nicks[self.account]
|
||||||
gajim.allow_notifications[name] = \
|
gajim.allow_notifications[name] = \
|
||||||
gajim.allow_notifications[self.account]
|
gajim.allow_notifications[self.account]
|
||||||
|
@ -1292,7 +1291,7 @@ _('To change the account name, you must be disconnected.')).get_response()
|
||||||
list[0] = name
|
list[0] = name
|
||||||
|
|
||||||
del self.plugin.windows[self.account]
|
del self.plugin.windows[self.account]
|
||||||
del gajim.awaiting_messages[self.account]
|
del gajim.awaiting_events[self.account]
|
||||||
del gajim.nicks[self.account]
|
del gajim.nicks[self.account]
|
||||||
del gajim.allow_notifications[self.account]
|
del gajim.allow_notifications[self.account]
|
||||||
del gajim.groups[self.account]
|
del gajim.groups[self.account]
|
||||||
|
@ -1349,7 +1348,7 @@ _('To change the account name, you must be disconnected.')).get_response()
|
||||||
'gc_config': {}}
|
'gc_config': {}}
|
||||||
self.plugin.windows[name]['xml_console'] = \
|
self.plugin.windows[name]['xml_console'] = \
|
||||||
dialogs.XMLConsoleWindow(self.plugin, name)
|
dialogs.XMLConsoleWindow(self.plugin, name)
|
||||||
gajim.awaiting_messages[name] = {}
|
gajim.awaiting_events[name] = {}
|
||||||
gajim.connections[name].connected = 0
|
gajim.connections[name].connected = 0
|
||||||
gajim.groups[name] = {}
|
gajim.groups[name] = {}
|
||||||
gajim.contacts[name] = {}
|
gajim.contacts[name] = {}
|
||||||
|
@ -2525,7 +2524,7 @@ class RemoveAccountWindow:
|
||||||
gajim.config.del_per('accounts', self.account)
|
gajim.config.del_per('accounts', self.account)
|
||||||
self.plugin.save_config()
|
self.plugin.save_config()
|
||||||
del self.plugin.windows[self.account]
|
del self.plugin.windows[self.account]
|
||||||
del gajim.awaiting_messages[self.account]
|
del gajim.awaiting_events[self.account]
|
||||||
del gajim.nicks[self.account]
|
del gajim.nicks[self.account]
|
||||||
del gajim.allow_notifications[self.account]
|
del gajim.allow_notifications[self.account]
|
||||||
del gajim.groups[self.account]
|
del gajim.groups[self.account]
|
||||||
|
@ -3009,7 +3008,7 @@ _('You need to enter a valid server address to continue.')).get_response()
|
||||||
'gc_config': {}}
|
'gc_config': {}}
|
||||||
self.plugin.windows[name]['xml_console'] = \
|
self.plugin.windows[name]['xml_console'] = \
|
||||||
dialogs.XMLConsoleWindow(self.plugin, name)
|
dialogs.XMLConsoleWindow(self.plugin, name)
|
||||||
gajim.awaiting_messages[name] = {}
|
gajim.awaiting_events[name] = {}
|
||||||
gajim.connections[name].connected = 0
|
gajim.connections[name].connected = 0
|
||||||
gajim.groups[name] = {}
|
gajim.groups[name] = {}
|
||||||
gajim.contacts[name] = {}
|
gajim.contacts[name] = {}
|
||||||
|
|
14
src/gajim.py
14
src/gajim.py
|
@ -316,7 +316,7 @@ class Interface:
|
||||||
if user1.jid in gajim.newly_added[account]:
|
if user1.jid in gajim.newly_added[account]:
|
||||||
gajim.newly_added[account].remove(user1.jid)
|
gajim.newly_added[account].remove(user1.jid)
|
||||||
self.roster.draw_contact(user1.jid, account)
|
self.roster.draw_contact(user1.jid, account)
|
||||||
if not gajim.awaiting_messages[account].has_key(jid):
|
if not gajim.awaiting_events[account].has_key(jid):
|
||||||
gobject.timeout_add(5000, self.roster.really_remove_contact, \
|
gobject.timeout_add(5000, self.roster.really_remove_contact, \
|
||||||
user1, account)
|
user1, account)
|
||||||
user1.show = array[1]
|
user1.show = array[1]
|
||||||
|
@ -340,7 +340,7 @@ class Interface:
|
||||||
'enabled'):
|
'enabled'):
|
||||||
helpers.play_sound('contact_connected')
|
helpers.play_sound('contact_connected')
|
||||||
if not self.windows[account]['chats'].has_key(jid) and \
|
if not self.windows[account]['chats'].has_key(jid) and \
|
||||||
not gajim.awaiting_messages[account].has_key(jid) and \
|
not gajim.awaiting_events[account].has_key(jid) and \
|
||||||
gajim.config.get('notify_on_signin') and \
|
gajim.config.get('notify_on_signin') and \
|
||||||
gajim.allow_notifications[account]:
|
gajim.allow_notifications[account]:
|
||||||
show_notification = False
|
show_notification = False
|
||||||
|
@ -366,7 +366,7 @@ class Interface:
|
||||||
'enabled'):
|
'enabled'):
|
||||||
helpers.play_sound('contact_disconnected')
|
helpers.play_sound('contact_disconnected')
|
||||||
if not self.windows[account]['chats'].has_key(jid) and \
|
if not self.windows[account]['chats'].has_key(jid) and \
|
||||||
not gajim.awaiting_messages[account].has_key(jid) and \
|
not gajim.awaiting_events[account].has_key(jid) and \
|
||||||
gajim.config.get('notify_on_signout'):
|
gajim.config.get('notify_on_signout'):
|
||||||
show_notification = False
|
show_notification = False
|
||||||
# check OUR status and if we allow notifications for that status
|
# check OUR status and if we allow notifications for that status
|
||||||
|
@ -409,7 +409,7 @@ class Interface:
|
||||||
nick = gajim.get_nick_from_fjid(array[0])
|
nick = gajim.get_nick_from_fjid(array[0])
|
||||||
fjid = array[0]
|
fjid = array[0]
|
||||||
if not self.windows[account]['chats'].has_key(fjid) and \
|
if not self.windows[account]['chats'].has_key(fjid) and \
|
||||||
not gajim.awaiting_messages[account].has_key(fjid):
|
not gajim.awaiting_events[account].has_key(fjid):
|
||||||
if show_notification:
|
if show_notification:
|
||||||
instance = dialogs.PopupNotificationWindow(self,
|
instance = dialogs.PopupNotificationWindow(self,
|
||||||
_('New Private Message'), fjid, account, 'pm')
|
_('New Private Message'), fjid, account, 'pm')
|
||||||
|
@ -445,7 +445,7 @@ class Interface:
|
||||||
|
|
||||||
first = False
|
first = False
|
||||||
if not self.windows[account]['chats'].has_key(jid) and \
|
if not self.windows[account]['chats'].has_key(jid) and \
|
||||||
not gajim.awaiting_messages[account].has_key(jid):
|
not gajim.awaiting_events[account].has_key(jid):
|
||||||
first = True
|
first = True
|
||||||
if gajim.config.get('notify_on_new_message'):
|
if gajim.config.get('notify_on_new_message'):
|
||||||
show_notification = False
|
show_notification = False
|
||||||
|
@ -602,7 +602,7 @@ class Interface:
|
||||||
self.windows['account_modification'].account_is_ok(array[0])
|
self.windows['account_modification'].account_is_ok(array[0])
|
||||||
self.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}, 'gc_config': {}}
|
self.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}, 'gc_config': {}}
|
||||||
self.windows[name]['xml_console'] = dialogs.XMLConsoleWindow(self, name)
|
self.windows[name]['xml_console'] = dialogs.XMLConsoleWindow(self, name)
|
||||||
gajim.awaiting_messages[name] = {}
|
gajim.awaiting_events[name] = {}
|
||||||
# disconnect from server - our status in roster is offline
|
# disconnect from server - our status in roster is offline
|
||||||
gajim.connections[name].connected = 1
|
gajim.connections[name].connected = 1
|
||||||
gajim.gc_contacts[name] = {}
|
gajim.gc_contacts[name] = {}
|
||||||
|
@ -1226,7 +1226,7 @@ class Interface:
|
||||||
gajim.gc_connected[a] = {}
|
gajim.gc_connected[a] = {}
|
||||||
gajim.newly_added[a] = []
|
gajim.newly_added[a] = []
|
||||||
gajim.to_be_removed[a] = []
|
gajim.to_be_removed[a] = []
|
||||||
gajim.awaiting_messages[a] = {}
|
gajim.awaiting_events[a] = {}
|
||||||
gajim.nicks[a] = gajim.config.get_per('accounts', a, 'name')
|
gajim.nicks[a] = gajim.config.get_per('accounts', a, 'name')
|
||||||
gajim.allow_notifications[a] = False
|
gajim.allow_notifications[a] = False
|
||||||
gajim.sleeper_state[a] = 0
|
gajim.sleeper_state[a] = 0
|
||||||
|
|
|
@ -399,7 +399,8 @@ class GroupchatWindow(chat.Chat):
|
||||||
nick = model[user_iter][C_NICK].decode('utf-8')
|
nick = model[user_iter][C_NICK].decode('utf-8')
|
||||||
show = gajim.gc_contacts[self.account][room_jid][nick].show
|
show = gajim.gc_contacts[self.account][room_jid][nick].show
|
||||||
state_images = roster.get_appropriate_state_images(room_jid)
|
state_images = roster.get_appropriate_state_images(room_jid)
|
||||||
if gajim.awaiting_messages[self.account].has_key(room_jid + '/'\
|
# We can't have FT events in gc, so if we have events, it's messages
|
||||||
|
if gajim.awaiting_events[self.account].has_key(room_jid + '/'\
|
||||||
+ nick):
|
+ nick):
|
||||||
image = state_images['message']
|
image = state_images['message']
|
||||||
else:
|
else:
|
||||||
|
@ -506,8 +507,9 @@ class GroupchatWindow(chat.Chat):
|
||||||
nb = 0
|
nb = 0
|
||||||
for nick in self.get_nick_list(room_jid):
|
for nick in self.get_nick_list(room_jid):
|
||||||
fjid = room_jid + '/' + nick
|
fjid = room_jid + '/' + nick
|
||||||
if gajim.awaiting_messages[self.account].has_key(fjid):
|
if gajim.awaiting_events[self.account].has_key(fjid):
|
||||||
nb += len(gajim.awaiting_messages[self.account][fjid])
|
# gc can only have messages as event
|
||||||
|
nb += len(gajim.awaiting_events[self.account][fjid])
|
||||||
return nb
|
return nb
|
||||||
|
|
||||||
def on_change_subject_menuitem_activate(self, widget):
|
def on_change_subject_menuitem_activate(self, widget):
|
||||||
|
@ -1362,7 +1364,7 @@ current room topic.') % command, room_jid)
|
||||||
def on_private_message(self, room_jid, nick, msg, tim):
|
def on_private_message(self, room_jid, nick, msg, tim):
|
||||||
# Do we have a queue?
|
# Do we have a queue?
|
||||||
fjid = room_jid + '/' + nick
|
fjid = room_jid + '/' + nick
|
||||||
qs = gajim.awaiting_messages[self.account]
|
qs = gajim.awaiting_events[self.account]
|
||||||
no_queue = True
|
no_queue = True
|
||||||
if qs.has_key(fjid):
|
if qs.has_key(fjid):
|
||||||
no_queue = False
|
no_queue = False
|
||||||
|
@ -1375,7 +1377,7 @@ current room topic.') % command, room_jid)
|
||||||
|
|
||||||
if no_queue:
|
if no_queue:
|
||||||
qs[fjid] = []
|
qs[fjid] = []
|
||||||
qs[fjid].append((msg, 'incoming', tim, False)) # False is for encrypted
|
qs[fjid].append(('message', (msg, '', 'incoming', tim, False)))
|
||||||
self.nb_unread[room_jid] += 1
|
self.nb_unread[room_jid] += 1
|
||||||
|
|
||||||
autopopup = gajim.config.get('autopopup')
|
autopopup = gajim.config.get('autopopup')
|
||||||
|
|
|
@ -143,7 +143,7 @@ class RosterWindow:
|
||||||
if user.show in ('offline', 'error') and \
|
if user.show in ('offline', 'error') and \
|
||||||
not showOffline and (not _('Transports') in user.groups or \
|
not showOffline and (not _('Transports') in user.groups or \
|
||||||
gajim.connections[account].connected < 2) and \
|
gajim.connections[account].connected < 2) and \
|
||||||
not gajim.awaiting_messages[account].has_key(user.jid):
|
not gajim.awaiting_events[account].has_key(user.jid):
|
||||||
return
|
return
|
||||||
|
|
||||||
model = self.tree.get_model()
|
model = self.tree.get_model()
|
||||||
|
@ -225,7 +225,8 @@ class RosterWindow:
|
||||||
name += ' (' + unicode(len(contact_instances)) + ')'
|
name += ' (' + unicode(len(contact_instances)) + ')'
|
||||||
|
|
||||||
state_images = self.get_appropriate_state_images(jid)
|
state_images = self.get_appropriate_state_images(jid)
|
||||||
if gajim.awaiting_messages[account].has_key(jid):
|
if gajim.awaiting_events[account].has_key(jid):
|
||||||
|
#TODO: change icon for FT
|
||||||
img = state_images['message']
|
img = state_images['message']
|
||||||
elif jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent
|
elif jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent
|
||||||
img = state_images[contact.show]
|
img = state_images[contact.show]
|
||||||
|
@ -614,7 +615,7 @@ class RosterWindow:
|
||||||
contact.show = show
|
contact.show = show
|
||||||
contact.status = status
|
contact.status = status
|
||||||
if show in ('offline', 'error') and \
|
if show in ('offline', 'error') and \
|
||||||
not gajim.awaiting_messages[account].has_key(contact.jid):
|
not gajim.awaiting_events[account].has_key(contact.jid):
|
||||||
if len(contact_instances) > 1: # if multiple resources
|
if len(contact_instances) > 1: # if multiple resources
|
||||||
contact_instances.remove(contact)
|
contact_instances.remove(contact)
|
||||||
self.draw_contact(contact.jid, account)
|
self.draw_contact(contact.jid, account)
|
||||||
|
@ -1579,7 +1580,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Do we have a queue?
|
# Do we have a queue?
|
||||||
qs = gajim.awaiting_messages[account]
|
qs = gajim.awaiting_events[account]
|
||||||
no_queue = True
|
no_queue = True
|
||||||
if qs.has_key(jid):
|
if qs.has_key(jid):
|
||||||
no_queue = False
|
no_queue = False
|
||||||
|
@ -1596,7 +1597,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
|
||||||
# We save it in a queue
|
# We save it in a queue
|
||||||
if no_queue:
|
if no_queue:
|
||||||
qs[jid] = []
|
qs[jid] = []
|
||||||
qs[jid].append((msg, msg_type, tim, encrypted))
|
qs[jid].append(('message', (msg, subject, msg_type, tim, encrypted)))
|
||||||
self.nb_unread += 1
|
self.nb_unread += 1
|
||||||
if (not autopopup or ( not autopopupaway and \
|
if (not autopopup or ( not autopopupaway and \
|
||||||
gajim.connections[account].connected > 2)) and not \
|
gajim.connections[account].connected > 2)) and not \
|
||||||
|
|
|
@ -449,7 +449,7 @@ class TabbedChatWindow(chat.Chat):
|
||||||
# restore previous conversation
|
# restore previous conversation
|
||||||
self.restore_conversation(contact.jid)
|
self.restore_conversation(contact.jid)
|
||||||
|
|
||||||
if gajim.awaiting_messages[self.account].has_key(contact.jid):
|
if gajim.awaiting_events[self.account].has_key(contact.jid):
|
||||||
self.read_queue(contact.jid)
|
self.read_queue(contact.jid)
|
||||||
|
|
||||||
self.childs[contact.jid].show_all()
|
self.childs[contact.jid].show_all()
|
||||||
|
@ -759,7 +759,7 @@ class TabbedChatWindow(chat.Chat):
|
||||||
|
|
||||||
def read_queue(self, jid):
|
def read_queue(self, jid):
|
||||||
'''read queue and print messages containted in it'''
|
'''read queue and print messages containted in it'''
|
||||||
l = gajim.awaiting_messages[self.account][jid]
|
l = gajim.awaiting_events[self.account][jid]
|
||||||
contact = self.contacts[jid]
|
contact = self.contacts[jid]
|
||||||
# Is it a pm ?
|
# Is it a pm ?
|
||||||
is_pm = False
|
is_pm = False
|
||||||
|
@ -767,25 +767,36 @@ class TabbedChatWindow(chat.Chat):
|
||||||
gcs = self.plugin.windows[self.account]['gc']
|
gcs = self.plugin.windows[self.account]['gc']
|
||||||
if gcs.has_key(room_jid):
|
if gcs.has_key(room_jid):
|
||||||
is_pm = True
|
is_pm = True
|
||||||
|
events_to_keep = []
|
||||||
for event in l:
|
for event in l:
|
||||||
ev1 = event[1]
|
typ = event[0]
|
||||||
if ev1 != 'error':
|
if typ != 'message':
|
||||||
ev1 = 'print_queue'
|
events_to_keep.append(event)
|
||||||
|
continue
|
||||||
|
data = event[1]
|
||||||
|
kind = data[2]
|
||||||
|
if kind == 'error':
|
||||||
|
kind = 'status'
|
||||||
else:
|
else:
|
||||||
ev1 = 'status'
|
kind = 'print_queue'
|
||||||
self.print_conversation(event[0], jid, ev1,
|
self.print_conversation(data[0], jid, kind, tim = data[3],
|
||||||
tim = event[2], encrypted = event[3])
|
encrypted = data[4], subject = data[1])
|
||||||
|
|
||||||
# remove from gc nb_unread if it's pm or from roster
|
# remove from gc nb_unread if it's pm or from roster
|
||||||
if is_pm:
|
if is_pm:
|
||||||
gcs[room_jid].nb_unread[room_jid] -= 1
|
gcs[room_jid].nb_unread[room_jid] -= 1
|
||||||
else:
|
else:
|
||||||
self.plugin.roster.nb_unread -= 1
|
self.plugin.roster.nb_unread -= 1
|
||||||
|
|
||||||
if is_pm:
|
if is_pm:
|
||||||
gcs[room_jid].show_title()
|
gcs[room_jid].show_title()
|
||||||
else:
|
else:
|
||||||
self.plugin.roster.show_title()
|
self.plugin.roster.show_title()
|
||||||
del gajim.awaiting_messages[self.account][jid]
|
# Keep only non-messages events
|
||||||
|
if len(events_to_keep):
|
||||||
|
gajim.awaiting_events[self.account][jid] = events_to_keep
|
||||||
|
else:
|
||||||
|
del gajim.awaiting_events[self.account][jid]
|
||||||
typ = 'chat' # Is it a normal chat or a pm ?
|
typ = 'chat' # Is it a normal chat or a pm ?
|
||||||
# reset to status image in gc if it is a pm
|
# reset to status image in gc if it is a pm
|
||||||
room_jid = jid.split('/', 1)[0]
|
room_jid = jid.split('/', 1)[0]
|
||||||
|
@ -852,11 +863,13 @@ class TabbedChatWindow(chat.Chat):
|
||||||
lines = [] # we'll need to reverse the lines from history
|
lines = [] # we'll need to reverse the lines from history
|
||||||
count = gajim.logger.get_no_of_lines(jid)
|
count = gajim.logger.get_no_of_lines(jid)
|
||||||
|
|
||||||
|
# pos: number of messages that are in queue and are printed in log file
|
||||||
if gajim.awaiting_messages[self.account].has_key(jid):
|
pos = 0
|
||||||
pos = len(gajim.awaiting_messages[self.account][jid])
|
if gajim.awaiting_events[self.account].has_key(jid):
|
||||||
else:
|
l = gajim.awaiting_events[self.account][jid]
|
||||||
pos = 0
|
for event in l:
|
||||||
|
if event[0] == 'message':
|
||||||
|
pos += 1
|
||||||
|
|
||||||
now = time.time()
|
now = time.time()
|
||||||
while size <= restore:
|
while size <= restore:
|
||||||
|
|
Loading…
Reference in New Issue