Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TSRh
gajim
Commits
e13c472e
Commit
e13c472e
authored
16 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
implement legacy pep protocol (v1.3). Fixes #4146
parent
ebe0f96e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/caps.py
+39
-23
39 additions, 23 deletions
src/common/caps.py
with
39 additions
and
23 deletions
src/common/caps.py
+
39
−
23
View file @
e13c472e
...
...
@@ -171,14 +171,20 @@ def preload(self, con, jid, node, hash_method, hash):
'''
Preload data about (node, ver, exts) caps using disco
query to jid using proper connection. Don
'
t query if
the data is already in cache.
'''
q
=
self
[(
hash_method
,
hash
)]
if
hash_method
==
'
old
'
:
q
=
self
[(
hash_method
,
node
+
'
#
'
+
hash
)]
else
:
q
=
self
[(
hash_method
,
hash
)]
if
q
.
queried
==
0
:
# do query for bare node+hash pair
# this will create proper object
q
.
queried
=
1
con
.
discoverInfo
(
jid
,
'
%s#%s
'
%
(
node
,
hash
))
if
hash_method
==
'
old
'
:
con
.
discoverInfo
(
jid
)
else
:
con
.
discoverInfo
(
jid
,
'
%s#%s
'
%
(
node
,
hash
))
def
is_supported
(
self
,
contact
,
feature
):
# No resource -> can't have any caps
if
not
contact
or
not
contact
.
resource
:
...
...
@@ -195,8 +201,11 @@ def is_supported(self, contact, feature):
# This is the "Asterix way", after 0.12 release, I will
# likely implement a fallback to disco (could be disabled
# for mobile users who pay for traffic)
features
=
self
[(
contact
.
caps_hash_method
,
contact
.
caps_hash
)].
features
if
contact
.
caps_hash_method
==
'
old
'
:
features
=
self
[(
contact
.
caps_hash_method
,
contact
.
caps_node
+
'
#
'
+
\
contact
.
caps_hash
)].
features
else
:
features
=
self
[(
contact
.
caps_hash_method
,
contact
.
caps_hash
)].
features
if
feature
in
features
or
features
==
[]:
return
True
...
...
@@ -214,8 +223,7 @@ def _capsPresenceCB(self, con, presence):
# for disco... so that disco will learn how to interpret
# these caps
jid
=
helpers
.
get_full_jid_from_iq
(
presence
)
contact
=
gajim
.
contacts
.
get_contact_from_full_jid
(
self
.
name
,
jid
)
contact
=
gajim
.
contacts
.
get_contact_from_full_jid
(
self
.
name
,
jid
)
if
contact
is
None
:
room_jid
,
nick
=
gajim
.
get_room_and_nick_from_fjid
(
jid
)
contact
=
gajim
.
contacts
.
get_gc_contact
(
...
...
@@ -233,8 +241,11 @@ def _capsPresenceCB(self, con, presence):
contact
.
hash_method
=
None
return
hash_method
,
node
,
hash
=
\
caps
[
'
hash
'
],
caps
[
'
node
'
],
caps
[
'
ver
'
]
hash_method
,
node
,
hash
=
caps
[
'
hash
'
],
caps
[
'
node
'
],
caps
[
'
ver
'
]
if
hash_method
is
None
and
node
and
hash
:
# Old XEP-115 implentation
hash_method
=
'
old
'
if
hash_method
is
None
or
node
is
None
or
hash
is
None
:
# improper caps in stanza, ignoring
...
...
@@ -260,23 +271,28 @@ def _capsDiscoCB(self, jid, node, identities, features, dataforms):
return
if
not
contact
.
caps_node
:
return
# we didn't asked for that?
if
not
node
.
startswith
(
contact
.
caps_node
+
'
#
'
):
if
contact
.
caps_hash_method
!=
'
old
'
and
not
node
.
startswith
(
contact
.
caps_node
+
'
#
'
):
return
node
,
hash
=
node
.
split
(
'
#
'
,
1
)
computed_hash
=
helpers
.
compute_caps_hash
(
identities
,
features
,
dataforms
=
dataforms
,
hash_method
=
contact
.
caps_hash_method
)
if
computed_hash
!=
hash
:
# wrong hash, forget it
contact
.
caps_node
=
''
contact
.
caps_hash_method
=
''
contact
.
caps_hash
=
''
return
# if we don't have this info already...
caps
=
gajim
.
capscache
[(
contact
.
caps_hash_method
,
hash
)]
if
contact
.
caps_hash_method
!=
'
old
'
:
node
,
hash
=
node
.
split
(
'
#
'
,
1
)
computed_hash
=
helpers
.
compute_caps_hash
(
identities
,
features
,
dataforms
=
dataforms
,
hash_method
=
contact
.
caps_hash_method
)
if
computed_hash
!=
hash
:
# wrong hash, forget it
contact
.
caps_node
=
''
contact
.
caps_hash_method
=
''
contact
.
caps_hash
=
''
return
# if we don't have this info already...
caps
=
gajim
.
capscache
[(
contact
.
caps_hash_method
,
contact
.
caps_hash
)]
else
:
# if we don't have this info already...
caps
=
gajim
.
capscache
[(
contact
.
caps_hash_method
,
contact
.
caps_node
+
\
'
#
'
+
contact
.
caps_hash
)]
if
caps
.
queried
==
2
:
return
caps
.
update
(
identities
,
features
)
# vim: se ts=3:
\ No newline at end of file
# vim: se ts=3:
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment