[polari/wip/fmuellner/add-channel-error-prop] room: Add :channel-error property
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/add-channel-error-prop] room: Add :channel-error property
- Date: Wed, 13 Feb 2019 18:01:43 +0000 (UTC)
commit 57a55d995ef998dd4a833e0a27afda70bcfc6507
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Feb 13 18:43:26 2019 +0100
room: Add :channel-error property
While we have TpAccount:connection-error to indicate problems with
a network connection as a whole, we don't have any indication for
errors that happen during channel creation (for example a full or
invite-only room).
Add a new :channel-error property that can be used to pass around
such an error condition.
https://gitlab.gnome.org/GNOME/polari/issues/17
src/lib/polari-room.c | 39 +++++++++++++++++++++++++++++++++++++++
src/lib/polari-room.h | 4 ++++
2 files changed, 43 insertions(+)
---
diff --git a/src/lib/polari-room.c b/src/lib/polari-room.c
index 4ddc668..7174805 100644
--- a/src/lib/polari-room.c
+++ b/src/lib/polari-room.c
@@ -42,6 +42,8 @@ struct _PolariRoomPrivate {
char *self_nick;
char *self_user;
+ char *channel_error;
+
TpHandleType type;
guint self_contact_notify_id;
@@ -59,6 +61,7 @@ enum
PROP_ICON,
PROP_ACCOUNT,
PROP_TYPE,
+ PROP_CHANNEL_ERROR,
PROP_CHANNEL_NAME,
PROP_CHANNEL,
PROP_DISPLAY_NAME,
@@ -151,6 +154,29 @@ polari_room_should_highlight_message (PolariRoom *room,
return match_self_nick (room, message);
}
+const char *
+polari_room_get_channel_error (PolariRoom *room)
+{
+ g_return_val_if_fail (POLARI_IS_ROOM (room), NULL);
+
+ return room->priv->channel_error;
+}
+
+void
+polari_room_set_channel_error (PolariRoom *room,
+ const char *channel_error)
+{
+ g_return_if_fail (POLARI_IS_ROOM (room));
+
+ if (g_strcmp0 (room->priv->channel_error, channel_error) == 0)
+ return;
+
+ g_free (room->priv->channel_error);
+ room->priv->channel_error = g_strdup (channel_error);
+
+ g_object_notify_by_pspec (G_OBJECT (room), props[PROP_CHANNEL_ERROR]);
+}
+
void
polari_room_set_topic (PolariRoom *room,
const char *topic)
@@ -771,6 +797,9 @@ polari_room_get_property (GObject *object,
case PROP_TYPE:
g_value_set_uint (value, priv->type);
break;
+ case PROP_CHANNEL_ERROR:
+ g_value_set_string (value, priv->channel_error);
+ break;
case PROP_CHANNEL_NAME:
g_value_set_string (value, priv->channel_name);
break;
@@ -809,6 +838,9 @@ polari_room_set_property (GObject *object,
case PROP_TYPE:
polari_room_set_type (room, g_value_get_uint (value));
break;
+ case PROP_CHANNEL_ERROR:
+ polari_room_set_channel_error (room, g_value_get_string (value));
+ break;
case PROP_CHANNEL_NAME:
polari_room_set_channel_name (room, g_value_get_string (value));
break;
@@ -897,6 +929,13 @@ polari_room_class_init (PolariRoomClass *klass)
TP_HANDLE_TYPE_ROOM,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+ props[PROP_CHANNEL_ERROR] =
+ g_param_spec_string ("channel-error",
+ "Channel error",
+ "Channel error",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+
props[PROP_CHANNEL_NAME] =
g_param_spec_string ("channel-name",
"Channel name",
diff --git a/src/lib/polari-room.h b/src/lib/polari-room.h
index db882b8..b48d654 100644
--- a/src/lib/polari-room.h
+++ b/src/lib/polari-room.h
@@ -27,6 +27,10 @@ G_BEGIN_DECLS
#define POLARI_TYPE_ROOM (polari_room_get_type())
G_DECLARE_FINAL_TYPE (PolariRoom, polari_room, POLARI, ROOM, GObject)
+const char *polari_room_get_channel_error (PolariRoom *room);
+void polari_room_set_channel_error (PolariRoom *room,
+ const char *channel_error);
+
gboolean polari_room_should_highlight_message (PolariRoom *room,
const char *sender,
const char *message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]