policy-{node|hooks}.lua: Fix issues in Zoom Desktop Video Sharing.
Fixes #339
This commit is contained in:

committed by
Julian Bouzas

parent
40a1c3b948
commit
bbe3b919d3
@@ -12,7 +12,7 @@
|
|||||||
local putils = require ("policy-utils")
|
local putils = require ("policy-utils")
|
||||||
local cutils = require ("common-utils")
|
local cutils = require ("common-utils")
|
||||||
|
|
||||||
local move = Settings.parse_boolean_safe ("default-policy-move", false)
|
local move = Settings.parse_boolean_safe("policy.default.move", false)
|
||||||
|
|
||||||
function settingsChangedCallback (_, setting, _)
|
function settingsChangedCallback (_, setting, _)
|
||||||
move = Settings.parse_boolean_safe ("policy.default.move", move)
|
move = Settings.parse_boolean_safe ("policy.default.move", move)
|
||||||
@@ -35,8 +35,8 @@ function findDefinedTarget (event)
|
|||||||
local si_flags = putils.get_flags (si_id)
|
local si_flags = putils.get_flags (si_id)
|
||||||
local si_target = nil
|
local si_target = nil
|
||||||
|
|
||||||
Log.info (si, string.format ("handling item: %s (%s)",
|
Log.info (si, string.format ("handling item: %s (%s) si id(%s)",
|
||||||
tostring (si_props ["node.name"]), tostring (si_props ["node.id"])))
|
tostring (si_props ["node.name"]), tostring (si_props ["node.id"]), si_id))
|
||||||
|
|
||||||
local metadata = move and putils.get_default_metadata_object ()
|
local metadata = move and putils.get_default_metadata_object ()
|
||||||
local target_key
|
local target_key
|
||||||
@@ -84,14 +84,17 @@ function findDefinedTarget (event)
|
|||||||
target_picked = true
|
target_picked = true
|
||||||
end
|
end
|
||||||
elseif target_value then
|
elseif target_value then
|
||||||
for si_target in linkables_om:iterate () do
|
for lnkbl in linkables_om:iterate () do
|
||||||
local target_props = si_target.properties
|
local target_props = lnkbl.properties
|
||||||
if (target_props ["node.name"] == target_value or
|
if (target_props ["node.name"] == target_value or
|
||||||
target_props ["object.path"] == target_value) and
|
target_props ["object.path"] == target_value) and
|
||||||
target_props ["item.node.direction"] == cutils.getTargetDirection (si_props) and
|
target_props ["item.node.direction"] == cutils.getTargetDirection (si_props) and
|
||||||
putils.canLink (si_props, si_target) then
|
putils.canLink (si_props, lnkbl) then
|
||||||
target_picked = true
|
target_picked = true
|
||||||
|
si_target = lnkbl
|
||||||
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -113,9 +116,7 @@ function findDefinedTarget (event)
|
|||||||
and not si_target
|
and not si_target
|
||||||
and not si_flags.was_handled
|
and not si_flags.was_handled
|
||||||
and not si_flags.done_waiting then
|
and not si_flags.done_waiting then
|
||||||
Log.info (si, string.format ("... waiting for target %s (%s)",
|
Log.info(si, "... waiting for target")
|
||||||
tostring (si_target.properties ["node.name"]),
|
|
||||||
tostring (si_target.properties ["node.id"])))
|
|
||||||
si_flags.done_waiting = true
|
si_flags.done_waiting = true
|
||||||
event:stop_processing ()
|
event:stop_processing ()
|
||||||
|
|
||||||
@@ -152,8 +153,8 @@ function findDefaultTarget (event)
|
|||||||
local si_props = si.properties
|
local si_props = si.properties
|
||||||
local target_picked = false
|
local target_picked = false
|
||||||
|
|
||||||
Log.info (si, string.format ("handling item: %s (%s)",
|
Log.info (si, string.format ("handling item: %s (%s) si id(%s)",
|
||||||
tostring (si_props ["node.name"]), tostring (si_props ["node.id"])))
|
tostring (si_props ["node.name"]), tostring (si_props ["node.id"]), si_id))
|
||||||
|
|
||||||
local si_target = putils.findDefaultLinkable (si)
|
local si_target = putils.findDefaultLinkable (si)
|
||||||
|
|
||||||
@@ -201,6 +202,9 @@ function findBestTarget (event)
|
|||||||
local target_priority = 0
|
local target_priority = 0
|
||||||
local target_plugged = 0
|
local target_plugged = 0
|
||||||
|
|
||||||
|
Log.info (si, string.format ("handling item: %s (%s) si id(%s)",
|
||||||
|
tostring (si_props ["node.name"]), tostring (si_props ["node.id"]), si_id))
|
||||||
|
|
||||||
for si_target in linkables_om:iterate {
|
for si_target in linkables_om:iterate {
|
||||||
Constraint { "item.node.type", "=", "device" },
|
Constraint { "item.node.type", "=", "device" },
|
||||||
Constraint { "item.node.direction", "=", target_direction },
|
Constraint { "item.node.direction", "=", target_direction },
|
||||||
@@ -282,8 +286,9 @@ function prepareLink (event)
|
|||||||
local exclusive = parseBool (si_props ["node.exclusive"])
|
local exclusive = parseBool (si_props ["node.exclusive"])
|
||||||
local si_must_passthrough = parseBool (si_props ["item.node.encoded-only"])
|
local si_must_passthrough = parseBool (si_props ["item.node.encoded-only"])
|
||||||
|
|
||||||
Log.info (si, string.format ("handling item: %s (%s)",
|
Log.info (si, string.format ("handling item: %s (%s) si id(%s)",
|
||||||
tostring (si_props ["node.name"]), tostring (si_props ["node.id"])))
|
tostring (si_props ["node.name"]), tostring (si_props ["node.id"]), si_id))
|
||||||
|
|
||||||
|
|
||||||
-- Check if item is linked to proper target, otherwise re-link
|
-- Check if item is linked to proper target, otherwise re-link
|
||||||
if si_flags.peer_id then
|
if si_flags.peer_id then
|
||||||
@@ -390,6 +395,9 @@ function createLink (event)
|
|||||||
local si_link = nil
|
local si_link = nil
|
||||||
local passthrough = si_flags.can_passthrough
|
local passthrough = si_flags.can_passthrough
|
||||||
|
|
||||||
|
Log.info (si, string.format ("handling item: %s (%s) si id(%s)",
|
||||||
|
tostring (si_props ["node.name"]), tostring (si_props ["node.id"]), si_id))
|
||||||
|
|
||||||
local exclusive = parseBool (si_props ["node.exclusive"])
|
local exclusive = parseBool (si_props ["node.exclusive"])
|
||||||
local passive = parseBool (si_props ["node.passive"]) or
|
local passive = parseBool (si_props ["node.passive"]) or
|
||||||
parseBool (target_props ["node.passive"])
|
parseBool (target_props ["node.passive"])
|
||||||
@@ -516,7 +524,7 @@ clients_om:activate ()
|
|||||||
default_nodes = Plugin.find ("default-nodes-api")
|
default_nodes = Plugin.find ("default-nodes-api")
|
||||||
|
|
||||||
SimpleEventHook {
|
SimpleEventHook {
|
||||||
name = "link-target-si@policy-node",
|
name = "link-target@policy-hooks",
|
||||||
type = "after-events-with-event",
|
type = "after-events-with-event",
|
||||||
priority = "link-target-si",
|
priority = "link-target-si",
|
||||||
interests = {
|
interests = {
|
||||||
@@ -530,7 +538,7 @@ SimpleEventHook {
|
|||||||
}:register ()
|
}:register ()
|
||||||
|
|
||||||
SimpleEventHook {
|
SimpleEventHook {
|
||||||
name = "prepare-link-si@policy-node",
|
name = "prepare-link@policy-hooks",
|
||||||
type = "after-events-with-event",
|
type = "after-events-with-event",
|
||||||
priority = "prepare-link-si",
|
priority = "prepare-link-si",
|
||||||
interests = {
|
interests = {
|
||||||
@@ -544,7 +552,7 @@ SimpleEventHook {
|
|||||||
}:register ()
|
}:register ()
|
||||||
|
|
||||||
SimpleEventHook {
|
SimpleEventHook {
|
||||||
name = "find-best-target-si@policy-node",
|
name = "find-best-target@policy-hooks",
|
||||||
type = "after-events-with-event",
|
type = "after-events-with-event",
|
||||||
priority = "find-best-target-si",
|
priority = "find-best-target-si",
|
||||||
interests = {
|
interests = {
|
||||||
@@ -558,7 +566,7 @@ SimpleEventHook {
|
|||||||
}:register ()
|
}:register ()
|
||||||
|
|
||||||
SimpleEventHook {
|
SimpleEventHook {
|
||||||
name = "find-default-target-si@policy-node",
|
name = "find-default-target@policy-hooks",
|
||||||
type = "after-events-with-event",
|
type = "after-events-with-event",
|
||||||
priority = "find-default-target-si",
|
priority = "find-default-target-si",
|
||||||
interests = {
|
interests = {
|
||||||
@@ -572,7 +580,7 @@ SimpleEventHook {
|
|||||||
}:register ()
|
}:register ()
|
||||||
|
|
||||||
SimpleEventHook {
|
SimpleEventHook {
|
||||||
name = "find-defined-target@policy-node",
|
name = "find-defined-target@policy-hooks",
|
||||||
type = "after-events-with-event",
|
type = "after-events-with-event",
|
||||||
priority = "find-defined-target-si",
|
priority = "find-defined-target-si",
|
||||||
interests = {
|
interests = {
|
||||||
|
@@ -103,6 +103,9 @@ function handleLinkable (si)
|
|||||||
if find_target_events [si_id] ~= nil then
|
if find_target_events [si_id] ~= nil then
|
||||||
-- stop the processing of the old event, we are going to queue a new one any
|
-- stop the processing of the old event, we are going to queue a new one any
|
||||||
-- way
|
-- way
|
||||||
|
Log.info(si, string.format("stopping item: %s (%s) si id(%s)",
|
||||||
|
tostring(si_props["node.name"]), tostring(si_props["node.id"]), si_id))
|
||||||
|
|
||||||
find_target_events [si_id]:stop_processing ()
|
find_target_events [si_id]:stop_processing ()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user