| ... |
... |
@@ -12,6 +12,8 @@ |
|
12
|
12
|
# You should have received a copy of the GNU General Public License
|
|
13
|
13
|
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
14
|
14
|
|
|
|
15
|
+from typing import Any
|
|
|
16
|
+
|
|
15
|
17
|
import logging
|
|
16
|
18
|
import random
|
|
17
|
19
|
|
| ... |
... |
@@ -19,6 +21,7 @@ |
|
19
|
21
|
from gi.repository import Gdk
|
|
20
|
22
|
|
|
21
|
23
|
from nbxmpp.errors import StanzaError
|
|
|
24
|
+from nbxmpp.task import Task
|
|
22
|
25
|
|
|
23
|
26
|
from gajim.common import app
|
|
24
|
27
|
from gajim.common.const import MUC_CREATION_EXAMPLES
|
| ... |
... |
@@ -57,15 +60,15 @@ def __init__(self, account: str) -> None: |
|
57
|
60
|
self._fill_placeholders()
|
|
58
|
61
|
|
|
59
|
62
|
self._ui.connect_signals(self)
|
|
60
|
|
- self.connect('key-press-event', self._on_key_press_event)
|
|
|
63
|
+ self.connect('key-press-event', self._on_key_press)
|
|
61
|
64
|
self.connect('destroy', self._on_destroy)
|
|
62
|
65
|
|
|
63
|
66
|
self.show_all()
|
|
64
|
67
|
self.set_focus(self._ui.address_entry)
|
|
65
|
68
|
|
|
66
|
69
|
def _get_muc_service_jid(self) -> str:
|
|
67
|
|
- con = app.connections[self._account]
|
|
68
|
|
- return str(con.get_module('MUC').service_jid or 'muc.example.com')
|
|
|
70
|
+ client = app.get_client(self._account)
|
|
|
71
|
+ return str(client.get_module('MUC').service_jid or 'muc.example.com')
|
|
69
|
72
|
|
|
70
|
73
|
def _fill_account_combo(self, account: str) -> str:
|
|
71
|
74
|
accounts = app.get_enabled_accounts_with_labels(connected_only=True)
|
| ... |
... |
@@ -106,15 +109,15 @@ def _fill_placeholders(self) -> None: |
|
106
|
109
|
self._ui.address_entry.set_placeholder_text(
|
|
107
|
110
|
f'{placeholder[2]}@{server}')
|
|
108
|
111
|
|
|
109
|
|
- def _on_key_press_event(self, _widget, event):
|
|
|
112
|
+ def _on_key_press(self, _widget: Gtk.Widget, event: Gdk.EventKey) -> None:
|
|
110
|
113
|
if event.keyval == Gdk.KEY_Escape:
|
|
111
|
114
|
self.destroy()
|
|
112
|
115
|
|
|
113
|
|
- def _on_account_combo_changed(self, combo):
|
|
|
116
|
+ def _on_account_combo_changed(self, combo: Gtk.ComboBox) -> None:
|
|
114
|
117
|
self._account = combo.get_active_id()
|
|
115
|
118
|
self._fill_placeholders()
|
|
116
|
119
|
|
|
117
|
|
- def _update_entry_completion(self, entry, text):
|
|
|
120
|
+ def _update_entry_completion(self, entry: Gtk.Entry, text: str) -> None:
|
|
118
|
121
|
text = entry.get_text()
|
|
119
|
122
|
if '@' in text:
|
|
120
|
123
|
text = text.split('@', 1)[0]
|
| ... |
... |
@@ -174,15 +177,15 @@ def _set_warning_from_error(self, error: StanzaError) -> None: |
|
174
|
177
|
def _set_warning_from_error_code(self, error_code: str) -> None:
|
|
175
|
178
|
self._set_warning(MUC_DISCO_ERRORS[error_code])
|
|
176
|
179
|
|
|
177
|
|
- def _on_address_entry_changed(self, entry):
|
|
|
180
|
+ def _on_address_entry_changed(self, entry: Gtk.Entry) -> None:
|
|
178
|
181
|
text = entry.get_text()
|
|
179
|
182
|
self._update_entry_completion(entry, text)
|
|
180
|
183
|
self._validate_jid(text)
|
|
181
|
184
|
|
|
182
|
|
- def _on_address_entry_activate(self, _widget):
|
|
|
185
|
+ def _on_address_entry_activate(self, _entry: Gtk.Entry) -> None:
|
|
183
|
186
|
self._on_create_clicked()
|
|
184
|
187
|
|
|
185
|
|
- def _on_create_clicked(self, *args):
|
|
|
188
|
+ def _on_create_clicked(self, *args: Any) -> None:
|
|
186
|
189
|
if not app.account_is_available(self._account):
|
|
187
|
190
|
ErrorDialog(
|
|
188
|
191
|
_('Not Connected'),
|
| ... |
... |
@@ -192,12 +195,12 @@ def _on_create_clicked(self, *args): |
|
192
|
195
|
room_jid = self._ui.address_entry.get_text()
|
|
193
|
196
|
|
|
194
|
197
|
self._set_processing_state(True)
|
|
195
|
|
- con = app.connections[self._account]
|
|
196
|
|
- con.get_module('Discovery').disco_info(
|
|
|
198
|
+ client = app.get_client(self._account)
|
|
|
199
|
+ client.get_module('Discovery').disco_info(
|
|
197
|
200
|
room_jid, callback=self._disco_info_received)
|
|
198
|
201
|
|
|
199
|
202
|
@ensure_not_destroyed
|
|
200
|
|
- def _disco_info_received(self, task):
|
|
|
203
|
+ def _disco_info_received(self, task: Task) -> None:
|
|
201
|
204
|
try:
|
|
202
|
205
|
result = task.finish()
|
|
203
|
206
|
except StanzaError as error:
|
| ... |
... |
@@ -238,5 +241,5 @@ def _create_muc(self, room_jid: str) -> None: |
|
238
|
241
|
|
|
239
|
242
|
self.destroy()
|
|
240
|
243
|
|
|
241
|
|
- def _on_destroy(self, *args):
|
|
|
244
|
+ def _on_destroy(self, _widget: Gtk.Widget) -> None:
|
|
242
|
245
|
self._destroyed = True
|