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
6429cc9d
Commit
6429cc9d
authored
Nov 20, 2018
by
Philipp Hörist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[omemo] Publish devicelist with id 'current'
parent
d6a46c7e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
42 deletions
+13
-42
omemo/gtk/config.py
omemo/gtk/config.py
+1
-1
omemo/omemo_connection.py
omemo/omemo_connection.py
+12
-23
omemo/xmpp.py
omemo/xmpp.py
+0
-18
No files found.
omemo/gtk/config.py
View file @
6429cc9d
...
...
@@ -171,7 +171,7 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
def
cleardevice_button_clicked_cb
(
self
,
button
,
*
args
):
active
=
self
.
_ui
.
get_object
(
'account_combobox'
).
get_active
()
account
=
self
.
account_store
[
active
][
0
]
self
.
plugin
.
connections
[
account
].
clear_device_list
(
)
self
.
plugin
.
connections
[
account
].
publish_own_devices_list
(
new
=
True
)
self
.
update_context_list
()
def
refresh_button_clicked_cb
(
self
,
button
,
*
args
):
...
...
omemo/omemo_connection.py
View file @
6429cc9d
...
...
@@ -17,9 +17,9 @@ from gajim.plugins.plugins_i18n import _
from
omemo.xmpp
import
(
NS_NOTIFY
,
NS_OMEMO
,
NS_EME
,
NS_HINTS
,
BundleInformationAnnouncement
,
BundleInformationQuery
,
Device
ListAnnouncement
,
Device
listQuery
,
BundleInformationQuery
,
DevicelistQuery
,
OmemoMessage
,
successful
,
unpack_device_bundle
,
unpack_device_list_update
,
unpack_encrypted
)
unpack_device_list_update
,
unpack_encrypted
,
NS_DEVICE_LIST
)
from
omemo.omemo.state
import
OmemoState
ALLOWED_TAGS
=
[(
'request'
,
nbxmpp
.
NS_RECEIPTS
),
...
...
@@ -677,13 +677,19 @@ class OMEMOConnection:
devices_list
=
list
(
set
(
devices_list
))
self
.
omemo
.
set_own_devices
(
devices_list
)
list_node
=
Node
(
'list'
,
attrs
=
{
'xmlns'
:
NS_OMEMO
})
for
device
in
devices_list
:
list_node
.
addChild
(
'device'
).
setAttr
(
'id'
,
device
)
con
=
app
.
connections
[
self
.
account
]
con
.
get_module
(
'PubSub'
).
send_pb_publish
(
''
,
NS_DEVICE_LIST
,
list_node
,
'current'
,
cb
=
self
.
device_list_publish_result
)
log
.
info
(
'%s => Publishing own Devices: %s'
,
self
.
account
,
devices_list
)
device_announce
=
DeviceListAnnouncement
(
devices_list
)
self
.
send_with_callback
(
device_announce
,
self
.
device_list_publish_result
)
def
device_list_publish_result
(
self
,
stanza
):
def
device_list_publish_result
(
self
,
_con
,
stanza
):
if
not
nbxmpp
.
isResultNode
(
stanza
):
log
.
error
(
'%s => Publishing devicelist failed: %s'
,
self
.
account
,
stanza
.
getError
())
...
...
@@ -852,23 +858,6 @@ class OMEMOConnection:
self
.
account
,
stanza
.
getError
())
self
.
publish_own_devices_list
(
new
=
True
)
def
clear_device_list
(
self
):
""" Overwrite the current devicelist on the server with only
our device id.
"""
if
not
app
.
account_is_connected
(
self
.
account
):
return
devices_list
=
[
self
.
omemo
.
own_device_id
]
self
.
omemo
.
set_own_devices
(
devices_list
)
log
.
info
(
'%s => Clearing devices_list %s'
,
self
.
account
,
devices_list
)
device_announce
=
DeviceListAnnouncement
(
devices_list
)
self
.
send_with_callback
(
device_announce
,
self
.
clear_device_list_result
)
@
staticmethod
def
clear_device_list_result
(
stanza
):
log
.
info
(
stanza
)
@
staticmethod
def
print_msg_to_log
(
stanza
):
""" Prints a stanza in a fancy way to the log """
...
...
omemo/xmpp.py
View file @
6429cc9d
...
...
@@ -57,24 +57,6 @@ class PubsubNode(Node):
self
.
addChild
(
node
=
data
)
class
DeviceListAnnouncement
(
Iq
):
def
__init__
(
self
,
device_list
):
assert
isinstance
(
device_list
,
list
)
assert
len
(
device_list
)
>
0
id_
=
app
.
get_an_id
()
attrs
=
{
'id'
:
id_
}
Iq
.
__init__
(
self
,
typ
=
'set'
,
attrs
=
attrs
)
list_node
=
Node
(
'list'
,
attrs
=
{
'xmlns'
:
NS_OMEMO
})
for
device
in
device_list
:
list_node
.
addChild
(
'device'
).
setAttr
(
'id'
,
device
)
publish
=
PublishNode
(
NS_DEVICE_LIST
,
list_node
)
pubsub
=
PubsubNode
(
publish
)
self
.
addChild
(
node
=
pubsub
)
class
OmemoMessage
(
Node
):
def
__init__
(
self
,
msg_dict
):
# , contact_jid, key, iv, payload, dev_id, my_dev_id):
...
...
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