Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service side properties #86

Merged
merged 19 commits into from
Feb 11, 2022
Merged

Service side properties #86

merged 19 commits into from
Feb 11, 2022

Conversation

mvidner
Copy link
Owner

@mvidner mvidner commented Nov 13, 2020

Until https://www.rubydoc.info/gems/ruby-dbus renders it, see Reference.md and the API comments in DBus::Object

Example

(rake doc:examples; cat examples/doc/exporting_properties.rb)

#! /usr/bin/env ruby
require "dbus"
# https://github.com/mvidner/ruby-dbus/blob/master/doc/Reference.md#exporting-properties
class Note < DBus::Object
  dbus_interface "net.vidner.Example.Properties" do
    # A read-write property "Title",
    # with `title` and `title=` accessing @title.
    dbus_attr_accessor :title, DBus::Type::STRING
    # A read-only property "Author"
    # (type specified via DBus signature)
    # with `author` reading `@author`
    dbus_attr_reader :author, "s"
    # A read-only property `Clock`
    def clock
      Time.now.to_s
    end
    dbus_reader :clock, "s"
    # Name mapping: `CreationTime`
    def creation_time
      "1993-01-01 00:00:00 +0100"
    end
    dbus_reader :creation_time, "s"
    dbus_attr_accessor :book_volume, DBus::Type::VARIANT, dbus_name: "Volume"
  end
  dbus_interface "net.vidner.Example.Audio" do
    dbus_attr_accessor :speaker_volume, DBus::Type::BYTE, dbus_name: "Volume"
  end
  # Must assign values because `nil` would crash our connection
  def initialize(opath)
    super
    @title = "Ahem"
    @author = "Martin"
    @book_volume = 1
    @speaker_volume = 11
  end
end
obj = Note.new("/net/vidner/Example/Properties")
bus = DBus::SessionBus.instance
service = bus.request_service("net.vidner.Example")
service.export(obj)
main = DBus::Main.new
main << bus
main.run

Tests

  • pass locally, rake spec
  • pass with rake osc:build on Tumbleweed (local problems with non-matching abuild user? edit /etc/passwd and chown home!)
  • reintroduce CI on GItHub instead of the discontinued Travis-CI.org: CI with GitHub Actions #93

Documentation

  • Review the doc/ files to update them regarding properties
  • make the example/ work

@lslezak
Copy link
Contributor

lslezak commented Nov 13, 2020

Thanks, LGTM so far.

@mvidner mvidner force-pushed the service-properties branch 2 times, most recently from 11bf7e0 to cdd60cb Compare February 6, 2022 20:59
@mvidner mvidner marked this pull request as ready for review February 6, 2022 21:03
@@ -70,7 +70,7 @@ def test_loop_quit(delay)
@obj.on_signal "LongTaskEnd"
end

it "tests loop quit" do
it "tests loop quit", slow: true do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mvidner mvidner force-pushed the service-properties branch from cdd60cb to cf9731e Compare February 9, 2022 10:12
@coveralls
Copy link

coveralls commented Feb 9, 2022

Coverage Status

Coverage decreased (-1.04%) to 84.32% when pulling 4d2a82e on service-properties into da3c1de on master.

@mvidner
Copy link
Owner Author

mvidner commented Feb 11, 2022

Coverage check fails because the new CI misses the code covered by the asynchronously started service and counts only the code run directly by RSpec. Locally it works :-/

@mvidner mvidner merged commit 73daeb0 into master Feb 11, 2022
@mvidner mvidner deleted the service-properties branch February 11, 2022 18:48
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Mar 24, 2022
https://build.opensuse.org/request/show/963982
by user mvidner + dimstar_suse
(Fix previous submissions by using the gem file from rubygems.org)

- 0.18.0.beta1
 API:
 * D-Bus structs have been passed as Ruby arrays. Now these arrays
   are frozen.
 * Ruby structs can be used as D-Bus structs.
 Bug fixes:
 * Returning the value for o.fd.DBus.Properties.Get, use the
   specific property signature, not the generic Variant
   (gh#mvidner/ruby-dbus#97).
- 0.17.0
 API:
 * Export properties with `dbus_attr_accessor`, `dbus_reader` etc.
   (gh#mvidner/ruby-dbus#86).
 Bug fixes:
 * Depend on rexml which is separate since Ruby 3.0
   (gh#mvidner/ruby-dbus#87, by Toshiaki Asai).
   Nokogiri is faster but bigger so it remains optional.
 * Fix connection in case ~/.dbus-keyrings has multiple cookies, showing
   as "Oops: undefined method `zero?' for nil:NilClass".
 * Add the mis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants