annotate libervia/backend/plugins/plugin_xep_0055.py @ 4332:71c939e34ca6

XEP-0373 (OX): Adjust to gpgme updates: generate with explicit algorithm and subkeys
author Syndace <me@syndace.dev>
date Sat, 13 Jul 2024 18:28:28 +0200
parents 94e0968987cd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
1 #!/usr/bin/env python3
3137
559a625a236b fixed shebangs
Goffi <goffi@goffi.org>
parents: 3136
diff changeset
2
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
3
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # SAT plugin for Jabber Search (xep-0055)
3479
be6d91572633 date update
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
6
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
11
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
16
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
19
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
20 from libervia.backend.core.i18n import _, D_
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
21 from libervia.backend.core.log import getLogger
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
22
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 867
diff changeset
23 log = getLogger(__name__)
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
24
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from twisted.words.protocols.jabber.xmlstream import IQ
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from twisted.words.protocols.jabber import jid
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 867
diff changeset
27 from twisted.internet import defer
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from wokkel import data_form
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
29 from libervia.backend.core.constants import Const as C
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
30 from libervia.backend.core.exceptions import DataError
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
31 from libervia.backend.tools import xml_tools
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
32
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
33 from wokkel import disco, iwokkel
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
34
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
35 try:
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
36 from twisted.words.protocols.xmlstream import XMPPHandler
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
37 except ImportError:
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
38 from wokkel.subprotocols import XMPPHandler
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
39 from zope.interface import implementer
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
40
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
41
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
42 NS_SEARCH = "jabber:iq:search"
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
43
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
44 PLUGIN_INFO = {
2145
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
45 C.PI_NAME: "Jabber Search",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
46 C.PI_IMPORT_NAME: "XEP-0055",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
47 C.PI_TYPE: "XEP",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
48 C.PI_PROTOCOLS: ["XEP-0055"],
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
49 C.PI_DEPENDENCIES: [],
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
50 C.PI_RECOMMENDATIONS: ["XEP-0059"],
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
51 C.PI_MAIN: "XEP_0055",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
52 C.PI_HANDLER: "no",
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
53 C.PI_DESCRIPTION: _("""Implementation of Jabber Search"""),
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
54 }
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
55
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
56 # config file parameters
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
57 CONFIG_SECTION = "plugin search"
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
58 CONFIG_SERVICE_LIST = "service_list"
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
59
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
60 DEFAULT_SERVICE_LIST = ["salut.libervia.org"]
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
61
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
62 FIELD_SINGLE = "field_single" # single text field for the simple search
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
63 FIELD_CURRENT_SERVICE = (
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
64 "current_service_jid" # read-only text field for the advanced search
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
65 )
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
66
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
67
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
68 class XEP_0055(object):
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
69 def __init__(self, host):
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 867
diff changeset
70 log.info(_("Jabber search plugin initialization"))
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
71 self.host = host
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
72
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
73 # default search services (config file + hard-coded lists)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
74 self.services = [
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
75 jid.JID(entry)
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
76 for entry in host.memory.config_get(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
77 CONFIG_SECTION, CONFIG_SERVICE_LIST, DEFAULT_SERVICE_LIST
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
78 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
79 ]
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
80
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
81 host.bridge.add_method(
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
82 "search_fields_ui_get",
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
83 ".plugin",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
84 in_sign="ss",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
85 out_sign="s",
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
86 method=self._get_fields_ui,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
87 async_=True,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
88 )
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
89 host.bridge.add_method(
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
90 "search_request",
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
91 ".plugin",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
92 in_sign="sa{ss}s",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
93 out_sign="s",
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
94 method=self._search_request,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
95 async_=True,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
96 )
799
7f2082b192ed plugin XEP-0055, Primitivus: Directory search dialogs are now entirely done in plugin XEP-0055, specific code in frontend is not needed anymore
Goffi <goffi@goffi.org>
parents: 771
diff changeset
97
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
98 self.__search_menu_id = host.register_callback(self._get_main_ui, with_data=True)
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
99 host.import_menu(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
100 (D_("Contacts"), D_("Search directory")),
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
101 self._get_main_ui,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
102 security_limit=1,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
103 help_string=D_("Search user directory"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
104 )
1509
72e6ee3fdf53 plugin XEP-0055: add "Directory subscription" menu + use the category "Service" for this plugin's menus instead of "Communication"
souliane <souliane@mailoo.org>
parents: 1508
diff changeset
105
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
106 def _get_host_services(self, profile):
1509
72e6ee3fdf53 plugin XEP-0055: add "Directory subscription" menu + use the category "Service" for this plugin's menus instead of "Communication"
souliane <souliane@mailoo.org>
parents: 1508
diff changeset
107 """Return the jabber search services associated to the user host.
1552
e0bde0d0b321 core (disco): use of “profile” instead of “profile_key” in several disco methods
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
108
1509
72e6ee3fdf53 plugin XEP-0055: add "Directory subscription" menu + use the category "Service" for this plugin's menus instead of "Communication"
souliane <souliane@mailoo.org>
parents: 1508
diff changeset
109 @param profile (unicode): %(doc_profile)s
72e6ee3fdf53 plugin XEP-0055: add "Directory subscription" menu + use the category "Service" for this plugin's menus instead of "Communication"
souliane <souliane@mailoo.org>
parents: 1508
diff changeset
110 @return: list[jid.JID]
72e6ee3fdf53 plugin XEP-0055: add "Directory subscription" menu + use the category "Service" for this plugin's menus instead of "Communication"
souliane <souliane@mailoo.org>
parents: 1508
diff changeset
111 """
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
112 client = self.host.get_client(profile)
4306
94e0968987cd plugin XEP-0033: code modernisation, improve delivery, data validation:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
113 d = defer.ensureDeferred(self.host.find_features_set(client, [NS_SEARCH]))
1509
72e6ee3fdf53 plugin XEP-0055: add "Directory subscription" menu + use the category "Service" for this plugin's menus instead of "Communication"
souliane <souliane@mailoo.org>
parents: 1508
diff changeset
114 return d.addCallback(lambda set_: list(set_))
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
115
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
116 ## Main search UI (menu item callback) ##
799
7f2082b192ed plugin XEP-0055, Primitivus: Directory search dialogs are now entirely done in plugin XEP-0055, specific code in frontend is not needed anymore
Goffi <goffi@goffi.org>
parents: 771
diff changeset
117
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
118 def _get_main_ui(self, raw_data, profile):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
119 """Get the XMLUI for selecting a service and searching the directory.
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
120
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
121 @param raw_data (dict): data received from the frontend
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
122 @param profile (unicode): %(doc_profile)s
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
123 @return: a deferred XMLUI string representation
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
124 """
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
125 # check if the user's server offers some search services
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
126 d = self._get_host_services(profile)
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
127 return d.addCallback(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
128 lambda services: self.get_main_ui(services, raw_data, profile)
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
129 )
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
130
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
131 def get_main_ui(self, services, raw_data, profile):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
132 """Get the XMLUI for selecting a service and searching the directory.
799
7f2082b192ed plugin XEP-0055, Primitivus: Directory search dialogs are now entirely done in plugin XEP-0055, specific code in frontend is not needed anymore
Goffi <goffi@goffi.org>
parents: 771
diff changeset
133
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
134 @param services (list[jid.JID]): search services offered by the user server
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
135 @param raw_data (dict): data received from the frontend
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
136 @param profile (unicode): %(doc_profile)s
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
137 @return: a deferred XMLUI string representation
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
138 """
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
139 # extend services offered by user's server with the default services
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
140 services.extend([service for service in self.services if service not in services])
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
141 data = xml_tools.xmlui_result_2_data_form_result(raw_data)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
142 main_ui = xml_tools.XMLUI(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
143 C.XMLUI_WINDOW,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
144 container="tabs",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
145 title=_("Search users"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
146 submit_id=self.__search_menu_id,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
147 )
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
148
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
149 d = self._add_simple_search_ui(services, main_ui, data, profile)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
150 d.addCallback(
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
151 lambda __: self._add_advanced_search_ui(services, main_ui, data, profile)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
152 )
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
153 return d.addCallback(lambda __: {"xmlui": main_ui.toXml()})
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
154
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
155 def _add_simple_search_ui(self, services, main_ui, data, profile):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
156 """Add to the main UI a tab for the simple search.
1552
e0bde0d0b321 core (disco): use of “profile” instead of “profile_key” in several disco methods
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
157
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
158 Display a single input field and search on the main service (it actually does one search per search field and then compile the results).
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
159
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
160 @param services (list[jid.JID]): search services offered by the user server
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
161 @param main_ui (XMLUI): the main XMLUI instance
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
162 @param data (dict): form data without SAT_FORM_PREFIX
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
163 @param profile (unicode): %(doc_profile)s
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
164
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
165 @return: a __ Deferred
799
7f2082b192ed plugin XEP-0055, Primitivus: Directory search dialogs are now entirely done in plugin XEP-0055, specific code in frontend is not needed anymore
Goffi <goffi@goffi.org>
parents: 771
diff changeset
166 """
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
167 service_jid = services[
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
168 0
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
169 ] # TODO: search on all the given services, not only the first one
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
170
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
171 form = data_form.Form("form", formNamespace=NS_SEARCH)
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
172 form.addField(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
173 data_form.Field(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
174 "text-single",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
175 FIELD_SINGLE,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
176 label=_("Search for"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
177 value=data.get(FIELD_SINGLE, ""),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
178 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
179 )
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
180
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
181 sub_cont = main_ui.main_container.add_tab(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
182 "simple_search",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
183 label=_("Simple search"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
184 container=xml_tools.VerticalContainer,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
185 )
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
186 main_ui.change_container(sub_cont.append(xml_tools.PairsContainer(main_ui)))
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
187 xml_tools.data_form_2_widgets(main_ui, form)
1552
e0bde0d0b321 core (disco): use of “profile” instead of “profile_key” in several disco methods
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
188
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
189 # FIXME: add colspan attribute to divider? (we are in a PairsContainer)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
190 main_ui.addDivider("blank")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
191 main_ui.addDivider("blank") # here we added a blank line before the button
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
192 main_ui.addDivider("blank")
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
193 main_ui.addButton(self.__search_menu_id, _("Search"), (FIELD_SINGLE,))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
194 main_ui.addDivider("blank")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
195 main_ui.addDivider("blank") # a blank line again after the button
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
196
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
197 simple_data = {
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
198 key: value for key, value in data.items() if key in (FIELD_SINGLE,)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
199 }
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
200 if simple_data:
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
201 log.debug("Simple search with %s on %s" % (simple_data, service_jid))
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
202 sub_cont.parent.set_selected(True)
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
203 main_ui.change_container(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
204 sub_cont.append(xml_tools.VerticalContainer(main_ui))
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
205 )
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
206 main_ui.addDivider("dash")
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
207 d = self.search_request(service_jid, simple_data, profile)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
208 d.addCallbacks(
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
209 lambda elt: self._display_search_result(main_ui, elt),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
210 lambda failure: main_ui.addText(failure.getErrorMessage()),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
211 )
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
212 return d
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
213
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
214 return defer.succeed(None)
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
215
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
216 def _add_advanced_search_ui(self, services, main_ui, data, profile):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
217 """Add to the main UI a tab for the advanced search.
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
218
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
219 Display a service selector and allow to search on all the fields that are implemented by the selected service.
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
220
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
221 @param services (list[jid.JID]): search services offered by the user server
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
222 @param main_ui (XMLUI): the main XMLUI instance
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
223 @param data (dict): form data without SAT_FORM_PREFIX
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
224 @param profile (unicode): %(doc_profile)s
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
225
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
226 @return: a __ Deferred
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
227 """
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
228 sub_cont = main_ui.main_container.add_tab(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
229 "advanced_search",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
230 label=_("Advanced search"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
231 container=xml_tools.VerticalContainer,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
232 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
233 service_selection_fields = ["service_jid", "service_jid_extra"]
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
234
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
235 if "service_jid_extra" in data:
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
236 # refresh button has been pushed, select the tab
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
237 sub_cont.parent.set_selected(True)
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
238 # get the selected service
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
239 service_jid_s = data.get("service_jid_extra", "")
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
240 if not service_jid_s:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
241 service_jid_s = data.get("service_jid", str(services[0]))
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
242 log.debug("Refreshing search fields for %s" % service_jid_s)
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
243 else:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
244 service_jid_s = data.get(FIELD_CURRENT_SERVICE, str(services[0]))
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
245 services_s = [str(service) for service in services]
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
246 if service_jid_s not in services_s:
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
247 services_s.append(service_jid_s)
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
248
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
249 main_ui.change_container(sub_cont.append(xml_tools.PairsContainer(main_ui)))
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
250 main_ui.addLabel(_("Search on"))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
251 main_ui.addList("service_jid", options=services_s, selected=service_jid_s)
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
252 main_ui.addLabel(_("Other service"))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
253 main_ui.addString(name="service_jid_extra")
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
254
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
255 # FIXME: add colspan attribute to divider? (we are in a PairsContainer)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
256 main_ui.addDivider("blank")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
257 main_ui.addDivider("blank") # here we added a blank line before the button
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
258 main_ui.addDivider("blank")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
259 main_ui.addButton(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
260 self.__search_menu_id, _("Refresh fields"), service_selection_fields
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
261 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
262 main_ui.addDivider("blank")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
263 main_ui.addDivider("blank") # a blank line again after the button
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
264 main_ui.addLabel(_("Displaying the search form for"))
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
265 main_ui.addString(name=FIELD_CURRENT_SERVICE, value=service_jid_s, read_only=True)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
266 main_ui.addDivider("dash")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
267 main_ui.addDivider("dash")
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
268
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
269 main_ui.change_container(sub_cont.append(xml_tools.VerticalContainer(main_ui)))
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
270 service_jid = jid.JID(service_jid_s)
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
271 d = self.get_fields_ui(service_jid, profile)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
272 d.addCallbacks(
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
273 self._add_advanced_form,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
274 lambda failure: main_ui.addText(failure.getErrorMessage()),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
275 [service_jid, main_ui, sub_cont, data, profile],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
276 )
799
7f2082b192ed plugin XEP-0055, Primitivus: Directory search dialogs are now entirely done in plugin XEP-0055, specific code in frontend is not needed anymore
Goffi <goffi@goffi.org>
parents: 771
diff changeset
277 return d
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
278
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
279 def _add_advanced_form(self, form_elt, service_jid, main_ui, sub_cont, data, profile):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
280 """Add the search form and the search results (if there is some to display).
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
281
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
282 @param form_elt (domish.Element): form element listing the fields
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
283 @param service_jid (jid.JID): current search service
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
284 @param main_ui (XMLUI): the main XMLUI instance
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
285 @param sub_cont (Container): the container of the current tab
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
286 @param data (dict): form data without SAT_FORM_PREFIX
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
287 @param profile (unicode): %(doc_profile)s
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
288
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
289 @return: a __ Deferred
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
290 """
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
291 field_list = data_form.Form.fromElement(form_elt).fieldList
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
292 adv_fields = [field.var for field in field_list if field.var]
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
293 adv_data = {key: value for key, value in data.items() if key in adv_fields}
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
294
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
295 xml_tools.data_form_2_widgets(main_ui, data_form.Form.fromElement(form_elt))
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
296
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
297 # refill the submitted values
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
298 # FIXME: wokkel's data_form.Form.fromElement doesn't parse the values, so we do it directly in XMLUI for now
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
299 for widget in main_ui.current_container.elem.childNodes:
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
300 name = widget.getAttribute("name")
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
301 if adv_data.get(name):
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
302 widget.setAttribute("value", adv_data[name])
1552
e0bde0d0b321 core (disco): use of “profile” instead of “profile_key” in several disco methods
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
303
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
304 # FIXME: add colspan attribute to divider? (we are in a PairsContainer)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
305 main_ui.addDivider("blank")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
306 main_ui.addDivider("blank") # here we added a blank line before the button
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
307 main_ui.addDivider("blank")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
308 main_ui.addButton(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
309 self.__search_menu_id, _("Search"), adv_fields + [FIELD_CURRENT_SERVICE]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
310 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
311 main_ui.addDivider("blank")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
312 main_ui.addDivider("blank") # a blank line again after the button
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
313
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
314 if adv_data: # display the search results
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
315 log.debug("Advanced search with %s on %s" % (adv_data, service_jid))
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
316 sub_cont.parent.set_selected(True)
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
317 main_ui.change_container(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
318 sub_cont.append(xml_tools.VerticalContainer(main_ui))
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
319 )
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
320 main_ui.addDivider("dash")
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
321 d = self.search_request(service_jid, adv_data, profile)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
322 d.addCallbacks(
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
323 lambda elt: self._display_search_result(main_ui, elt),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
324 lambda failure: main_ui.addText(failure.getErrorMessage()),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
325 )
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
326 return d
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
327
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
328 return defer.succeed(None)
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
329
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
330 def _display_search_result(self, main_ui, elt):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
331 """Display the search results.
1552
e0bde0d0b321 core (disco): use of “profile” instead of “profile_key” in several disco methods
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
332
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
333 @param main_ui (XMLUI): the main XMLUI instance
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
334 @param elt (domish.Element): form result element
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
335 """
1552
e0bde0d0b321 core (disco): use of “profile” instead of “profile_key” in several disco methods
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
336 if [child for child in elt.children if child.name == "item"]:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
337 headers, xmlui_data = xml_tools.data_form_elt_result_2_xmlui_data(elt)
1508
ec60682a9d17 plugin XEP-0055: display the search results using XMLUI JidsListWidget
souliane <souliane@mailoo.org>
parents: 1506
diff changeset
338 if "jid" in headers: # use XMLUI JidsListWidget to display the results
ec60682a9d17 plugin XEP-0055: display the search results using XMLUI JidsListWidget
souliane <souliane@mailoo.org>
parents: 1506
diff changeset
339 values = {}
ec60682a9d17 plugin XEP-0055: display the search results using XMLUI JidsListWidget
souliane <souliane@mailoo.org>
parents: 1506
diff changeset
340 for i in range(len(xmlui_data)):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
341 header = list(headers.keys())[i % len(headers)]
1508
ec60682a9d17 plugin XEP-0055: display the search results using XMLUI JidsListWidget
souliane <souliane@mailoo.org>
parents: 1506
diff changeset
342 widget_type, widget_args, widget_kwargs = xmlui_data[i]
ec60682a9d17 plugin XEP-0055: display the search results using XMLUI JidsListWidget
souliane <souliane@mailoo.org>
parents: 1506
diff changeset
343 value = widget_args[0]
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
344 values.setdefault(header, []).append(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
345 jid.JID(value) if header == "jid" else value
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
346 )
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
347 main_ui.addJidsList(jids=values["jid"], name=D_("Search results"))
1508
ec60682a9d17 plugin XEP-0055: display the search results using XMLUI JidsListWidget
souliane <souliane@mailoo.org>
parents: 1506
diff changeset
348 # TODO: also display the values other than JID
ec60682a9d17 plugin XEP-0055: display the search results using XMLUI JidsListWidget
souliane <souliane@mailoo.org>
parents: 1506
diff changeset
349 else:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
350 xml_tools.xmlui_data_2_advanced_list(main_ui, headers, xmlui_data)
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
351 else:
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
352 main_ui.addText(D_("The search gave no result"))
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
353
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
354 ## Retrieve the search fields ##
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
355
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
356 def _get_fields_ui(self, to_jid_s, profile_key):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
357 """Ask a service to send us the list of the form fields it manages.
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
358
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
359 @param to_jid_s (unicode): XEP-0055 compliant search entity
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
360 @param profile_key (unicode): %(doc_profile_key)s
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
361 @return: a deferred XMLUI instance
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
362 """
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
363 d = self.get_fields_ui(jid.JID(to_jid_s), profile_key)
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
364 d.addCallback(lambda form: xml_tools.data_form_elt_result_2_xmlui(form).toXml())
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
365 return d
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
366
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
367 def get_fields_ui(self, to_jid, profile_key):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
368 """Ask a service to send us the list of the form fields it manages.
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
369
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
370 @param to_jid (jid.JID): XEP-0055 compliant search entity
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
371 @param profile_key (unicode): %(doc_profile_key)s
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
372 @return: a deferred domish.Element
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
373 """
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
374 client = self.host.get_client(profile_key)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
375 fields_request = IQ(client.xmlstream, "get")
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
376 fields_request["from"] = client.jid.full()
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
377 fields_request["to"] = to_jid.full()
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
378 fields_request.addElement("query", NS_SEARCH)
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
379 d = fields_request.send(to_jid.full())
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
380 d.addCallbacks(self._get_fields_ui_cb, self._get_fields_ui_eb)
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
381 return d
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
382
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
383 def _get_fields_ui_cb(self, answer):
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
384 """Callback for self.get_fields_ui.
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
385
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
386 @param answer (domish.Element): search query element
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
387 @return: domish.Element
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
388 """
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
389 try:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
390 query_elts = next(answer.elements("jabber:iq:search", "query"))
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
391 except StopIteration:
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 867
diff changeset
392 log.info(_("No query element found"))
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
393 raise DataError # FIXME: StanzaError is probably more appropriate, check the RFC
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
394 try:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
395 form_elt = next(query_elts.elements(data_form.NS_X_DATA, "x"))
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
396 except StopIteration:
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 867
diff changeset
397 log.info(_("No data form found"))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
398 raise NotImplementedError(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
399 "Only search through data form is implemented so far"
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
400 )
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
401 return form_elt
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
402
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
403 def _get_fields_ui_eb(self, failure):
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
404 """Errback to self.get_fields_ui.
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
405
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
406 @param failure (defer.failure.Failure): twisted failure
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
407 @raise: the unchanged defer.failure.Failure
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
408 """
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
409 log.info(_("Fields request failure: %s") % str(failure.getErrorMessage()))
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
410 raise failure
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
411
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
412 ## Do the search ##
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
413
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
414 def _search_request(self, to_jid_s, search_data, profile_key):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
415 """Actually do a search, according to filled data.
799
7f2082b192ed plugin XEP-0055, Primitivus: Directory search dialogs are now entirely done in plugin XEP-0055, specific code in frontend is not needed anymore
Goffi <goffi@goffi.org>
parents: 771
diff changeset
416
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
417 @param to_jid_s (unicode): XEP-0055 compliant search entity
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
418 @param search_data (dict): filled data, corresponding to the form obtained in get_fields_ui
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
419 @param profile_key (unicode): %(doc_profile_key)s
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
420 @return: a deferred XMLUI string representation
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
421 """
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
422 d = self.search_request(jid.JID(to_jid_s), search_data, profile_key)
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
423 d.addCallback(lambda form: xml_tools.data_form_elt_result_2_xmlui(form).toXml())
799
7f2082b192ed plugin XEP-0055, Primitivus: Directory search dialogs are now entirely done in plugin XEP-0055, specific code in frontend is not needed anymore
Goffi <goffi@goffi.org>
parents: 771
diff changeset
424 return d
7f2082b192ed plugin XEP-0055, Primitivus: Directory search dialogs are now entirely done in plugin XEP-0055, specific code in frontend is not needed anymore
Goffi <goffi@goffi.org>
parents: 771
diff changeset
425
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
426 def search_request(self, to_jid, search_data, profile_key):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
427 """Actually do a search, according to filled data.
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
428
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
429 @param to_jid (jid.JID): XEP-0055 compliant search entity
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
430 @param search_data (dict): filled data, corresponding to the form obtained in get_fields_ui
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
431 @param profile_key (unicode): %(doc_profile_key)s
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
432 @return: a deferred domish.Element
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
433 """
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
434 if FIELD_SINGLE in search_data:
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
435 value = search_data[FIELD_SINGLE]
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
436 d = self.get_fields_ui(to_jid, profile_key)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
437 d.addCallback(
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
438 lambda elt: self.search_request_multi(to_jid, value, elt, profile_key)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
439 )
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
440 return d
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
441
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
442 client = self.host.get_client(profile_key)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
443 search_request = IQ(client.xmlstream, "set")
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
444 search_request["from"] = client.jid.full()
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
445 search_request["to"] = to_jid.full()
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
446 query_elt = search_request.addElement("query", NS_SEARCH)
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
447 x_form = data_form.Form("submit", formNamespace=NS_SEARCH)
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
448 x_form.makeFields(search_data)
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
449 query_elt.addChild(x_form.toElement())
1219
16484ebb695b plugin XEP-0059: first draft, pubsub and jabber search do not exploit it yet
souliane <souliane@mailoo.org>
parents: 993
diff changeset
450 # TODO: XEP-0059 could be used here (with the needed new method attributes)
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
451 d = search_request.send(to_jid.full())
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
452 d.addCallbacks(self._search_ok, self._search_err)
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
453 return d
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
454
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
455 def search_request_multi(self, to_jid, value, form_elt, profile_key):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
456 """Search for a value simultaneously in all fields, returns the results compilation.
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
457
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
458 @param to_jid (jid.JID): XEP-0055 compliant search entity
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
459 @param value (unicode): value to search
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
460 @param form_elt (domish.Element): form element listing the fields
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
461 @param profile_key (unicode): %(doc_profile_key)s
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
462 @return: a deferred domish.Element
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
463 """
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
464 form = data_form.Form.fromElement(form_elt)
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
465 d_list = []
1506
8405d622bde0 plugin XEP-0055: remove a "debug" break that has been forgotten here
souliane <souliane@mailoo.org>
parents: 1498
diff changeset
466
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
467 for field in [field.var for field in form.fieldList if field.var]:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
468 d_list.append(self.search_request(to_jid, {field: value}, profile_key))
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
469
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
470 def cb(result): # return the results compiled in one domish element
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
471 result_elt = None
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
472 for success, form_elt in result:
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
473 if not success:
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
474 continue
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
475 if (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
476 result_elt is None
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
477 ): # the result element is built over the first answer
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
478 result_elt = form_elt
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
479 continue
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
480 for item_elt in form_elt.elements("jabber:x:data", "item"):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
481 result_elt.addChild(item_elt)
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
482 if result_elt is None:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
483 raise defer.failure.Failure(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
484 DataError(_("The search could not be performed"))
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
485 )
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
486 return result_elt
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
487
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
488 return defer.DeferredList(d_list).addCallback(cb)
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
489
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
490 def _search_ok(self, answer):
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
491 """Callback for self.search_request.
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
492
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
493 @param answer (domish.Element): search query element
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
494 @return: domish.Element
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
495 """
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
496 try:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
497 query_elts = next(answer.elements("jabber:iq:search", "query"))
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
498 except StopIteration:
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 867
diff changeset
499 log.info(_("No query element found"))
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
500 raise DataError # FIXME: StanzaError is probably more appropriate, check the RFC
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
501 try:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
502 form_elt = next(query_elts.elements(data_form.NS_X_DATA, "x"))
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
503 except StopIteration:
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 867
diff changeset
504 log.info(_("No data form found"))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
505 raise NotImplementedError(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
506 "Only search through data form is implemented so far"
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
507 )
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
508 return form_elt
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
509
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
510 def _search_err(self, failure):
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
511 """Errback to self.search_request.
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
512
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
513 @param failure (defer.failure.Failure): twisted failure
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
514 @raise: the unchanged defer.failure.Failure
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
515 """
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
516 log.info(_("Search request failure: %s") % str(failure.getErrorMessage()))
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
517 raise failure
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
518
631
694f118d0cd5 plugin XEP-0055: implementation of Jabber Search
Goffi <goffi@goffi.org>
parents:
diff changeset
519
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
520 @implementer(iwokkel.IDisco)
1810
25c3569abb71 plugin XEP-0055, tmp_directory_subscription: move directory subscription to a new temporary plugin
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
521 class XEP_0055_handler(XMPPHandler):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
522
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
523 def __init__(self, plugin_parent, profile):
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
524 self.plugin_parent = plugin_parent
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
525 self.host = plugin_parent.host
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
526 self.profile = profile
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
527
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
528 def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
529 return [disco.DiscoFeature(NS_SEARCH)]
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
530
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
531 def getDiscoItems(self, requestor, target, nodeIdentifier=""):
1498
e3330ce65285 plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
souliane <souliane@mailoo.org>
parents: 1409
diff changeset
532 return []