priority is now by default set from status. online: 50, away: 40...
priorities are configurable with autopriority_* ACE options. Fixes #1999, #1439, #1885, #1076
This commit is contained in:
parent
1345afa86c
commit
725325eb7e
|
@ -221,6 +221,13 @@ class Config:
|
|||
'password': [ opt_str, '' ],
|
||||
'resource': [ opt_str, 'gajim', '', True ],
|
||||
'priority': [ opt_int, 5, '', True ],
|
||||
'adjust_priority_with_status': [ opt_bool, True, _('Priority will change automatically according to your status. Priorities are defined in autopriority_* options.') ],
|
||||
'autopriority_online' [ opt_int, 50],
|
||||
'autopriority_chat' [ opt_int, 50],
|
||||
'autopriority_away' [ opt_int, 40],
|
||||
'autopriority_xa' [ opt_int, 30],
|
||||
'autopriority_dnd' [ opt_int, 20],
|
||||
'autopriority_invisible' [ opt_int, 10],
|
||||
'autoconnect': [ opt_bool, False, '', True ],
|
||||
'autoreconnect': [ opt_bool, True ],
|
||||
'active': [ opt_bool, True],
|
||||
|
|
|
@ -47,6 +47,7 @@ class Connection(ConnectionHandlers):
|
|||
self.last_connection = None # last ClientCommon instance
|
||||
self.gpg = None
|
||||
self.status = ''
|
||||
self.priority = gajim.get_priority(name, 'offline')
|
||||
self.old_show = ''
|
||||
# increase/decrease default timeout for server responses
|
||||
self.try_connecting_for_foo_secs = 45
|
||||
|
@ -524,14 +525,15 @@ class Connection(ConnectionHandlers):
|
|||
# active the privacy rule
|
||||
self.privacy_rules_supported = True
|
||||
self.activate_privacy_rule('invisible')
|
||||
prio = unicode(gajim.config.get_per('accounts', self.name, 'priority'))
|
||||
p = common.xmpp.Presence(typ = ptype, priority = prio, show = show)
|
||||
priority = unicode(gajim.get_priority(self.name, show))
|
||||
p = common.xmpp.Presence(typ = ptype, priority = priority, show = show)
|
||||
p = self.add_sha(p, ptype != 'unavailable')
|
||||
if msg:
|
||||
p.setStatus(msg)
|
||||
if signed:
|
||||
p.setTag(common.xmpp.NS_SIGNED + ' x').setData(signed)
|
||||
self.connection.send(p)
|
||||
self.priority = priority
|
||||
self.dispatch('STATUS', 'invisible')
|
||||
if initial:
|
||||
#ask our VCard
|
||||
|
@ -642,9 +644,8 @@ class Connection(ConnectionHandlers):
|
|||
iq = self.build_privacy_rule('visible', 'allow')
|
||||
self.connection.send(iq)
|
||||
self.activate_privacy_rule('visible')
|
||||
prio = unicode(gajim.config.get_per('accounts', self.name,
|
||||
'priority'))
|
||||
p = common.xmpp.Presence(typ = None, priority = prio, show = sshow)
|
||||
priority = unicode(gajim.get_priority(self.name, sshow))
|
||||
p = common.xmpp.Presence(typ = None, priority = priority, show = sshow)
|
||||
p = self.add_sha(p)
|
||||
if msg:
|
||||
p.setStatus(msg)
|
||||
|
@ -652,6 +653,7 @@ class Connection(ConnectionHandlers):
|
|||
p.setTag(common.xmpp.NS_SIGNED + ' x').setData(signed)
|
||||
if self.connection:
|
||||
self.connection.send(p)
|
||||
self.priority = priority
|
||||
self.dispatch('STATUS', show)
|
||||
|
||||
def _on_disconnected(self):
|
||||
|
@ -696,7 +698,7 @@ class Connection(ConnectionHandlers):
|
|||
msgtxt = _('[This message is *encrypted* (See :JEP:`27`]') +\
|
||||
' ([This message is *encrypted* (See :JEP:`27`])'
|
||||
if msgtxt and not xhtml and gajim.config.get(
|
||||
'rst_formatting_outgoing_messages'):
|
||||
'rst_formatting_outgoing_messages'):
|
||||
# Generate a XHTML part using reStructured text markup
|
||||
xhtml = create_xhtml(msgtxt)
|
||||
if type == 'chat':
|
||||
|
|
|
@ -956,9 +956,7 @@ class ConnectionVcard:
|
|||
'invisible':
|
||||
self.vcard_sha = new_sha
|
||||
sshow = helpers.get_xmpp_show(STATUS_LIST[self.connected])
|
||||
prio = unicode(gajim.config.get_per('accounts', self.name,
|
||||
'priority'))
|
||||
p = common.xmpp.Presence(typ = None, priority = prio,
|
||||
p = common.xmpp.Presence(typ = None, priority = self.priority,
|
||||
show = sshow, status = self.status)
|
||||
p = self.add_sha(p)
|
||||
self.connection.send(p)
|
||||
|
@ -1089,10 +1087,8 @@ class ConnectionVcard:
|
|||
if STATUS_LIST[self.connected] == 'invisible':
|
||||
return
|
||||
sshow = helpers.get_xmpp_show(STATUS_LIST[self.connected])
|
||||
prio = unicode(gajim.config.get_per('accounts', self.name,
|
||||
'priority'))
|
||||
p = common.xmpp.Presence(typ = None, priority = prio, show = sshow,
|
||||
status = self.status)
|
||||
p = common.xmpp.Presence(typ = None, priority = self.priority,
|
||||
show = sshow, status = self.status)
|
||||
p = self.add_sha(p)
|
||||
self.connection.send(p)
|
||||
else:
|
||||
|
@ -1803,12 +1799,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
|
|||
if show == 'invisible':
|
||||
self.send_invisible_presence(msg, signed, True)
|
||||
return
|
||||
prio = unicode(gajim.config.get_per('accounts', self.name,
|
||||
'priority'))
|
||||
priority = gajim.get_priority(self.name, sshow)
|
||||
vcard = self.get_cached_vcard(jid)
|
||||
if vcard and vcard.has_key('PHOTO') and vcard['PHOTO'].has_key('SHA'):
|
||||
self.vcard_sha = vcard['PHOTO']['SHA']
|
||||
p = common.xmpp.Presence(typ = None, priority = prio, show = sshow)
|
||||
p = common.xmpp.Presence(typ = None, priority = priority, show = sshow)
|
||||
p = self.add_sha(p)
|
||||
if msg:
|
||||
p.setStatus(msg)
|
||||
|
@ -1817,6 +1812,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
|
|||
|
||||
if self.connection:
|
||||
self.connection.send(p)
|
||||
self.priority = priority
|
||||
self.dispatch('STATUS', show)
|
||||
# ask our VCard
|
||||
self.request_vcard(None)
|
||||
|
|
|
@ -120,6 +120,10 @@ status_before_autoaway = {}
|
|||
SHOW_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd',
|
||||
'invisible']
|
||||
|
||||
priority_dict = {}
|
||||
for status in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'):
|
||||
priority_dict[status] = config.get('autopriority' + status)
|
||||
|
||||
def get_nick_from_jid(jid):
|
||||
pos = jid.find('@')
|
||||
return jid[:pos]
|
||||
|
@ -324,3 +328,12 @@ def get_name_from_jid(account, jid):
|
|||
else:
|
||||
actor = jid
|
||||
return actor
|
||||
|
||||
def get_priority(account, show):
|
||||
'''return the priority an account must have'''
|
||||
if not show:
|
||||
show = 'online'
|
||||
if show in priority_dict and config.get_per('accounts', account,
|
||||
'adjust_priority_with_status'):
|
||||
return priority_dict[show]
|
||||
return config.get_per('accounts', account, 'priority')
|
||||
|
|
|
@ -1192,6 +1192,9 @@ class AccountModificationWindow:
|
|||
|
||||
self.xml.get_widget('resource_entry').set_text(gajim.config.get_per(
|
||||
'accounts', self.account, 'resource'))
|
||||
self.xml.get_widget('adjust_priority_with_status_checkbutton').set_active(
|
||||
gajim.config.get_per('accounts', self.account,
|
||||
'adjust_priority_with_status'))
|
||||
self.xml.get_widget('priority_spinbutton').set_value(gajim.config.\
|
||||
get_per('accounts', self.account, 'priority'))
|
||||
|
||||
|
@ -1256,6 +1259,10 @@ class AccountModificationWindow:
|
|||
return True
|
||||
return False
|
||||
|
||||
def on_adjust_priority_with_status_checkbutton_toggled(self, widget):
|
||||
self.xml.get_widget('priority_spinbutton').set_sensitive(
|
||||
not widget.get_active())
|
||||
|
||||
def on_save_button_clicked(self, widget):
|
||||
'''When save button is clicked: Save information in config file'''
|
||||
config = {}
|
||||
|
|
|
@ -341,8 +341,7 @@ class SignalObject(dbus.service.Object):
|
|||
result['name'] = DBUS_STRING(account.name)
|
||||
result['jid'] = DBUS_STRING(gajim.get_jid_from_account(account.name))
|
||||
result['message'] = DBUS_STRING(account.status)
|
||||
result['priority'] = DBUS_STRING(unicode(gajim.config.get_per('accounts',
|
||||
account.name, 'priority')))
|
||||
result['priority'] = DBUS_STRING(unicode(account.priority))
|
||||
result['resource'] = DBUS_STRING(unicode(gajim.config.get_per('accounts',
|
||||
account.name, 'resource')))
|
||||
return result
|
||||
|
|
|
@ -1186,8 +1186,7 @@ class RosterWindow:
|
|||
status = connection.status,
|
||||
resource = gajim.config.get_per('accounts', connection.name,
|
||||
'resource'),
|
||||
priority = gajim.config.get_per('accounts', connection.name,
|
||||
'priority'),
|
||||
priority = connection.priority,
|
||||
keyID = gajim.config.get_per('accounts', connection.name,
|
||||
'keyid'))
|
||||
contacts.append(contact)
|
||||
|
|
Loading…
Reference in New Issue