libdbus-sys-0.2.5/.cargo_vcs_info.json0000644000000001510000000000100132750ustar { "git": { "sha1": "570530cc307c398e7fb5113de47a4e3bfac7b9db" }, "path_in_vcs": "libdbus-sys" }libdbus-sys-0.2.5/Cargo.toml0000644000000024510000000000100113000ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] name = "libdbus-sys" version = "0.2.5" authors = ["David Henningsson "] build = "build.rs" links = "dbus" description = "FFI bindings to libdbus." documentation = "http://docs.rs/libdbus-sys" readme = "README.md" keywords = [ "D-Bus", "DBus", "libdbus", ] categories = [ "os::unix-apis", "external-ffi-bindings", ] license = "Apache-2.0/MIT" repository = "https://github.com/diwic/dbus-rs" [package.metadata.pkg-config] dbus-1 = "1.6" [build-dependencies.cc] version = "1.0.78" optional = true [build-dependencies.pkg-config] version = "0.3" optional = true [features] default = ["pkg-config"] vendored = ["cc"] [badges.is-it-maintained-issue-resolution] repository = "diwic/dbus-rs" [badges.is-it-maintained-open-issues] repository = "diwic/dbus-rs" [badges.travis-ci] repository = "diwic/dbus-rs" libdbus-sys-0.2.5/Cargo.toml.orig0000644000000017160000000000100122420ustar [package] name = "libdbus-sys" version = "0.2.5" authors = ["David Henningsson "] description = "FFI bindings to libdbus." repository = "https://github.com/diwic/dbus-rs" documentation = "http://docs.rs/libdbus-sys" keywords = ["D-Bus", "DBus", "libdbus"] license = "Apache-2.0/MIT" categories = ["os::unix-apis", "external-ffi-bindings"] build = "build.rs" links = "dbus" readme = "README.md" [features] # By default use pkg-config to locate the local libdbus installation default = ["pkg-config"] # Provide vendoring as an option, which will compile libdbus from source for the target vendored = ["cc"] [build-dependencies] pkg-config = {version = "0.3", optional = true} cc = {version = "1.0.78", optional = true } [package.metadata.pkg-config] dbus-1 = "1.6" [badges] is-it-maintained-open-issues = { repository = "diwic/dbus-rs" } is-it-maintained-issue-resolution = { repository = "diwic/dbus-rs" } travis-ci = { repository = "diwic/dbus-rs" } libdbus-sys-0.2.5/Cargo.toml.orig000064400000000000000000000017161046102023000147640ustar 00000000000000[package] name = "libdbus-sys" version = "0.2.5" authors = ["David Henningsson "] description = "FFI bindings to libdbus." repository = "https://github.com/diwic/dbus-rs" documentation = "http://docs.rs/libdbus-sys" keywords = ["D-Bus", "DBus", "libdbus"] license = "Apache-2.0/MIT" categories = ["os::unix-apis", "external-ffi-bindings"] build = "build.rs" links = "dbus" readme = "README.md" [features] # By default use pkg-config to locate the local libdbus installation default = ["pkg-config"] # Provide vendoring as an option, which will compile libdbus from source for the target vendored = ["cc"] [build-dependencies] pkg-config = {version = "0.3", optional = true} cc = {version = "1.0.78", optional = true } [package.metadata.pkg-config] dbus-1 = "1.6" [badges] is-it-maintained-open-issues = { repository = "diwic/dbus-rs" } is-it-maintained-issue-resolution = { repository = "diwic/dbus-rs" } travis-ci = { repository = "diwic/dbus-rs" } libdbus-sys-0.2.5/LICENSE-APACHE000064400000000000000000000261421046102023000140210ustar 00000000000000Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2014-2018 David Henningsson and other contributors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. libdbus-sys-0.2.5/LICENSE-MIT000064400000000000000000000021231046102023000135220ustar 00000000000000Copyright (c) 2014-2018 David Henningsson and other contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.libdbus-sys-0.2.5/README.md000064400000000000000000000014601046102023000133500ustar 00000000000000Raw FFI bindings to libdbus --------------------------- Libdbus is licensed under GPL-2.0+/AFL (Academic free license), whereas the bindings are licensed under MIT/Apache-2.0. By default, libdbus is dynamically linked, meaning that `libdbus-1.so` must be installed on the target system (which it is, by default, in all common Linux distributions). As an option, libdbus can be built from source and included in the final executable. For this, enable the `vendored` feature. The crates.io package contains source code from libdbus; but it is only included in the build if the `vendored` feature is enabled. The `vendored` feature is the current recommended way to cross compile dbus-rs, although some other methods are mentioned [here](https://github.com/diwic/dbus-rs/blob/master/libdbus-sys/cross_compile.md). libdbus-sys-0.2.5/build.rs000064400000000000000000000020731046102023000135370ustar 00000000000000extern crate pkg_config; use std::error::Error; #[cfg(feature = "vendored")] mod build_vendored; fn main() -> Result<(), Box> { // Invalidate the built crate whenever these files change println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=build_vendored.rs"); // See https://github.com/joshtriplett/metadeps/issues/9 for why we don't use // metadeps here, but instead keep this manually in sync with Cargo.toml. #[cfg(not(feature = "vendored"))] if let Err(e) = pkg_config::Config::new().atleast_version("1.6").probe("dbus-1") { eprintln!("pkg_config failed: {}", e); eprintln!( "One possible solution is to check whether packages\n\ 'libdbus-1-dev' and 'pkg-config' are installed:\n\ On Ubuntu:\n\ sudo apt install libdbus-1-dev pkg-config\n\ On Fedora:\n\ sudo dnf install dbus-devel pkgconf-pkg-config\n" ); panic!(); } #[cfg(feature = "vendored")] build_vendored::build_libdbus()?; Ok(()) } libdbus-sys-0.2.5/cross_compile.md000064400000000000000000000163171046102023000152630ustar 00000000000000Cross compiling dbus ==================== There are (at least) three different approaches to cross compiling dbus. Choose which one fits you best: * Using rust-embedded/cross, see below * There is an alternative guide at [issue 184](https://github.com/diwic/dbus-rs/issues/184#issuecomment-520228758), which also contains a [powershell script](https://github.com/diwic/dbus-rs/issues/184#issuecomment-520791888) that set things up for you. * Setting things up manually, see below The examples below all assume you're trying to compile for Raspberry Pi 2 or 3 running Raspbian. Adjust target triples accordingly if your target is something else. Cross compiling using rust-embedded/cross ========================================= The `vendored` feature is the current recommended way to cross compile dbus-rs: ``` dbus = {version = "0.9.7", features = ["vendored"]} ``` Then simply build your project with cross: ``` cross build --target arm-unknown-linux-musleabihf ``` #### Legacy Instructions: Thanks to [jobale](https://github.com/jobale) for providing these instructions (taken from [issue 292](https://github.com/diwic/dbus-rs/issues/292)). Tested on Ubuntu 20.04 | rustc 1.47.0 - Install [rust-embedded/cross](https://github.com/rust-embedded/cross) - In your project directory, create a **Cross.toml** file: `touch Cross.toml` Add this code in it: ``` [target.armv7-unknown-linux-gnueabihf] image = "rustcross:dbus-armhf" [build.env] passthrough = [ "RUSTFLAGS", ] ``` - In your project directory create a **Dockerfile**: `touch Dockerfile` Put this code in it: ``` # Base image for rapsberrypi 3 target FROM rustembedded/cross:armv7-unknown-linux-gnueabihf # Install libdbus libraries and pkg-config RUN dpkg --add-architecture armhf && \ apt-get update && \ apt-get install --assume-yes libdbus-1-dev libdbus-1-dev:armhf pkg-config ``` For whatever reason, _in the docker image_, armhf libraries are installed in at least 2 locations. That's the reason of all my troubles: - /usr/arm-linux-gnueabihf/lib/ - /usr/lib/arm-linux-gnueabihf/ - Cross needs to know those locations. We pass them to the compiler through a command flag. For convenience I put it in a bash script: ``` #!/bin/bash set -o errexit set -o nounset set -o pipefail set -o xtrace readonly TARGET_ARCH=armv7-unknown-linux-gnueabihf readonly LINK_FLAGS='-L /usr/arm-linux-gnueabihf/lib/ -L /usr/lib/arm-linux-gnueabihf/' RUSTFLAGS=${LINK_FLAGS} cross build --release --target=${TARGET_ARCH} ``` Some more explanations for newcomers like me: - Cross command act as cargo command (e.g: `cross build` is the same as `cargo build` but for cross-compiling). - In Cross.toml, `passthrough = [ "RUSTFLAGS",]` is what enable us to pass flags/parameters to the compiler in the docker image. Setting up cross compiling manually =================================== A cross linker -------------- Apparently, `rustc` in itself can generate code for many archs but not assemble the generated code into the final executable. Hence you need a cross linker. **Install it** - here follow whatever guide you have for the target arch. Distributions may also ship with cross toolchains. Example for Ubuntu 18.04: `sudo apt install gcc-8-multilib-arm-linux-gnueabihf` **Tell rustc where to find it** - in [.cargo/config](https://doc.rust-lang.org/cargo/reference/config.html) add the following: ``` [target.armv7-unknown-linux-gnueabihf] linker = "arm-linux-gnueabihf-gcc-8" ``` Target rust std --------------- This one's easy, just run rustup: `rustup target add armv7-unknown-linux-gnueabihf` Target dbus libraries --------------------- **Installing the libraries** Now to the more challenging part. Since we link to a C library `libdbus-1.so`, we also need the target version of that library. However, `libdbus-1.so` in itself links to a systemd library (at least it does so here) which in turn links to other libraries etc, so we need target versions of those libraries too. Getting an entire rootfs/image is probably the easiest option. The rootfs needs to have `libdbus-1-dev` installed. I e: * Boot your target (i e, a raspberry), install `libdbus-1-dev` on it, turn it off and put the SD card into your computer's SD card reader. Mount the partition. * If the above is not an option, you could download an image, mount it at the right offset, like this (ugly hack!) `sudo mount -o loop,offset=50331648 2019-04-08-raspbian-stretch-lite.img /tmp/mnt` and then, to manually make the symlink that `libdbus-1-dev` does for you: `cd /tmp/mnt/usr/lib/arm-linux-gnueabihf && ln -s ../../../lib/arm-linux-gnueabihf/libdbus-1.so.3 libdbus-1.so`. * Or you can use the alternative guide's approach to download, extract and post-process the relevant `.deb` files manually. This might be a preferrable option if an entire image/rootfs would be too large. **Finding the libraries** When not cross compiling, finding the right library is done by a `build.rs` script which calls `pkg-config`. This will not work when cross compiling because it will point to the `libdbus-1.so` on the host, not the `libdbus-1.so` of the target. Maybe it is possible to teach `pkg-config` how to return the target library instead, but I have not tried this approach. Instead we can override build script altogether and provide the same info manually. This is possible because `libdbus-sys` has a `links = dbus` line. For the example below we assume that we have mounted a Raspbian rootfs on `/tmp/mnt`, and that the cross linker came with some basic libraries (libc, libpthread etc) that are installed on `/usr/arm-linux-gnueabihf/lib`. Unfortunately, we can't use the basic libraries that are present on the image, because they might contain absolute paths. And so we add the following to [.cargo/config](https://doc.rust-lang.org/cargo/reference/config.html): ``` [target.armv7-unknown-linux-gnueabihf.dbus] rustc-link-search = ["/usr/arm-linux-gnueabihf/lib", "/tmp/mnt/usr/lib/arm-linux-gnueabihf"] rustc-link-lib = ["dbus-1"] ``` Finally ------- If we are all set up, you should be able to successfully compile with: `cargo build --target=armv7-unknown-linux-gnueabihf` Docker compose ============== Dockerfile ```docker FROM rust:1.64.0-slim-bullseye RUN apt update && apt upgrade -y RUN apt install -y g++-arm-linux-gnueabihf libc6-dev-armhf-cross RUN rustup target add armv7-unknown-linux-gnueabihf RUN rustup toolchain install stable-armv7-unknown-linux-gnueabihf RUN dpkg --add-architecture armhf RUN apt update RUN apt install --assume-yes libdbus-1-dev libdbus-1-dev:armhf pkg-config WORKDIR /app ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc ENV CC_armv7_unknown_Linux_gnueabihf=arm-linux-gnueabihf-gcc ENV CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=/usr/bin/arm-linux-gnueabihf-gcc ENV PKG_CONFIG_ALLOW_CROSS="true" ENV PKG_CONFIG_PATH="/usr/lib/arm-linux-gnueabihf/pkgconfig" ENV RUSTFLAGS="-L /usr/arm-linux-gnueabihf/lib/ -L /usr/lib/arm-linux-gnueabihf/" ``` docker-compose.yml ```yaml version: "3" services: compilation: build: . volumes: - ./:/app command: "cargo build --release --target=armv7-unknown-linux-gnueabihf" ``` You just have to add these two files to your project root and run `docker-compose up`. libdbus-sys-0.2.5/src/lib.rs000064400000000000000000000405561046102023000140050ustar 00000000000000use std::os::raw::{c_void, c_char, c_uint, c_int, c_long}; pub type DBusConnection = c_void; pub type DBusMessage = c_void; pub type DBusWatch = c_void; pub type DBusPendingCall = c_void; pub type DBusTimeout = c_void; #[repr(C)] #[derive(Debug, PartialEq, Copy, Clone)] /// System or Session bus pub enum DBusBusType { Session = 0, System = 1, Starter = 2, } pub const DBUS_TYPE_ARRAY: c_int = 'a' as c_int; pub const DBUS_TYPE_VARIANT: c_int = 'v' as c_int; pub const DBUS_TYPE_BOOLEAN: c_int = 'b' as c_int; pub const DBUS_TYPE_INVALID: c_int = 0; pub const DBUS_TYPE_STRING: c_int = 's' as c_int; pub const DBUS_TYPE_DICT_ENTRY: c_int = 'e' as c_int; pub const DBUS_TYPE_BYTE: c_int = 'y' as c_int; pub const DBUS_TYPE_INT16: c_int = 'n' as c_int; pub const DBUS_TYPE_UINT16: c_int = 'q' as c_int; pub const DBUS_TYPE_INT32: c_int = 'i' as c_int; pub const DBUS_TYPE_UINT32: c_int = 'u' as c_int; pub const DBUS_TYPE_INT64: c_int = 'x' as c_int; pub const DBUS_TYPE_UINT64: c_int = 't' as c_int; pub const DBUS_TYPE_DOUBLE: c_int = 'd' as c_int; pub const DBUS_TYPE_UNIX_FD: c_int = 'h' as c_int; pub const DBUS_TYPE_STRUCT: c_int = 'r' as c_int; pub const DBUS_TYPE_OBJECT_PATH: c_int = 'o' as c_int; pub const DBUS_TYPE_SIGNATURE: c_int = 'g' as c_int; pub const DBUS_TIMEOUT_USE_DEFAULT: c_int = -1; pub const DBUS_TIMEOUT_INFINITE: c_int = 0x7fffffff; pub const DBUS_NAME_FLAG_ALLOW_REPLACEMENT: c_int = 1; pub const DBUS_NAME_FLAG_REPLACE_EXISTING: c_int = 2; pub const DBUS_NAME_FLAG_DO_NOT_QUEUE: c_int = 4; pub const DBUS_WATCH_READABLE: c_int = 1; pub const DBUS_WATCH_WRITABLE: c_int = 2; pub const DBUS_WATCH_ERROR: c_int = 4; pub const DBUS_WATCH_HANGUP: c_int = 8; #[repr(C)] #[derive(Debug, PartialEq, Copy, Clone)] pub enum DBusRequestNameReply { PrimaryOwner = 1, InQueue = 2, Exists = 3, AlreadyOwner = 4, } #[repr(C)] #[derive(Debug, PartialEq, Copy, Clone)] pub enum DBusReleaseNameReply { Released = 1, NonExistent = 2, NotOwner = 3, } #[repr(C)] #[derive(Debug, PartialEq, Copy, Clone)] pub enum DBusHandlerResult { Handled = 0, NotYetHandled = 1, NeedMemory = 2, } #[repr(C)] #[derive(Debug, PartialEq, Copy, Clone)] /// One of the four different D-Bus message types. pub enum DBusMessageType { /// This is not a valid message type (rarely used) Invalid = 0, /// This is a method call D-Bus message MethodCall = 1, /// This is a method return Ok D-Bus message, used when the method call message was successfully processed MethodReturn = 2, /// This is a method return with error D-Bus message, used when the method call message could not be handled Error = 3, /// This is a signal, usually sent to whoever wants to listen Signal = 4, } #[repr(C)] #[derive(Debug, PartialEq, Copy, Clone)] pub enum DBusDispatchStatus { DataRemains = 0, Complete = 1, NeedMemory = 2, } #[repr(C)] pub struct DBusError { pub name: *const c_char, pub message: *const c_char, pub dummy: c_uint, pub padding1: *const c_void } #[repr(C)] #[derive(Copy, Clone)] pub struct DBusMessageIter { pub dummy1: *mut c_void, pub dummy2: *mut c_void, pub dummy3: u32, pub dummy4: c_int, pub dummy5: c_int, pub dummy6: c_int, pub dummy7: c_int, pub dummy8: c_int, pub dummy9: c_int, pub dummy10: c_int, pub dummy11: c_int, pub pad1: c_int, pub pad2: c_int, // Here would have been padding; because pad3 is a 8 byte aligned pointer (on amd64). // Rust reserves the right not to copy the padding when cloning a struct, // but the D-Bus library uses this part of the struct too. // Hence, add a field as big as the padding to ensure Rust copies all data. pub pad2_added_by_rust: c_int, pub pad3: *mut c_void, } pub type DBusHandleMessageFunction = Option DBusHandlerResult>; pub type DBusAddWatchFunction = Option u32>; pub type DBusRemoveWatchFunction = Option; pub type DBusWatchToggledFunction = Option; pub type DBusAddTimeoutFunction = Option u32>; pub type DBusTimeoutToggledFunction = Option; pub type DBusRemoveTimeoutFunction = Option; pub type DBusDispatchStatusFunction = Option; pub type DBusWakeupMainFunction = Option; pub type DBusPendingCallNotifyFunction = Option; pub type DBusFreeFunction = Option; #[repr(C)] pub struct DBusObjectPathVTable { pub unregister_function: Option, pub message_function: DBusHandleMessageFunction, pub dbus_internal_pad1: Option, pub dbus_internal_pad2: Option, pub dbus_internal_pad3: Option, pub dbus_internal_pad4: Option, } extern "C" { pub fn dbus_bus_get_private(t: DBusBusType, error: *mut DBusError) -> *mut DBusConnection; pub fn dbus_bus_get_unique_name(conn: *mut DBusConnection) -> *const c_char; pub fn dbus_bus_request_name(conn: *mut DBusConnection, name: *const c_char, flags: c_uint, error: *mut DBusError) -> c_int; pub fn dbus_bus_release_name(conn: *mut DBusConnection, name: *const c_char, error: *mut DBusError) -> c_int; pub fn dbus_bus_add_match(conn: *mut DBusConnection, rule: *const c_char, error: *mut DBusError); pub fn dbus_bus_remove_match(conn: *mut DBusConnection, rule: *const c_char, error: *mut DBusError); pub fn dbus_bus_register(conn: *mut DBusConnection, error: *mut DBusError) -> u32; pub fn dbus_connection_close(conn: *mut DBusConnection); pub fn dbus_connection_dispatch(conn: *mut DBusConnection) -> DBusDispatchStatus; pub fn dbus_connection_flush(conn: *mut DBusConnection); pub fn dbus_connection_open_private(address: *const c_char, error: *mut DBusError) -> *mut DBusConnection; pub fn dbus_connection_unref(conn: *mut DBusConnection); pub fn dbus_connection_get_is_connected(conn: *mut DBusConnection) -> u32; pub fn dbus_connection_set_exit_on_disconnect(conn: *mut DBusConnection, enable: u32); pub fn dbus_connection_send_with_reply_and_block(conn: *mut DBusConnection, message: *mut DBusMessage, timeout_milliseconds: c_int, error: *mut DBusError) -> *mut DBusMessage; pub fn dbus_connection_send_with_reply(conn: *mut DBusConnection, message: *mut DBusMessage, pending_return: *mut *mut DBusPendingCall, timeout_milliseconds: c_int) -> u32; pub fn dbus_connection_send(conn: *mut DBusConnection, message: *mut DBusMessage, serial: *mut u32) -> u32; pub fn dbus_connection_read_write_dispatch(conn: *mut DBusConnection, timeout_milliseconds: c_int) -> u32; pub fn dbus_connection_read_write(conn: *mut DBusConnection, timeout_milliseconds: c_int) -> u32; pub fn dbus_connection_try_register_object_path(conn: *mut DBusConnection, path: *const c_char, vtable: *const DBusObjectPathVTable, user_data: *mut c_void, error: *mut DBusError) -> u32; pub fn dbus_connection_unregister_object_path(conn: *mut DBusConnection, path: *const c_char) -> u32; pub fn dbus_connection_list_registered(conn: *mut DBusConnection, parent_path: *const c_char, child_entries: *mut *mut *mut c_char) -> u32; pub fn dbus_connection_add_filter(conn: *mut DBusConnection, function: DBusHandleMessageFunction, user_data: *mut c_void, free_data_function: DBusFreeFunction) -> u32; pub fn dbus_connection_remove_filter(conn: *mut DBusConnection, function: DBusHandleMessageFunction, user_data: *mut c_void) -> u32; pub fn dbus_connection_set_watch_functions(conn: *mut DBusConnection, add_function: DBusAddWatchFunction, remove_function: DBusRemoveWatchFunction, toggled_function: DBusWatchToggledFunction, data: *mut c_void, free_data_function: DBusFreeFunction) -> u32; pub fn dbus_connection_set_timeout_functions(conn: *mut DBusConnection, add_function: DBusAddTimeoutFunction, remove_function: DBusRemoveTimeoutFunction, toggled_function: DBusTimeoutToggledFunction, data: *mut c_void, free_data_function: DBusFreeFunction) -> u32; pub fn dbus_connection_set_dispatch_status_function(conn: *mut DBusConnection, dispatch_function: DBusDispatchStatusFunction, data: *mut c_void, free_data_function: DBusFreeFunction); pub fn dbus_connection_set_wakeup_main_function(conn: *mut DBusConnection, wakeup_function: DBusWakeupMainFunction, data: *mut c_void, free_data_function: DBusFreeFunction); pub fn dbus_connection_pop_message(conn: *mut DBusConnection) -> *mut DBusMessage; pub fn dbus_connection_get_dispatch_status(conn: *mut DBusConnection) -> DBusDispatchStatus; pub fn dbus_error_init(error: *mut DBusError); pub fn dbus_error_free(error: *mut DBusError); pub fn dbus_set_error(error: *mut DBusError, name: *const c_char, message: *const c_char, ...); pub fn dbus_set_error_from_message(error: *mut DBusError, message: *mut DBusMessage) -> u32; pub fn dbus_message_new_method_call(destination: *const c_char, path: *const c_char, iface: *const c_char, method: *const c_char) -> *mut DBusMessage; pub fn dbus_message_new_method_return(message: *mut DBusMessage) -> *mut DBusMessage; pub fn dbus_message_new_error(message: *mut DBusMessage, error_name: *const c_char, error_message: *const c_char) -> *mut DBusMessage; pub fn dbus_message_new_signal(path: *const c_char, iface: *const c_char, name: *const c_char) -> *mut DBusMessage; pub fn dbus_message_ref(message: *mut DBusMessage) -> *mut DBusMessage; pub fn dbus_message_unref(message: *mut DBusMessage); pub fn dbus_message_get_type(message: *mut DBusMessage) -> c_int; pub fn dbus_message_is_method_call(message: *mut DBusMessage, iface: *const c_char, method: *const c_char) -> u32; pub fn dbus_message_is_signal(message: *mut DBusMessage, iface: *const c_char, signal_name: *const c_char) -> u32; pub fn dbus_message_get_reply_serial(message: *mut DBusMessage) -> u32; pub fn dbus_message_get_serial(message: *mut DBusMessage) -> u32; pub fn dbus_message_get_path(message: *mut DBusMessage) -> *const c_char; pub fn dbus_message_get_interface(message: *mut DBusMessage) -> *const c_char; pub fn dbus_message_get_destination(message: *mut DBusMessage) -> *const c_char; pub fn dbus_message_get_member(message: *mut DBusMessage) -> *const c_char; pub fn dbus_message_get_sender(message: *mut DBusMessage) -> *const c_char; pub fn dbus_message_set_serial(message: *mut DBusMessage, serial: u32); pub fn dbus_message_set_sender(message: *mut DBusMessage, sender: *const c_char) -> u32; pub fn dbus_message_set_destination(message: *mut DBusMessage, destination: *const c_char) -> u32; pub fn dbus_message_get_no_reply(message: *mut DBusMessage) -> u32; pub fn dbus_message_set_no_reply(message: *mut DBusMessage, no_reply: u32); pub fn dbus_message_get_auto_start(message: *mut DBusMessage) -> u32; pub fn dbus_message_set_auto_start(message: *mut DBusMessage, no_reply: u32); pub fn dbus_message_copy(message: *const DBusMessage) -> *mut DBusMessage; pub fn dbus_message_iter_append_basic(iter: *mut DBusMessageIter, t: c_int, value: *const c_void) -> u32; pub fn dbus_message_iter_append_fixed_array(iter: *mut DBusMessageIter, element_type: c_int, value: *const c_void, n_elements: c_int) -> u32; pub fn dbus_message_iter_init(message: *mut DBusMessage, iter: *mut DBusMessageIter) -> u32; pub fn dbus_message_iter_init_append(message: *mut DBusMessage, iter: *mut DBusMessageIter); pub fn dbus_message_iter_get_arg_type(iter: *mut DBusMessageIter) -> c_int; pub fn dbus_message_iter_get_basic(iter: *mut DBusMessageIter, value: *mut c_void); pub fn dbus_message_iter_get_element_type(iter: *mut DBusMessageIter) -> c_int; pub fn dbus_message_iter_get_fixed_array(iter: *mut DBusMessageIter, value: *mut c_void, n_elements: *mut c_int) -> u32; pub fn dbus_message_iter_get_signature(iter: *mut DBusMessageIter) -> *mut c_char; pub fn dbus_message_iter_next(iter: *mut DBusMessageIter) -> u32; pub fn dbus_message_iter_recurse(iter: *mut DBusMessageIter, subiter: *mut DBusMessageIter); pub fn dbus_message_iter_open_container(iter: *mut DBusMessageIter, _type: c_int, contained_signature: *const c_char, sub: *mut DBusMessageIter) -> u32; pub fn dbus_message_iter_close_container(iter: *mut DBusMessageIter, sub: *mut DBusMessageIter) -> u32; pub fn dbus_free(memory: *mut c_void); pub fn dbus_free_string_array(str_array: *mut *mut c_char) -> c_void; pub fn dbus_signature_validate_single(signature: *const c_char, error: *mut DBusError) -> u32; pub fn dbus_threads_init_default() -> c_int; pub fn dbus_validate_bus_name(busname: *const c_char, error: *mut DBusError) -> u32; pub fn dbus_validate_error_name(errorname: *const c_char, error: *mut DBusError) -> u32; pub fn dbus_validate_interface(interface: *const c_char, error: *mut DBusError) -> u32; pub fn dbus_validate_member(member: *const c_char, error: *mut DBusError) -> u32; pub fn dbus_validate_path(path: *const c_char, error: *mut DBusError) -> u32; pub fn dbus_watch_get_enabled(watch: *mut DBusWatch) -> u32; pub fn dbus_watch_get_flags(watch: *mut DBusWatch) -> c_uint; pub fn dbus_watch_get_unix_fd(watch: *mut DBusWatch) -> c_int; pub fn dbus_watch_get_socket(watch: *mut DBusWatch) -> c_int; pub fn dbus_watch_handle(watch: *mut DBusWatch, flags: c_uint) -> u32; pub fn dbus_watch_get_data(watch: *mut DBusWatch) -> *mut c_void; pub fn dbus_watch_set_data(watch: *mut DBusWatch, user_data: *mut c_void, free_data_function: DBusFreeFunction); pub fn dbus_timeout_get_enabled(timeout: *mut DBusTimeout) -> u32; pub fn dbus_timeout_get_interval(timeout: *mut DBusTimeout) -> c_int; pub fn dbus_timeout_handle(timeout: *mut DBusTimeout) -> u32; pub fn dbus_timeout_get_data(timeout: *mut DBusTimeout) -> *mut c_void; pub fn dbus_timeout_set_data(timeout: *mut DBusTimeout, user_data: *mut c_void, free_data_function: DBusFreeFunction); pub fn dbus_pending_call_ref(pending: *mut DBusPendingCall) -> *mut DBusPendingCall; pub fn dbus_pending_call_unref(pending: *mut DBusPendingCall); pub fn dbus_pending_call_set_notify(pending: *mut DBusPendingCall, n: DBusPendingCallNotifyFunction, user_data: *mut c_void, free_user_data: DBusFreeFunction) -> u32; pub fn dbus_pending_call_steal_reply(pending: *mut DBusPendingCall) -> *mut DBusMessage; pub fn dbus_message_marshal(msg: *mut DBusMessage, marshalled_data_p: *mut *mut c_char, len_p: *mut c_int) -> u32; pub fn dbus_message_demarshal(s: *const c_char, len: c_int, error: *mut DBusError) -> *mut DBusMessage; pub fn dbus_message_demarshal_bytes_needed(buf: *const c_char, len: c_int) -> c_int; pub fn dbus_connection_set_max_message_size(conn: *mut DBusConnection, size: c_long); pub fn dbus_connection_get_max_message_size(conn: *mut DBusConnection) -> c_long; pub fn dbus_connection_set_max_message_unix_fds(conn: *mut DBusConnection, n: c_long); pub fn dbus_connection_get_max_message_unix_fds(conn: *mut DBusConnection) -> c_long; pub fn dbus_connection_set_max_received_size(conn: *mut DBusConnection, size: c_long); pub fn dbus_connection_get_max_received_size(conn: *mut DBusConnection) -> c_long; pub fn dbus_connection_set_max_received_unix_fds(conn: *mut DBusConnection, n: c_long); pub fn dbus_connection_get_max_received_unix_fds(conn: *mut DBusConnection) -> c_long; pub fn dbus_connection_get_outgoing_size(conn: *mut DBusConnection) -> c_long; pub fn dbus_connection_get_outgoing_unix_fds(conn: *mut DBusConnection) -> c_long; pub fn dbus_connection_has_messages_to_send(conn: *mut DBusConnection) -> u32; pub fn dbus_try_get_local_machine_id(error: *mut DBusError) -> *mut c_char; pub fn dbus_get_local_machine_id() -> *mut c_char; }