Bug 19145 - GetAll() ignores the interface for multi-interface objects
Summary: GetAll() ignores the interface for multi-interface objects
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: GLib (show other bugs)
Version: 1.2.x
Hardware: Other All
: medium normal
Assignee: Rob Taylor
QA Contact: John (J5) Palmieri
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-17 14:31 UTC by Dan Williams
Modified: 2008-12-19 08:25 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Proposed patch (3.94 KB, patch)
2008-12-18 02:12 UTC, Tambet Ingo
Details | Splinter Review
testcases for GetAll with interfaces (17.31 KB, patch)
2008-12-18 09:49 UTC, Dan Williams
Details | Splinter Review

Description Dan Williams 2008-12-17 14:31:46 UTC
GetAll() ignores the interface passed in the D-Bus message because lookup_object_and_method() returns the last object_info in the object's info list if there wasn't a matching method on the object.

  for (info_list_walk = info_list; info_list_walk != NULL; info_list_walk = g_list_next (info_list_walk))
    {
      info = (DBusGObjectInfo *) info_list_walk->data;
      *object_ret = info;

      for (i = 0; i < info->n_method_infos; i++)
        {
          const char *expected_member;
          const char *expected_interface;
          char *expected_signature;
          const DBusGMethodInfo *method;

          method = &(info->method_infos[i]);

          /* Check method interface/name and input signature */ 
          expected_interface = method_interface_from_object_info (*object_ret, method);
          expected_member = method_name_from_object_info (*object_ret, method);
          expected_signature = method_input_signature_from_object_info (*object_ret, method);

          if ((interface == NULL
              || strcmp (expected_interface, interface) == 0)
              && strcmp (expected_member, member) == 0
              && strcmp (expected_signature, signature) == 0)
            {
              g_free (expected_signature);
              *method_ret = method;
              g_list_free (info_list);
              return TRUE;
            }
            g_free (expected_signature);
        }
    }

Thus, for GetAll(), unless an interface of the object itself provides GetAll(), the last object info in the list will always be returned, which might well be incorrect.
Comment 1 Tambet Ingo 2008-12-18 02:12:18 UTC
Created attachment 21269 [details] [review]
Proposed patch
Comment 2 Colin Walters 2008-12-18 08:45:53 UTC
I believe David wrote the GetAll code, adding him.
Comment 3 Dan Williams 2008-12-18 09:31:47 UTC
I was doing patch too.  But I like yours more.  The testcases I wrote should still apply regardless of which patch gets committed.
Comment 4 Dan Williams 2008-12-18 09:49:47 UTC
Created attachment 21279 [details] [review]
testcases for GetAll with interfaces
Comment 5 Colin Walters 2008-12-18 10:16:44 UTC
Pushed both patches, thanks!

commit d55ffa5bbccd027caf7f2e7376b555e397a7ac3c
Author: Dan Williams <dcbw@redhat.com>
Date:   Thu Dec 18 13:09:33 2008 -0500

    Bug 19145: test cases for GetAll
    
    Add test cases for GetAll.
    
    Signed-off-by: Colin Walters <walters@verbum.org>

commit 94d68f00d9d244de3b1d66d3cf78bb5171552311
Author: Tambet Ingo <tambet@gmail.com>
Date:   Thu Dec 18 12:09:43 2008 +0200

    Use the provided interface for org.freedesktop.DBus.Properties.GetAll call.

Comment 6 Dan Williams 2008-12-19 06:06:03 UTC
Colin; looks like the new testcase files in test/core/ didn't get added to the repo:

test/core/test-service-glib-subclass.xml
test/core/my-object-subclass.c
test/core/my-object-subclass.h
Comment 7 Colin Walters 2008-12-19 08:25:40 UTC
commit 88684866d06df99f89b30a07e4809369b4cb0453
Author: Colin Walters <walters@verbum.org>
Date:   Fri Dec 19 11:18:26 2008 -0500

    Add new files missed from last commit



Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.