[PolicyKit-gnome] Update for changes in PolicyKit API
- From: David Zeuthen <davidz src gnome org>
- To: svn-commits-list gnome org
- Subject: [PolicyKit-gnome] Update for changes in PolicyKit API
- Date: Wed, 13 May 2009 11:02:00 -0400 (EDT)
commit d7e442583a38bede1d537807b1d8c32d83729952
Author: David Zeuthen <davidz redhat com>
Date: Wed May 13 10:59:32 2009 -0400
Update for changes in PolicyKit API
---
src/polkitgnomeauthenticationdialog.c | 85 ++++++++++++++++++++-------------
src/polkitgnomeauthenticationdialog.h | 4 +-
src/polkitgnomeauthenticator.c | 31 +++++++-----
src/polkitgnomeauthenticator.h | 9 ++-
src/polkitgnomelistener.c | 9 ++++
5 files changed, 87 insertions(+), 51 deletions(-)
diff --git a/src/polkitgnomeauthenticationdialog.c b/src/polkitgnomeauthenticationdialog.c
index 8c847fe..c0942ac 100644
--- a/src/polkitgnomeauthenticationdialog.c
+++ b/src/polkitgnomeauthenticationdialog.c
@@ -53,10 +53,11 @@ struct _PolkitGnomeAuthenticationDialogPrivate
gchar *message;
gchar *action_id;
- gchar *program;
gchar *vendor;
gchar *vendor_url;
gchar *icon_name;
+ GHashTable *details;
+
gchar **users;
gchar *selected_user;
@@ -69,12 +70,12 @@ G_DEFINE_TYPE (PolkitGnomeAuthenticationDialog, polkit_gnome_authentication_dial
enum {
PROP_0,
- PROP_PROGRAM,
PROP_ACTION_ID,
PROP_VENDOR,
PROP_VENDOR_URL,
PROP_ICON_NAME,
PROP_MESSAGE,
+ PROP_DETAILS,
PROP_USERS,
PROP_SELECTED_USER,
};
@@ -325,8 +326,8 @@ polkit_gnome_authentication_dialog_set_property (GObject *object,
switch (prop_id)
{
- case PROP_PROGRAM:
- dialog->priv->program = g_value_dup_string (value);
+ case PROP_DETAILS:
+ dialog->priv->details = g_value_dup_boxed (value);
break;
case PROP_ACTION_ID:
@@ -475,10 +476,11 @@ polkit_gnome_authentication_dialog_finalize (GObject *object)
g_free (dialog->priv->message);
g_free (dialog->priv->action_id);
- g_free (dialog->priv->program);
g_free (dialog->priv->vendor);
g_free (dialog->priv->vendor_url);
g_free (dialog->priv->icon_name);
+ g_hash_table_unref (dialog->priv->details);
+
g_strfreev (dialog->priv->users);
g_free (dialog->priv->selected_user);
@@ -504,6 +506,8 @@ polkit_gnome_authentication_dialog_constructed (GObject *object)
GtkWidget *image;
gboolean have_user_combobox;
gchar *s;
+ GList *keys, *l;
+ guint rows;
dialog = POLKIT_GNOME_AUTHENTICATION_DIALOG (object);
@@ -622,12 +626,27 @@ polkit_gnome_authentication_dialog_constructed (GObject *object)
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_container_add (GTK_CONTAINER (table_alignment), table);
- label = gtk_label_new (NULL);
- s = g_strdup_printf ("<small>%s</small>", dialog->priv->program);
- gtk_label_set_markup (GTK_LABEL (label), s);
- g_free (s);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 1.0);
- add_row (table, 0, _("<small><b>Application:</b></small>"), label);
+ rows = 0;
+ keys = g_hash_table_get_keys (dialog->priv->details);
+ keys = g_list_sort (keys, (GCompareFunc) g_strcmp0);
+ for (l = keys; l != NULL; l = l->next)
+ {
+ const gchar *key = l->data;
+ const gchar *value;
+
+ value = g_hash_table_lookup (dialog->priv->details, key);
+
+ label = gtk_label_new (NULL);
+ s = g_strdup_printf ("<small>%s</small>", value);
+ gtk_label_set_markup (GTK_LABEL (label), s);
+ g_free (s);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 1.0);
+ s = g_strdup_printf ("<small><b>%s:</b></small>", key);
+ add_row (table, rows++, s, label);
+ g_free (s);
+ }
+ g_list_free (keys);
+
/* --- */
@@ -638,7 +657,7 @@ polkit_gnome_authentication_dialog_constructed (GObject *object)
sexy_url_label_set_markup (SEXY_URL_LABEL (label), s);
g_free (s);
gtk_misc_set_alignment (GTK_MISC (label), 0, 1.0);
- add_row (table, 1, _("<small><b>Action:</b></small>"), label);
+ add_row (table, rows++, _("<small><b>Action:</b></small>"), label);
g_signal_connect (label, "url-activated", G_CALLBACK (action_id_activated), NULL);
s = g_strdup_printf (_("Click to edit %s"), dialog->priv->action_id);
@@ -654,7 +673,7 @@ polkit_gnome_authentication_dialog_constructed (GObject *object)
sexy_url_label_set_markup (SEXY_URL_LABEL (label), s);
g_free (s);
gtk_misc_set_alignment (GTK_MISC (label), 0, 1.0);
- add_row (table, 2, _("<small><b>Vendor:</b></small>"), label);
+ add_row (table, rows++, _("<small><b>Vendor:</b></small>"), label);
g_signal_connect (label, "url-activated", G_CALLBACK (vendor_url_activated), NULL);
s = g_strdup_printf (_("Click to open %s"), dialog->priv->vendor_url);
@@ -687,16 +706,16 @@ polkit_gnome_authentication_dialog_class_init (PolkitGnomeAuthenticationDialogCl
gobject_class->constructed = polkit_gnome_authentication_dialog_constructed;
g_object_class_install_property (gobject_class,
- PROP_PROGRAM,
- g_param_spec_string ("program",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ PROP_DETAILS,
+ g_param_spec_boxed ("details",
+ NULL,
+ NULL,
+ G_TYPE_HASH_TABLE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property (gobject_class,
PROP_ACTION_ID,
@@ -791,26 +810,26 @@ polkit_gnome_authentication_dialog_class_init (PolkitGnomeAuthenticationDialogCl
* Returns: A new password dialog.
**/
GtkWidget *
-polkit_gnome_authentication_dialog_new (const gchar *path_to_program,
- const gchar *action_id,
+polkit_gnome_authentication_dialog_new (const gchar *action_id,
const gchar *vendor,
const gchar *vendor_url,
const gchar *icon_name,
const gchar *message_markup,
+ GHashTable *details,
gchar **users)
{
PolkitGnomeAuthenticationDialog *dialog;
GtkWindow *window;
dialog = g_object_new (POLKIT_GNOME_TYPE_AUTHENTICATION_DIALOG,
- "program", path_to_program,
- "action-id", action_id,
- "vendor", vendor,
- "vendor-url", vendor_url,
- "icon-name", icon_name,
- "message", message_markup,
- "users", users,
- NULL);
+ "action-id", action_id,
+ "vendor", vendor,
+ "vendor-url", vendor_url,
+ "icon-name", icon_name,
+ "message", message_markup,
+ "details", details,
+ "users", users,
+ NULL);
window = GTK_WINDOW (dialog);
diff --git a/src/polkitgnomeauthenticationdialog.h b/src/polkitgnomeauthenticationdialog.h
index 59dd3e9..18c6db6 100644
--- a/src/polkitgnomeauthenticationdialog.h
+++ b/src/polkitgnomeauthenticationdialog.h
@@ -48,12 +48,12 @@ struct _PolkitGnomeAuthenticationDialogClass
};
GType polkit_gnome_authentication_dialog_get_type (void);
-GtkWidget *polkit_gnome_authentication_dialog_new (const gchar *path_to_program,
- const gchar *action_id,
+GtkWidget *polkit_gnome_authentication_dialog_new (const gchar *action_id,
const gchar *vendor,
const gchar *vendor_url,
const gchar *icon_name,
const gchar *message_markup,
+ GHashTable *details,
gchar **users);
gchar *polkit_gnome_authentication_dialog_get_selected_user (PolkitGnomeAuthenticationDialog *dialog);
gboolean polkit_gnome_authentication_dialog_run_until_user_is_selected (PolkitGnomeAuthenticationDialog *dialog);
diff --git a/src/polkitgnomeauthenticator.c b/src/polkitgnomeauthenticator.c
index 13dc4e0..ee9d5a4 100644
--- a/src/polkitgnomeauthenticator.c
+++ b/src/polkitgnomeauthenticator.c
@@ -39,11 +39,13 @@ struct _PolkitGnomeAuthenticator
PolkitAuthority *authority;
gchar *action_id;
+ gchar *message;
+ gchar *icon_name;
+ GHashTable *details;
gchar *cookie;
GList *identities;
PolkitActionDescription *action_desc;
- gchar *icon_name;
gchar **users;
gboolean gained_authorization;
@@ -87,13 +89,15 @@ polkit_gnome_authenticator_finalize (GObject *object)
if (authenticator->authority != NULL)
g_object_unref (authenticator->authority);
g_free (authenticator->action_id);
+ g_free (authenticator->message);
+ g_free (authenticator->icon_name);
+ g_hash_table_unref (authenticator->details);
g_free (authenticator->cookie);
g_list_foreach (authenticator->identities, (GFunc) g_object_unref, NULL);
g_list_free (authenticator->identities);
if (authenticator->action_desc != NULL)
g_object_unref (authenticator->action_desc);
- g_free (authenticator->icon_name);
g_strfreev (authenticator->users);
g_free (authenticator->selected_user);
@@ -170,12 +174,14 @@ get_desc_for_action (PolkitAuthority *authority,
}
PolkitGnomeAuthenticator *
-polkit_gnome_authenticator_new (const gchar *action_id,
- const gchar *cookie,
- GList *identities)
+polkit_gnome_authenticator_new (const gchar *action_id,
+ const gchar *message,
+ const gchar *icon_name,
+ GHashTable *details,
+ const gchar *cookie,
+ GList *identities)
{
PolkitGnomeAuthenticator *authenticator;
- GIcon *icon;
GList *l;
guint n;
@@ -183,6 +189,9 @@ polkit_gnome_authenticator_new (const gchar *action_id,
authenticator->authority = polkit_authority_get ();
authenticator->action_id = g_strdup (action_id);
+ authenticator->message = g_strdup (message);
+ authenticator->icon_name = g_strdup (icon_name);
+ authenticator->details = g_hash_table_ref (details);
authenticator->cookie = g_strdup (cookie);
authenticator->identities = g_list_copy (identities);
g_list_foreach (authenticator->identities, (GFunc) g_object_ref, NULL);
@@ -192,10 +201,6 @@ polkit_gnome_authenticator_new (const gchar *action_id,
if (authenticator->action_desc == NULL)
goto error;
- icon = polkit_action_description_get_icon (authenticator->action_desc);
- if (icon != NULL)
- authenticator->icon_name = g_icon_to_string (icon);
-
authenticator->users = g_new0 (gchar *, g_list_length (authenticator->identities) + 1);
for (l = authenticator->identities, n = 0; l != NULL; l = l->next, n++)
{
@@ -209,12 +214,12 @@ polkit_gnome_authenticator_new (const gchar *action_id,
}
authenticator->dialog = polkit_gnome_authentication_dialog_new
- ("/todo/path/to/program/requesting/auth",
- authenticator->action_id,
+ (authenticator->action_id,
polkit_action_description_get_vendor_name (authenticator->action_desc),
polkit_action_description_get_vendor_url (authenticator->action_desc),
authenticator->icon_name,
- polkit_action_description_get_message (authenticator->action_desc),
+ authenticator->message,
+ authenticator->details,
authenticator->users);
return authenticator;
diff --git a/src/polkitgnomeauthenticator.h b/src/polkitgnomeauthenticator.h
index 8e2cff2..d04ccfe 100644
--- a/src/polkitgnomeauthenticator.h
+++ b/src/polkitgnomeauthenticator.h
@@ -37,9 +37,12 @@ typedef struct _PolkitGnomeAuthenticator PolkitGnomeAuthenticator;
typedef struct _PolkitGnomeAuthenticatorClass PolkitGnomeAuthenticatorClass;
GType polkit_gnome_authenticator_get_type (void) G_GNUC_CONST;
-PolkitGnomeAuthenticator *polkit_gnome_authenticator_new (const gchar *action_id,
- const gchar *cookie,
- GList *identities);
+PolkitGnomeAuthenticator *polkit_gnome_authenticator_new (const gchar *action_id,
+ const gchar *message,
+ const gchar *icon_name,
+ GHashTable *details,
+ const gchar *cookie,
+ GList *identities);
void polkit_gnome_authenticator_initiate (PolkitGnomeAuthenticator *authenticator);
void polkit_gnome_authenticator_cancel (PolkitGnomeAuthenticator *authenticator);
const gchar *polkit_gnome_authenticator_get_cookie (PolkitGnomeAuthenticator *authenticator);
diff --git a/src/polkitgnomelistener.c b/src/polkitgnomelistener.c
index 969b44d..d8a6390 100644
--- a/src/polkitgnomelistener.c
+++ b/src/polkitgnomelistener.c
@@ -42,6 +42,9 @@ struct _PolkitGnomeListenerClass
static void polkit_gnome_listener_initiate_authentication (PolkitAgentListener *listener,
const gchar *action_id,
+ const gchar *message,
+ const gchar *icon_name,
+ GHashTable *details,
const gchar *cookie,
GList *identities,
GCancellable *cancellable,
@@ -155,6 +158,9 @@ cancelled_cb (GCancellable *cancellable,
static void
polkit_gnome_listener_initiate_authentication (PolkitAgentListener *agent_listener,
const gchar *action_id,
+ const gchar *message,
+ const gchar *icon_name,
+ GHashTable *details,
const gchar *cookie,
GList *identities,
GCancellable *cancellable,
@@ -181,6 +187,9 @@ polkit_gnome_listener_initiate_authentication (PolkitAgentListener *agent_liste
}
listener->the_authenticator = polkit_gnome_authenticator_new (action_id,
+ message,
+ icon_name,
+ details,
cookie,
identities);
if (listener->the_authenticator == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]