pidgin/pidgin

Add description to PurpleProtocol

2021-07-13, Prateek Pardeshi
ddc26be7f597
Parents 1ad595619528
Children e5564f7d6ebd
Add description to PurpleProtocol

Testing Done:
Ran and tested on the Account Assistant, which I'm developing currently.

![](https://i.ibb.co/bsVHdJv/Screenshot-from-2021-07-12-11-13-55.png)

Bugs closed: PIDGIN-17460

Reviewed at https://reviews.imfreedom.org/r/803/
--- a/libpurple/protocol.c Tue Jul 13 14:56:02 2021 -0500
+++ b/libpurple/protocol.c Tue Jul 13 15:23:59 2021 -0500
@@ -28,6 +28,7 @@
PROP_0,
PROP_ID,
PROP_NAME,
+ PROP_DESCRIPTION,
PROP_OPTIONS,
N_PROPERTIES,
};
@@ -36,6 +37,7 @@
typedef struct {
gchar *id;
gchar *name;
+ gchar *description;
PurpleProtocolOptions options;
} PurpleProtocolPrivate;
@@ -69,6 +71,17 @@
}
static void
+purple_protocol_set_description(PurpleProtocol *protocol, const gchar *description) {
+ PurpleProtocolPrivate *priv = NULL;
+
+ priv = purple_protocol_get_instance_private(protocol);
+ g_free(priv->description);
+ priv->description = g_strdup(description);
+
+ g_object_notify_by_pspec(G_OBJECT(protocol), properties[PROP_DESCRIPTION]);
+}
+
+static void
purple_protocol_set_options(PurpleProtocol *protocol,
PurpleProtocolOptions options)
{
@@ -96,6 +109,9 @@
case PROP_NAME:
g_value_set_string(value, purple_protocol_get_name(protocol));
break;
+ case PROP_DESCRIPTION:
+ g_value_set_string(value, purple_protocol_get_description(protocol));
+ break;
case PROP_OPTIONS:
g_value_set_flags(value, purple_protocol_get_options(protocol));
break;
@@ -118,6 +134,9 @@
case PROP_NAME:
purple_protocol_set_name(protocol, g_value_get_string(value));
break;
+ case PROP_DESCRIPTION:
+ purple_protocol_set_description(protocol, g_value_get_string(value));
+ break;
case PROP_OPTIONS:
purple_protocol_set_options(protocol, g_value_get_flags(value));
break;
@@ -141,7 +160,7 @@
g_clear_pointer(&priv->id, g_free);
g_clear_pointer(&priv->name, g_free);
-
+ g_clear_pointer(&priv->description, g_free);
/* I'm not sure that we can finalize a protocol plugin if an account is
* still using it.. Right now accounts don't ref protocols, but maybe
* they should?
@@ -203,6 +222,17 @@
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
/**
+ * PurpleProtocol::description:
+ *
+ * The description to show in user interface for the protocol.
+ */
+ properties[PROP_DESCRIPTION] = g_param_spec_string(
+ "description", "description",
+ "The description of the protocol to show in the user interface",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ /**
* PurpleProtocol::options:
*
* The #PurpleProtocolOptions for the protocol.
@@ -242,6 +272,17 @@
return priv->name;
}
+const gchar *
+purple_protocol_get_description(PurpleProtocol *protocol) {
+ PurpleProtocolPrivate *priv = NULL;
+
+ g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol), NULL);
+
+ priv = purple_protocol_get_instance_private(protocol);
+
+ return priv->description;
+}
+
PurpleProtocolOptions
purple_protocol_get_options(PurpleProtocol *protocol) {
PurpleProtocolPrivate *priv = NULL;
--- a/libpurple/protocol.h Tue Jul 13 14:56:02 2021 -0500
+++ b/libpurple/protocol.h Tue Jul 13 15:23:59 2021 -0500
@@ -199,6 +199,18 @@
const gchar *purple_protocol_get_name(PurpleProtocol *protocol);
/**
+ * purple_protocol_get_description:
+ * @protocol: The #PurpleProtocol instance.
+ *
+ * Gets the description of a protocol.
+ *
+ * Returns: The Description of the protocol.
+ *
+ * Since: 3.0.0
+ */
+const gchar *purple_protocol_get_description(PurpleProtocol *protocol);
+
+/**
* purple_protocol_get_options:
* @protocol: The #PurpleProtocol instance.
*
--- a/libpurple/protocols/bonjour/bonjour.c Tue Jul 13 14:56:02 2021 -0500
+++ b/libpurple/protocols/bonjour/bonjour.c Tue Jul 13 15:23:59 2021 -0500
@@ -753,6 +753,7 @@
BONJOUR_TYPE_PROTOCOL,
"id", "prpl-bonjour",
"name", "Bonjour",
+ "description", "Bonjour is a serverless protocol, developed by Apple",
"options", OPT_PROTO_NO_PASSWORD,
NULL));
}
--- a/libpurple/protocols/facebook/facebook.c Tue Jul 13 14:56:02 2021 -0500
+++ b/libpurple/protocols/facebook/facebook.c Tue Jul 13 15:23:59 2021 -0500
@@ -1706,6 +1706,7 @@
fb_protocol = g_object_new(FACEBOOK_TYPE_PROTOCOL,
"id", FB_PROTOCOL_ID,
"name", "Facebook",
+ "description", "Facebook is a chat protocol, developed by Facebook",
"options", OPT_PROTO_CHAT_TOPIC,
NULL);
--- a/libpurple/protocols/gg/gg.c Tue Jul 13 14:56:02 2021 -0500
+++ b/libpurple/protocols/gg/gg.c Tue Jul 13 15:23:59 2021 -0500
@@ -1209,6 +1209,7 @@
GGP_TYPE_PROTOCOL,
"id", "prpl-gg",
"name", "Gadu-Gadu",
+ "description", "Gadu-Gadu is a Polish instant messaging client",
NULL));
}
--- a/libpurple/protocols/irc/irc.c Tue Jul 13 14:56:02 2021 -0500
+++ b/libpurple/protocols/irc/irc.c Tue Jul 13 15:23:59 2021 -0500
@@ -1135,6 +1135,7 @@
IRC_TYPE_PROTOCOL,
"id", "prpl-irc",
"name", "IRC",
+ "description", "Internet Relay Chat (IRC) is a text-based chat system",
"options", OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL |
OPT_PROTO_SLASH_COMMANDS_NATIVE,
NULL));
--- a/libpurple/protocols/jabber/xmpp.c Tue Jul 13 14:56:02 2021 -0500
+++ b/libpurple/protocols/jabber/xmpp.c Tue Jul 13 15:23:59 2021 -0500
@@ -146,6 +146,7 @@
XMPP_TYPE_PROTOCOL,
"id", XMPP_PROTOCOL_ID,
"name", "XMPP",
+ "description", "Extensible Messaging and Presence Protocol for IM, voice and video",
"options", options,
NULL
));
--- a/libpurple/protocols/novell/novell.c Tue Jul 13 14:56:02 2021 -0500
+++ b/libpurple/protocols/novell/novell.c Tue Jul 13 15:23:59 2021 -0500
@@ -3625,6 +3625,7 @@
NOVELL_TYPE_PROTOCOL,
"id", "prpl-novell",
"name", "GroupWise",
+ "description", "GroupWise is a messaging and collaboration platform from Micro Focus",
NULL));
}
--- a/libpurple/protocols/sametime/sametime.c Tue Jul 13 14:56:02 2021 -0500
+++ b/libpurple/protocols/sametime/sametime.c Tue Jul 13 15:23:59 2021 -0500
@@ -68,6 +68,7 @@
#define PROTOCOL_ID "prpl-meanwhile"
#define PROTOCOL_NAME "Sametime"
+#define PROTOCOL_DESCRIPTION "Sametime chat by Lotus"
/* considering that there's no display of this information for protocols,
@@ -5385,6 +5386,7 @@
MW_TYPE_PROTOCOL,
"id", PROTOCOL_ID,
"name", PROTOCOL_NAME,
+ "description", PROTOCOL_DESCRIPTION,
NULL));
}
--- a/libpurple/protocols/silc/silc.c Tue Jul 13 14:56:02 2021 -0500
+++ b/libpurple/protocols/silc/silc.c Tue Jul 13 15:23:59 2021 -0500
@@ -2341,6 +2341,7 @@
SILCPURPLE_TYPE_PROTOCOL,
"id", "prpl-silc",
"name", "SILC",
+ "description", "SILC - Secure Internet Live Conferencing protocol",
"options", OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME |
OPT_PROTO_PASSWORD_OPTIONAL |
OPT_PROTO_SLASH_COMMANDS_NATIVE,
--- a/libpurple/protocols/zephyr/zephyr.c Tue Jul 13 14:56:02 2021 -0500
+++ b/libpurple/protocols/zephyr/zephyr.c Tue Jul 13 15:23:59 2021 -0500
@@ -1713,6 +1713,7 @@
ZEPHYR_TYPE_PROTOCOL,
"id", "prpl-zephyr",
"name", "Zephyr",
+ "description", "Zephyr is an instant messaging protocol, created at MIT",
"options", OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD,
NULL));
}