awaiting_messages is now named awaiting events

it now contains subject of messages
This commit is contained in:
Yann Leboulanger 2005-10-15 20:49:08 +00:00
parent 6b097f465a
commit 966afbb031
6 changed files with 56 additions and 38 deletions

View File

@ -54,7 +54,10 @@ gc_connected = {} # tell if we are connected to the room or not {room_jid: True}
groups = {} # list of groups
newly_added = {} # list of contacts that has just signed in
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
allow_notifications = {} # do we allow notifications for each account ?
con_types = {} # type of each connection (ssl, tls, tcp, ...)

View File

@ -1261,8 +1261,7 @@ _('To change the account name, you must be disconnected.')).get_response()
if name != self.account:
#update variables
self.plugin.windows[name] = self.plugin.windows[self.account]
gajim.awaiting_messages[name] = \
gajim.awaiting_messages[self.account]
gajim.awaiting_events[name] = gajim.awaiting_events[self.account]
gajim.nicks[name] = gajim.nicks[self.account]
gajim.allow_notifications[name] = \
gajim.allow_notifications[self.account]
@ -1292,7 +1291,7 @@ _('To change the account name, you must be disconnected.')).get_response()
list[0] = name
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.allow_notifications[self.account]
del gajim.groups[self.account]
@ -1349,7 +1348,7 @@ _('To change the account name, you must be disconnected.')).get_response()
'gc_config': {}}
self.plugin.windows[name]['xml_console'] = \
dialogs.XMLConsoleWindow(self.plugin, name)
gajim.awaiting_messages[name] = {}
gajim.awaiting_events[name] = {}
gajim.connections[name].connected = 0
gajim.groups[name] = {}
gajim.contacts[name] = {}
@ -2525,7 +2524,7 @@ class RemoveAccountWindow:
gajim.config.del_per('accounts', self.account)
self.plugin.save_config()
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.allow_notifications[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': {}}
self.plugin.windows[name]['xml_console'] = \
dialogs.XMLConsoleWindow(self.plugin, name)
gajim.awaiting_messages[name] = {}
gajim.awaiting_events[name] = {}
gajim.connections[name].connected = 0
gajim.groups[name] = {}
gajim.contacts[name] = {}

View File

@ -316,7 +316,7 @@ class Interface:
if user1.jid in gajim.newly_added[account]:
gajim.newly_added[account].remove(user1.jid)
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, \
user1, account)
user1.show = array[1]
@ -340,7 +340,7 @@ class Interface:
'enabled'):
helpers.play_sound('contact_connected')
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.allow_notifications[account]:
show_notification = False
@ -366,7 +366,7 @@ class Interface:
'enabled'):
helpers.play_sound('contact_disconnected')
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'):
show_notification = False
# 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])
fjid = array[0]
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:
instance = dialogs.PopupNotificationWindow(self,
_('New Private Message'), fjid, account, 'pm')
@ -445,7 +445,7 @@ class Interface:
first = False
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
if gajim.config.get('notify_on_new_message'):
show_notification = False
@ -602,7 +602,7 @@ class Interface:
self.windows['account_modification'].account_is_ok(array[0])
self.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}, 'gc_config': {}}
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
gajim.connections[name].connected = 1
gajim.gc_contacts[name] = {}
@ -1226,7 +1226,7 @@ class Interface:
gajim.gc_connected[a] = {}
gajim.newly_added[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.allow_notifications[a] = False
gajim.sleeper_state[a] = 0

View File

@ -399,7 +399,8 @@ class GroupchatWindow(chat.Chat):
nick = model[user_iter][C_NICK].decode('utf-8')
show = gajim.gc_contacts[self.account][room_jid][nick].show
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):
image = state_images['message']
else:
@ -506,8 +507,9 @@ class GroupchatWindow(chat.Chat):
nb = 0
for nick in self.get_nick_list(room_jid):
fjid = room_jid + '/' + nick
if gajim.awaiting_messages[self.account].has_key(fjid):
nb += len(gajim.awaiting_messages[self.account][fjid])
if gajim.awaiting_events[self.account].has_key(fjid):
# gc can only have messages as event
nb += len(gajim.awaiting_events[self.account][fjid])
return nb
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):
# Do we have a queue?
fjid = room_jid + '/' + nick
qs = gajim.awaiting_messages[self.account]
qs = gajim.awaiting_events[self.account]
no_queue = True
if qs.has_key(fjid):
no_queue = False
@ -1375,7 +1377,7 @@ current room topic.') % command, room_jid)
if no_queue:
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
autopopup = gajim.config.get('autopopup')

View File

@ -143,7 +143,7 @@ class RosterWindow:
if user.show in ('offline', 'error') and \
not showOffline and (not _('Transports') in user.groups or \
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
model = self.tree.get_model()
@ -225,7 +225,8 @@ class RosterWindow:
name += ' (' + unicode(len(contact_instances)) + ')'
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']
elif jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent
img = state_images[contact.show]
@ -614,7 +615,7 @@ class RosterWindow:
contact.show = show
contact.status = status
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
contact_instances.remove(contact)
self.draw_contact(contact.jid, account)
@ -1579,7 +1580,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
return
# Do we have a queue?
qs = gajim.awaiting_messages[account]
qs = gajim.awaiting_events[account]
no_queue = True
if qs.has_key(jid):
no_queue = False
@ -1596,7 +1597,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
# We save it in a queue
if no_queue:
qs[jid] = []
qs[jid].append((msg, msg_type, tim, encrypted))
qs[jid].append(('message', (msg, subject, msg_type, tim, encrypted)))
self.nb_unread += 1
if (not autopopup or ( not autopopupaway and \
gajim.connections[account].connected > 2)) and not \

View File

@ -449,7 +449,7 @@ class TabbedChatWindow(chat.Chat):
# restore previous conversation
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.childs[contact.jid].show_all()
@ -759,7 +759,7 @@ class TabbedChatWindow(chat.Chat):
def read_queue(self, jid):
'''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]
# Is it a pm ?
is_pm = False
@ -767,25 +767,36 @@ class TabbedChatWindow(chat.Chat):
gcs = self.plugin.windows[self.account]['gc']
if gcs.has_key(room_jid):
is_pm = True
events_to_keep = []
for event in l:
ev1 = event[1]
if ev1 != 'error':
ev1 = 'print_queue'
typ = event[0]
if typ != 'message':
events_to_keep.append(event)
continue
data = event[1]
kind = data[2]
if kind == 'error':
kind = 'status'
else:
ev1 = 'status'
self.print_conversation(event[0], jid, ev1,
tim = event[2], encrypted = event[3])
kind = 'print_queue'
self.print_conversation(data[0], jid, kind, tim = data[3],
encrypted = data[4], subject = data[1])
# remove from gc nb_unread if it's pm or from roster
if is_pm:
gcs[room_jid].nb_unread[room_jid] -= 1
else:
self.plugin.roster.nb_unread -= 1
if is_pm:
gcs[room_jid].show_title()
else:
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 ?
# reset to status image in gc if it is a pm
room_jid = jid.split('/', 1)[0]
@ -852,11 +863,13 @@ class TabbedChatWindow(chat.Chat):
lines = [] # we'll need to reverse the lines from history
count = gajim.logger.get_no_of_lines(jid)
if gajim.awaiting_messages[self.account].has_key(jid):
pos = len(gajim.awaiting_messages[self.account][jid])
else:
pos = 0
# pos: number of messages that are in queue and are printed in log file
pos = 0
if gajim.awaiting_events[self.account].has_key(jid):
l = gajim.awaiting_events[self.account][jid]
for event in l:
if event[0] == 'message':
pos += 1
now = time.time()
while size <= restore: