{"id":15515260,"url":"https://github.com/fgasper/p5-protocol-dbus","last_synced_at":"2025-04-23T03:20:52.289Z","repository":{"id":43331431,"uuid":"148924802","full_name":"FGasper/p5-Protocol-DBus","owner":"FGasper","description":"CPAN’s Protocol::DBus","archived":false,"fork":false,"pushed_at":"2022-07-06T17:53:47.000Z","size":339,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T21:32:18.986Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FGasper.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-15T17:35:46.000Z","updated_at":"2022-04-12T18:06:43.000Z","dependencies_parsed_at":"2022-09-04T13:21:34.820Z","dependency_job_id":null,"html_url":"https://github.com/FGasper/p5-Protocol-DBus","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FGasper%2Fp5-Protocol-DBus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FGasper%2Fp5-Protocol-DBus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FGasper%2Fp5-Protocol-DBus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FGasper%2Fp5-Protocol-DBus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FGasper","download_url":"https://codeload.github.com/FGasper/p5-Protocol-DBus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250361335,"owners_count":21417874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T10:01:38.067Z","updated_at":"2025-04-23T03:20:52.275Z","avatar_url":"https://github.com/FGasper.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nProtocol::DBus - D-Bus in pure Perl\n\n# SYNOPSIS\n\n(NB: Examples below assume use of\n[subroutine signatures](https://metacpan.org/pod/perlsub#Signatures).)\n\nFor blocking I/O:\n\n    my $dbus = Protcol::DBus::Client::system();\n\n    # Authentication and “Hello” call/response:\n    $dbus-\u003einitialize();\n\n    $dbus-\u003esend_call(\n        path =\u003e '/org/freedesktop/DBus',\n        interface =\u003e 'org.freedesktop.DBus.Properties',\n        member =\u003e 'GetAll',\n        destination =\u003e 'org.freedesktop.DBus',\n        signature =\u003e 's',\n        body =\u003e [ 'org.freedesktop.DBus' ],\n    )-\u003ethen( sub ($resp_msg) { .. } );\n\n    my $msg = $dbus-\u003eget_message();\n\nFor non-blocking I/O, it is recommended to use an event loop.\nThis distribution includes some connectors to simplify that work:\n\n- [Protocol::DBus::Client::IOAsync](https://metacpan.org/pod/Protocol%3A%3ADBus%3A%3AClient%3A%3AIOAsync) (for [IO::Async](https://metacpan.org/pod/IO%3A%3AAsync))\n- [Protocol::DBus::Client::Mojo](https://metacpan.org/pod/Protocol%3A%3ADBus%3A%3AClient%3A%3AMojo) (for [Mojolicious](https://metacpan.org/pod/Mojolicious))\n- [Protocol::DBus::Client::AnyEvent](https://metacpan.org/pod/Protocol%3A%3ADBus%3A%3AClient%3A%3AAnyEvent) (for [AnyEvent](https://metacpan.org/pod/AnyEvent))\n\nExample:\n\n    my $loop = IO::Async::Loop-\u003enew();\n\n    my $dbus = Protcol::DBus::Client::IOAsync::login_session($loop);\n\n    $dbus-\u003einitialize()-\u003ethen(\n        sub ($dbus) {\n            return $dbus-\u003esend_call( … );  # same arguments as above\n        },\n    )-\u003efinally( sub { $loop-\u003estop() } );\n\n    $loop-\u003erun();\n\nYou can also interface with a manually-written event loop.\nSee [the example](#example-using-manually-written-event-loop) below.\n\n# DESCRIPTION\n\n\u003cdiv\u003e\n    \u003ca href='https://coveralls.io/github/FGasper/p5-Protocol-DBus?branch=master'\u003e\u003cimg src='https://coveralls.io/repos/github/FGasper/p5-Protocol-DBus/badge.svg?branch=master' alt='Coverage Status' /\u003e\u003c/a\u003e\n\u003c/div\u003e\n\nThis is an original, pure-Perl implementation of client messaging logic for\n[the D-Bus protocol](https://dbus.freedesktop.org/doc/dbus-specification.html).\n\nIt’s not much more than an implementation of the wire protocol; it doesn’t\nknow about objects, services, or anything else besides the actual messages.\nThis is fine, of course, if all you want to do is, e.g., replace\nan invocation of `gdbus` or `dbus-send` with pure Perl.\n\nIf you want an interface that mimics D-Bus’s actual object system,\nyou’ll need to implement it yourself or use something like [Net::DBus](https://metacpan.org/pod/Net%3A%3ADBus).\n(See [\"DIFFERENCES FROM Net::DBus\"](#differences-from-net-dbus) below.)\n\n# STATUS\n\nThis project is in BETA status. While the API should be pretty stable now,\nbreaking changes can still happen. If you use this module\nin your project, you **MUST** check the changelog before deploying a new\nversion. Please file bug reports as appropriate.\n\n# EXAMPLES\n\nSee [Protocol::DBus::Client](https://metacpan.org/pod/Protocol%3A%3ADBus%3A%3AClient) and the above samples for a starting point.\n\nAlso see the distribution’s `examples/` directory.\n\n# DIFFERENCES FROM Net::DBus\n\n[Net::DBus](https://metacpan.org/pod/Net%3A%3ADBus) is an XS binding to\n[libdbus](https://www.freedesktop.org/wiki/Software/dbus/),\nthe reference D-Bus implementation. It is CPAN’s most mature D-Bus\nimplementation.\n\nThere are several reasons why you might prefer this module instead,\nthough, such as:\n\n- Net::DBus discerns how to send a method call via D-Bus introspection.\nWhile handy, this costs extra network overhead and requires an XML parser.\nWith Protocol::DBus you give a signature directly to send a method call.\n- Protocol::DBus can work smoothly with any event system you like,\nincluding custom-written ones. (The distribution ships with connectors for\nthree popular ones.) Net::DBus, on the other hand, expects you to use its\nown event loop, [Net::DBus::Reactor](https://metacpan.org/pod/Net%3A%3ADBus%3A%3AReactor).\n- Protocol::DBus has a considerably lighter memory footprint.\n- Protocol::DBus is pure Perl, so on most OSes you can fat-pack it\nfor easy distribution.\n- Protocol::DBus exposes a simpler API.\n\nOf course, there are tradeoffs: most notably, Protocol::DBus’s API is\nsimpler because it doesn’t attempt to implement D-Bus’s object system.\n(You never **need** the object system, but it can be a useful abstraction.)\nAn XS-powered D-Bus library is also likely to outperform a\npure-Perl one, introspection overhead notwithstanding. YMMV. BYOB.\n\n# NOTES\n\n- UNIX FD support requires that [Socket::MsgHdr](https://metacpan.org/pod/Socket%3A%3AMsgHdr) be loaded at\nauthentication time.\n- Certain OSes may require [Socket::MsgHdr](https://metacpan.org/pod/Socket%3A%3AMsgHdr) in order to authenticate\nvia a UNIX socket. (Linux, notably, does not.) It depends if your OS can\nsend local socket credentials without using [sendmsg(2)](http://man.he.net/man2/sendmsg).\n- EXTERNAL and DBUS\\_COOKIE\\_SHA1 authentications are supported.\n\n# EXAMPLE USING MANUALLY-WRITTEN EVENT LOOP\n\n    my $dbus = Protcol::DBus::Client::system();\n\n    $dbus-\u003eblocking(0);\n\n    my $fileno = $dbus-\u003efileno();\n\n    # You can use whatever polling method you prefer;\n    # the following is just for demonstration:\n    vec( my $mask, $fileno, 1 ) = 1;\n\n    while (!$dbus-\u003einitialize()) {\n        if ($dbus-\u003einit_pending_send()) {\n            select( undef, my $wout = $mask, undef, undef );\n        }\n        else {\n            select( my $rout = $mask, undef, undef, undef );\n        }\n    }\n\n    $dbus-\u003esend_call( .. );     # same parameters as above\n\n    while (1) {\n        my $wout = $dbus-\u003epending_send() || q\u003c\u003e;\n        $wout \u0026\u0026= $mask;\n\n        select( my $rout = $mask, $wout, undef, undef );\n\n        if ($wout =~ tr\u003c\\0\u003e\u003c\u003ec) {\n            $dbus-\u003eflush_write_queue();\n        }\n\n        if ($rout =~ tr\u003c\\0\u003e\u003c\u003ec) {\n\n            # It’s critical to get_message() until undef is returned.\n            1 while $dbus-\u003eget_message();\n        }\n    }\n\nLife is easier if you use someone else’s event loop. :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgasper%2Fp5-protocol-dbus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffgasper%2Fp5-protocol-dbus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgasper%2Fp5-protocol-dbus/lists"}