merge bug 4212 branch
This commit is contained in:
commit
a8cd67706b
|
@ -1487,6 +1487,11 @@ class Connection(ConnectionHandlers):
|
||||||
self.connection.getRoster().setItem(jid = jid, name = name,
|
self.connection.getRoster().setItem(jid = jid, name = name,
|
||||||
groups = groups)
|
groups = groups)
|
||||||
|
|
||||||
|
def update_contacts(self, contacts):
|
||||||
|
'''update multiple roster items on jabber server'''
|
||||||
|
if self.connection:
|
||||||
|
self.connection.getRoster().setItemMulti(contacts)
|
||||||
|
|
||||||
def send_new_account_infos(self, form, is_form):
|
def send_new_account_infos(self, form, is_form):
|
||||||
if is_form:
|
if is_form:
|
||||||
# Get username and password and put them in new_account_info
|
# Get username and password and put them in new_account_info
|
||||||
|
|
|
@ -174,6 +174,16 @@ class NonBlockingRoster(PlugIn):
|
||||||
item=query.setTag('item',attrs)
|
item=query.setTag('item',attrs)
|
||||||
for group in groups: item.addChild(node=Node('group',payload=[group]))
|
for group in groups: item.addChild(node=Node('group',payload=[group]))
|
||||||
self._owner.send(iq)
|
self._owner.send(iq)
|
||||||
|
def setItemMulti(self,items):
|
||||||
|
''' Renames multiple contacts and sets their group lists.'''
|
||||||
|
iq=Iq('set',NS_ROSTER)
|
||||||
|
query=iq.getTag('query')
|
||||||
|
for i in items:
|
||||||
|
attrs={'jid':i['jid']}
|
||||||
|
if i['name']: attrs['name']=i['name']
|
||||||
|
item=query.setTag('item',attrs)
|
||||||
|
for group in i['groups']: item.addChild(node=Node('group',payload=[group]))
|
||||||
|
self._owner.send(iq)
|
||||||
def getItems(self):
|
def getItems(self):
|
||||||
''' Return list of all [bare] JIDs that the roster is currently tracks.'''
|
''' Return list of all [bare] JIDs that the roster is currently tracks.'''
|
||||||
return self._data.keys()
|
return self._data.keys()
|
||||||
|
|
|
@ -526,6 +526,11 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
|
||||||
self.connection.getRoster().setItem(jid = jid, name = name,
|
self.connection.getRoster().setItem(jid = jid, name = name,
|
||||||
groups = groups)
|
groups = groups)
|
||||||
|
|
||||||
|
def update_contacts(self, contacts):
|
||||||
|
'''update multiple roster items'''
|
||||||
|
if self.connection:
|
||||||
|
self.connection.getRoster().setItemMulti(contacts)
|
||||||
|
|
||||||
def new_account(self, name, config, sync = False):
|
def new_account(self, name, config, sync = False):
|
||||||
gajim.log.debug('This should not happen (new_account)')
|
gajim.log.debug('This should not happen (new_account)')
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,10 @@ class Roster:
|
||||||
self._data[jid]['status'] = status
|
self._data[jid]['status'] = status
|
||||||
self._data[jid]['show'] = status
|
self._data[jid]['show'] = status
|
||||||
|
|
||||||
|
def setItemMulti(self, items):
|
||||||
|
for i in items:
|
||||||
|
self.setItem(jid=i['jid'], name=i['name'], groups=i['groups'])
|
||||||
|
|
||||||
def delItem(self, jid):
|
def delItem(self, jid):
|
||||||
#print 'roster_zeroconf.py: delItem %s' % jid
|
#print 'roster_zeroconf.py: delItem %s' % jid
|
||||||
if jid in self._data:
|
if jid in self._data:
|
||||||
|
|
|
@ -848,6 +848,51 @@ class RosterWindow:
|
||||||
'''Remove transport from roster and redraw account and group.'''
|
'''Remove transport from roster and redraw account and group.'''
|
||||||
self.remove_contact(jid, account, force=True, backend=True)
|
self.remove_contact(jid, account, force=True, backend=True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def rename_group(self, old_name, new_name):
|
||||||
|
"""
|
||||||
|
rename a roster group
|
||||||
|
"""
|
||||||
|
if old_name == new_name:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Groups may not change name from or to a special groups
|
||||||
|
for g in helpers.special_groups:
|
||||||
|
if g in (new_name, old_name):
|
||||||
|
return
|
||||||
|
|
||||||
|
# update all contacts in the given group
|
||||||
|
if self.regroup:
|
||||||
|
accounts = gajim.connections.keys()
|
||||||
|
else:
|
||||||
|
accounts = [account,]
|
||||||
|
|
||||||
|
for acc in accounts:
|
||||||
|
changed_contacts = []
|
||||||
|
for jid in gajim.contacts.get_jid_list(acc):
|
||||||
|
contact = gajim.contacts.get_first_contact_from_jid(acc, jid)
|
||||||
|
if old_name not in contact.groups:
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.remove_contact(jid, acc, force=True)
|
||||||
|
|
||||||
|
contact.groups.remove(old_name)
|
||||||
|
if new_name not in contact.groups:
|
||||||
|
contact.groups.append(new_name)
|
||||||
|
|
||||||
|
changed_contacts.append({'jid':jid, 'name':contact.name,
|
||||||
|
'groups':contact.groups})
|
||||||
|
|
||||||
|
gajim.connections[acc].update_contacts(changed_contacts)
|
||||||
|
|
||||||
|
for c in changed_contacts:
|
||||||
|
self.add_contact(c['jid'], acc)
|
||||||
|
|
||||||
|
self._adjust_group_expand_collapse_state(new_name, acc)
|
||||||
|
|
||||||
|
self.draw_group(old_name, acc)
|
||||||
|
self.draw_group(new_name, acc)
|
||||||
|
|
||||||
|
|
||||||
def add_contact_to_groups(self, jid, account, groups, update=True):
|
def add_contact_to_groups(self, jid, account, groups, update=True):
|
||||||
'''Add contact to given groups and redraw them.
|
'''Add contact to given groups and redraw them.
|
||||||
|
@ -2711,23 +2756,7 @@ class RosterWindow:
|
||||||
win.show_title()
|
win.show_title()
|
||||||
elif row_type == 'group':
|
elif row_type == 'group':
|
||||||
# in C_JID column, we hold the group name (which is not escaped)
|
# in C_JID column, we hold the group name (which is not escaped)
|
||||||
if old_text == new_text:
|
self.rename_group(old_text, new_text)
|
||||||
return
|
|
||||||
# Groups may not change name from or to a special groups
|
|
||||||
for g in helpers.special_groups:
|
|
||||||
if g in (new_text, old_text):
|
|
||||||
return
|
|
||||||
# update all contacts in the given group
|
|
||||||
if self.regroup:
|
|
||||||
accounts = gajim.connections.keys()
|
|
||||||
else:
|
|
||||||
accounts = [account,]
|
|
||||||
for acc in accounts:
|
|
||||||
for jid in gajim.contacts.get_jid_list(acc):
|
|
||||||
contact = gajim.contacts.get_first_contact_from_jid(acc, jid)
|
|
||||||
if old_text in contact.groups:
|
|
||||||
self.add_contact_to_groups(jid, acc, [new_text,])
|
|
||||||
self.remove_contact_from_groups(jid, acc, [old_text,])
|
|
||||||
|
|
||||||
def on_canceled():
|
def on_canceled():
|
||||||
if 'rename' in gajim.interface.instances:
|
if 'rename' in gajim.interface.instances:
|
||||||
|
|
Loading…
Reference in New Issue