new way to handle incominf messages, new notification event.
[gajim.git] / src / notify.py
blob6da2f2e2e07ed4e2812ebfef6e593c42ab595996
1 # -*- coding:utf-8 -*-
2 ## src/notify.py
3 ##
4 ## Copyright (C) 2005 Sebastian Estienne
5 ## Copyright (C) 2005-2006 Andrew Sayman <lorien420 AT myrealbox.com>
6 ## Copyright (C) 2005-2007 Nikos Kouremenos <kourem AT gmail.com>
7 ## Copyright (C) 2005-2010 Yann Leboulanger <asterix AT lagaule.org>
8 ## Copyright (C) 2006 Travis Shirk <travis AT pobox.com>
9 ## Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT lapin.org>
10 ## Copyright (C) 2007 Julien Pivotto <roidelapluie AT gmail.com>
11 ## Stephan Erb <steve-e AT h3c.de>
12 ## Copyright (C) 2008 Brendan Taylor <whateley AT gmail.com>
13 ## Jonathan Schleifer <js-gajim AT webkeks.org>
15 ## This file is part of Gajim.
17 ## Gajim is free software; you can redistribute it and/or modify
18 ## it under the terms of the GNU General Public License as published
19 ## by the Free Software Foundation; version 3 only.
21 ## Gajim is distributed in the hope that it will be useful,
22 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ## GNU General Public License for more details.
26 ## You should have received a copy of the GNU General Public License
27 ## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
30 import os
31 import time
32 import dialogs
33 import gobject
34 import gtkgui_helpers
35 import gtk
37 from common import gajim
38 from common import helpers
39 from common import ged
41 from common import dbus_support
42 if dbus_support.supported:
43 import dbus
44 import dbus.glib
47 USER_HAS_PYNOTIFY = True # user has pynotify module
48 try:
49 import pynotify
50 pynotify.init('Gajim Notification')
51 except ImportError:
52 USER_HAS_PYNOTIFY = False
54 def get_show_in_roster(event, account, contact, session=None):
55 """
56 Return True if this event must be shown in roster, else False
57 """
58 if event == 'gc_message_received':
59 return True
60 num = get_advanced_notification(event, account, contact)
61 if num is not None:
62 if gajim.config.get_per('notifications', str(num), 'roster') == 'yes':
63 return True
64 if gajim.config.get_per('notifications', str(num), 'roster') == 'no':
65 return False
66 if event == 'message_received':
67 if session and session.control:
68 return False
69 return True
71 def get_show_in_systray(event, account, contact, type_=None):
72 """
73 Return True if this event must be shown in systray, else False
74 """
75 num = get_advanced_notification(event, account, contact)
76 if num is not None:
77 if gajim.config.get_per('notifications', str(num), 'systray') == 'yes':
78 return True
79 if gajim.config.get_per('notifications', str(num), 'systray') == 'no':
80 return False
81 if type_ == 'printed_gc_msg' and not gajim.config.get(
82 'notify_on_all_muc_messages'):
83 # it's not an highlighted message, don't show in systray
84 return False
85 return gajim.config.get('trayicon_notification_on_events')
87 def get_advanced_notification(event, account, contact):
88 """
89 Returns the number of the first (top most) advanced notification else None
90 """
91 num = 0
92 notif = gajim.config.get_per('notifications', str(num))
93 while notif:
94 recipient_ok = False
95 status_ok = False
96 tab_opened_ok = False
97 # test event
98 if gajim.config.get_per('notifications', str(num), 'event') == event:
99 # test recipient
100 recipient_type = gajim.config.get_per('notifications', str(num),
101 'recipient_type')
102 recipients = gajim.config.get_per('notifications', str(num),
103 'recipients').split()
104 if recipient_type == 'all':
105 recipient_ok = True
106 elif recipient_type == 'contact' and contact.jid in recipients:
107 recipient_ok = True
108 elif recipient_type == 'group':
109 for group in contact.groups:
110 if group in contact.groups:
111 recipient_ok = True
112 break
113 if recipient_ok:
114 # test status
115 our_status = gajim.SHOW_LIST[gajim.connections[account].connected]
116 status = gajim.config.get_per('notifications', str(num), 'status')
117 if status == 'all' or our_status in status.split():
118 status_ok = True
119 if status_ok:
120 # test window_opened
121 tab_opened = gajim.config.get_per('notifications', str(num),
122 'tab_opened')
123 if tab_opened == 'both':
124 tab_opened_ok = True
125 else:
126 chat_control = helpers.get_chat_control(account, contact)
127 if (chat_control and tab_opened == 'yes') or (not chat_control \
128 and tab_opened == 'no'):
129 tab_opened_ok = True
130 if tab_opened_ok:
131 return num
133 num += 1
134 notif = gajim.config.get_per('notifications', str(num))
136 def notify(event, jid, account, parameters, advanced_notif_num=None):
138 Check what type of notifications we want, depending on basic and the
139 advanced configuration of notifications and do these notifications;
140 advanced_notif_num holds the number of the first (top most) advanced
141 notification
143 # First, find what notifications we want
144 do_popup = False
145 do_sound = False
146 do_cmd = False
147 if event == 'status_change':
148 new_show = parameters[0]
149 status_message = parameters[1]
150 # Default: No popup for status change
151 elif event == 'contact_connected':
152 status_message = parameters
153 j = gajim.get_jid_without_resource(jid)
154 server = gajim.get_server_from_jid(j)
155 account_server = account + '/' + server
156 block_transport = False
157 if account_server in gajim.block_signed_in_notifications and \
158 gajim.block_signed_in_notifications[account_server]:
159 block_transport = True
160 if helpers.allow_showing_notification(account, 'notify_on_signin') and \
161 not gajim.block_signed_in_notifications[account] and \
162 not block_transport:
163 do_popup = True
164 if gajim.config.get_per('soundevents', 'contact_connected',
165 'enabled') and not gajim.block_signed_in_notifications[account] and \
166 not block_transport and helpers.allow_sound_notification(account,
167 event, advanced_notif_num):
168 do_sound = True
169 elif event == 'contact_disconnected':
170 status_message = parameters
171 if helpers.allow_showing_notification(account, 'notify_on_signout'):
172 do_popup = True
173 if gajim.config.get_per('soundevents', 'contact_disconnected',
174 'enabled') and helpers.allow_sound_notification(account,
175 event, advanced_notif_num):
176 do_sound = True
177 elif event == 'new_message':
178 message_type = parameters[0]
179 is_first_message = parameters[1]
180 nickname = parameters[2]
181 if gajim.config.get('notification_preview_message'):
182 message = parameters[3]
183 if message.startswith('/me ') or message.startswith('/me\n'):
184 message = '* ' + nickname + message[3:]
185 else:
186 # We don't want message preview, do_preview = False
187 message = ''
188 focused = parameters[4]
189 if helpers.allow_showing_notification(account, 'notify_on_new_message',
190 advanced_notif_num, is_first_message):
191 do_popup = True
192 if is_first_message and helpers.allow_sound_notification(account,
193 'first_message_received', advanced_notif_num):
194 do_sound = True
195 elif not is_first_message and focused and \
196 helpers.allow_sound_notification(account,
197 'next_message_received_focused', advanced_notif_num):
198 do_sound = True
199 elif not is_first_message and not focused and \
200 helpers.allow_sound_notification(account,
201 'next_message_received_unfocused', advanced_notif_num):
202 do_sound = True
203 else:
204 print '*Event not implemeted yet*'
206 if advanced_notif_num is not None and gajim.config.get_per('notifications',
207 str(advanced_notif_num), 'run_command'):
208 do_cmd = True
210 # Do the wanted notifications
211 if do_popup:
212 if event in ('contact_connected', 'contact_disconnected',
213 'status_change'): # Common code for popup for these three events
214 if event == 'contact_disconnected':
215 show_image = 'offline.png'
216 suffix = '_notif_size_bw'
217 else: # Status Change or Connected
218 # FIXME: for status change,
219 # we don't always 'online.png', but we
220 # first need 48x48 for all status
221 show_image = 'online.png'
222 suffix = '_notif_size_colored'
223 transport_name = gajim.get_transport_name_from_jid(jid)
224 img_path = None
225 if transport_name:
226 img_path = os.path.join(helpers.get_transport_path(
227 transport_name), '48x48', show_image)
228 if not img_path or not os.path.isfile(img_path):
229 iconset = gajim.config.get('iconset')
230 img_path = os.path.join(helpers.get_iconset_path(iconset),
231 '48x48', show_image)
232 path = gtkgui_helpers.get_path_to_generic_or_avatar(img_path,
233 jid=jid, suffix=suffix)
234 if event == 'status_change':
235 title = _('%(nick)s Changed Status') % \
236 {'nick': gajim.get_name_from_jid(account, jid)}
237 text = _('%(nick)s is now %(status)s') % \
238 {'nick': gajim.get_name_from_jid(account, jid),\
239 'status': helpers.get_uf_show(gajim.SHOW_LIST[new_show])}
240 if status_message:
241 text = text + " : " + status_message
242 popup(_('Contact Changed Status'), jid, account,
243 path_to_image=path, title=title, text=text)
244 elif event == 'contact_connected':
245 title = _('%(nickname)s Signed In') % \
246 {'nickname': gajim.get_name_from_jid(account, jid)}
247 text = ''
248 if status_message:
249 text = status_message
250 popup(_('Contact Signed In'), jid, account,
251 path_to_image=path, title=title, text=text)
252 elif event == 'contact_disconnected':
253 title = _('%(nickname)s Signed Out') % \
254 {'nickname': gajim.get_name_from_jid(account, jid)}
255 text = ''
256 if status_message:
257 text = status_message
258 popup(_('Contact Signed Out'), jid, account,
259 path_to_image=path, title=title, text=text)
260 elif event == 'new_message':
261 if message_type == 'normal': # single message
262 event_type = _('New Single Message')
263 img_name = 'gajim-single_msg_recv'
264 title = _('New Single Message from %(nickname)s') % \
265 {'nickname': nickname}
266 text = message
267 elif message_type == 'pm': # private message
268 event_type = _('New Private Message')
269 room_name = gajim.get_nick_from_jid(jid)
270 img_name = 'gajim-priv_msg_recv'
271 title = _('New Private Message from group chat %s') % room_name
272 if message:
273 text = _('%(nickname)s: %(message)s') % \
274 {'nickname': nickname, 'message': message}
275 else:
276 text = _('Messaged by %(nickname)s') % \
277 {'nickname': nickname}
279 else: # chat message
280 event_type = _('New Message')
281 img_name = 'gajim-chat_msg_recv'
282 title = _('New Message from %(nickname)s') % \
283 {'nickname': nickname}
284 text = message
285 img_path = gtkgui_helpers.get_icon_path(img_name, 48)
286 popup(event_type, jid, account, message_type,
287 path_to_image=img_path, title=title, text=text)
289 if do_sound:
290 snd_file = None
291 snd_event = None # If not snd_file, play the event
292 if event == 'new_message':
293 if advanced_notif_num is not None and gajim.config.get_per(
294 'notifications', str(advanced_notif_num), 'sound') == 'yes':
295 snd_file = gajim.config.get_per('notifications',
296 str(advanced_notif_num), 'sound_file')
297 elif advanced_notif_num is not None and gajim.config.get_per(
298 'notifications', str(advanced_notif_num), 'sound') == 'no':
299 pass # do not set snd_event
300 elif is_first_message:
301 snd_event = 'first_message_received'
302 elif focused:
303 snd_event = 'next_message_received_focused'
304 else:
305 snd_event = 'next_message_received_unfocused'
306 elif event in ('contact_connected', 'contact_disconnected'):
307 snd_event = event
308 if snd_file:
309 helpers.play_sound_file(snd_file)
310 if snd_event:
311 helpers.play_sound(snd_event)
313 if do_cmd:
314 command = gajim.config.get_per('notifications', str(advanced_notif_num),
315 'command')
316 try:
317 helpers.exec_command(command)
318 except Exception:
319 pass
321 def popup(event_type, jid, account, msg_type='', path_to_image=None, title=None,
322 text=None):
324 Notify a user of an event. It first tries to a valid implementation of
325 the Desktop Notification Specification. If that fails, then we fall back to
326 the older style PopupNotificationWindow method
328 # default image
329 if not path_to_image:
330 path_to_image = gtkgui_helpers.get_icon_path('gajim-chat_msg_recv', 48)
332 # Try to show our popup via D-Bus and notification daemon
333 if gajim.config.get('use_notif_daemon') and dbus_support.supported:
334 try:
335 DesktopNotification(event_type, jid, account, msg_type,
336 path_to_image, title, gobject.markup_escape_text(text))
337 return # sucessfully did D-Bus Notification procedure!
338 except dbus.DBusException, e:
339 # Connection to D-Bus failed
340 gajim.log.debug(str(e))
341 except TypeError, e:
342 # This means that we sent the message incorrectly
343 gajim.log.debug(str(e))
345 # Ok, that failed. Let's try pynotify, which also uses notification daemon
346 if gajim.config.get('use_notif_daemon') and USER_HAS_PYNOTIFY:
347 if not text and event_type == 'new_message':
348 # empty text for new_message means do_preview = False
349 # -> default value for text
350 _text = gobject.markup_escape_text(
351 gajim.get_name_from_jid(account, jid))
352 else:
353 _text = gobject.markup_escape_text(text)
355 if not title:
356 _title = ''
357 else:
358 _title = title
360 notification = pynotify.Notification(_title, _text)
361 timeout = gajim.config.get('notification_timeout') * 1000 # make it ms
362 notification.set_timeout(timeout)
364 notification.set_category(event_type)
365 notification.set_data('event_type', event_type)
366 notification.set_data('jid', jid)
367 notification.set_data('account', account)
368 notification.set_data('msg_type', msg_type)
369 notification.set_property('icon-name', path_to_image)
370 if 'actions' in pynotify.get_server_caps():
371 notification.add_action('default', 'Default Action',
372 on_pynotify_notification_clicked)
374 try:
375 notification.show()
376 return
377 except gobject.GError, e:
378 # Connection to notification-daemon failed, see #2893
379 gajim.log.debug(str(e))
381 # Either nothing succeeded or the user wants old-style notifications
382 instance = dialogs.PopupNotificationWindow(event_type, jid, account,
383 msg_type, path_to_image, title, text)
384 gajim.interface.roster.popup_notification_windows.append(instance)
386 def on_pynotify_notification_clicked(notification, action):
387 jid = notification.get_data('jid')
388 account = notification.get_data('account')
389 msg_type = notification.get_data('msg_type')
391 notification.close()
392 gajim.interface.handle_event(account, jid, msg_type)
394 class Notification:
396 Handle notifications
398 def __init__(self):
399 gajim.ged.register_event_handler('notification', ged.GUI2,
400 self._nec_notification)
402 def _nec_notification(self, obj):
403 if obj.do_popup:
404 popup(obj.popup_event_type, obj.jid, obj.conn.name,
405 obj.popup_msg_type, path_to_image=obj.popup_image,
406 title=obj.popup_title, text=obj.popup_text)
408 if obj.do_sound:
409 if obj.sound_file:
410 helpers.play_sound_file(obj.sound_file)
411 elif obj.sound_event:
412 helpers.play_sound(obj.sound_event)
414 if obj.do_command:
415 try:
416 helpers.exec_command(obj.command)
417 except Exception:
418 pass
420 class NotificationResponseManager:
422 Collect references to pending DesktopNotifications and manages there
423 signalling. This is necessary due to a bug in DBus where you can't remove a
424 signal from an interface once it's connected
427 def __init__(self):
428 self.pending = {}
429 self.received = []
430 self.interface = None
432 def attach_to_interface(self):
433 if self.interface is not None:
434 return
435 self.interface = dbus_support.get_notifications_interface()
436 self.interface.connect_to_signal('ActionInvoked',
437 self.on_action_invoked)
438 self.interface.connect_to_signal('NotificationClosed', self.on_closed)
440 def on_action_invoked(self, id_, reason):
441 self.received.append((id_, time.time(), reason))
442 if id_ in self.pending:
443 notification = self.pending[id_]
444 notification.on_action_invoked(id_, reason)
445 del self.pending[id_]
446 if len(self.received) > 20:
447 curt = time.time()
448 for rec in self.received:
449 diff = curt - rec[1]
450 if diff > 10:
451 self.received.remove(rec)
453 def on_closed(self, id_, reason=None):
454 if id_ in self.pending:
455 del self.pending[id_]
457 def add_pending(self, id_, object_):
458 # Check to make sure that we handle an event immediately if we're adding
459 # an id that's already been triggered
460 for rec in self.received:
461 if rec[0] == id_:
462 object_.on_action_invoked(id_, rec[2])
463 self.received.remove(rec)
464 return
465 if id_ not in self.pending:
466 # Add it
467 self.pending[id_] = object_
468 else:
469 # We've triggered an event that has a duplicate ID!
470 gajim.log.debug('Duplicate ID of notification. Can\'t handle this.')
472 notification_response_manager = NotificationResponseManager()
474 class DesktopNotification:
476 A DesktopNotification that interfaces with D-Bus via the Desktop
477 Notification Specification
480 def __init__(self, event_type, jid, account, msg_type='',
481 path_to_image=None, title=None, text=None):
482 self.path_to_image = path_to_image
483 self.event_type = event_type
484 self.title = title
485 self.text = text
486 # 0.3.1 is the only version of notification daemon that has no way
487 # to determine which version it is. If no method exists, it means
488 # they're using that one.
489 self.default_version = [0, 3, 1]
490 self.account = account
491 self.jid = jid
492 self.msg_type = msg_type
494 # default value of text
495 if not text and event_type == 'new_message':
496 # empty text for new_message means do_preview = False
497 self.text = gajim.get_name_from_jid(account, jid)
499 if not title:
500 self.title = event_type # default value
502 if event_type == _('Contact Signed In'):
503 ntype = 'presence.online'
504 elif event_type == _('Contact Signed Out'):
505 ntype = 'presence.offline'
506 elif event_type in (_('New Message'), _('New Single Message'),
507 _('New Private Message')):
508 ntype = 'im.received'
509 elif event_type == _('File Transfer Request'):
510 ntype = 'transfer'
511 elif event_type == _('File Transfer Error'):
512 ntype = 'transfer.error'
513 elif event_type in (_('File Transfer Completed'),
514 _('File Transfer Stopped')):
515 ntype = 'transfer.complete'
516 elif event_type == _('New E-mail'):
517 ntype = 'email.arrived'
518 elif event_type == _('Groupchat Invitation'):
519 ntype = 'im.invitation'
520 elif event_type == _('Contact Changed Status'):
521 ntype = 'presence.status'
522 elif event_type == _('Connection Failed'):
523 ntype = 'connection.failed'
524 elif event_type == _('Subscription request'):
525 ntype = 'subscription.request'
526 elif event_type == _('Unsubscribed'):
527 ntype = 'unsubscribed'
528 else:
529 # default failsafe values
530 self.path_to_image = gtkgui_helpers.get_icon_path(
531 'gajim-chat_msg_recv', 48)
532 ntype = 'im' # Notification Type
534 self.notif = dbus_support.get_notifications_interface(self)
535 if self.notif is None:
536 raise dbus.DBusException('unable to get notifications interface')
537 self.ntype = ntype
539 if self.kde_notifications:
540 self.attempt_notify()
541 else:
542 self.capabilities = self.notif.GetCapabilities()
543 if self.capabilities is None:
544 self.capabilities = ['actions']
545 self.get_version()
547 def attempt_notify(self):
548 timeout = gajim.config.get('notification_timeout') # in seconds
549 ntype = self.ntype
550 if self.kde_notifications:
551 notification_text = ('<html><img src="%(image)s" align=left />' \
552 '%(title)s<br/>%(text)s</html>') % {'title': self.title,
553 'text': self.text, 'image': self.path_to_image}
554 gajim_icon = gtkgui_helpers.get_icon_path('gajim', 48)
555 try:
556 self.notif.Notify(
557 dbus.String(_('Gajim')), # app_name (string)
558 dbus.UInt32(0), # replaces_id (uint)
559 ntype, # event_id (string)
560 dbus.String(gajim_icon), # app_icon (string)
561 dbus.String(''), # summary (string)
562 dbus.String(notification_text), # body (string)
563 # actions (stringlist)
564 (dbus.String('default'), dbus.String(self.event_type),
565 dbus.String('ignore'), dbus.String(_('Ignore'))),
566 [], # hints (not used in KDE yet)
567 dbus.UInt32(timeout*1000), # timeout (int), in ms
568 reply_handler=self.attach_by_id,
569 error_handler=self.notify_another_way)
570 return
571 except Exception:
572 pass
573 version = self.version
574 if version[:2] == [0, 2]:
575 actions = {}
576 if 'actions' in self.capabilities:
577 actions = {'default': 0}
578 try:
579 self.notif.Notify(
580 dbus.String(_('Gajim')),
581 dbus.String(self.path_to_image),
582 dbus.UInt32(0),
583 ntype,
584 dbus.Byte(0),
585 dbus.String(self.title),
586 dbus.String(self.text),
587 [dbus.String(self.path_to_image)],
588 actions,
589 [''],
590 True,
591 dbus.UInt32(timeout),
592 reply_handler=self.attach_by_id,
593 error_handler=self.notify_another_way)
594 except AttributeError:
595 # we're actually dealing with the newer version
596 version = [0, 3, 1]
597 if version > [0, 3]:
598 if gajim.interface.systray_enabled and \
599 gajim.config.get('attach_notifications_to_systray'):
600 status_icon = gajim.interface.systray.status_icon
601 x, y, width, height = status_icon.get_geometry()[1]
602 pos_x = x + (width / 2)
603 pos_y = y + (height / 2)
604 hints = {'x': pos_x, 'y': pos_y}
605 else:
606 hints = {}
607 if version >= [0, 3, 2]:
608 hints['urgency'] = dbus.Byte(0) # Low Urgency
609 hints['category'] = dbus.String(ntype)
610 # it seems notification-daemon doesn't like empty text
611 if self.text:
612 text = self.text
613 else:
614 text = ' '
615 if os.environ.get('KDE_FULL_SESSION') == 'true':
616 self.path_to_image = os.path.abspath(self.path_to_image)
617 text = '<table style=\'padding: 3px\'><tr><td>' \
618 '<img src=\"%s\"></td><td width=20> </td>' \
619 '<td>%s</td></tr></table>' % (self.path_to_image,
620 text)
621 self.path_to_image = os.path.abspath(
622 gtkgui_helpers.get_icon_path('gajim', 48))
623 actions = ()
624 if 'actions' in self.capabilities:
625 actions = (dbus.String('default'), dbus.String(
626 self.event_type))
627 try:
628 self.notif.Notify(
629 dbus.String(_('Gajim')),
630 # this notification does not replace other
631 dbus.UInt32(0),
632 dbus.String(self.path_to_image),
633 dbus.String(self.title),
634 dbus.String(text),
635 actions,
636 hints,
637 dbus.UInt32(timeout*1000),
638 reply_handler=self.attach_by_id,
639 error_handler=self.notify_another_way)
640 except Exception, e:
641 self.notify_another_way(e)
642 else:
643 try:
644 self.notif.Notify(
645 dbus.String(_('Gajim')),
646 dbus.String(self.path_to_image),
647 dbus.UInt32(0),
648 dbus.String(self.title),
649 dbus.String(self.text),
650 dbus.String(''),
651 hints,
652 dbus.UInt32(timeout*1000),
653 reply_handler=self.attach_by_id,
654 error_handler=self.notify_another_way)
655 except Exception, e:
656 self.notify_another_way(e)
658 def attach_by_id(self, id_):
659 self.id = id_
660 notification_response_manager.attach_to_interface()
661 notification_response_manager.add_pending(self.id, self)
663 def notify_another_way(self, e):
664 gajim.log.debug('Error when trying to use notification daemon: %s' % \
665 str(e))
666 instance = dialogs.PopupNotificationWindow(self.event_type, self.jid,
667 self.account, self.msg_type, self.path_to_image, self.title,
668 self.text)
669 gajim.interface.roster.popup_notification_windows.append(instance)
671 def on_action_invoked(self, id_, reason):
672 if self.notif is None:
673 return
674 self.notif.CloseNotification(dbus.UInt32(id_))
675 self.notif = None
677 if reason == 'ignore':
678 return
680 gajim.interface.handle_event(self.account, self.jid, self.msg_type)
682 def version_reply_handler(self, name, vendor, version, spec_version=None):
683 if spec_version:
684 version = spec_version
685 elif vendor == 'Xfce' and version.startswith('0.1.0'):
686 version = '0.9'
687 version_list = version.split('.')
688 self.version = []
689 try:
690 while len(version_list):
691 self.version.append(int(version_list.pop(0)))
692 except ValueError:
693 self.version_error_handler_3_x_try(None)
694 self.attempt_notify()
696 def get_version(self):
697 self.notif.GetServerInfo(
698 reply_handler=self.version_reply_handler,
699 error_handler=self.version_error_handler_2_x_try)
701 def version_error_handler_2_x_try(self, e):
702 self.notif.GetServerInformation(
703 reply_handler=self.version_reply_handler,
704 error_handler=self.version_error_handler_3_x_try)
706 def version_error_handler_3_x_try(self, e):
707 self.version = self.default_version
708 self.attempt_notify()