~jpsamaroo/DBus.jl

ref: 27d88b403cffe036cb76e3ac14a074f163f610b9 DBus.jl/src/api.jl -rw-r--r-- 1.6 KiB
27d88b40Julian P Samaroo Add working connect() and request_name!() 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
struct DBusError
    name::Cstring
    message::Cstring

    dummy1::Cuint
    dummy2::Cuint
    dummy3::Cuint
    dummy4::Cuint
    dummy5::Cuint

    padding::Ptr{Cvoid}
end

function dbus_error_init(error)
    ccall((:dbus_error_init, libdbus), Cvoid, (Ptr{DBusError},), error)
end
function dbus_error_free(error)
    ccall((:dbus_error_free, libdbus), Cvoid, (Ptr{DBusError},), error)
end
function dbus_error_is_set(error)
    ccall((:dbus_error_is_set, libdbus), Cint, (Ptr{DBusError},), error) != 0
end

const DBusConnection = Cvoid
@enum DBusBusType begin
    DBUS_BUS_SESSION = Cint(0)
    DBUS_BUS_SYSTEM = Cint(1)
    DBUS_BUS_STARTER = Cint(2)
end
@enum DBusNameFlag begin
    DBUS_NAME_FLAG_ALLOW_REPLACEMENT = Cuint(1)
    DBUS_NAME_FLAG_REPLACE_EXISTING = Cuint(2)
    DBUS_NAME_FLAG_DO_NOT_QUEUE = Cuint(4)
end
@enum DBusRequestNameReplyFlag begin
    DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER = Cuint(1)
    DBUS_REQUEST_NAME_REPLY_IN_QUEUE = Cuint(2)
    DBUS_REQUEST_NAME_REPLY_EXISTS = Cuint(3)
    DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER = Cuint(4)
end

function dbus_bus_get(bus_type::DBusBusType, error)
    ccall((:dbus_bus_get, libdbus), Ptr{DBusConnection}, (DBusBusType, Ptr{DBusError},), bus_type, error)
end
function dbus_connection_close(conn)
    ccall((:dbus_connection_close, libdbus), Cvoid, (Ptr{DBusConnection},), conn)
end
function dbus_bus_request_name(conn, name, flag, error)
    ccall((:dbus_bus_request_name, libdbus),
          DBusRequestNameReplyFlag,
          (Ptr{DBusConnection}, Cstring, DBusNameFlag, Ptr{DBusError}),
          conn, name, flag, error)
end