title: How can I get the g_dbus_connection_signal_subscribe function to tell me about pre-existing objects/interfaces?
body: <p>The function g_dbus_connection_signal_subscribe works great for telling me when new DBus objects appear (or vanish) with InterfacesAdded signal (or InterfacesRemoved signal).  But I need for to know about pre-existing objects/interfaces.</p>
  
  <p>I wrote the following piece of C code to provide callbacks when DBus objects are added/removed from the bus.  Error-checking omitted for simplicity.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;gio/gio.h&gt;
  
  static void signal_cb(GDBusConnection *connection,
          const gchar *sender_name,const gchar *object_path,
          const gchar *interface_name,const gchar *signal_name,
          GVariant *parameters,gpointer user_data)
  {
      printf("%s: %s.%s %s\n",object_path,interface_name,signal_name,
          g_variant_print(parameters,TRUE));
  }
  
  int main(int argc,char *argv[])
  {
  GDBusConnection *c;
  GMainLoop *loop;
  int filter_id;
  
      c = g_bus_get_sync(G_BUS_TYPE_SYSTEM,NULL,&amp;err);
      loop = g_main_loop_new(NULL,0);
      filter_id = g_dbus_connection_signal_subscribe(c,
          "org.bluez",NULL,NULL,NULL,NULL,
          G_DBUS_SIGNAL_FLAGS_NONE,signal_cb,NULL,NULL);   
      g_main_loop_run (loop);
      g_main_loop_unref (loop);
  
      exit(0);
  }
  </code></pre>
  
  <p>So what I'm trying to do is keep track of all the DBus objects that exist under the org.bluez branch of the tree.  (These represent pluggable Bluetooth controllers and the devices that are discovered by each controller).  I need to know about DBus objects that were already there before my program started, and I need to know about new objects that appear after my program starts.</p>
  
  <p>My code above tells me about new objects, but nothing about the objects that are already there.  Is there a way in the gdbus API to get an "InterfacesCreated" signal for objects that already exist?  I suppose could read the entire DBus object hierarchy and then subscribe to changes, but that leads to race conditions where if an object appears between the time I read the object hierarchy and the time I subscribe, then I would miss those objects....</p>
  
  <p>What's the best-practice way to accomplish this with the gdbus API?</p>