Esempio n. 1
0
static gboolean
initable_init (GInitable *initable,
               GCancellable *cancellable,
               GError **error)
{
    MMManagerPrivate *priv = MM_MANAGER (initable)->priv;

    /* Create plugin manager */
    priv->plugin_manager = mm_plugin_manager_new (error);
    if (!priv->plugin_manager)
        return FALSE;

    /* Export the manager interface */
    if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (initable),
                                           priv->connection,
                                           MM_DBUS_PATH,
                                           error))
        return FALSE;

    /* Export the Object Manager interface */
    g_dbus_object_manager_server_set_connection (priv->object_manager,
                                                 priv->connection);

    /* All good */
    return TRUE;
}
Esempio n. 2
0
static void
on_bus_acquired (GDBusConnection *connection,
    const gchar *name,
    gpointer user_data)
{
  TcmmdDbus *self = user_data;
  GError *error = NULL;

  self->priv->connection = g_object_ref (connection);

  self->priv->iface = tcmmd_managed_connections_skeleton_new ();
  g_signal_connect (self->priv->iface, "handle-set-policy",
                    G_CALLBACK (handle_set_policy_cb), self);
  g_signal_connect (self->priv->iface, "handle-set-fixed-policy",
                    G_CALLBACK (handle_set_fixed_policy_cb), self);
  g_signal_connect (self->priv->iface, "handle-unset-policy",
                    G_CALLBACK (handle_unset_policy_cb), self);

  if (!g_dbus_interface_skeleton_export (
          G_DBUS_INTERFACE_SKELETON (self->priv->iface),
          self->priv->connection,
          "/org/tcmmd/ManagedConnections", &error))
    {
      g_critical ("Failed to export iface: %s", error->message);
      g_clear_error (&error);
    }
}
Esempio n. 3
0
static gboolean
register_factory (GdmLocalDisplayFactory *factory)
{
        GError *error = NULL;

        error = NULL;
        factory->priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
        if (factory->priv->connection == NULL) {
                g_critical ("error getting system bus: %s", error->message);
                g_error_free (error);
                exit (1);
        }

        factory->priv->skeleton = GDM_DBUS_LOCAL_DISPLAY_FACTORY (gdm_dbus_local_display_factory_skeleton_new ());

        g_signal_connect (factory->priv->skeleton,
                          "handle-create-transient-display",
                          G_CALLBACK (handle_create_transient_display),
                          factory);

        if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (factory->priv->skeleton),
                                               factory->priv->connection,
                                               GDM_LOCAL_DISPLAY_FACTORY_DBUS_PATH,
                                               &error)) {
                g_critical ("error exporting LocalDisplayFactory object: %s", error->message);
                g_error_free (error);
                exit (1);
        }

        return TRUE;
}
static void
gkd_secret_objects_register_item (GkdSecretObjects *self,
				  const gchar *item_path)
{
	GkdExportedItem *skeleton;
	GError *error = NULL;

	skeleton = g_hash_table_lookup (self->items_to_skeletons, item_path);
	if (skeleton != NULL) {
		g_warning ("asked to register item %s, but it's already registered", item_path);
		return;
	}

	skeleton = gkd_secret_item_skeleton_new (self);
	g_hash_table_insert (self->items_to_skeletons, g_strdup (item_path), skeleton);

	g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton),
					  gkd_secret_service_get_connection (self->service),
					  item_path, &error);
	if (error != NULL) {
		g_warning ("could not register secret item on session bus: %s", error->message);
		g_error_free (error);
	}

	g_signal_connect (skeleton, "handle-delete",
			  G_CALLBACK (item_method_delete), self);
	g_signal_connect (skeleton, "handle-get-secret",
			  G_CALLBACK (item_method_get_secret), self);
	g_signal_connect (skeleton, "handle-set-secret",
			  G_CALLBACK (item_method_set_secret), self);
}
void
gkd_secret_objects_register_collection (GkdSecretObjects *self,
					const gchar *collection_path)
{
	GkdExportedCollection *skeleton;
	GError *error = NULL;

	skeleton = g_hash_table_lookup (self->collections_to_skeletons, collection_path);
	if (skeleton != NULL) {
		g_warning ("asked to register collection %s, but it's already registered", collection_path);
		return;
	}

	skeleton = gkd_secret_collection_skeleton_new (self);
	g_hash_table_insert (self->collections_to_skeletons, g_strdup (collection_path), skeleton);

	g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton),
					  gkd_secret_service_get_connection (self->service),
					  collection_path, &error);
	if (error != NULL) {
		g_warning ("could not register secret collection on session bus: %s", error->message);
		g_error_free (error);
	}

	g_signal_connect (skeleton, "handle-create-item",
			  G_CALLBACK (collection_method_create_item), self);
	g_signal_connect (skeleton, "handle-delete",
			  G_CALLBACK (collection_method_delete), self);
	g_signal_connect (skeleton, "handle-search-items",
			  G_CALLBACK (collection_method_search_items), self);

	gkd_secret_objects_init_collection_items (self, collection_path);
}
Esempio n. 6
0
void bus_acquired (GObject *object,
                   GAsyncResult * res,
                   gpointer user_data)
{
  //g_debug("bus acquired");
  GDBusConnection *bus;
  GError *error = NULL;
  bus = g_bus_get_finish (res, &error);
  if (!bus) {
    //g_warning ("unable to connect to the session bus: %s", error->message);
    g_error_free (error);
    return;
  }
  g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (autopilot_introspection),
                                    bus,
                                    AUTOPILOT_INTROSPECTION_OBJECT_PATH.c_str(),
                                    &error);
  if (error) {
    //g_warning ("unable to export autopilot introspection service on dbus: %s", error->message);
    g_error_free (error);
    return;
  }
  g_signal_connect (autopilot_introspection,
                    "handle-get-state",
                    G_CALLBACK(handle_get_state),
                    NULL);
  g_signal_connect (autopilot_introspection,
                    "handle-get-version",
                    G_CALLBACK(handle_get_version),
                    NULL);
  g_object_unref (bus);
}
Esempio n. 7
0
static void
on_bus_acquired (GDBusConnection *connection,
                 const gchar     *name,
                 gpointer         user_data)
{
  GError *error = NULL;

  g_debug ("Bus acquired, creating skeleton");

  helper = flatpak_system_helper_skeleton_new ();

  g_object_set_data_full (G_OBJECT(helper), "track-alive", GINT_TO_POINTER(42), skeleton_died_cb);

  g_dbus_interface_skeleton_set_flags (G_DBUS_INTERFACE_SKELETON (helper),
                                       G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD);

  g_signal_connect (helper, "handle-deploy", G_CALLBACK (handle_deploy), NULL);
  g_signal_connect (helper, "handle-deploy-appstream", G_CALLBACK (handle_deploy_appstream), NULL);
  g_signal_connect (helper, "handle-uninstall", G_CALLBACK (handle_uninstall), NULL);
  g_signal_connect (helper, "handle-install-bundle", G_CALLBACK (handle_install_bundle), NULL);
  g_signal_connect (helper, "handle-configure-remote", G_CALLBACK (handle_configure_remote), NULL);

  g_signal_connect (helper, "g-authorize-method",
                    G_CALLBACK (flatpak_authorize_method_handler),
                    NULL);

  if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (helper),
                                         connection,
                                         "/org/freedesktop/Flatpak/SystemHelper",
                                         &error))
    {
      g_warning ("error: %s\n", error->message);
      g_error_free (error);
    }
}
Esempio n. 8
0
static void
on_bus_acquired (GDBusConnection *connection,
                 const gchar     *name,
                 gpointer         user_data)
{
  XdpDbusDocuments *helper;
  GError *error = NULL;

  helper = xdp_dbus_documents_skeleton_new ();

  g_signal_connect_swapped (helper, "handle-get-mount-point", G_CALLBACK (handle_get_mount_point), NULL);
  g_signal_connect_swapped (helper, "handle-add", G_CALLBACK (handle_method), portal_add);
  g_signal_connect_swapped (helper, "handle-add-named", G_CALLBACK (handle_method), portal_add_named);
  g_signal_connect_swapped (helper, "handle-grant-permissions", G_CALLBACK (handle_method), portal_grant_permissions);
  g_signal_connect_swapped (helper, "handle-revoke-permissions", G_CALLBACK (handle_method), portal_revoke_permissions);
  g_signal_connect_swapped (helper, "handle-delete", G_CALLBACK (handle_method), portal_delete);

  xdg_app_connection_track_name_owners (connection);

  if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (helper),
                                         connection,
                                         "/org/freedesktop/portal/documents",
                                         &error))
    {
      g_warning ("error: %s", error->message);
      g_error_free (error);
    }
}
Esempio n. 9
0
static void on_bus_acquired(GDBusConnection *bus,
                            const gchar *name,
                            gpointer user_data)
{
	LoginKitManager *interface;
	GError *error = NULL;

	interface = login_kit_manager_skeleton_new();
	g_signal_connect(interface,
	                 "handle-unlock-session",
	                 G_CALLBACK(on_handle_unlock_session),
	                 NULL);
	g_signal_connect(interface,
	                 "handle-list-seats",
	                 G_CALLBACK(on_handle_list_seats),
	                 NULL);
	g_signal_connect(interface,
	                 "handle-activate-session-on-seat",
	                 G_CALLBACK(on_handle_activate_session_on_seat),
	                 NULL);

	signals_subscribe(interface);

	if (!g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(interface),
	                                      bus,
	                                      "/org/freedesktop/login1",
	                                      &error)) {
		if (NULL != error)
			g_error_free(error);
	}
}
static void bus_acquired_cb(GDBusConnection *connection, const gchar *name, gpointer user_data)
{
	GError *error = NULL;
	connman_agent_t *agent = user_data;

	agent->path = g_strdup(AGENT_DBUS_PATH);
	agent->interface = connman_interface_agent_skeleton_new();

	g_signal_connect(agent->interface, "handle-request-input", G_CALLBACK(request_input_cb), agent);
	g_signal_connect(agent->interface, "handle-report-error", G_CALLBACK(report_error_cb), agent);

	error = NULL;
	if (!g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(agent->interface), connection,
										  agent->path, &error))
	{
		g_error("Could not export agent object: %s", error->message);
		g_error_free(error);
	}

	if (agent->registered_cb != NULL) {
		agent->registered_cb(agent->registered_data);
	}

	g_message("Agent successfully exported");
}
Esempio n. 11
0
/**
 * bus_acquired_cb - handler to invoke when connected to the bus 
 *                   of type bus_type or NULL.
 *
 * @connection: The GDBusConnection to a message bus
 * @bus_name  : The name that is requested to be owned
 * @user_data :
 *
 * returns:
 *     void
 *
 */
static void
bus_acquired_cb(GDBusConnection *connection,
                                const gchar     *bus_name,
                                gpointer        user_data)
{

  GError *pError = NULL;
  gchar *obj_path = user_data;

  INFO_LOG ("bus_acquired_cb ,Acquired session bus.\n");

  /** Second step: Try to get a connection to the given bus. */
  pSkeleton = gdbus_mcuinfo_skeleton_new();

  /** Third step: Attach to dbus signals. */
  (void) g_signal_connect(pSkeleton, "handle-send-mcuinfo", G_CALLBACK(method_send_mcuinfo), NULL);

  /** Fourth step: Export interface skeleton. */
  (void) g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(pSkeleton),
                                            connection,
                                            obj_path,//AUTOLINK_GDBUS_BUS_OBJECT_PATH,
                                            &pError);
  if(pError != NULL){
    ERR_LOG ("bus_acquired_cb: Failed to export object. Reason: %s.\n", pError->message);
    g_error_free(pError);
    g_main_loop_quit(mainloop);
  }

}
Esempio n. 12
0
static void
nemo_dbus_manager_init (NemoDBusManager *self)
{
  GDBusConnection *connection;

  connection = g_application_get_dbus_connection (g_application_get_default ());

  self->object_manager = g_dbus_object_manager_server_new ("/org/Nemo");
  self->file_operations = nemo_dbus_file_operations_skeleton_new ();

  g_signal_connect (self->file_operations,
		    "handle-copy-uris",
		    G_CALLBACK (handle_copy_uris),
		    self);
  g_signal_connect (self->file_operations,
		    "handle-copy-file",
		    G_CALLBACK (handle_copy_file),
		    self);
  g_signal_connect (self->file_operations,
		    "handle-empty-trash",
		    G_CALLBACK (handle_empty_trash),
		    self);

  g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->file_operations), connection,
				    "/org/Nemo", NULL);

  g_dbus_object_manager_server_set_connection (self->object_manager, connection);
}
gboolean
screenshot_init (GDBusConnection *bus,
                 GError **error)
{
  GDBusInterfaceSkeleton *helper;

  helper = G_DBUS_INTERFACE_SKELETON (xdp_impl_screenshot_skeleton_new ());

  g_signal_connect (helper, "handle-screenshot", G_CALLBACK (handle_screenshot), NULL);

  if (!g_dbus_interface_skeleton_export (helper,
                                         bus,
                                         DESKTOP_PORTAL_OBJECT_PATH,
                                         error))
    return FALSE;

  shell = org_gnome_shell_screenshot_proxy_new_sync (bus,
                                                     G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
                                                     "org.gnome.Shell.Screenshot",
                                                     "/org/gnome/Shell/Screenshot",
                                                     NULL,
                                                     error);
  if (shell == NULL)
    return FALSE;

  g_debug ("providing %s", g_dbus_interface_skeleton_get_info (helper)->name);

  return TRUE;
}
Esempio n. 14
0
static gboolean
gom_application_dbus_register (GApplication *application,
                               GDBusConnection *connection,
                               const gchar *object_path,
                               GError **error)
{
  GomApplication *self = GOM_APPLICATION (application);
  gboolean retval = FALSE;

  if (!G_APPLICATION_CLASS (gom_application_parent_class)->dbus_register (application,
                                                                          connection,
                                                                          object_path,
                                                                          error))
    goto out;

  if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->skeleton),
                                         connection,
                                         object_path,
                                         error))
    goto out;

  retval = TRUE;

 out:
  return retval;
}
Esempio n. 15
0
/**
 * @user_data: daemon itself
 */
static void 
_on_bus_acquired (GDBusConnection *connection,
                  const gchar     *name,
                  gpointer         user_data)
{
    RatdbProxyEngine *skeleton;
    GError *error = NULL;
    RatdbDaemonPrivate *priv = RATDB_DAEMON (user_data)->priv;

    g_debug ("Bus acquired");

    /* /org/ratdb/Interface */
    skeleton = ratdb_proxy_engine_skeleton_new ();
    if (error)
    {
        g_error (_("Couldn't create a skeleton for clients: %s"), error->message);
        g_error_free (error);
    }

    g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton), 
                                      connection, "/org/ratdb/Interface", &error);
    if (error)
    {
        g_error (_("Failed to export symbols: %s"), error->message);
        g_error_free (error);
    }

    /* handle functions */
    RATDB_CONNECT_DBUS_IFACE (request, ratdb_dbus_handler, priv->client_list);
    RATDB_CONNECT_DBUS_IFACE (remove_client, ratdb_dbus_handler, user_data);
    RATDB_CONNECT_DBUS_IFACE (new_database, ratdb_dbus_handler, user_data);
    RATDB_CONNECT_DBUS_IFACE (new_table, ratdb_dbus_handler, user_data);
}
Esempio n. 16
0
static void
on_bus_acquired (GDBusConnection *connection,
                 const gchar     *name,
                 gpointer         user_data)
{
  XdpDbusContentPortal *helper;
  GError *error = NULL;

  helper = xdp_dbus_content_portal_skeleton_new ();

  g_signal_connect (helper, "handle-open",
                    G_CALLBACK (handle_open), NULL);

  g_signal_connect (helper, "handle-create",
                    G_CALLBACK (handle_create), NULL);

  xdp_connection_track_name_owners (connection);

  if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (helper),
                                         connection,
                                         "/org/freedesktop/portal/content",
                                         &error))
    {
      g_warning ("error: %s\n", error->message);
      g_error_free (error);
    }
}
Esempio n. 17
0
static gboolean
initable_init (GInitable *initable,
               GCancellable *cancellable,
               GError **error)
{
    MMBaseManagerPrivate *priv = MM_BASE_MANAGER (initable)->priv;

    /* If autoscan enabled, list for udev events */
    if (priv->auto_scan)
        g_signal_connect (priv->udev, "uevent", G_CALLBACK (handle_uevent), initable);

    /* Create plugin manager */
    priv->plugin_manager = mm_plugin_manager_new (priv->plugin_dir, error);
    if (!priv->plugin_manager)
        return FALSE;

    /* Export the manager interface */
    if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (initable),
                                           priv->connection,
                                           MM_DBUS_PATH,
                                           error))
        return FALSE;

    /* Export the Object Manager interface */
    g_dbus_object_manager_server_set_connection (priv->object_manager,
                                                 priv->connection);

    /* Setup the Test skeleton and export the interface */
    if (priv->enable_test) {
        priv->test_skeleton = mm_gdbus_test_skeleton_new ();
        g_signal_connect (priv->test_skeleton,
                          "handle-set-profile",
                          G_CALLBACK (handle_set_profile),
                          initable);
        if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (priv->test_skeleton),
                                               priv->connection,
                                               MM_DBUS_PATH,
                                               error))
            return FALSE;
    }

    /* All good */
    return TRUE;
}
Esempio n. 18
0
static gboolean
photos_thumbnailer_dbus_register (GApplication *application,
                                  GDBusConnection *connection,
                                  const gchar *object_path,
                                  GError **error)
{
  PhotosThumbnailer *self = PHOTOS_THUMBNAILER (application);
  g_autoptr (GDBusAuthObserver) observer = NULL;
  gboolean ret_val = FALSE;

  g_return_val_if_fail (self->skeleton == NULL, FALSE);

  if (!G_APPLICATION_CLASS (photos_thumbnailer_parent_class)->dbus_register (application,
                                                                             connection,
                                                                             object_path,
                                                                             error))
    goto out;

  observer = g_dbus_auth_observer_new ();
  g_signal_connect_swapped (observer,
                            "authorize-authenticated-peer",
                            G_CALLBACK (photos_thumbnailer_authorize_authenticated_peer),
                            self);

  self->connection = g_dbus_connection_new_for_address_sync (self->address,
                                                             G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
                                                             observer,
                                                             NULL,
                                                             error);
  if (self->connection == NULL)
    goto out;

  self->skeleton = photos_thumbnailer_dbus_skeleton_new ();
  g_signal_connect_swapped (self->skeleton,
                            "handle-cancel",
                            G_CALLBACK (photos_thumbnailer_handle_cancel),
                            self);
  g_signal_connect_swapped (self->skeleton,
                            "handle-generate-thumbnail",
                            G_CALLBACK (photos_thumbnailer_handle_generate_thumbnail),
                            self);

  if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->skeleton),
                                         self->connection,
                                         THUMBNAILER_PATH,
                                         error))
    {
      g_clear_object (&self->skeleton);
      goto out;
    }

  ret_val = TRUE;

 out:
  return ret_val;
}
Esempio n. 19
0
static void __bt_telephony_gdbus_init(void)
{
	GDBusConnection *g_conn;
	GError *g_err = NULL;
	BT_DBG("+");

	ret_if(bluetooth_telephony_obj != NULL);

	g_conn = _bt_init_system_gdbus_conn();
	ret_if(g_conn == NULL);

	bluetooth_telephony_obj = org_tizen_csd_call_instance_skeleton_new();

	g_signal_connect(bluetooth_telephony_obj,
			"handle-answer",
			G_CALLBACK(bluetooth_telephony_method_answer),
			NULL);

	g_signal_connect(bluetooth_telephony_obj,
			"handle-release",
			G_CALLBACK(bluetooth_telephony_method_release),
			NULL);

	g_signal_connect(bluetooth_telephony_obj,
			"handle-reject",
			G_CALLBACK(bluetooth_telephony_method_reject),
			NULL);

	g_signal_connect(bluetooth_telephony_obj,
			"handle-threeway",
			G_CALLBACK(bluetooth_telephony_method_threeway),
			NULL);

	g_signal_connect(bluetooth_telephony_obj,
			"handle-send-dtmf",
			G_CALLBACK(bluetooth_telephony_method_send_dtmf),
			NULL);

	if (g_dbus_interface_skeleton_export(
			G_DBUS_INTERFACE_SKELETON(bluetooth_telephony_obj),
			g_conn,
			"/",
			&g_err) == FALSE) {
			if (g_err) {
				BT_ERR("Export error: %s", g_err->message);
				g_clear_error(&g_err);
			}
			g_object_unref(bluetooth_telephony_obj);
			bluetooth_telephony_obj = NULL;
			g_dbus_connection_close_sync(gdbus_conn, NULL, NULL);
			gdbus_conn = NULL;
			return;
	}
	gdbus_conn = g_conn;
	BT_DBG("-");
}
gboolean
gcal_shell_search_provider_dbus_export (GcalShellSearchProvider *search_provider,
                                        GDBusConnection         *connection,
                                        const gchar             *object_path,
                                        GError                 **error)
{
  GcalShellSearchProviderPrivate *priv = GCAL_SHELL_SEARCH_PROVIDER (search_provider)->priv;

  return g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (priv->skel), connection, object_path, error);
}
Esempio n. 21
0
gint
main (gint argc,
      gchar *argv[])
{
  g_autoptr(GDBusConnection) connection = NULL;
  g_autoptr(IpcGitService) service = NULL;
  g_autoptr(GOutputStream) stdout_stream = NULL;
  g_autoptr(GInputStream) stdin_stream = NULL;
  g_autoptr(GIOStream) stream = NULL;
  g_autoptr(GMainLoop) main_loop = NULL;
  g_autoptr(GError) error = NULL;

  g_set_prgname ("gnome-builder-git");
  g_set_application_name ("gnome-builder-git");

  prctl (PR_SET_PDEATHSIG, SIGTERM);

  signal (SIGPIPE, SIG_IGN);

  ggit_init ();

  g_log_set_handler (NULL, G_LOG_LEVEL_MASK, log_func, NULL);

  if (!g_unix_set_fd_nonblocking (STDIN_FILENO, TRUE, &error) ||
      !g_unix_set_fd_nonblocking (STDOUT_FILENO, TRUE, &error))
    goto error;

  main_loop = g_main_loop_new (NULL, FALSE);
  stdin_stream = g_unix_input_stream_new (STDIN_FILENO, FALSE);
  stdout_stream = g_unix_output_stream_new (STDOUT_FILENO, FALSE);
  stream = g_simple_io_stream_new (stdin_stream, stdout_stream);

  if (!(connection = create_connection (stream, main_loop, &error)))
    goto error;

  service = ipc_git_service_impl_new ();

  if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (service),
                                         connection,
                                         "/org/gnome/Builder/Git",
                                         &error))
    goto error;

  g_dbus_connection_start_message_processing (connection);
  g_main_loop_run (main_loop);

  return EXIT_SUCCESS;

error:
  if (error != NULL)
    g_printerr ("%s\n", error->message);

  return EXIT_FAILURE;
}
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);
            }
        }
    }
}
Esempio n. 23
0
static void
on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
{
    vinay245BusGDBUS *interface;
    GError *error;

    interface = vinay245_bus_gdbus_skeleton_new();
    g_print(" Client ==== Acquired Bus on Vinay245 ");
    g_signal_connect (interface, "handle-hello-client", G_CALLBACK (on_handle_hello_world), NULL);
    error = NULL;
    !g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (interface), connection, "/com/vinay245/GDBUS", &error);
}
Esempio n. 24
0
static void
on_bus_acquired (GDBusConnection *connection,
                 const char      *name,
                 gpointer         user_data)
{
  MetaMonitorManager *manager = user_data;

  g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (manager),
                                    connection,
                                    "/org/gnome/Mutter/DisplayConfig",
                                    NULL);
}
/**
 * la_handler_service_start:
 * @service: A #LAHandlerService.
 * @error:   Return location for error or %NULL.
 * 
 * Makes @service export its #LAHandler interface so that it is available to the
 * #legacy-app-handler helper binary.
 * 
 * Returns: %TRUE if the interface was exported successfully, otherwise %FALSE with @error
 * set.
 */
gboolean
la_handler_service_start (LAHandlerService *service,
                           GError         **error)
{
  g_return_val_if_fail (LA_HANDLER_IS_SERVICE (service), FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  /* announce the org.genivi.NodeStartupController1.LegacyAppHandler service on the bus */
  return g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (service->interface),
                                           service->connection,
                                           "/org/genivi/NodeStartupController1/LegacyAppHandler",
                                           error);
}
Esempio n. 26
0
/**
 * Initialize GATT characteristic fields.
 *
 * This function initializes the @c CAGattCharacteristic object fields.
 *
 * @param[out] c                   GATT characteristic information to
 *                                 be initialized.
 * @param[in]  context             Object containing the D-Bus
 *                                 connection to the bus on which the
 *                                 characteristic will be exported, as
 *                                 well as the list of connected
 *                                 devices.
 * @param[in]  s                   Information about GATT service
 *                                 to which the characteristic
 *                                 belongs.
 * @param[in]  characteristic_path @c GattCharacteristic1 object
 *                                 path.
 * @param[in]  uuid                GATT characteristic UUID.
 * @param[in]  flag                GATT characteristic property flag,
 *                                 i.e. @c "write-without-response"
 *                                 for the request characteristic, and
 *                                 @c "notify" for the response
 *                                 characteristic.
 *
 * @note This function does not allocate the @a characteristic object
 *       itself.  The caller is responsible for allocating that
 *       memory.
 *
 * @todo Too many parameters.  Perhaps pass in a pointer to a struct
 *       instead.
 */
static bool CAGattCharacteristicInitialize(
    CAGattCharacteristic * c,
    CALEContext * context,
    CAGattService * s,
    char const * characteristic_path,
    char const * uuid,
    char const * flag)
{
    // Path of the form /org/iotivity/gatt/hci0/service0/char0.
    c->object_path =
        g_strdup_printf("%s/%s", s->object_path, characteristic_path);

    assert(g_variant_is_object_path(c->object_path));

    c->context = context;
    c->service = s;

    c->characteristic = gatt_characteristic1_skeleton_new();

    gatt_characteristic1_set_uuid(c->characteristic, uuid);
    gatt_characteristic1_set_service(c->characteristic, s->object_path);
    gatt_characteristic1_set_notifying(c->characteristic, FALSE);

    char const * flags[] = { flag, NULL };
    gatt_characteristic1_set_flags(c->characteristic, flags);

    CAGattRecvInfoInitialize(&c->recv_info);

    // Export the characteristic interface on the bus.
    GError * error = NULL;
    if (!g_dbus_interface_skeleton_export(
            G_DBUS_INTERFACE_SKELETON(c->characteristic),
            context->connection,
            c->object_path,
            &error))
    {
        CAGattCharacteristicDestroy(c);

        OIC_LOG_V(ERROR,
                  TAG,
                  "Unable to export D-Bus GATT characteristic "
                  "interface: %s",
                  error->message);

        g_error_free(error);

        return false;
    }

    return true;
}
Esempio n. 27
0
/*
** DBus event: Manager bus acquired
**  - Export manager interface
**  - Bind manager interface methods
**  - Create manager service file
*/
static void on_bus_acquired(GDBusConnection *conn,
                            const gchar *name,
                            gpointer user_data)
{
    WarfacebotMngr *wbm = NULL;
    WarfacebotMngrIface *iface = NULL;
    GError *error = NULL;
    gboolean ret = FALSE;

    g_print ("Manager acquired message bus %s\n", name);

    create_service_file(API_MNGR_NAME, NULL, NULL);

    /* Create Manager */

    connection = conn;
    manager = g_dbus_object_manager_server_new(API_MNGR_PATH);

    g_dbus_object_manager_server_set_connection(manager, connection);

    /* Create Custom Interface */

    wbm = warfacebot_mngr_skeleton_new();

    iface = WARFACEBOT_MNGR_GET_IFACE (wbm);

    iface->handle_create = on_handle_create;
    iface->handle_quit = on_handle_quit;
    iface->handle_instance_exit = on_handle_instance_exit;
    iface->handle_instance_ready = on_handle_instance_ready;

    ret = g_dbus_interface_skeleton_export(
        G_DBUS_INTERFACE_SKELETON (wbm),
        connection,
        API_MNGR_PATH,
        &error);

    if (ret == FALSE)
    {
        g_warning(error->message);
        return;
    }

    g_print("Manager interface exported\n");
}
NMSstpPlugin *
nm_sstp_plugin_new (const char *bus_name)
{
	NMSstpPlugin *plugin;
	NMSstpPluginPrivate *priv;
	GDBusConnection *bus;
	GError *error = NULL;

	plugin = (NMSstpPlugin *) g_initable_new (NM_TYPE_SSTP_PLUGIN, NULL, &error,
	                                          NM_VPN_SERVICE_PLUGIN_DBUS_SERVICE_NAME, bus_name,
	                                          NM_VPN_SERVICE_PLUGIN_DBUS_WATCH_PEER, !debug,
	                                          NULL);
	if (plugin) {
		g_signal_connect (G_OBJECT (plugin), "state-changed", G_CALLBACK (state_changed_cb), NULL);
	} else {
		g_warning ("Failed to initialize a plugin instance: %s", error->message);
		g_error_free (error);
	}

	bus = nm_vpn_service_plugin_get_connection (NM_VPN_SERVICE_PLUGIN (plugin)),
	priv = NM_SSTP_PLUGIN_GET_PRIVATE (plugin);
	priv->dbus_skeleton = nmdbus_sstp_ppp_skeleton_new ();
	if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (priv->dbus_skeleton),
	                                       bus,
	                                       NM_DBUS_PATH_SSTP_PPP,
	                                       &error)) {
		g_warning ("Failed to export helper interface: %s", error->message);
		g_error_free (error);
		g_clear_object (&plugin);
		goto out;
	}

	g_dbus_connection_register_object (bus, NM_DBUS_PATH_SSTP_PPP,
	                                   nmdbus_sstp_ppp_interface_info (),
	                                   NULL, NULL, NULL, NULL);

	g_signal_connect (priv->dbus_skeleton, "handle-need-secrets", G_CALLBACK (handle_need_secrets), plugin);
	g_signal_connect (priv->dbus_skeleton, "handle-set-state", G_CALLBACK (handle_set_state), plugin);
	g_signal_connect (priv->dbus_skeleton, "handle-set-ip4-config", G_CALLBACK (handle_set_ip4_config), plugin);

out:
	g_clear_object (&bus);
	return plugin;
}
static void
registration_data_export_interface (RegistrationData        *data,
                                    GDBusInterfaceSkeleton  *interface_skeleton)
{
  GDBusInterfaceInfo *info;
  GError *error;
  const gchar *object_path;

  object_path = g_dbus_object_get_object_path (G_DBUS_OBJECT (data->object));

  info = g_dbus_interface_skeleton_get_info (interface_skeleton);
  error = NULL;
  if (data->manager->priv->connection != NULL)
    {
      if (!g_dbus_interface_skeleton_export (interface_skeleton,
                                             data->manager->priv->connection,
                                             object_path,
                                             &error))
        {
          g_warning ("%s: Error registering object at %s with interface %s: %s",
                     G_STRLOC,
                     object_path,
                     info->name,
                     error->message);
          g_error_free (error);
        }
    }

  g_assert (g_hash_table_lookup (data->map_iface_name_to_iface, info->name) == NULL);
  g_hash_table_insert (data->map_iface_name_to_iface,
                       info->name,
                       g_object_ref (interface_skeleton));

  /* if we are already exported, then... */
  if (data->exported)
    {
      const gchar *interfaces[2];
      /* emit InterfacesAdded on the ObjectManager object */
      interfaces[0] = info->name;
      interfaces[1] = NULL;
      g_dbus_object_manager_server_emit_interfaces_added (data->manager, data, interfaces);
    }
}
/*
 * Called when a reference to the system bus is acquired. This is where you are
 * supposed to export your well-known name, not in name_acquired; that is too
 * late.
 */
static void
on_bus_acquired (GDBusConnection *system_bus,
                 const gchar     *name,
                 gpointer         user_data)
{
  EmerDaemon *daemon = EMER_DAEMON (user_data);
  EmerEventRecorderServer *server = emer_event_recorder_server_skeleton_new ();

  g_signal_connect (server, "handle-record-singular-event",
                    G_CALLBACK (on_record_singular_event), daemon);
  g_signal_connect (server, "handle-record-aggregate-event",
                    G_CALLBACK (on_record_aggregate_event), daemon);
  g_signal_connect (server, "handle-record-event-sequence",
                    G_CALLBACK (on_record_event_sequence), daemon);
  g_signal_connect (server, "handle-set-enabled",
                    G_CALLBACK (on_set_enabled), daemon);
  g_signal_connect (server, "handle-upload-events",
                    G_CALLBACK (on_upload_events), daemon);
  g_signal_connect (server, "handle-reset-tracking-id",
                    G_CALLBACK (on_reset_tracking_id), daemon);
  g_signal_connect (server, "g-authorize-method",
                    G_CALLBACK (on_authorize_method_check), daemon);

  EmerPermissionsProvider *permissions =
    emer_daemon_get_permissions_provider (daemon);
  g_object_bind_property_full (permissions, "daemon-enabled", server, "enabled",
                               G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE,
                               sync_recorder_server_enabled_for_daemon, NULL,
                               daemon, NULL);
  g_object_bind_property_full (permissions, "uploading-enabled", server, "enabled",
                               G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE,
                               sync_recorder_server_enabled_for_upload, NULL,
                               daemon, NULL);

  GError *error = NULL;
  if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (server),
                                         system_bus,
                                         "/com/endlessm/Metrics",
                                         &error))
    g_error ("Could not export metrics interface on system bus: %s.",
             error->message);
}