Skip to content

daurnimator/ldbus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DBus for Lua.

ldbus is a C binding to dbus for Lua.

Compatible with Lua 5.1, 5.2, 5.3 and 5.4 (thanks compat-5.3).

Status

Installation

ldbus is on luarocks: https://luarocks.org/modules/daurnimator/ldbus

Install via luarocks, you will need to provide paths to dbus/dbus.h and dbus/dbus-arch-deps.h

luarocks install --server=http://luarocks.org/manifests/daurnimator ldbus DBUS_INCDIR=/usr/include/dbus-1.0/ DBUS_ARCH_INCDIR=/usr/lib/dbus-1.0/include

Usage

example.lua is a lua version of Matthew Johnson's example

Bound from C

  • Functions that normally take a DBusError return nil, "error_message" on failure.
  • Errors will be thrown on out of memory
C Lua Comments
dbus_bus_get() ldbus.bus.get() Takes type as one of "session", "system" or "starter". The connection will not have exit_on_disconnect set.
dbus_bus_get_private() ldbus.bus.get_private() Takes type as one of "session", "system" or "starter". The connection will not have exit_on_disconnect set.
dbus_bus_register() ldbus.bus.register()
dbus_bus_set_unique_name() ldbus.bus.set_unique_name()
dbus_bus_get_unique_name() ldbus.bus.get_unique_name()
dbus_bus_request_name() ldbus.bus.request_name() Takes flags as a table contain keys "allow_replacement", "do_not_queue" and "replace_existing"; On success returns one of "primary_owner", "in_queue", "exists" or "already_owner"
dbus_bus_release_name() ldbus.bus.release_name() On success, returns one of "released", "non_existant" or "not_owner"
dbus_bus_name_has_owner() ldbus.bus.name_has_owner()
dbus_bus_start_service_by_name() ldbus.bus.start_service_by_name()
dbus_bus_add_match() ldbus.bus.add_match() On success, returns one of "success" or "already_running"
dbus_bus_remove_match() ldbus.bus.remove_match()
dbus_connection_open() ldbus.connection.open()
dbus_connection_get_is_connected() my_conn:get_is_connected()
dbus_connection_get_is_authenticated() my_conn:get_is_authenticated()
dbus_connection_get_is_anonymous() my_conn:get_is_anonymous()
dbus_connection_get_server_id() my_conn:get_server_id()
dbus_connection_send() my_conn:send()
dbus_connection_send_with_reply() pending_call = my_conn:send_with_reply(msg [, timeout]) Timeout is in seconds, when not provided there will be no timeout.
dbus_connection_send_with_reply_and_block() response_msg = my_conn:send_with_reply_and_block(msg [, timeout]) Timeout is in seconds, when not provided there will be no timeout.
dbus_connection_flush() my_conn:flush()
dbus_connection_read_write_dispatch() my_conn:read_write_dispatch()
dbus_connection_read_write() my_conn:read_write()
dbus_connection_pop_message() my_conn:pop_message()
dbus_connection_get_dispatch_status() my_conn:get_dispatch_status()
dbus_connection_dispatch() my_conn:dispatch()
dbus_connection_set_watch_functions() my_conn:set_watch_functions()
dbus_connection_set_timeout_functions() my_conn:set_timeout_functions()
dbus_connection_set_dispatch_status_function() my_conn:set_dispatch_status_function()
dbus_connection_set_wakeup_main_function() my_conn:set_wakeup_main_function(callback)
dbus_connection_register_object_path() my_conn:register_object_path()
dbus_connection_register_fallback() my_conn:register_fallback()
dbus_connection_unregister_object_path() my_conn:unregister_object_path()
dbus_connection_set_max_message_size() my_conn:set_max_message_size()
dbus_connection_get_max_message_size() my_conn:get_max_message_size()
dbus_connection_set_max_received_size() my_conn:set_max_received_size()
dbus_connection_get_max_received_size() my_conn:get_max_received_size()
dbus_connection_get_outgoing_size() my_conn:get_outgoing_size()
dbus_connection_has_messages_to_send() my_conn:has_messages_to_send()
dbus_message_new() ldbus.message.new(type_str) The type is taken as a string (uses dbus_message_type_from_string())
dbus_message_new_method_call() ldbus.message.new_method_call()
dbus_message_new_signal() ldbus.message.new_signal()
dbus_message_get_serial() my_message:get_serial()
dbus_message_set_reply_serial() my_message:set_reply_serial()
dbus_message_get_reply_serial() my_message:get_reply_serial()
dbus_message_new_method_return() my_message:new_method_return()
dbus_message_new_error() my_message:new_error()
dbus_message_copy() my_message:copy()
dbus_message_get_type() my_message:get_type()
dbus_message_iter_init() my_iter = my_message:iter_init([my_iter]) Returns nil if message has no arguments
dbus_message_iter_init_append() my_iter = my_message:iter_init_append([my_iter])
dbus_message_set_no_reply() my_message:set_no_reply()
dbus_message_get_no_reply() my_message:get_no_reply()
dbus_message_set_auto_start() my_message:set_auto_start()
dbus_message_get_auto_start() my_message:get_auto_start()
dbus_message_set_path() my_message:set_path()
dbus_message_get_path() my_message:get_path()
dbus_message_get_path_decomposed() my_message:get_path_decomposed()
dbus_message_set_interface() my_message:set_interface()
dbus_message_get_interface() my_message:get_interface()
dbus_message_set_member() my_message:set_member()
dbus_message_get_member() my_message:get_member()
dbus_message_set_error_name() my_message:set_error_name()
dbus_message_get_error_name() my_message:get_error_name()
dbus_message_set_destination() my_message:set_destination()
dbus_message_get_destination() my_message:get_destination()
dbus_message_set_sender() my_message:set_sender()
dbus_message_get_sender() my_message:get_sender()
dbus_message_get_signature() my_message:get_signature()
dbus_message_iter_has_next() bool = my_message_iter:has_next()
dbus_message_iter_next() bool = my_message_iter:next()
dbus_message_iter_get_element_type() type = my_message_iter:get_element_type() DBUS_TYPE_INVALID is returned as nil
dbus_message_iter_recurse() sub_iter = my_message_iter:recurse([sub_iter]) Creates a new DBusMessageIter if one is not passed
dbus_message_iter_get_signature() sig = my_message_iter:get_signature()
dbus_message_iter_get_basic() object = my_message_iter:get_basic() number types are all returned as lua numbers (even 64bit integers at the moment; so watch out); strings, object paths and signatures will be returned as strings
dbus_message_iter_append_basic() my_message_iter:append_basic(object [, type])
dbus_message_iter_open_container() sub_iter = my_message_iter:open_container(type [, sign [, sub_iter]]) Creates sub_iter if not passed. Returns the sub_iter or nil on failure
dbus_message_iter_close_container() ok = my_message_iter:close_container(sub_iter)
dbus_pending_call_set_notify() my_pending_call:set_notify(callback) Callback gets no arguments
dbus_pending_call_cancel() my_pending_call:cancel()
dbus_pending_call_get_completed() completed = my_pending_call:get_completed()
dbus_pending_call_steal_reply() message = my_pending_call:steal_reply()
dbus_pending_call_block() my_pending_call:block()
dbus_timeout_get_interval() secs = my_timeout:get_interval() Returned number is in seconds (rather than milliseconds)
dbus_timeout_handle() ok = my_timeout:handle()
dbus_timeout_get_enabled() enabled = my_timeout:get_enabled()
DBUS_WATCH_READABLE ldbus.watch.READABLE
DBUS_WATCH_WRITABLE ldbus.watch.WRITABLE
DBUS_WATCH_HANGUP ldbus.watch.HANGUP
DBUS_WATCH_ERROR ldbus.watch.ERROR
dbus_watch_get_unix_fd() fd = my_watch:get_unix_fd() Returns nil when no fd is available
dbus_watch_get_socket() fd = my_watch:get_socket() Returns nil when no fd is available
dbus_watch_get_flags() flags = my_watch:get_flags() flags will be the a number
dbus_watch_handle() ok = my_watch:handle(flags)
dbus_watch_get_enabled() enabled = my_watch:get_enabled()

Other

ldbus.types

A table of the dbus types from name to type (as a character)

key value
"boolean" "b"
"byte" "y"
"double" "d"
"int16" "n"
"int32" "i"
"int64" "x"
"uint16" "q"
"uint32" "u"
"uint64" "t"
"string" "s"
"signature" "g"
"object_path" "o"
"array" "a"
"dict_entry" "e"
"variant" "v"
"struct" "r"

ldbus.basic_types

A table of the dbus basic types from name to type (as a character)

key value
"boolean" "b"
"byte" "y"
"double" "d"
"int16" "n"
"int32" "i"
"int64" "x"
"uint16" "q"
"uint32" "u"
"uint64" "t"
"string" "s"
"signature" "g"
"object_path" "o"

my_iter = ldbus.message.iter.new()

Creates a new DBusMessageIter object

new_iter = my_iter:clone()

Creates a copy of the given DBusMessageIter

About

Lua Bindings to dbus.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published