static void
bus_acquired_handler (GDBusConnection *connection,
		      const gchar     *name,
		      gpointer         user_data)
{
	SensorData *data = user_data;

	g_dbus_connection_register_object (connection,
					   SENSOR_PROXY_DBUS_PATH,
					   data->introspection_data->interfaces[0],
					   &interface_vtable,
					   data,
					   NULL,
					   NULL);

	g_dbus_connection_register_object (connection,
					   SENSOR_PROXY_COMPASS_DBUS_PATH,
					   data->introspection_data->interfaces[1],
					   &compass_interface_vtable,
					   data,
					   NULL,
					   NULL);

	data->connection = g_object_ref (connection);
}
Exemplo n.º 2
0
static void
on_bus_acquired (GDBusConnection *connection,
                 const gchar     *name,
                 gpointer         user_data)
{
  auto policy_rid = g_dbus_connection_register_object(connection,
                                                      "/org/usbguard/Policy",
                                                      introspection_data->interfaces[0],
                                                      &policy_interface_vtable,
                                                      /*user_data=*/dbus_bridge,
                                                      /*user_data_free_func=*/nullptr,
                                                      /*GError=*/nullptr);
  auto devices_rid = g_dbus_connection_register_object(connection,
                                                      "/org/usbguard/Devices",
                                                      introspection_data->interfaces[1],
                                                      &devices_interface_vtable,
                                                      /*user_data=*/dbus_bridge,
                                                      /*user_data_free_func=*/nullptr,
                                                      /*GError=*/nullptr);
  if (policy_rid <= 0 || devices_rid <= 0) {
    std::cerr << "Unable to register required objects on the bus." << std::endl;
    g_main_loop_quit(main_loop);
    global_ret = EXIT_FAILURE;
  }
}
Exemplo n.º 3
0
gboolean
load_dlna (SnappyMP * mp)
{
  guint owner_id, player_id, root_id;
  GError *error = NULL;
  GDBusInterfaceInfo *ifaceinfo;
  GDBusConnection *connection;

  g_type_init ();

  connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);

  /* Build the introspection data structures from the XML */
  introspection_data =
      g_dbus_node_info_new_for_xml (mpris_introspection_xml, NULL);
  g_assert (introspection_data != NULL);

  /* register media player interface */
  ifaceinfo =
      g_dbus_node_info_lookup_interface (introspection_data,
      MPRIS_PLAYER_INTERFACE);
  mp->player_id =
      g_dbus_connection_register_object (connection, MPRIS_OBJECT_NAME,
      ifaceinfo, &interface_vtable, mp, NULL, &error);

  /* register root interface */
  ifaceinfo =
      g_dbus_node_info_lookup_interface (introspection_data,
      MPRIS_ROOT_INTERFACE);
  mp->root_id =
      g_dbus_connection_register_object (connection, MPRIS_OBJECT_NAME,
      ifaceinfo, &root_vtable, NULL, NULL, &error);
  if (error != NULL) {
    g_warning ("unable to register MPRIS root interface: %s", error->message);
    g_error_free (error);
  }

  mp->owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
      "org.mpris.MediaPlayer2.snappy",
      G_BUS_NAME_OWNER_FLAGS_NONE,
      NULL,
      (GBusNameAcquiredCallback) on_name_acquired,
      (GBusNameLostCallback) on_name_lost, mp, NULL);
  g_assert (mp->owner_id > 0);

  mp->name = g_strdup ("snappy");

  return TRUE;
}
Exemplo n.º 4
0
static guint
start_service (GDBusConnection *bus,
               NMConnectionList *list,
               guint *out_registration_id)
{
	static const gchar introspection_xml[] =
		"<node>"
		"  <interface name='org.gnome.nm_connection_editor'>"
		"    <method name='Start'>"
		"      <arg type='a{sv}' name='args' direction='in'/>"
		"    </method>"
		"  </interface>"
		"</node>";

	introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
	g_assert (introspection_data != NULL);

	*out_registration_id = g_dbus_connection_register_object (bus,
	                                                          "/",
	                                                          introspection_data->interfaces[0],
	                                                          &interface_vtable,
	                                                          list,  /* user_data */
	                                                          NULL,  /* user_data_free_func */
	                                                          NULL); /* GError** */

	return g_bus_own_name_on_connection (bus,
	                                     NM_CE_DBUS_SERVICE,
	                                     G_BUS_NAME_OWNER_FLAGS_NONE,
	                                     NULL,
	                                     NULL,
	                                     NULL,
	                                     NULL);
}
Exemplo n.º 5
0
static void
on_bus_acquired(GDBusConnection *connection, const gchar *name,
		gpointer user_data)
{
  GDBusProxy *connman = user_data;
  GError *err = NULL;

  GDBusNodeInfo *node_info =
    g_dbus_node_info_new_for_xml(connman_agent_xml, NULL);

  g_dbus_connection_register_object(connection,
				    "/showtime/netagent",
				    node_info->interfaces[0],
				    &connman_agent_vtable,
				    NULL, NULL, NULL);

  GVariant *params;

  params = g_variant_new("(o)", "/showtime/netagent");

  GVariant *v =
    g_dbus_proxy_call_sync(connman, "RegisterAgent", params,
			   G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
  if(v == NULL) {
    TRACE(TRACE_ERROR, "CONNMAN", "Unable to register agent -- %s",
	  err->message);
    g_error_free(err);
    return;
  }
  g_variant_unref(v);
}
Exemplo n.º 6
0
static void
bus_acquired_cb (GDBusConnection *connection,
		 const gchar     *name,
		 gpointer         user_data)
{
	GMainLoop *loop = (GMainLoop *) user_data;
	guint      registration_id;
	GError    *error = NULL;

	if (!introspection_data)
		introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);

	registration_id = g_dbus_connection_register_object (connection,
							     EV_DBUS_DAEMON_OBJECT_PATH,
							     introspection_data->interfaces[0],
							     &interface_vtable,
							     g_main_loop_ref (loop),
							     (GDestroyNotify) g_main_loop_unref,
							     &error);
	if (registration_id == 0) {
		g_printerr ("Failed to register object: %s\n", error->message);
		g_error_free (error);

		if (g_main_loop_is_running (loop))
			g_main_loop_quit (loop);
	}
}
Exemplo n.º 7
0
guint bluez_create_watcher(GDBusConnection* conn, BLEThread* thread)
{
    /* We are lazy here - we don't want to manually provide
    * the introspection data structures - so we just build
    * them from XML.
    */
    introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
    g_assert(introspection_data != NULL);

    guint registration_id;

    gchar path[255];
    g_snprintf(path, 255, "/test/bluez/%d", getpid());

    registration_id = g_dbus_connection_register_object(conn,
                                                       path,
                                                       introspection_data->interfaces[0],
                                                       &interface_vtable,
                                                       thread,  /* user_data */
                                                       NULL,  /* user_data_free_func */
                                                       NULL); /* GError** */
    g_assert(registration_id > 0);

    return g_bus_own_name_on_connection(conn,
                                     "org.test.bluez",
                                     G_BUS_NAME_OWNER_FLAGS_NONE,
                                     on_name_acquired,
                                     on_name_lost,
                                     NULL,
                                     NULL);
}
Exemplo n.º 8
0
/**
 * g_dbus_connection_export_menu_model:
 * @connection: a #GDBusConnection
 * @object_path: a D-Bus object path
 * @menu: a #GMenuModel
 * @error: return location for an error, or %NULL
 *
 * Exports @menu on @connection at @object_path.
 *
 * The implemented D-Bus API should be considered private.
 * It is subject to change in the future.
 *
 * An object path can only have one action group exported on it. If this
 * constraint is violated, the export will fail and 0 will be
 * returned (with @error set accordingly).
 *
 * You can unexport the menu model using
 * g_dbus_connection_unexport_menu_model() with the return value of
 * this function.
 *
 * Returns: the ID of the export (never zero), or 0 in case of failure
 *
 * Since: 2.32
 */
guint
g_dbus_connection_export_menu_model (GDBusConnection  *connection,
                                     const gchar      *object_path,
                                     GMenuModel       *menu,
                                     GError          **error)
{
  const GDBusInterfaceVTable vtable = {
    g_menu_exporter_method_call,
  };
  GMenuExporter *exporter;
  guint id;

  exporter = g_slice_new0 (GMenuExporter);

  id = g_dbus_connection_register_object (connection, object_path, org_gtk_Menus_get_interface (),
                                          &vtable, exporter, g_menu_exporter_free, error);

  if (id == 0)
    {
      g_slice_free (GMenuExporter, exporter);
      return 0;
    }

  exporter->connection = g_object_ref (connection);
  exporter->object_path = g_strdup (object_path);
  exporter->groups = g_hash_table_new (NULL, NULL);
  exporter->remotes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_menu_exporter_remote_free);
  exporter->root = g_menu_exporter_group_add_menu (g_menu_exporter_create_group (exporter), menu);

  return id;
}
Exemplo n.º 9
0
/**
 * urf_device_register_device:
 **/
static gboolean
urf_killswitch_register_switch (UrfKillswitch *killswitch)
{
	UrfKillswitchPrivate *priv = killswitch->priv;
	GDBusInterfaceInfo **infos;
	guint reg_id;
	GError *error = NULL;

	priv->introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
	g_assert (priv->introspection_data != NULL);

	priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
	if (priv->connection == NULL) {
		g_error ("error getting system bus: %s", error->message);
		g_error_free (error);
		return FALSE;
	}

	priv->object_path = g_strdup_printf (BASE_OBJECT_PATH"%s",
					     type_to_string (priv->type));
	infos = priv->introspection_data->interfaces;
	reg_id = g_dbus_connection_register_object (priv->connection,
		                                    priv->object_path,
		                                    infos[0],
		                                    &interface_vtable,
		                                    killswitch,
		                                    NULL,
		                                    NULL);
	g_assert (reg_id > 0);

	return TRUE;
}
Exemplo n.º 10
0
static void
_on_bus_acquired ( GDBusConnection *connection, 
        const gchar *name, 
        gpointer user_data )
{
    g_debug(" on bus acquired ...\n");

    lock_connection = connection;

    //register object
    GError *error = NULL;
    lock_service_reg_id = g_dbus_connection_register_object( connection, 
            DBUS_PYSQL_PATH, 
            interface_info, 
            &interface_table, 
            user_data, 
            NULL, 
            &error );

    if ( error != NULL ) {
        g_critical ( "Unable to register object to the dbus: %s\n", 
                error->message );
        g_error_free(error);
        g_bus_unown_name(lock_service_owner_id);
        lock_service_owner_id = 0;
        retry_reg_timeout_id = g_timeout_add_seconds(1, 
                _retry_registration, NULL );
        return;
    }

    return;
}
Exemplo n.º 11
0
/**
 * @brief Invoked when a new incomming client connection is established.
 * @memberof GstSwitchController
 */
static gboolean
gst_switch_controller_on_new_connection (GDBusServer * server,
    GDBusConnection * connection, gpointer user_data)
{
  GstSwitchController *controller = GST_SWITCH_CONTROLLER (user_data);
  guint register_id = 0;
  GError *error = NULL;

  register_id = g_dbus_connection_register_object (connection, SWITCH_CONTROLLER_OBJECT_PATH, introspection_data->interfaces[0], &gst_switch_controller_interface_vtable, controller,   /* user_data */
      NULL,                     /* user_data_free_func */
      &error);

  if (error != NULL) {
    ERROR ("failed to register controller: %s", error->message);
    g_error_free (error);
    return FALSE;
  } else if (register_id <= 0) {
    ERROR ("register_id invalid (<= 0): %d", register_id);
    return FALSE;
  } else {
    INFO ("registered: %d, %s, %s", register_id,
        SWITCH_CONTROLLER_OBJECT_PATH, introspection_data->interfaces[0]->name);
  }

  g_signal_connect (connection, "closed",
      G_CALLBACK (gst_switch_controller_on_connection_closed), controller);

  GST_SWITCH_CONTROLLER_LOCK_CLIENTS (controller);
  controller->clients = g_list_append (controller->clients, connection);
  GST_SWITCH_CONTROLLER_UNLOCK_CLIENTS (controller);

  g_object_ref (connection);

  return TRUE;
}
Exemplo n.º 12
0
static void
on_bus_acquired (GObject      *source_object,
                 GAsyncResult *result,
                 gpointer      user_data)
{
  DbusInput *self = user_data;
  GError *error = NULL;


  self->connection = g_bus_get_finish (result, &error);

  if (!self->connection)
    {
      g_warning ("Could not acquire bus connection: %s", error->message);
      g_error_free (error);
      return;
    }

  /* Note: Dbus object and name subject to change */
  guint id = g_dbus_connection_register_object (self->connection,
                                     "/org/Pinpoint/Input",
                                     self->introspection_data->interfaces[0],
                                     &interface_table,
                                     self,
                                     NULL,
                                     &error);
  if (id == 0)
    {
      g_warning ("Problem registering object: %s", error->message);
      g_error_free (error);
    }
}
Exemplo n.º 13
0
static void
new_connection_cb (GDBusServer *server,
		   GDBusConnection *connection,
		   ServiceData *svc)
{
	GError *error = NULL;
	rb_debug ("new connection to metadata service");

	/* don't allow more than one connection at a time */
	if (svc->connection) {
		rb_debug ("metadata service already has a client.  go away.");
		return;
	}
	g_dbus_connection_register_object (connection,
					   RB_METADATA_DBUS_OBJECT_PATH,
					   g_dbus_node_info_lookup_interface (svc->node_info, RB_METADATA_DBUS_INTERFACE),
					   &metadata_vtable,
					   svc,
					   NULL,
					   &error);
	if (error != NULL) {
		rb_debug ("unable to register metadata object: %s", error->message);
		g_clear_error (&error);
	} else {
		svc->connection = g_object_ref (connection);
		g_signal_connect (connection, "closed", G_CALLBACK (connection_closed_cb), svc);

		g_dbus_connection_set_exit_on_close (connection, (svc->external == FALSE));
	}
}
Exemplo n.º 14
0
static void busAcquiredCallback(GDBusConnection* connection, const char* name, gpointer userData)
{
    static GDBusNodeInfo* introspectionData = 0;
    if (!introspectionData)
        introspectionData = g_dbus_node_info_new_for_xml(introspectionXML, 0);

    GOwnPtr<GError> error;
    unsigned registrationID = g_dbus_connection_register_object(
        connection,
        "/org/webkit/gtk/WebExtensionTest",
        introspectionData->interfaces[0],
        &interfaceVirtualTable,
        g_object_ref(userData),
        static_cast<GDestroyNotify>(g_object_unref),
        &error.outPtr());
    if (!registrationID)
        g_warning("Failed to register object: %s\n", error->message);

    g_object_set_data(G_OBJECT(userData), "dbus-connection", connection);
    while (delayedSignalsQueue.size()) {
        OwnPtr<DelayedSignal> delayedSignal = delayedSignalsQueue.takeFirst();
        switch (delayedSignal->type) {
        case DocumentLoadedSignal:
            emitDocumentLoaded(connection);
            break;
        case URIChangedSignal:
            emitURIChanged(connection, delayedSignal->uri.data());
            break;
        }
    }
}
Exemplo n.º 15
0
static void
on_bus_acquired (GDBusConnection *connection,
                 const gchar *name,
                 gpointer user_data)
{
  GError *error = NULL;

  print_debug ("Connected to the session bus: %s", name);

  g_dbus_connection_register_object (connection,
                                     "/org/Cinnamon/HotplugSniffer",
                                     introspection_data->interfaces[0],
                                     &interface_vtable,
                                     NULL,
                                     NULL,
                                     &error);

  if (error != NULL)
    {
      g_printerr ("Error exporting object on the session bus: %s",
                  error->message);
      g_error_free (error);

      _exit(1);
    }

  print_debug ("Object exported on the session bus");
}
Exemplo n.º 16
0
static void
appfinder_gdbus_bus_acquired (GDBusConnection *connection,
                              const gchar     *name,
                              gpointer         user_data)
{
  guint          register_id;
  GDBusNodeInfo *info;
  GError        *error = NULL;

  info = g_dbus_node_info_new_for_xml (appfinder_gdbus_introspection_xml, NULL);
  g_assert (info != NULL);
  g_assert (*info->interfaces != NULL);

  register_id = g_dbus_connection_register_object (connection,
                                                   APPFINDER_DBUS_PATH,
                                                   *info->interfaces, /* first iface */
                                                   &appfinder_gdbus_vtable,
                                                   user_data,
                                                   NULL,
                                                   &error);

  APPFINDER_DEBUG ("registered interface with id %d", register_id);

  if (register_id == 0)
    {
      g_message ("Failed to register object: %s", error->message);
      g_error_free (error);
    }

  g_dbus_node_info_unref (info);
}
Exemplo n.º 17
0
static gboolean
on_new_connection (GDBusServer *server,
                   GDBusConnection *connection,
                   gpointer user_data)
{
  guint registration_id;
  GCredentials *credentials;
  gchar *s;

  credentials = g_dbus_connection_get_peer_credentials (connection);
  if (credentials == NULL)
    s = g_strdup ("(no credentials received)");
  else
    s = g_credentials_to_string (credentials);


  g_print ("Client connected.\n"
           "Peer credentials: %s\n"
           "Negotiated capabilities: unix-fd-passing=%d\n",
           s,
           g_dbus_connection_get_capabilities (connection) & G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);

  g_object_ref (connection);
  registration_id = g_dbus_connection_register_object (connection,
                                                       "/org/gtk/GDBus/TestObject",
                                                       introspection_data->interfaces[0],
                                                       &interface_vtable,
                                                       NULL,  /* user_data */
                                                       NULL,  /* user_data_free_func */
                                                       NULL); /* GError** */
  g_assert (registration_id > 0);

  return TRUE;
}
static void
on_bus_acquired (GDBusConnection *connection,
                 const gchar     *name,
                 gpointer         user_data)
{
  GError *error;
  guint registration_id;

  _global_app = app_new (connection);

  error = NULL;
  registration_id = g_dbus_connection_register_object (connection,
                                                       "/org/gnome/Shell/CalendarServer",
                                                       introspection_data->interfaces[0],
                                                       &interface_vtable,
                                                       _global_app,
                                                       NULL,  /* user_data_free_func */
                                                       &error);
  if (registration_id == 0)
    {
      g_printerr ("Error exporting object: %s (%s %d)",
                  error->message,
                  g_quark_to_string (error->domain),
                  error->code);
      g_error_free (error);
      _exit (1);
    }

  print_debug ("Connected to the session bus");

}
Exemplo n.º 19
0
void
cockpit_dbus_user_startup (struct passwd *pwd)
{
  GDBusConnection *connection;
  GHashTable *props;
  GError *error = NULL;

  connection = cockpit_dbus_internal_server ();
  g_return_if_fail (connection != NULL);

  props = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify)g_variant_unref);
  populate_passwd_props (props, pwd);

  g_dbus_connection_register_object (connection, "/user", &user_interface,
                                     &user_vtable, props, (GDestroyNotify)g_hash_table_unref,
                                     &error);

  if (error != NULL)
    {
      g_critical ("couldn't register user object: %s", error->message);
      g_hash_table_unref (props);
      g_error_free (error);
    }

  g_object_unref (connection);
}
void AbstractDBusInterface::registerObject()
{
	if(!mConnection)
	{
		throw std::runtime_error("forgot to call setDBusConnection on AbstractDBusInterface");
	}

	if(introspectionXml.empty())
	{
		cerr<<"no interface to export: "<<mInterfaceName<<endl;
		throw -1;
	}

	if(!boost::algorithm::ends_with(introspectionXml,"</node>"))
	{
		introspectionXml += "</interface>"
				"</node>";
	}

	GError* error=NULL;

	GDBusNodeInfo* introspection = g_dbus_node_info_new_for_xml(introspectionXml.c_str(), &error);

	if(!introspection || error)
	{

		DebugOut(DebugOut::Error)<<"Error in "<<__FILE__<<" - "<<__FUNCTION__<<":"<<__LINE__<<endl;
		DebugOut(DebugOut::Error)<<error->message<<endl;
		DebugOut(DebugOut::Error)<<"probably bad xml:"<<endl;
		DebugOut(DebugOut::Error)<<introspectionXml<<endl;

		g_error_free(error);

		return;
	}

	GDBusInterfaceInfo* mInterfaceInfo = g_dbus_node_info_lookup_interface(introspection, mInterfaceName.c_str());


	const GDBusInterfaceVTable vtable = { handleMyMethodCall, nullptr, nullptr };

	GError* error2=NULL;

	DebugOut()<<"registering DBus path: "<<mObjectPath<<endl;

	regId = g_dbus_connection_register_object(mConnection, mObjectPath.c_str(), mInterfaceInfo, &vtable, this, NULL, &error2);
	g_dbus_node_info_unref(introspection);
	if(error2)
	{
		DebugOut(DebugOut::Error)<<error2->message<<endl;
		g_error_free(error2);
	}

	if(regId == 0)
	{
		DebugOut(DebugOut::Error)<<"We failed to register on DBus"<<endl;
	}
}
Exemplo n.º 21
0
/* Called when dbus has been acquired */
static void service_on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data)
{
	START_FUNC
	struct service *service=(struct service *)user_data;
	static const GDBusInterfaceVTable vtable={ service_method_call, NULL, NULL };
	g_dbus_connection_register_object(connection, "/org/florence/Keyboard",
		service->introspection_data->interfaces[0], &vtable, user_data, NULL, NULL);
	service->connection=connection;
	END_FUNC
}
Exemplo n.º 22
0
static void on_bus_acquired (GDBusConnection * connection, const gchar * name, gpointer user_data)
{
	g_print ("\n Inside on_bus_acquired \n");

	guint registration_id;

	registration_id = g_dbus_connection_register_object (connection, "/org/myapp/JelariObject", introspection_data->interfaces[0], &interface_vtable, NULL,	/* user_data */
		NULL,					/* user_data_free_func */
		NULL);					/* GError** */
	g_assert (registration_id > 0);

}
static void
export_all (GDBusObjectManagerServer *manager)
{
  GHashTableIter iter;
  const gchar *object_path;
  RegistrationData *data;
  GHashTableIter iface_iter;
  GDBusInterfaceSkeleton *iface;
  GError *error;

  g_return_if_fail (manager->priv->connection != NULL);

  error = NULL;
  g_warn_if_fail (manager->priv->manager_reg_id == 0);
  manager->priv->manager_reg_id = g_dbus_connection_register_object (manager->priv->connection,
                                                                     manager->priv->object_path,
                                                                     (GDBusInterfaceInfo *) &manager_interface_info,
                                                                     &manager_interface_vtable,
                                                                     manager,
                                                                     NULL, /* user_data_free_func */
                                                                     &error);
  if (manager->priv->manager_reg_id == 0)
    {
      g_warning ("%s: Error registering manager at %s: %s",
                 G_STRLOC,
                 manager->priv->object_path,
                 error->message);
      g_error_free (error);
    }

  g_hash_table_iter_init (&iter, manager->priv->map_object_path_to_data);
  while (g_hash_table_iter_next (&iter, (gpointer) &object_path, (gpointer) &data))
    {
      g_hash_table_iter_init (&iface_iter, data->map_iface_name_to_iface);
      while (g_hash_table_iter_next (&iface_iter, NULL, (gpointer) &iface))
        {
          g_warn_if_fail (g_dbus_interface_skeleton_get_connection (iface) == NULL);
          error = NULL;
          if (!g_dbus_interface_skeleton_export (iface,
                                                 manager->priv->connection,
                                                 object_path,
                                                 &error))
            {
              g_warning ("%s: Error registering object at %s with interface %s: %s",
                         G_STRLOC,
                         object_path,
                         g_dbus_interface_skeleton_get_info (iface)->name,
                         error->message);
              g_error_free (error);
            }
        }
    }
}
Exemplo n.º 24
0
static void
bus_acquired_cb (GDBusConnection *connection,
                 const char *name,
                 gpointer user_data)
{
	static const char dbus_introspection_xml[] =
	    "<node name='/org/mate/Terminal'>"
	    "<interface name='org.mate.Terminal.Factory'>"
	    "<method name='HandleArguments'>"
	    "<arg type='ay' name='working_directory' direction='in' />"
	    "<arg type='ay' name='display_name' direction='in' />"
	    "<arg type='ay' name='startup_id' direction='in' />"
	    "<arg type='ay' name='environment' direction='in' />"
        "<arg type='i' name='workspace' direction='in' />"        
	    "<arg type='ay' name='arguments' direction='in' />"
	    "</method>"
	    "</interface>"
	    "</node>";

	static const GDBusInterfaceVTable interface_vtable =
	{
		method_call_cb,
		NULL,
		NULL,
	};

	OwnData *data = (OwnData *) user_data;
	GDBusNodeInfo *introspection_data;
	guint registration_id;
	GError *error = NULL;

	_terminal_debug_print (TERMINAL_DEBUG_FACTORY,
	                       "Bus %s acquired\n", name);

	introspection_data = g_dbus_node_info_new_for_xml (dbus_introspection_xml, NULL);
	g_assert (introspection_data != NULL);

	registration_id = g_dbus_connection_register_object (connection,
	                  TERMINAL_FACTORY_SERVICE_PATH,
	                  introspection_data->interfaces[0],
	                  &interface_vtable,
	                  NULL, NULL,
	                  &error);
	g_dbus_node_info_unref (introspection_data);

	if (registration_id == 0)
	{
		g_printerr ("Failed to register object: %s\n", error->message);
		g_error_free (error);
		data->exit_code = EXIT_FAILURE;
		gtk_main_quit ();
	}
}
Exemplo n.º 25
0
static void
on_bus_acquired (GObject      *source_object,
                 GAsyncResult *result,
                 gpointer      user_data)
{
  MexMprisPlugin *self = user_data;
  MexMprisPluginPrivate *priv = MEX_MPRIS_PLUGIN (self)->priv;
  GError *error = NULL;

  priv->connection = g_bus_get_finish (result, &error);
  if (error)
    {
      g_warning ("Could not acquire bus connection: %s", error->message);
      g_error_free (error);
      return;
    }

  /* Note: Dbus object and name subject to change */
  g_dbus_connection_register_object (priv->connection,
                                     MPRIS_OBJECT_NAME,
                                     priv->introspection_data->interfaces[0],
                                     &root_interface_table,
                                     self,
                                     NULL,
                                     &error);

  g_dbus_connection_register_object (priv->connection,
                                     MPRIS_OBJECT_NAME,
                                     priv->introspection_data->interfaces[1],
                                     &player_interface_table,
                                     self,
                                     NULL,
                                     &error);

  if (error)
    {
      g_warning ("Problem registering object: %s", error->message);
      g_error_free (error);
    }
}
Exemplo n.º 26
0
Arquivo: dbus.c Projeto: Toqozz/yarn-c
static void
on_bus_acquired (GDBusConnection *connection,
                 const gchar *name,
                 gpointer user_data)
{
    //guint registration_id;
    //registration_id = 
    g_dbus_connection_register_object(connection,
                                      "/org/freedesktop/Notifications",
                                      introspection_data->interfaces[0],
                                      &interface_vtable,
                                      NULL, NULL, NULL);
}
Exemplo n.º 27
0
static void on_bus_acquired(GDBusConnection *connection,
			    const gchar *name,
			    gpointer user_data)
{
	guint registration_id;

	registration_id = g_dbus_connection_register_object
		(connection, ObjPath, introspection_data->interfaces[0],
		 &interface_vtable, NULL, NULL, NULL);
	g_assert(registration_id > 0);

	printf("bus acquired: %d\n", registration_id);
}
Exemplo n.º 28
0
guint steadyflow_iapp_service_register_object (gpointer object, GDBusConnection* connection, const gchar* path, GError** error) {
	guint result;
	gpointer *data;
	data = g_new (gpointer, 3);
	data[0] = g_object_ref (object);
	data[1] = g_object_ref (connection);
	data[2] = g_strdup (path);
	result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_steadyflow_iapp_service_dbus_interface_info), &_steadyflow_iapp_service_dbus_interface_vtable, data, _steadyflow_iapp_service_unregister_object, error);
	if (!result) {
		return 0;
	}
	return result;
}
Exemplo n.º 29
0
static void _on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
{
  dt_dbus_t *dbus = (dt_dbus_t *)user_data;

  dbus->registration_id
      = g_dbus_connection_register_object(connection, "/darktable", dbus->introspection_data->interfaces[0],
                                          &interface_vtable, dbus, /* user_data */
                                          NULL,                    /* user_data_free_func */
                                          NULL);                   /* GError** */

  if(dbus->registration_id == 0)
    dbus->connected
        = 0; // technically we are connected, but we are not exporting anything. or something like that
}
AutomotiveManager::AutomotiveManager(GDBusConnection *connection)
	:mConnection(connection)
{
	GError* error = NULL;

	GDBusNodeInfo* introspection = g_dbus_node_info_new_for_xml(introspection_xml, &error);
	GDBusInterfaceInfo* mInterfaceInfo = g_dbus_node_info_lookup_interface(introspection, "org.automotive.Manager");

	regId = g_dbus_connection_register_object(mConnection, "/", mInterfaceInfo, &interfaceVTable, this, NULL, &error);

	if(error) throw -1;

	g_assert(regId > 0);
}