Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
gajim
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
210
Issues
210
List
Boards
Labels
Service Desk
Milestones
Merge Requests
22
Merge Requests
22
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gajim
gajim
Commits
739ead2b
Commit
739ead2b
authored
Feb 12, 2021
by
Philipp Hörist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client: Determine some Settings right before connecting
parent
d0e602bd
Pipeline
#7289
passed with stages
in 10 minutes and 8 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
26 deletions
+29
-26
gajim/common/client.py
gajim/common/client.py
+29
-26
No files found.
gajim/common/client.py
View file @
739ead2b
...
...
@@ -157,38 +157,16 @@ def _create_client(self):
self
.
_client
.
set_username
(
self
.
_user
)
self
.
_client
.
set_resource
(
get_resource
(
self
.
_account
))
custom_host
=
get_custom_host
(
self
.
_account
)
if
custom_host
is
not
None
:
self
.
_client
.
set_custom_host
(
*
custom_host
)
pass_saved
=
app
.
settings
.
get_account_setting
(
self
.
_account
,
'savepass'
)
if
pass_saved
:
# Request password from keyring only if the user chose to save
# his password
self
.
password
=
passwords
.
get_password
(
self
.
_account
)
gssapi
=
app
.
settings
.
get_account_setting
(
self
.
_account
,
'enable_gssapi'
)
if
gssapi
:
self
.
_client
.
set_mechs
([
'GSSAPI'
])
anonymous
=
app
.
settings
.
get_account_setting
(
self
.
_account
,
'anonymous_auth'
)
if
anonymous
:
self
.
_client
.
set_mechs
([
'ANONYMOUS'
])
self
.
_client
.
set_password
(
self
.
password
)
self
.
_client
.
set_accepted_certificates
(
app
.
cert_store
.
get_certificates
())
if
app
.
settings
.
get_account_setting
(
self
.
_account
,
'use_plain_connection'
):
self
.
_client
.
set_connection_types
([
ConnectionType
.
PLAIN
])
proxy
=
get_user_proxy
(
self
.
_account
)
if
proxy
is
not
None
:
self
.
_client
.
set_proxy
(
proxy
)
self
.
_client
.
subscribe
(
'resume-failed'
,
self
.
_on_resume_failed
)
self
.
_client
.
subscribe
(
'resume-successful'
,
self
.
_on_resume_successful
)
self
.
_client
.
subscribe
(
'disconnected'
,
self
.
_on_disconnected
)
...
...
@@ -277,7 +255,7 @@ def _on_disconnected(self, _client, _signal_name):
def
_on_password
(
password
):
self
.
password
=
password
self
.
_client
.
set_password
(
password
)
self
.
connect
()
self
.
_prepare_for_
connect
()
app
.
nec
.
push_incoming_event
(
NetworkEvent
(
'password-required'
,
conn
=
self
,
on_password
=
_on_password
))
...
...
@@ -372,7 +350,7 @@ def change_status(self, show, message):
if
show
==
'offline'
:
return
self
.
connect
()
self
.
_prepare_for_
connect
()
return
if
self
.
_state
.
is_connecting
:
...
...
@@ -387,7 +365,7 @@ def change_status(self, show, message):
self
.
_destroy_client
=
True
self
.
_abort_reconnect
()
else
:
self
.
connect
()
self
.
_prepare_for_
connect
()
return
# We are connected
...
...
@@ -522,6 +500,31 @@ def send_messages(self, jids, message):
message
.
stanza
=
stanza
self
.
_send_message
(
message
)
def
_prepare_for_connect
(
self
):
custom_host
=
get_custom_host
(
self
.
_account
)
if
custom_host
is
not
None
:
self
.
_client
.
set_custom_host
(
*
custom_host
)
gssapi
=
app
.
settings
.
get_account_setting
(
self
.
_account
,
'enable_gssapi'
)
if
gssapi
:
self
.
_client
.
set_mechs
([
'GSSAPI'
])
anonymous
=
app
.
settings
.
get_account_setting
(
self
.
_account
,
'anonymous_auth'
)
if
anonymous
:
self
.
_client
.
set_mechs
([
'ANONYMOUS'
])
if
app
.
settings
.
get_account_setting
(
self
.
_account
,
'use_plain_connection'
):
self
.
_client
.
set_connection_types
([
ConnectionType
.
PLAIN
])
proxy
=
get_user_proxy
(
self
.
_account
)
if
proxy
is
not
None
:
self
.
_client
.
set_proxy
(
proxy
)
self
.
connect
()
def
connect
(
self
,
ignored_tls_errors
=
None
):
if
self
.
_state
not
in
(
ClientState
.
DISCONNECTED
,
ClientState
.
RECONNECT_SCHEDULED
):
...
...
@@ -550,7 +553,7 @@ def _schedule_reconnect(self):
self
.
_set_state
(
ClientState
.
RECONNECT_SCHEDULED
)
log
.
info
(
"Reconnect to %s in 3s"
,
self
.
_account
)
self
.
_reconnect_timer_source
=
GLib
.
timeout_add_seconds
(
3
,
self
.
connect
)
3
,
self
.
_prepare_for_
connect
)
def
_abort_reconnect
(
self
):
self
.
_set_state
(
ClientState
.
DISCONNECTED
)
...
...
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