--[==========================================================================[
rc.lua: remote control module for VLC
--[==========================================================================[
- Copyright (C) 2007 the VideoLAN team
+ Copyright (C) 2007-2009 the VideoLAN team
$Id$
Authors: Antoine Cellerier <dionoea at videolan dot org>
end
end
list = list..")"
- if count ~= 0 then
+ if count ~= 0 and env.welcome then
env.welcome = env.welcome .. "\r\nWarning: "..count.." functions are still unimplemented "..list.."."
end
end
return vlcerr
end
+function call_object_command(cmd,client,arg)
+ local var, val = split_input(arg)
+ local ok, vlcmsg, vlcerr, vlcerrmsg = pcall( vlc.var.command, cmd, var, val )
+ if not ok then
+ client:append("Error in `"..cmd.." "..var.." "..val.."' ".. vlcmsg) -- when pcall fails the 2nd arg is the error message
+ end
+ if vlcmsg ~= "" then
+ client:append(vlcmsg)
+ end
+ return vlcerr
+end
+
--[[ Setup host ]]
require("host")
h = host.host()
client:switch_status(host.status.write)
if commands[cmd] then
call_command(cmd,client,arg)
+ elseif string.sub(cmd,0,1)=='@'
+ and call_object_command(string.sub(cmd,2,#cmd),client,arg) == 0 then
+ --
+ elseif client.type == host.client_type.stdio
+ and call_libvlc_command(cmd,client,arg) == 0 then
+ --
else
- if client.type == host.client_type.stdio
- and call_libvlc_command(cmd,client,arg) == 0 then
- else
- local choices = {}
- if client.env.autocompletion ~= 0 then
- for v,_ in common.pairs_sorted(commands) do
- if string.sub(v,0,#cmd)==cmd then
- table.insert(choices, v)
- end
+ local choices = {}
+ if client.env.autocompletion ~= 0 then
+ for v,_ in common.pairs_sorted(commands) do
+ if string.sub(v,0,#cmd)==cmd then
+ table.insert(choices, v)
end
end
- if #choices == 1 and client.env.autoalias ~= 0 then
- -- client:append("Aliasing to \""..choices[1].."\".")
- cmd = choices[1]
- call_command(cmd,client,arg)
- else
- client:append("Unknown command `"..cmd.."'. Type `help' for help.")
- if #choices ~= 0 then
- client:append("Possible choices are:")
- local cols = math.floor(client.env.width/(client.env.colwidth+1))
- local fmt = "%-"..client.env.colwidth.."s"
- for i = 1, #choices do
- choices[i] = string.format(fmt,choices[i])
- end
- for i = 1, #choices, cols do
- local j = i + cols - 1
- if j > #choices then j = #choices end
- client:append(" "..table.concat(choices," ",i,j))
- end
+ end
+ if #choices == 1 and client.env.autoalias ~= 0 then
+ -- client:append("Aliasing to \""..choices[1].."\".")
+ cmd = choices[1]
+ call_command(cmd,client,arg)
+ else
+ client:append("Unknown command `"..cmd.."'. Type `help' for help.")
+ if #choices ~= 0 then
+ client:append("Possible choices are:")
+ local cols = math.floor(client.env.width/(client.env.colwidth+1))
+ local fmt = "%-"..client.env.colwidth.."s"
+ for i = 1, #choices do
+ choices[i] = string.format(fmt,choices[i])
+ end
+ for i = 1, #choices, cols do
+ local j = i + cols - 1
+ if j > #choices then j = #choices end
+ client:append(" "..table.concat(choices," ",i,j))
end
end
end