annotate src/stdui/ui_contact_list.py @ 2163:75667727c500

jp (output): template output first draft: template output use the new template renderer and data_objects module in backend tools. Options can be specified: template to give a direct path to template, browser to display result directly, inline-css to include css in the HTML page. Default template can be specified in command's TEMPLATE attribute, and a template_data_mapping method is called if it exists to map data to what is expected by the template.
author Goffi <goffi@goffi.org>
date Tue, 21 Feb 2017 21:01:40 +0100
parents c2fdee1bd908
children 90189f312fd3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1934
2daf7b4c6756 use of /usr/bin/env instead of /usr/bin/python in shebang
Goffi <goffi@goffi.org>
parents: 1766
diff changeset
1 #!/usr/bin/env python2
987
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
3
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
4 # SAT standard user interface for managing contacts
1766
d17772b0fe22 copyright update
Goffi <goffi@goffi.org>
parents: 1714
diff changeset
5 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org)
987
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
6
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
10 # (at your option) any later version.
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
11
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
16
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
19
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
20 from sat.core.i18n import _, D_
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
21 from sat.core.constants import Const as C
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
22 from sat.tools import xml_tools
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
23 from twisted.words.protocols.jabber import jid
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
24 from xml.dom.minidom import Element
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
25
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
26
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
27 class ContactList(object):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
28 """Add, update and remove contacts."""
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
29
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
30 def __init__(self, host):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
31 self.host = host
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
32 self.__add_id = host.registerCallback(self._addContact, with_data=True)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
33 self.__update_id = host.registerCallback(self._updateContact, with_data=True)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
34 self.__confirm_delete_id = host.registerCallback(self._getConfirmRemoveXMLUI, with_data=True)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
35
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
36 host.importMenu((D_("Contacts"), D_("Add contact")), self._getAddDialogXMLUI, security_limit=2, help_string=D_("Add contact"))
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
37 host.importMenu((D_("Contacts"), D_("Update contact")), self._getUpdateDialogXMLUI, security_limit=2, help_string=D_("Update contact"))
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
38 host.importMenu((D_("Contacts"), D_("Remove contact")), self._getRemoveDialogXMLUI, security_limit=2, help_string=D_("Remove contact"))
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
39
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
40 if 'MISC-ACCOUNT' in self.host.plugins:
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
41 self.default_host = self.host.plugins['MISC-ACCOUNT'].getNewAccountDomain()
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
42 else:
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
43 self.default_host = 'example.net'
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
44
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
45 def getContacts(self, profile):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
46 """Return a sorted list of the contacts for that profile
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
47
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
48 @param profile: %(doc_profile)s
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
49 @return: list[string]
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
50 """
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
51 client = self.host.getClient(profile)
1262
f8a8434dbac7 core: improved roster management + misc:
Goffi <goffi@goffi.org>
parents: 987
diff changeset
52 ret = [contact.full() for contact in client.roster.getJids()]
987
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
53 ret.sort()
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
54 return ret
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
55
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
56 def getGroups(self, new_groups=None, profile=C.PROF_KEY_NONE):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
57 """Return a sorted list of the groups for that profile
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
58
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
59 @param new_group (list): add these groups to the existing ones
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
60 @param profile: %(doc_profile)s
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
61 @return: list[string]
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
62 """
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
63 client = self.host.getClient(profile)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
64 ret = client.roster.getGroups()
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
65 ret.sort()
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
66 ret.extend([group for group in new_groups if group not in ret])
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
67 return ret
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
68
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
69 def getGroupsOfContact(self, user_jid_s, profile):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
70 """Return all the groups of the given contact
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
71
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
72 @param user_jid_s (string)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
73 @param profile: %(doc_profile)s
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
74 @return: list[string]
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
75 """
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
76 client = self.host.getClient(profile)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
77 return client.roster.getItem(jid.JID(user_jid_s)).groups
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
78
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
79 def getGroupsOfAllContacts(self, profile):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
80 """Return a mapping between the contacts and their groups
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
81
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
82 @param profile: %(doc_profile)s
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
83 @return: dict (key: string, value: list[string]):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
84 - key: the JID userhost
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
85 - value: list of groups
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
86 """
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
87 client = self.host.getClient(profile)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
88 return {item.jid.userhost(): item.groups for item in client.roster.getItems()}
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
89
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
90 def _data2elts(self, data):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
91 """Convert a contacts data dict to minidom Elements
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
92
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
93 @param data (dict)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
94 @return list[Element]
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
95 """
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
96 elts = []
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
97 for key in data:
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
98 key_elt = Element('jid')
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
99 key_elt.setAttribute('name', key)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
100 for value in data[key]:
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
101 value_elt = Element('group')
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
102 value_elt.setAttribute('name', value)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
103 key_elt.childNodes.append(value_elt)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
104 elts.append(key_elt)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
105 return elts
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
106
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
107 def getDialogXMLUI(self, options, data, profile):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
108 """Generic method to return the XMLUI dialog for adding or updating a contact
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
109
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
110 @param options (dict): parameters for the dialog, with the keys:
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
111 - 'id': the menu callback id
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
112 - 'title': deferred localized string
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
113 - 'contact_text': deferred localized string
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
114 @param data (dict)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
115 @param profile: %(doc_profile)s
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
116 @return dict
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
117 """
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
118 form_ui = xml_tools.XMLUI("form", title=options['title'], submit_id=options['id'])
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
119 if 'message' in data:
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
120 form_ui.addText(data['message'])
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
121 form_ui.addDivider('dash')
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
122
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
123 form_ui.addText(options['contact_text'])
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
124 if options['id'] == self.__add_id:
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
125 contact = data.get(xml_tools.formEscape('contact_jid'), '@%s' % self.default_host)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
126 form_ui.addString('contact_jid', value=contact)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
127 elif options['id'] == self.__update_id:
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
128 contacts = self.getContacts(profile)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
129 list_ = form_ui.addList('contact_jid', options=contacts, selected=contacts[0])
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
130 elts = self._data2elts(self.getGroupsOfAllContacts(profile))
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
131 list_.setInternalCallback('groups_of_contact', fields=['contact_jid', 'groups_list'], data_elts=elts)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
132
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
133 form_ui.addDivider('blank')
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
134
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
135 form_ui.addText(_("Select in which groups your contact is:"))
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
136 selected_groups = []
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
137 if 'selected_groups' in data:
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
138 selected_groups = data['selected_groups']
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
139 elif options['id'] == self.__update_id:
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
140 try:
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
141 selected_groups = self.getGroupsOfContact(contacts[0], profile)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
142 except IndexError:
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
143 pass
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
144 groups = self.getGroups(selected_groups, profile)
1546
62d6310e7c04 core (stdui): fixed a keyword argument not changed after commit 48706f4ff19c
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
145 form_ui.addList('groups_list', options=groups, selected=selected_groups, styles=['multi'])
987
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
146
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
147 adv_list = form_ui.changeContainer("advanced_list", columns=3, selectable='no')
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
148 form_ui.addLabel(D_("Add group"))
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
149 form_ui.addString("add_group")
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
150 button = form_ui.addButton('', value=D_('Add'))
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
151 button.setInternalCallback('move', fields=['add_group', 'groups_list'])
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
152 adv_list.end()
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
153
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
154 form_ui.addDivider('blank')
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
155 return {'xmlui': form_ui.toXml()}
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
156
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
157 def _getAddDialogXMLUI(self, data, profile):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
158 """Get the dialog for adding contact
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
159
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
160 @param data (dict)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
161 @param profile: %(doc_profile)s
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
162 @return dict
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
163 """
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
164 options = {'id': self.__add_id,
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
165 'title': D_('Add contact'),
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
166 'contact_text': D_("New contact identifier (JID):"),
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
167 }
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
168 return self.getDialogXMLUI(options, {}, profile)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
169
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
170 def _getUpdateDialogXMLUI(self, data, profile):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
171 """Get the dialog for updating contact
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
172
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
173 @param data (dict)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
174 @param profile: %(doc_profile)s
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
175 @return dict
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
176 """
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
177 if not self.getContacts(profile):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
178 _dialog = xml_tools.XMLUI('popup', title=D_('Nothing to update'))
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
179 _dialog.addText(_('Your contact list is empty.'))
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
180 return {'xmlui': _dialog.toXml()}
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
181
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
182 options = {'id': self.__update_id,
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
183 'title': D_('Update contact'),
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
184 'contact_text': D_("Which contact do you want to update?"),
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
185 }
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
186 return self.getDialogXMLUI(options, {}, profile)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
187
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
188 def _getRemoveDialogXMLUI(self, data, profile):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
189 """Get the dialog for removing contact
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
190
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
191 @param data (dict)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
192 @param profile: %(doc_profile)s
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
193 @return dict
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
194 """
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
195 if not self.getContacts(profile):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
196 _dialog = xml_tools.XMLUI('popup', title=D_('Nothing to delete'))
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
197 _dialog.addText(_('Your contact list is empty.'))
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
198 return {'xmlui': _dialog.toXml()}
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
199
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
200 form_ui = xml_tools.XMLUI("form", title=D_('Who do you want to remove from your contacts?'), submit_id=self.__confirm_delete_id)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
201 form_ui.addList('contact_jid', options=self.getContacts(profile))
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
202 return {'xmlui': form_ui.toXml()}
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
203
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
204 def _getConfirmRemoveXMLUI(self, data, profile):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
205 """Get the confirmation dialog for removing contact
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
206
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
207 @param data (dict)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
208 @param profile: %(doc_profile)s
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
209 @return dict
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
210 """
2071
c2fdee1bd908 core (stdui): fixed cancellation of ContactList forms
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
211 if C.bool(data.get('cancelled', 'false')):
c2fdee1bd908 core (stdui): fixed cancellation of ContactList forms
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
212 return {}
987
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
213 contact = data[xml_tools.formEscape('contact_jid')]
2071
c2fdee1bd908 core (stdui): fixed cancellation of ContactList forms
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
214 def delete_cb(data, profile):
c2fdee1bd908 core (stdui): fixed cancellation of ContactList forms
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
215 if not C.bool(data.get('cancelled', 'false')):
c2fdee1bd908 core (stdui): fixed cancellation of ContactList forms
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
216 self._deleteContact(jid.JID(contact), profile)
c2fdee1bd908 core (stdui): fixed cancellation of ContactList forms
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
217 return {}
c2fdee1bd908 core (stdui): fixed cancellation of ContactList forms
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
218 delete_id = self.host.registerCallback(delete_cb, with_data=True, one_shot=True)
987
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
219 form_ui = xml_tools.XMLUI("form", title=D_("Delete contact"), submit_id=delete_id)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
220 form_ui.addText(D_("Are you sure you want to remove %s from your contact list?") % contact)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
221 return {'xmlui': form_ui.toXml()}
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
222
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
223 def _addContact(self, data, profile):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
224 """Add the selected contact
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
225
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
226 @param data (dict)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
227 @param profile: %(doc_profile)s
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
228 @return dict
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
229 """
2071
c2fdee1bd908 core (stdui): fixed cancellation of ContactList forms
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
230 if C.bool(data.get('cancelled', 'false')):
c2fdee1bd908 core (stdui): fixed cancellation of ContactList forms
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
231 return {}
987
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
232 contact_jid_s = data[xml_tools.formEscape('contact_jid')]
1714
0b4c1f6ada52 stdui (contact_list): use jid.JID to check the JID instead of an approximative regex
souliane <souliane@mailoo.org>
parents: 1546
diff changeset
233 try:
0b4c1f6ada52 stdui (contact_list): use jid.JID to check the JID instead of an approximative regex
souliane <souliane@mailoo.org>
parents: 1546
diff changeset
234 contact_jid = jid.JID(contact_jid_s)
0b4c1f6ada52 stdui (contact_list): use jid.JID to check the JID instead of an approximative regex
souliane <souliane@mailoo.org>
parents: 1546
diff changeset
235 except (RuntimeError, jid.InvalidFormat, AttributeError):
987
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
236 # TODO: replace '\t' by a constant (see tools.xmlui.XMLUI.onFormSubmitted)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
237 data['selected_groups'] = data[xml_tools.formEscape('groups_list')].split('\t')
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
238 options = {'id': self.__add_id,
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
239 'title': D_('Add contact'),
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
240 'contact_text': D_('Please enter a valid JID (like "contact@%s"):') % self.default_host,
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
241 }
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
242 return self.getDialogXMLUI(options, data, profile)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
243 self.host.addContact(contact_jid, profile_key=profile)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
244 return self._updateContact(data, profile) # after adding, updating
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
245
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
246 def _updateContact(self, data, profile):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
247 """Update the selected contact
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
248
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
249 @param data (dict)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
250 @param profile: %(doc_profile)s
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
251 @return dict
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
252 """
2071
c2fdee1bd908 core (stdui): fixed cancellation of ContactList forms
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
253 if C.bool(data.get('cancelled', 'false')):
c2fdee1bd908 core (stdui): fixed cancellation of ContactList forms
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
254 return {}
987
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
255 contact_jid = jid.JID(data[xml_tools.formEscape('contact_jid')])
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
256 # TODO: replace '\t' by a constant (see tools.xmlui.XMLUI.onFormSubmitted)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
257 groups = data[xml_tools.formEscape('groups_list')].split('\t')
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
258 self.host.updateContact(contact_jid, name='', groups=groups, profile_key=profile)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
259 return {}
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
260
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
261 def _deleteContact(self, contact_jid, profile):
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
262 """Delete the selected contact
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
263
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
264 @param contact_jid (JID)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
265 @param profile: %(doc_profile)s
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
266 @return dict
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
267 """
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
268 self.host.delContact(contact_jid, profile_key=profile)
3a96920c07b7 core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
diff changeset
269 return {}