libpurple/purplepresence.c

changeset 42310
eea341b0d614
parent 42270
1bdd57a0c0d1
child 42432
59c8baad6549
--- a/libpurple/purplepresence.c	Mon Sep 04 23:41:48 2023 -0500
+++ b/libpurple/purplepresence.c	Mon Sep 04 23:44:44 2023 -0500
@@ -41,6 +41,7 @@
 	char *message;
 	char *emoji;
 	gboolean mobile;
+	gboolean notifications_disabled;
 } PurplePresencePrivate;
 
 enum {
@@ -53,6 +54,7 @@
 	PROP_MESSAGE,
 	PROP_EMOJI,
 	PROP_MOBILE,
+	PROP_NOTIFICATIONS_DISABLED,
 	N_PROPERTIES
 };
 static GParamSpec *properties[N_PROPERTIES];
@@ -117,6 +119,10 @@
 		case PROP_MOBILE:
 			purple_presence_set_mobile(presence, g_value_get_boolean(value));
 			break;
+		case PROP_NOTIFICATIONS_DISABLED:
+			purple_presence_set_notifications_disabled(presence,
+			                                           g_value_get_boolean(value));
+			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
 			break;
@@ -154,6 +160,10 @@
 		case PROP_MOBILE:
 			g_value_set_boolean(value, purple_presence_get_mobile(presence));
 			break;
+		case PROP_NOTIFICATIONS_DISABLED:
+			g_value_set_boolean(value,
+			                    purple_presence_get_notifications_disabled(presence));
+			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
 			break;
@@ -290,6 +300,23 @@
 		FALSE,
 		G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
+	/**
+	 * PurplePresence:notifications-disabled:
+	 *
+	 * Whether or not the presence has notifications disabled.
+	 *
+	 * Some protocols, like Slack, allow users to set an available schedule. By
+	 * default it displays that the user has notifications turned off outside
+	 * of that schedule.
+	 *
+	 * Since: 3.0.0
+	 */
+	properties[PROP_NOTIFICATIONS_DISABLED] = g_param_spec_boolean(
+		"notifications-disabled", "notifications-disabled",
+		"Whether or not this presence has notifications disabled.",
+		FALSE,
+		G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
 	g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
 }
 
@@ -734,6 +761,35 @@
 	}
 }
 
+gboolean
+purple_presence_get_notifications_disabled(PurplePresence *presence) {
+	PurplePresencePrivate *priv = NULL;
+
+	g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), FALSE);
+
+	priv = purple_presence_get_instance_private(presence);
+
+	return priv->notifications_disabled;
+}
+
+void
+purple_presence_set_notifications_disabled(PurplePresence *presence,
+                                           gboolean notifications_disabled)
+{
+	PurplePresencePrivate *priv = NULL;
+
+	g_return_if_fail(PURPLE_IS_PRESENCE(presence));
+
+	priv = purple_presence_get_instance_private(presence);
+
+	if(priv->notifications_disabled != notifications_disabled) {
+		priv->notifications_disabled = notifications_disabled;
+
+		g_object_notify_by_pspec(G_OBJECT(presence),
+		                         properties[PROP_NOTIFICATIONS_DISABLED]);
+	}
+}
+
 const char *
 purple_presence_primitive_to_string(PurplePresencePrimitive primitive) {
 	switch(primitive) {

mercurial