Commit f95ca7ac authored by David Zeuthen's avatar David Zeuthen

add a hash() method to PolkitIdentity

parent aa46c2f3
......@@ -65,6 +65,12 @@ polkit_identity_get_type (void)
return iface_type;
}
guint
polkit_identity_hash (PolkitIdentity *identity)
{
return POLKIT_IDENTITY_GET_IFACE (identity)->hash (identity);
}
gboolean
polkit_identity_equal (PolkitIdentity *a,
PolkitIdentity *b)
......
......@@ -42,6 +42,8 @@ struct _PolkitIdentityIface
{
GTypeInterface parent_iface;
guint (*hash) (PolkitIdentity *identity);
gboolean (*equal) (PolkitIdentity *a,
PolkitIdentity *b);
......@@ -49,6 +51,7 @@ struct _PolkitIdentityIface
};
GType polkit_identity_get_type (void) G_GNUC_CONST;
guint polkit_identity_hash (PolkitIdentity *a);
gboolean polkit_identity_equal (PolkitIdentity *a,
PolkitIdentity *b);
gchar *polkit_identity_to_string (PolkitIdentity *identity);
......
......@@ -183,6 +183,16 @@ polkit_unix_group_new_for_name (const gchar *name,
return identity;
}
static guint
polkit_unix_group_hash (PolkitIdentity *identity)
{
PolkitUnixGroup *group;
group = POLKIT_UNIX_GROUP (identity);
return g_direct_hash (GINT_TO_POINTER (((gint) (group->gid)) * 2 + 1));
}
static gboolean
polkit_unix_group_equal (PolkitIdentity *a,
PolkitIdentity *b)
......@@ -213,6 +223,7 @@ polkit_unix_group_to_string (PolkitIdentity *identity)
static void
identity_iface_init (PolkitIdentityIface *identity_iface)
{
identity_iface->hash = polkit_unix_group_hash;
identity_iface->equal = polkit_unix_group_equal;
identity_iface->to_string = polkit_unix_group_to_string;
}
......@@ -196,6 +196,16 @@ polkit_unix_user_equal (PolkitIdentity *a,
return user_a->uid == user_b->uid;
}
static guint
polkit_unix_user_hash (PolkitIdentity *identity)
{
PolkitUnixUser *user;
user = POLKIT_UNIX_USER (identity);
return g_direct_hash (GINT_TO_POINTER (((gint) (user->uid)) * 2));
}
static gchar *
polkit_unix_user_to_string (PolkitIdentity *identity)
{
......@@ -213,6 +223,7 @@ polkit_unix_user_to_string (PolkitIdentity *identity)
static void
identity_iface_init (PolkitIdentityIface *identity_iface)
{
identity_iface->hash = polkit_unix_user_hash;
identity_iface->equal = polkit_unix_user_equal;
identity_iface->to_string = polkit_unix_user_to_string;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment