# HG changeset patch
# Node ID 7c3469099db5
# Parent  8bdccbde0536
diff --git a/libpurple/meson.build b/libpurple/meson.build
--- a/libpurple/meson.build
+++ b/libpurple/meson.build
@@ -260,6 +260,7 @@
 	'plugins.h',
 	'purplechatuser.h',
 	'purpleconnectionerrorinfo.h',
+	'purplecontact.h',
 	'purpleconversation.h',
 	'purpleimconversation.h',
 	'purplemessage.h',
diff --git a/libpurple/purplecontact.h b/libpurple/purplecontact.h
--- a/libpurple/purplecontact.h
+++ b/libpurple/purplecontact.h
@@ -36,6 +36,12 @@
 #define PURPLE_TYPE_CONTACT (purple_contact_get_type())
 G_DECLARE_FINAL_TYPE(PurpleContact, purple_contact, PURPLE, CONTACT, GObject)
 
+typedef enum {
+	PURPLE_CONTACT_PERMISSION_UNSET = 0,
+	PURPLE_CONTACT_PERMISSION_ALLOW,
+	PURPLE_CONTACT_PERMISSION_DENY,
+} PurpleContactPermission;
+
 #include <libpurple/purpleperson.h>
 
 /**
@@ -242,6 +248,29 @@
  */
 PurplePerson *purple_contact_get_person(PurpleContact *contact);
 
+/**
+ * purple_contact_get_permission:
+ * @contact: The instance.
+ *
+ * Gets the [enum@Purple.ContactPermission] for @contact.
+ *
+ * Returns: The permission for @contact.
+ *
+ * Since: 3.0.0
+ */
+PurpleContactPermission purple_contact_get_permission(PurpleContact *contact);
+
+/**
+ * purple_contact_set_permission:
+ * @contact: The instance.
+ * @permission: The new permission of the contact.
+ *
+ * Sets the permission of @contact to @permission.
+ *
+ * Since: 3.0.0
+ */
+void purple_contact_set_permission(PurpleContact *contact, PurpleContactPermission permission);
+
 G_END_DECLS
 
 #endif /* PURPLE_CONTACT_H */
diff --git a/libpurple/purplecontact.c b/libpurple/purplecontact.c
--- a/libpurple/purplecontact.c
+++ b/libpurple/purplecontact.c
@@ -18,6 +18,8 @@
 
 #include "purplecontact.h"
 
+#include "purpleenums.h"
+
 struct _PurpleContact {
 	GObject parent;
 
@@ -35,6 +37,8 @@
 	PurpleTags *tags;
 
 	PurplePerson *person;
+
+	PurpleContactPermission permission;
 };
 
 enum {
@@ -48,6 +52,7 @@
 	PROP_PRESENCE,
 	PROP_TAGS,
 	PROP_PERSON,
+	PROP_PERMISSION,
 	N_PROPERTIES
 };
 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
@@ -119,6 +124,9 @@
 		case PROP_PERSON:
 			g_value_set_object(value, purple_contact_get_person(contact));
 			break;
+		case PROP_PERMISSION:
+			g_value_set_enum(value, purple_contact_get_permission(contact));
+			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
 			break;
@@ -153,6 +161,9 @@
 		case PROP_PERSON:
 			purple_contact_set_person(contact, g_value_get_object(value));
 			break;
+		case PROP_PERMISSION:
+			purple_contact_set_permission(contact, g_value_get_enum(value));
+			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
 			break;
@@ -206,11 +217,11 @@
 purple_contact_class_init(PurpleContactClass *klass) {
 	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
 
-	obj_class->get_property = purple_contact_get_property;
-	obj_class->set_property = purple_contact_set_property;
 	obj_class->constructed = purple_contact_constructed;
 	obj_class->dispose = purple_contact_dispose;
 	obj_class->finalize = purple_contact_finalize;
+	obj_class->get_property = purple_contact_get_property;
+	obj_class->set_property = purple_contact_set_property;
 
 	/**
 	 * PurpleContact:id:
@@ -334,6 +345,20 @@
 		PURPLE_TYPE_PERSON,
 		G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
+	/**
+	 * PurpleContact:permission:
+	 *
+	 * The permission level for the contact.
+	 *
+	 * Since: 3.0.0
+	 */
+	properties[PROP_PERMISSION] = g_param_spec_enum(
+		"permission", "permission",
+		"The permission level of the contact",
+		PURPLE_TYPE_CONTACT_PERMISSION,
+		PURPLE_CONTACT_PERMISSION_UNSET,
+		G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
 	g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
 }
 
@@ -463,3 +488,22 @@
 
 	return contact->person;
 }
+
+PurpleContactPermission
+purple_contact_get_permission(PurpleContact *contact) {
+	g_return_val_if_fail(PURPLE_IS_CONTACT(contact),
+	                     PURPLE_CONTACT_PERMISSION_UNSET);
+
+	return contact->permission;
+}
+
+void
+purple_contact_set_permission(PurpleContact *contact,
+                              PurpleContactPermission permission)
+{
+	g_return_if_fail(PURPLE_IS_CONTACT(contact));
+
+	contact->permission = permission;
+
+	g_object_notify_by_pspec(G_OBJECT(contact), properties[PROP_PERMISSION]);
+}
diff --git a/libpurple/tests/test_contact.c b/libpurple/tests/test_contact.c
--- a/libpurple/tests/test_contact.c
+++ b/libpurple/tests/test_contact.c
@@ -45,6 +45,7 @@
 	PurpleAccount *account = NULL;
 	PurpleAccount *account1 = NULL;
 	PurpleContact *contact = NULL;
+	PurpleContactPermission permission;
 	PurplePerson *person = NULL;
 	PurplePerson *person1 = NULL;
 	PurplePresence *presence1 = NULL;
@@ -73,6 +74,7 @@
 		"alias", "alias",
 		"avatar", avatar,
 		"person", person,
+		"permission", PURPLE_CONTACT_PERMISSION_ALLOW,
 		NULL);
 
 	/* Now use g_object_get to read all of the properties. */
@@ -86,6 +88,7 @@
 		"presence", &presence1,
 		"tags", &tags,
 		"person", &person1,
+		"permission", &permission,
 		NULL);
 
 	/* Compare all the things. */
@@ -98,6 +101,7 @@
 	g_assert_nonnull(presence1);
 	g_assert_nonnull(tags);
 	g_assert_true(person1 == person);
+	g_assert_true(permission == PURPLE_CONTACT_PERMISSION_ALLOW);
 
 	/* Free/unref all the things. */
 	g_clear_pointer(&id, g_free);
@@ -131,4 +135,4 @@
 	                test_purple_contact_properties);
 
 	return g_test_run();
-}
\ No newline at end of file
+}
