Example #1
0
 def attach_to_interface(self):
     if self.interface is not None:
         return
     self.interface = dbus_support.get_notifications_interface()
     self.interface.connect_to_signal('ActionInvoked',
                                      self.on_action_invoked)
     self.interface.connect_to_signal('NotificationClosed', self.on_closed)
Example #2
0
File: notify.py Project: irl/gajim
 def attach_to_interface(self):
     if self.interface is not None:
         return
     self.interface = dbus_support.get_notifications_interface()
     self.interface.connect_to_signal('ActionInvoked',
         self.on_action_invoked)
     self.interface.connect_to_signal('NotificationClosed', self.on_closed)
Example #3
0
 def notification_available(self):
     if os.name == 'nt':
         return False
     from common import dbus_support
     if self.dbus_available() and dbus_support.get_notifications_interface():
         return True
     try:
         __import__('pynotify')
     except Exception:
         return False
     return True
Example #4
0
	def __init__(self, event_type, jid, account, msg_type='',
		path_to_image=None, title=None, text=None):
		self.path_to_image = path_to_image
		self.event_type = event_type
		self.title = title
		self.text = text
		'''0.3.1 is the only version of notification daemon that has no way to determine which version it is. If no method exists, it means they're using that one.'''
		self.default_version = [0, 3, 1]
		self.account = account
		self.jid = jid
		self.msg_type = msg_type

		# default value of text
		if not text and event_type == 'new_message':
			# empty text for new_message means do_preview = False
			self.text = gajim.get_name_from_jid(account, jid)

		if not title:
			self.title = event_type # default value

		if event_type == _('Contact Signed In'):
			ntype = 'presence.online'
		elif event_type == _('Contact Signed Out'):
			ntype = 'presence.offline'
		elif event_type in (_('New Message'), _('New Single Message'),
			_('New Private Message')):
			ntype = 'im.received'
		elif event_type == _('File Transfer Request'):
			ntype = 'transfer'
		elif event_type == _('File Transfer Error'):
			ntype = 'transfer.error'
		elif event_type in (_('File Transfer Completed'), _('File Transfer Stopped')):
			ntype = 'transfer.complete'
		elif event_type == _('New E-mail'):
			ntype = 'email.arrived'
		elif event_type == _('Groupchat Invitation'):
			ntype = 'im.invitation'
		elif event_type == _('Contact Changed Status'):
			ntype = 'presence.status'
		elif event_type == _('Connection Failed'):
			ntype = 'connection.failed'
		else:
			# default failsafe values
			self.path_to_image = os.path.abspath(
				os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
					'chat_msg_recv.png')) # img to display
			ntype = 'im' # Notification Type

		self.notif = dbus_support.get_notifications_interface()
		if self.notif is None:
			raise dbus.DBusException('unable to get notifications interface')
		self.ntype = ntype

		self.get_version()
Example #5
0
 def notification_available(self):
     if os.name == 'nt':
         return False
     from common import dbus_support
     if self.dbus_available() and dbus_support.get_notifications_interface():
         return True
     try:
         __import__('pynotify')
     except Exception:
         return False
     return True
Example #6
0
	def notification_available(self):
		if os.name == 'nt':
			return False
		elif sys.platform == 'darwin':
			try:
				import osx.growler
			except Exception:
				return False
			return True
		from common import dbus_support
		if self.dbus_available() and dbus_support.get_notifications_interface():
			return True
		try:
			import pynotify
		except Exception:
			return False
		return True
Example #7
0
 def notification_available(self):
     if os.name == 'nt':
         return False
     elif sys.platform == 'darwin':
         try:
             import osx.growler
         except Exception:
             return False
         return True
     from common import dbus_support
     if self.dbus_available() and dbus_support.get_notifications_interface(
     ):
         return True
     try:
         import pynotify
     except Exception:
         return False
     return True
Example #8
0
File: notify.py Project: irl/gajim
    def __init__(self, event_type, jid, account, msg_type='',
    path_to_image=None, title=None, text=None, timeout=-1):
        self.path_to_image = os.path.abspath(path_to_image)
        self.event_type = event_type
        self.title = title
        self.text = text
        self.timeout = timeout
        # 0.3.1 is the only version of notification daemon that has no way
        # to determine which version it is. If no method exists, it means
        # they're using that one.
        self.default_version = [0, 3, 1]
        self.account = account
        self.jid = jid
        self.msg_type = msg_type

        # default value of text
        if not text and event_type == 'new_message':
            # empty text for new_message means do_preview = False
            self.text = gajim.get_name_from_jid(account, jid)

        if not title:
            self.title = event_type # default value

        if event_type == _('Contact Signed In'):
            ntype = 'presence.online'
        elif event_type == _('Contact Signed Out'):
            ntype = 'presence.offline'
        elif event_type in (_('New Message'), _('New Single Message'),
        _('New Private Message')):
            ntype = 'im.received'
        elif event_type == _('File Transfer Request'):
            ntype = 'transfer'
        elif event_type == _('File Transfer Error'):
            ntype = 'transfer.error'
        elif event_type in (_('File Transfer Completed'),
        _('File Transfer Stopped')):
            ntype = 'transfer.complete'
        elif event_type == _('New E-mail'):
            ntype = 'email.arrived'
        elif event_type == _('Groupchat Invitation'):
            ntype = 'im.invitation'
        elif event_type == _('Contact Changed Status'):
            ntype = 'presence.status'
        elif event_type == _('Connection Failed'):
            ntype = 'connection.failed'
        elif event_type == _('Subscription request'):
            ntype = 'subscription.request'
        elif event_type == _('Unsubscribed'):
            ntype = 'unsubscribed'
        else:
            # default failsafe values
            self.path_to_image = gtkgui_helpers.get_icon_path(
                'gajim-chat_msg_recv', 48)
            ntype = 'im' # Notification Type

        self.notif = dbus_support.get_notifications_interface(self)
        if self.notif is None:
            raise dbus.DBusException('unable to get notifications interface')
        self.ntype = ntype

        if self.kde_notifications:
            self.attempt_notify()
        else:
            self.capabilities = self.notif.GetCapabilities()
            if self.capabilities is None:
                self.capabilities = ['actions']
            self.get_version()
Example #9
0
    def __init__(self,
                 event_type,
                 jid,
                 account,
                 msg_type='',
                 path_to_image=None,
                 title=None,
                 text=None,
                 timeout=-1):
        self.path_to_image = os.path.abspath(path_to_image)
        self.event_type = event_type
        self.title = title
        self.text = text
        self.timeout = timeout
        # 0.3.1 is the only version of notification daemon that has no way
        # to determine which version it is. If no method exists, it means
        # they're using that one.
        self.default_version = [0, 3, 1]
        self.account = account
        self.jid = jid
        self.msg_type = msg_type

        # default value of text
        if not text and event_type == 'new_message':
            # empty text for new_message means do_preview = False
            self.text = gajim.get_name_from_jid(account, jid)

        if not title:
            self.title = event_type  # default value

        if event_type == _('Contact Signed In'):
            ntype = 'presence.online'
        elif event_type == _('Contact Signed Out'):
            ntype = 'presence.offline'
        elif event_type in (_('New Message'), _('New Single Message'),
                            _('New Private Message')):
            ntype = 'im.received'
        elif event_type == _('File Transfer Request'):
            ntype = 'transfer'
        elif event_type == _('File Transfer Error'):
            ntype = 'transfer.error'
        elif event_type in (_('File Transfer Completed'),
                            _('File Transfer Stopped')):
            ntype = 'transfer.complete'
        elif event_type == _('New E-mail'):
            ntype = 'email.arrived'
        elif event_type == _('Groupchat Invitation'):
            ntype = 'im.invitation'
        elif event_type == _('Contact Changed Status'):
            ntype = 'presence.status'
        elif event_type == _('Connection Failed'):
            ntype = 'connection.failed'
        elif event_type == _('Subscription request'):
            ntype = 'subscription.request'
        elif event_type == _('Unsubscribed'):
            ntype = 'unsubscribed'
        else:
            # default failsafe values
            self.path_to_image = gtkgui_helpers.get_icon_path(
                'gajim-chat_msg_recv', 48)
            ntype = 'im'  # Notification Type

        self.notif = dbus_support.get_notifications_interface(self)
        if self.notif is None:
            raise dbus.DBusException('unable to get notifications interface')
        self.ntype = ntype

        if self.kde_notifications:
            self.attempt_notify()
        else:
            self.capabilities = self.notif.GetCapabilities()
            if self.capabilities is None:
                self.capabilities = ['actions']
            self.get_version()
Example #10
0
    def __init__(self,
                 event_type,
                 jid,
                 account,
                 msg_type='',
                 path_to_image=None,
                 title=None,
                 text=None):
        self.path_to_image = path_to_image
        self.event_type = event_type
        self.title = title
        self.text = text
        '''0.3.1 is the only version of notification daemon that has no way to determine which version it is. If no method exists, it means they're using that one.'''
        self.default_version = [0, 3, 1]
        self.account = account
        self.jid = jid
        self.msg_type = msg_type

        # default value of text
        if not text and event_type == 'new_message':
            # empty text for new_message means do_preview = False
            self.text = gajim.get_name_from_jid(account, jid)

        if not title:
            self.title = event_type  # default value

        if event_type == _('Contact Signed In'):
            ntype = 'presence.online'
        elif event_type == _('Contact Signed Out'):
            ntype = 'presence.offline'
        elif event_type in (_('New Message'), _('New Single Message'),
                            _('New Private Message')):
            ntype = 'im.received'
        elif event_type == _('File Transfer Request'):
            ntype = 'transfer'
        elif event_type == _('File Transfer Error'):
            ntype = 'transfer.error'
        elif event_type in (_('File Transfer Completed'),
                            _('File Transfer Stopped')):
            ntype = 'transfer.complete'
        elif event_type == _('New E-mail'):
            ntype = 'email.arrived'
        elif event_type == _('Groupchat Invitation'):
            ntype = 'im.invitation'
        elif event_type == _('Contact Changed Status'):
            ntype = 'presence.status'
        elif event_type == _('Connection Failed'):
            ntype = 'connection.failed'
        else:
            # default failsafe values
            self.path_to_image = os.path.abspath(
                os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
                             'chat_msg_recv.png'))  # img to display
            ntype = 'im'  # Notification Type

        self.notif = dbus_support.get_notifications_interface()
        if self.notif is None:
            raise dbus.DBusException('unable to get notifications interface')
        self.ntype = ntype

        self.get_version()