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

Fixed problems with introspection, the path names and structure were not #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dashxdr
Copy link

@dashxdr dashxdr commented Feb 27, 2017

correct and didn't allow for proper recursion. Now the path names for all
child nodes have names relative to the path specified in the query, and are
provided with a null node placeholder entry so they appear in the xml, and
the caller can then recursively scan as desired.

The code could probably be made more efficient with fewer checks for
exceptions.

correct and didn't allow for proper recursion. Now the path names for all
child nodes have names relative to the path specified in the query, and are
provided with a null node placeholder entry so they appear in the xml, and
the caller can then recursively scan as desired.

The code could probably be made more efficient with fewer checks for
exceptions.
@sidorares
Copy link
Owner

Hi @dashxdr ! I think I understand the issue, but could you provide step-by-step example where old code would fail?

@dashxdr
Copy link
Author

dashxdr commented Feb 27, 2017

Here is an example, it mimics the ofono dbus interface (just a little). It can be placed in the node-dbus/test directory.

// ****************** START
#!/usr/bin/env node
"use strict";

var dbus = require('../../node-dbus');
var bus = dbus.systemBus();


var ManagerIface = {
	name: 'org.ofono.Manager',
	methods: {
		GetModems: ['', 'a(oa{sv})', [], ['modems']], 
	},
	signals: {
		ModemAdded: ['oa{sv}', ['path'], ['properties']],
		ModemRemoved: ['o', ['path']],
	},
};

var Manager = {
	GetModems: function()
	{
		console.log('Manager.GetModems');

		return [[
			'/sim5320_0',
			[
				['Online', ['b', true]],
			]
		]];
	},
};

bus.requestName('org.ofono', 0x4, function(e, retCode) {
	if(e) console.log('error with requestName');
	else {
		console.log('requestName worked, retCode = ' + retCode);
		bus.exportInterface(Manager, '/', ManagerIface);

	}
});
//********************* END

When you run it you can test functionality with this:
dbus-send --system --dest=org.ofono --print-reply / org.ofono.Manager.GetModems
And it should output this:

   array [
      struct {
         object path "/sim5320_0"
         array [
            dict entry(
               string "Online"
               variant                   boolean true
            )
         ]
      }
   ]

To verify some instrospection functionality do this first:
gdbus introspect --system --dest org.ofono --object-path /
The output should be this:

node / {
  node  {
  };
};

NOW to cause the failure, add the --recurse onto the query:
gdbus introspect --system --dest org.ofono --object-path / --recurse
and voila:

node / {
  node / {
    node / {
      node / {
        node / {
          node / {
            node / {
              node / {
                node / {
                  node / {
                    node / {
                      node / {

... etc

With my version we get this for both queries, which is what we want:

node / {
  interface org.ofono.Manager {
    methods:
      GetModems(out a(oa{sv}) modems);
    signals:
      ModemAdded(o path,
                 a{sv} properties);
      ModemRemoved(o path);
    properties:
  };
  interface org.freedesktop.DBus.Properties {
    methods:
      Get(in  s interface_name,
          in  s property_name,
          out v value);
      GetAll(in  s interface_name,
             out a{sv} properties);
      Set(in  s interface_name,
          in  s property_name,
          in  v value);
    signals:
      PropertiesChanged(s interface_name,
                        a{sv} changed_properties,
                        as invalidated_properties);
    properties:
  };
  interface org.freedesktop.DBus.Introspectable {
    methods:
      Introspect(out s xml_data);
    signals:
    properties:
  };
  interface org.freedesktop.DBus.Peer {
    methods:
      Ping();
      GetMachineId(out s machine_uuid);
    signals:
    properties:
  };
};

@dashxdr
Copy link
Author

dashxdr commented Feb 27, 2017

One other note, you need to make sure your permissions are set to allow queries on the system dbus, I'm a little hazy on the details. Here is my /etc/dbus-1/system.d/ofono.conf file if it helps...

<!-- This configuration file specifies the required security policies
     for oFono core daemon to work. -->

<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>

  <!-- ../system.conf have denied everything, so we just punch some holes -->

  <policy user="root">
    <allow own="org.ofono"/>
    <allow send_destination="org.ofono"/>
    <allow send_interface="org.ofono.SimToolkitAgent"/>
    <allow send_interface="org.ofono.PushNotificationAgent"/>
    <allow send_interface="org.ofono.SmartMessagingAgent"/>
    <allow send_interface="org.ofono.PositioningRequestAgent"/>
    <allow send_interface="org.ofono.HandsfreeAudioAgent"/>
  </policy>

  <policy at_console="true">
    <allow send_destination="org.ofono"/>
  </policy>

  <policy context="default">
    <deny send_destination="org.ofono"/>
  </policy>

</busconfig>

@sidorares
Copy link
Owner

thanks! I'll try to have a look soon ( there is a huge backlog on this project I never had enough time to action )

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.

2 participants