~ubuntu-branches/ubuntu/wily/policykit-1/wily

« back to all changes in this revision

Viewing changes to src/polkitagent/polkitagentlistener.c

  • Committer: Steve Langasek
  • Date: 2012-11-05 07:17:25 UTC
  • mfrom: (22.1.1 sid)
  • Revision ID: steve.langasek@canonical.com-20121105071725-cw9ah4q015gjtr1o
Merge version 0.105-1 from Debian unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 * evidence that the user is one of the requested identities.
44
44
 *
45
45
 * To register a #PolkitAgentListener with the PolicyKit daemon, use
46
 
 * polkit_agent_listener_register().
 
46
 * polkit_agent_listener_register() or
 
47
 * polkit_agent_listener_register_with_options().
47
48
 */
48
49
 
49
50
typedef struct
62
63
 
63
64
  PolkitAgentListener *listener;
64
65
 
 
66
  GVariant *registration_options;
 
67
 
65
68
  PolkitSubject *subject;
66
69
  gchar *object_path;
67
70
 
104
107
  if (server->interface_info != NULL)
105
108
    g_dbus_interface_info_unref (server->interface_info);
106
109
 
 
110
  if (server->registration_options != NULL)
 
111
    g_variant_unref (server->registration_options);
 
112
 
107
113
  if (server->listener != NULL)
108
114
    g_object_unref (server->listener);
109
115
 
143
149
    locale = "en_US.UTF-8";
144
150
 
145
151
  local_error = NULL;
146
 
  if (!polkit_authority_register_authentication_agent_sync (server->authority,
147
 
                                                            server->subject,
148
 
                                                            locale,
149
 
                                                            server->object_path,
150
 
                                                            NULL,
151
 
                                                            &local_error))
 
152
  if (!polkit_authority_register_authentication_agent_with_options_sync (server->authority,
 
153
                                                                         server->subject,
 
154
                                                                         locale,
 
155
                                                                         server->object_path,
 
156
                                                                         server->registration_options,
 
157
                                                                         NULL,
 
158
                                                                         &local_error))
152
159
    {
153
160
      g_warning ("Unable to register authentication agent: %s", local_error->message);
154
161
      g_propagate_error (error, local_error);
360
367
}
361
368
 
362
369
/**
363
 
 * polkit_agent_listener_register:
 
370
 * polkit_agent_listener_register_with_options:
364
371
 * @listener: A #PolkitAgentListener.
365
372
 * @flags: A set of flags from the #PolkitAgentRegisterFlags enumeration.
366
373
 * @subject: The subject to become an authentication agent for, typically a #PolkitUnixSession object.
367
374
 * @object_path: The D-Bus object path to use for the authentication agent or %NULL for the default object path.
 
375
 * @options: (allow-none): A #GVariant with options or %NULL.
368
376
 * @cancellable: A #GCancellable or %NULL.
369
377
 * @error: Return location for error.
370
378
 *
371
 
 * Registers @listener with the PolicyKit daemon as an authentication
372
 
 * agent for @subject. This is implemented by registering a D-Bus
373
 
 * object at @object_path on the unique name assigned by the system
374
 
 * message bus.
375
 
 *
376
 
 * Whenever the PolicyKit daemon needs to authenticate a processes
377
 
 * that is related to @subject, the methods
378
 
 * polkit_agent_listener_initiate_authentication() and
379
 
 * polkit_agent_listener_initiate_authentication_finish() will be
380
 
 * invoked on @listener.
381
 
 *
382
 
 * Note that registration of an authentication agent can fail; for
383
 
 * example another authentication agent may already be registered for
384
 
 * @subject.
385
 
 *
386
 
 * Note that the calling thread is blocked until a reply is received.
 
379
 * Like polkit_agent_listener_register() but takes options to influence registration. See the
 
380
 * <link linkend="eggdbus-method-org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgentWithOptions">RegisterAuthenticationAgentWithOptions()</link> D-Bus method for details.
387
381
 *
388
382
 * Returns: (transfer full): %NULL if @error is set, otherwise a
389
383
 * registration handle that can be used with
390
384
 * polkit_agent_listener_unregister().
391
385
 */
392
386
gpointer
393
 
polkit_agent_listener_register (PolkitAgentListener      *listener,
394
 
                                PolkitAgentRegisterFlags  flags,
395
 
                                PolkitSubject            *subject,
396
 
                                const gchar              *object_path,
397
 
                                GCancellable             *cancellable,
398
 
                                GError                  **error)
 
387
polkit_agent_listener_register_with_options (PolkitAgentListener      *listener,
 
388
                                             PolkitAgentRegisterFlags  flags,
 
389
                                             PolkitSubject            *subject,
 
390
                                             const gchar              *object_path,
 
391
                                             GVariant                 *options,
 
392
                                             GCancellable             *cancellable,
 
393
                                             GError                  **error)
399
394
{
400
395
  Server *server;
401
396
  GDBusNodeInfo *node_info;
425
420
 
426
421
  server->listener = g_object_ref (listener);
427
422
 
 
423
  server->registration_options = options != NULL ? g_variant_ref_sink (options) : NULL;
 
424
 
428
425
  if (flags & POLKIT_AGENT_REGISTER_FLAGS_RUN_IN_THREAD)
429
426
    {
430
427
      server->thread = g_thread_create (server_thread_func,
472
469
}
473
470
 
474
471
/**
 
472
 * polkit_agent_listener_register:
 
473
 * @listener: A #PolkitAgentListener.
 
474
 * @flags: A set of flags from the #PolkitAgentRegisterFlags enumeration.
 
475
 * @subject: The subject to become an authentication agent for, typically a #PolkitUnixSession object.
 
476
 * @object_path: The D-Bus object path to use for the authentication agent or %NULL for the default object path.
 
477
 * @cancellable: A #GCancellable or %NULL.
 
478
 * @error: Return location for error.
 
479
 *
 
480
 * Registers @listener with the PolicyKit daemon as an authentication
 
481
 * agent for @subject. This is implemented by registering a D-Bus
 
482
 * object at @object_path on the unique name assigned by the system
 
483
 * message bus.
 
484
 *
 
485
 * Whenever the PolicyKit daemon needs to authenticate a processes
 
486
 * that is related to @subject, the methods
 
487
 * polkit_agent_listener_initiate_authentication() and
 
488
 * polkit_agent_listener_initiate_authentication_finish() will be
 
489
 * invoked on @listener.
 
490
 *
 
491
 * Note that registration of an authentication agent can fail; for
 
492
 * example another authentication agent may already be registered for
 
493
 * @subject.
 
494
 *
 
495
 * Note that the calling thread is blocked until a reply is received.
 
496
 *
 
497
 * Returns: (transfer full): %NULL if @error is set, otherwise a
 
498
 * registration handle that can be used with
 
499
 * polkit_agent_listener_unregister().
 
500
 */
 
501
gpointer
 
502
polkit_agent_listener_register (PolkitAgentListener      *listener,
 
503
                                PolkitAgentRegisterFlags  flags,
 
504
                                PolkitSubject            *subject,
 
505
                                const gchar              *object_path,
 
506
                                GCancellable             *cancellable,
 
507
                                GError                  **error)
 
508
{
 
509
  return polkit_agent_listener_register_with_options (listener, flags, subject, object_path, NULL, cancellable, error);
 
510
}
 
511
 
 
512
/**
475
513
 * polkit_agent_listener_unregister:
476
514
 * @registration_handle: A handle obtained from polkit_agent_listener_register().
477
515
 *