Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gajim
python-nbxmpp
Commits
637b3930
Commit
637b3930
authored
May 28, 2022
by
Philipp Hörist
Browse files
feat: Examples: Allow to connect with different modes
parent
d65100e1
Pipeline
#10024
passed with stages
in 1 minute and 6 seconds
Changes
2
Pipelines
1
Expand all
Show whitespace changes
Inline
Side-by-side
nbxmpp/examples/client.py
View file @
637b3930
...
...
@@ -16,10 +16,10 @@ from nbxmpp.protocol import JID
from
nbxmpp.client
import
Client
from
nbxmpp.structs
import
ProxyData
from
nbxmpp.structs
import
StanzaHandler
from
nbxmpp.addresses
import
ServerAddress
from
nbxmpp.const
import
ConnectionType
from
nbxmpp.const
import
ConnectionProtocol
from
nbxmpp.const
import
StreamError
from
nbxmpp.const
import
Mode
consoleloghandler
=
logging
.
StreamHandler
()
log
=
logging
.
getLogger
(
'nbxmpp'
)
...
...
@@ -94,6 +94,17 @@ class TestClient(Gtk.Window):
self
.
_builder
.
proxy_password
.
get_text
()
or
None
)
self
.
_client
.
set_proxy
(
proxy
)
if
self
.
_builder
.
login_mode
.
get_active
():
self
.
_client
.
set_mode
(
Mode
.
LOGIN_TEST
)
elif
self
.
_builder
.
client_mode
.
get_active
():
self
.
_client
.
set_mode
(
Mode
.
CLIENT
)
elif
self
.
_builder
.
register_mode
.
get_active
():
self
.
_client
.
set_mode
(
Mode
.
REGISTER
)
elif
self
.
_builder
.
anon_mode
.
get_active
():
self
.
_client
.
set_mode
(
Mode
.
ANONYMOUS_TEST
)
else
:
raise
ValueError
(
'No mode selected'
)
self
.
_client
.
set_connection_types
(
self
.
_get_connection_types
())
self
.
_client
.
set_protocols
(
self
.
_get_connection_protocols
())
...
...
@@ -168,7 +179,9 @@ class TestClient(Gtk.Window):
self
.
_scroll_timeout
=
GLib
.
timeout_add
(
50
,
self
.
scroll_to_end
)
def
_connect_clicked
(
self
,
*
args
):
if
self
.
_client
is
None
:
if
self
.
_client
is
not
None
:
self
.
_client
.
destroy
()
self
.
_create_client
()
self
.
_client
.
connect
()
...
...
nbxmpp/examples/client.ui
View file @
637b3930
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment