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
G
gajim-plugins
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
56
Issues
56
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
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-plugins
Commits
43ecb95a
Commit
43ecb95a
authored
Nov 15, 2017
by
Philipp Hörist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[omemo] Use extension point to add caps
parent
3318e2e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
23 deletions
+17
-23
omemo/omemo_connection.py
omemo/omemo_connection.py
+10
-22
omemo/omemoplugin.py
omemo/omemoplugin.py
+7
-1
No files found.
omemo/omemo_connection.py
View file @
43ecb95a
...
...
@@ -9,7 +9,7 @@ from nbxmpp.simplexml import Node
from
gajim.common
import
app
from
gajim.common
import
ged
from
gajim.common
import
caps_cache
from
gajim.common
import
helpers
from
gajim.common.connection_handlers_events
import
(
MessageReceivedEvent
,
MamMessageReceivedEvent
,
MessageNotSentEvent
)
...
...
@@ -126,11 +126,10 @@ class OMEMOConnection:
def
activate
(
self
):
""" Method called when the Plugin is activated in the PluginManager
"""
# self.query_for_bundles = []
if
app
.
caps_hash
[
self
.
account
]
!=
''
:
# Gajim has already a caps hash calculated, update it
helpers
.
update_optional_features
(
self
.
account
)
if
NS_NOTIFY
not
in
app
.
gajim_optional_features
[
self
.
account
]:
app
.
gajim_optional_features
[
self
.
account
].
append
(
NS_NOTIFY
)
self
.
_compute_caps_hash
()
if
app
.
account_is_connected
(
self
.
account
):
log
.
info
(
'%s => Announce Support after Plugin Activation'
,
self
.
account
)
...
...
@@ -140,24 +139,13 @@ class OMEMOConnection:
def
deactivate
(
self
):
""" Method called when the Plugin is deactivated in the PluginManager
Removes OMEMO from the Entity Capabilities list
"""
if
NS_NOTIFY
in
app
.
gajim_optional_features
[
self
.
account
]:
app
.
gajim_optional_features
[
self
.
account
].
remove
(
NS_NOTIFY
)
self
.
_compute_caps_hash
()
def
_compute_caps_hash
(
self
):
""" Computes the hash for Entity Capabilities and publishes it """
app
.
caps_hash
[
self
.
account
]
=
caps_cache
.
compute_caps_hash
(
[
app
.
gajim_identity
],
app
.
gajim_common_features
+
app
.
gajim_optional_features
[
self
.
account
])
# re-send presence with new hash
connected
=
app
.
connections
[
self
.
account
].
connected
if
connected
>
1
and
app
.
SHOW_LIST
[
connected
]
!=
'invisible'
:
app
.
connections
[
self
.
account
].
change_status
(
app
.
SHOW_LIST
[
connected
],
app
.
connections
[
self
.
account
].
status
)
self
.
query_for_bundles
=
[]
@
staticmethod
def
update_caps
(
account
):
if
NS_NOTIFY
not
in
app
.
gajim_optional_features
[
account
]:
app
.
gajim_optional_features
[
account
].
append
(
NS_NOTIFY
)
def
message_received
(
self
,
conn
,
obj
,
callback
):
if
obj
.
encrypted
:
...
...
omemo/omemoplugin.py
View file @
43ecb95a
...
...
@@ -106,7 +106,8 @@ class OmemoPlugin(GajimPlugin):
'encryption_dialog'
+
self
.
encryption_name
:
(
self
.
on_encryption_button_clicked
,
None
),
'encryption_state'
+
self
.
encryption_name
:
(
self
.
encryption_state
,
None
)}
self
.
encryption_state
,
None
),
'update_caps'
:
(
self
.
_update_caps
,
None
)}
SUPPORTED_PERSONAL_USER_EVENTS
.
append
(
DevicelistPEP
)
self
.
disabled_accounts
=
[]
...
...
@@ -159,6 +160,11 @@ class OmemoPlugin(GajimPlugin):
continue
self
.
connections
[
account
].
deactivate
()
def
_update_caps
(
self
,
account
):
if
account
==
'Local'
:
return
self
.
connections
[
account
].
update_caps
(
account
)
def
activate_encryption
(
self
,
chat_control
):
if
isinstance
(
chat_control
,
GroupchatControl
):
omemo_con
=
self
.
connections
[
chat_control
.
account
]
...
...
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