notifications for completed download

This commit is contained in:
Dimitur Kirov 2005-07-30 14:14:10 +00:00
parent 35c8487325
commit fd1e2e7a3f
3 changed files with 42 additions and 6 deletions

View file

@ -4,6 +4,7 @@
## - Yann Le Boulanger <asterix@lagaule.org>
## - Vincent Hanquez <tab@snarc.org>
## - Nikos Kouremenos <kourem@gmail.com>
## - Dimitur Kirov <dkirov@gmail.com>
##
## Copyright (C) 2003-2005 Gajim Team
##
@ -989,7 +990,11 @@ class PopupNotificationWindow:
close_button.modify_bg(gtk.STATE_NORMAL, bg_color)
eventbox.modify_bg(gtk.STATE_NORMAL, bg_color)
txt = _('From %s') % txt
elif event_type in [_('File Completed'), _('File Stopped')]:
bg_color = gtk.gdk.color_parse('coral')
close_button.modify_bg(gtk.STATE_NORMAL, bg_color)
eventbox.modify_bg(gtk.STATE_NORMAL, bg_color)
# position the window to bottom-right of screen
window_width, self.window_height = self.window.get_size()
self.plugin.roster.popups_notification_height += self.window_height
@ -1044,13 +1049,26 @@ class PopupNotificationWindow:
if self.msg_type == 'normal': # it's single message
return # FIXME: I think I should not print here but in new_chat?
contact = self.contacts[account][jid][0]
dialogs.SingleMessageWindow(self.plugin, self.account, contact,
dialogs.SingleMessageWindow(self.plugin, self.account, contact,
action = 'receive', from_whom = jid, subject = subject, message = msg)
elif self.msg_type == 'file': # it's file request
self.plugin.roster.show_file_request(self.account, contact,
self.file_props)
elif self.msg_type == 'file-completed': # it's file request
sectext ='\t' + _('File Name: %s') % self.file_props['name']
sectext +='\n\t' + _('Size: %s') % \
gtkgui_helpers.convert_bytes(self.file_props['size'])
sectext +='\n\t' +_('Sender: %s') % self.jid
InformationDialog(_('File Transfer Completed'), sectext).get_response()
elif self.msg_type == 'file-stopped': # it's file request
sectext ='\t' + _('File Name: %s') % self.file_props['name']
sectext +='\n\t' + _('Sender: %s') % self.jid
ErrorDialog(_('File Transfer Stopped by Peer'), \
sectext).get_response()
else: # 'chat'
self.plugin.roster.new_chat(contact, self.account)
chats_window = self.plugin.windows[self.account]['chats'][self.jid]

View file

@ -8,6 +8,7 @@ exec python -OOt "$0" ${1+"$@"}
## - Yann Le Boulanger <asterix@lagaule.org>
## - Vincent Hanquez <tab@snarc.org>
## - Nikos Kouremenos <kourem@gmail.com>
## - Dimitur Kirov <dkirov@gmail.com>
##
## Copyright (C) 2003-2005 Gajim Team
##
@ -698,20 +699,32 @@ class Interface:
def handle_event_file_request(self, account, array):
jid = array[0]
#~ print 'handle_event_file_request:', jid, gajim.contacts[account]
if not gajim.contacts[account].has_key(jid):
return
file_props = array[1]
#~ print 'handle_event_file_request:', array
if gajim.config.get('notify_on_new_message'):
# check OUR status and if we allow notifications for that status
if gajim.config.get('autopopupaway') or \
gajim.connections[account].connected in (2, 3): # we're online or chat
print 'HERE'
instance = dialogs.PopupNotificationWindow(self,
_('File Request'), jid, account, 'file', file_props)
self.roster.popup_notification_windows.append(instance)
def handle_event_file_rcv_completed(self, account, file_props):
# it is good to have 'notify_on_new_event'
if gajim.config.get('notify_on_new_message'):
if gajim.config.get('autopopupaway') or \
gajim.connections[account].connected in (2, 3): # we're online or chat
if file_props['error'] == 0:
msg_type = 'file-completed'
event_type = _('File Completed')
elif file_props['error'] == -1:
msg_type = 'file-stopped'
event_type = _('File Stopped')
instance = dialogs.PopupNotificationWindow(self, event_type,
file_props['sender'].getStripped(), account, msg_type, file_props)
self.roster.popup_notification_windows.append(instance)
def read_sleepy(self):
'''Check idle status and change that status if needed'''
if not self.sleeper.poll():
@ -878,6 +891,8 @@ class Interface:
con.register_handler('BOOKMARKS', self.handle_event_bookmarks)
con.register_handler('CON_TYPE', self.handle_event_con_type)
con.register_handler('FILE_REQUEST', self.handle_event_file_request)
con.register_handler('FILE_RCV_COMPLETED', \
self.handle_event_file_rcv_completed)
def process_connections(self):
try:

View file

@ -1324,7 +1324,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
def show_file_request(self, account, contact, file_props):
if file_props is None or not file_props.has_key('name'):
return
sec_text = _('\tFile: %s') % file_props['name']
sec_text = '\t' + _('File: %s') % file_props['name']
if file_props.has_key('size'):
sec_text += '\n\t' + _('Size: %s') % \
gtkgui_helpers.convert_bytes(file_props['size'])
@ -1349,6 +1349,9 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
else:
gajim.connections[account].send_file_rejection(file_props)
dialog.destroy()
else:
gajim.connections[account].send_file_rejection(file_props)
def new_chat(self, user, account):
if gajim.config.get('usetabbedchat'):