--- a/doc/reference/libpurple/libpurple-docs.xml Thu Sep 02 21:22:55 2021 -0500
+++ b/doc/reference/libpurple/libpurple-docs.xml Thu Sep 02 21:28:40 2021 -0500
@@ -80,6 +80,7 @@
<xi:include href="xml/purpleplugininfo.xml" />
<xi:include href="xml/purplepresence.xml" />
<xi:include href="xml/purplewhiteboard.xml" />
+ <xi:include href="xml/purplewhiteboardmanager.xml" /> <xi:include href="xml/purplewhiteboardops.xml" />
<xi:include href="xml/purplewhiteboarduiops.xml" />
<xi:include href="xml/purpleuiinfo.xml" />
--- a/libpurple/core.c Thu Sep 02 21:22:55 2021 -0500
+++ b/libpurple/core.c Thu Sep 02 21:28:40 2021 -0500
@@ -170,6 +170,7 @@
purple_conversations_init();
purple_conversation_manager_startup();
+ purple_whiteboard_manager_startup(); @@ -219,6 +220,7 @@
/* Save .xml files, remove signals, etc. */
+ purple_whiteboard_manager_shutdown(); purple_conversation_manager_shutdown();
purple_conversations_uninit();
--- a/libpurple/meson.build Thu Sep 02 21:22:55 2021 -0500
+++ b/libpurple/meson.build Thu Sep 02 21:28:40 2021 -0500
@@ -73,6 +73,7 @@
'purpleprotocolserver.c',
+ 'purplewhiteboardmanager.c', 'purplewhiteboarduiops.c',
@@ -164,6 +165,7 @@
'purpleprotocolserver.h',
+ 'purplewhiteboardmanager.h', 'purplewhiteboarduiops.h',
--- a/libpurple/protocols/silc/wb.c Thu Sep 02 21:22:55 2021 -0500
+++ b/libpurple/protocols/silc/wb.c Thu Sep 02 21:28:40 2021 -0500
@@ -105,13 +105,24 @@
PurpleWhiteboard *silcpurple_wb_init(SilcPurple sg, SilcClientEntry client_entry)
+ PurpleWhiteboardManager *manager; + manager = purple_whiteboard_manager_get_default(); - wb = purple_whiteboard_get_session(sg->account, client_entry->nickname);
- wb = purple_whiteboard_new(sg->account, client_entry->nickname, 0);
+ id = g_strdup_printf("silc-client-%s", client_entry->nickname); + wb = purple_whiteboard_manager_find(manager, id); + if(!PURPLE_IS_WHITEBOARD(wb)) { + wb = purple_whiteboard_new(sg->account, id, 0); + purple_whiteboard_manager_register(manager, wb, NULL); + if(!PURPLE_IS_WHITEBOARD(wb)) { if (!purple_whiteboard_get_protocol_data(wb)) {
wbs = silc_calloc(1, sizeof(*wbs));
@@ -135,14 +146,24 @@
PurpleWhiteboard *silcpurple_wb_init_ch(SilcPurple sg, SilcChannelEntry channel)
+ PurpleWhiteboardManager *manager = NULL; - wb = purple_whiteboard_get_session(sg->account, channel->channel_name);
- wb = purple_whiteboard_new(sg->account, channel->channel_name, 0);
+ manager = purple_whiteboard_manager_get_default(); + id = g_strdup_printf("silc-channel-%s", channel->channel_name); + wb = purple_whiteboard_manager_find(manager, id); + if(!PURPLE_IS_WHITEBOARD(wb)) { + wb = purple_whiteboard_new(sg->account, id, 0); + if(!PURPLE_IS_WHITEBOARD(wb)) { if (!purple_whiteboard_get_protocol_data(wb)) {
wbs = silc_calloc(1, sizeof(*wbs));
@@ -315,18 +336,19 @@
SilcMessageFlags flags, const unsigned char *message,
+ PurpleWhiteboardManager *manager; + manager = purple_whiteboard_manager_get_default(); - gc = client->application;
- sg = purple_connection_get_protocol_data(gc);
+ id = g_strdup_printf("silc-client-%s", sender->nickname); + wb = purple_whiteboard_manager_find(manager, id); - wb = purple_whiteboard_get_session(sg->account, sender->nickname);
+ if(!PURPLE_IS_WHITEBOARD(wb)) { /* Ask user if they want to open the whiteboard */
- silcpurple_wb_request(client, message, message_len,
+ silcpurple_wb_request(client, message, message_len, sender, NULL); @@ -342,18 +364,20 @@
const unsigned char *message,
+ PurpleWhiteboardManager *manager; + manager = purple_whiteboard_manager_get_default(); - gc = client->application;
- sg = purple_connection_get_protocol_data(gc);
+ id = g_strdup_printf("silc-channel-%s", channel->channel_name); + wb = purple_whiteboard_manager_find(manager, id); - wb = purple_whiteboard_get_session(sg->account, channel->channel_name);
+ if(!PURPLE_IS_WHITEBOARD(wb)) { /* Ask user if they want to open the whiteboard */
- silcpurple_wb_request(client, message, message_len,
+ silcpurple_wb_request(client, message, message_len, sender, channel); @@ -430,9 +454,14 @@
void silcpurple_wb_end(PurpleWhiteboard *wb)
SilcPurpleWb wbs = purple_whiteboard_get_protocol_data(wb);
+ PurpleWhiteboardManager *manager; + manager = purple_whiteboard_manager_get_default(); purple_whiteboard_set_protocol_data(wb, NULL);
+ purple_whiteboard_manager_unregister(manager, wb, NULL); void silcpurple_wb_get_dimensions(const PurpleWhiteboard *wb, int *width, int *height)
--- a/libpurple/purpleprivate.h Thu Sep 02 21:22:55 2021 -0500
+++ b/libpurple/purpleprivate.h Thu Sep 02 21:28:40 2021 -0500
@@ -255,6 +255,25 @@
void purple_credential_provider_deactivate(PurpleCredentialProvider *provider);
+ * purple_whiteboard_manager_startup: + * Starts up the whiteboard manager by creating the default instance. +void purple_whiteboard_manager_startup(void); + * purple_whiteboard_manager_shutdown: + * Shuts down the whiteboard manager by destroying the default instance. +void purple_whiteboard_manager_shutdown(void); #endif /* PURPLE_PRIVATE_H */
--- a/libpurple/purplewhiteboard.c Thu Sep 02 21:22:55 2021 -0500
+++ b/libpurple/purplewhiteboard.c Thu Sep 02 21:28:40 2021 -0500
@@ -27,12 +27,13 @@
#include "purpleprotocolfactory.h"
#include "purplewhiteboarduiops.h"
/* TODO Remove this and use protocol-specific subclasses. */
@@ -47,7 +48,7 @@
@@ -56,11 +57,6 @@
G_DEFINE_TYPE_WITH_PRIVATE(PurpleWhiteboard, purple_whiteboard, G_TYPE_OBJECT)
/******************************************************************************
- *****************************************************************************/
-static GList *wb_list = NULL;
-/******************************************************************************
*****************************************************************************/
@@ -78,15 +74,15 @@
-purple_whiteboard_set_who(PurpleWhiteboard *whiteboard, const gchar *who) {
+purple_whiteboard_set_id(PurpleWhiteboard *whiteboard, const gchar *id) { PurpleWhiteboardPrivate *priv = NULL;
priv = purple_whiteboard_get_instance_private(whiteboard);
- g_clear_pointer(&priv->who, g_free);
- priv->who = g_strdup(who);
+ priv->id = g_strdup(id); - g_object_notify_by_pspec(G_OBJECT(whiteboard), properties[PROP_WHO]);
+ g_object_notify_by_pspec(G_OBJECT(whiteboard), properties[PROP_ID]); /******************************************************************************
@@ -106,8 +102,8 @@
purple_whiteboard_set_account(whiteboard,
g_value_get_object(value));
- purple_whiteboard_set_who(whiteboard, g_value_get_string(value));
+ purple_whiteboard_set_id(whiteboard, g_value_get_string(value)); purple_whiteboard_set_draw_list(whiteboard,
@@ -133,9 +129,9 @@
g_value_set_object(value,
purple_whiteboard_get_account(whiteboard));
g_value_set_string(value,
- purple_whiteboard_get_who(whiteboard));
+ purple_whiteboard_get_id(whiteboard)); g_value_set_pointer(value,
@@ -170,8 +166,6 @@
if(priv->protocol_ops != NULL && priv->protocol_ops->start != NULL) {
priv->protocol_ops->start(whiteboard);
- wb_list = g_list_append(wb_list, whiteboard);
@@ -186,10 +180,8 @@
priv->protocol_ops->end(whiteboard);
- wb_list = g_list_remove(wb_list, whiteboard);
g_clear_object(&priv->account);
- g_clear_pointer(&priv->who, g_free);
+ g_clear_pointer(&priv->id, g_free); /* TODO: figure out how we need to clean up the drawlist */
@@ -216,9 +208,9 @@
"The whiteboard's account.", PURPLE_TYPE_ACCOUNT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
- properties[PROP_WHO] = g_param_spec_string(
- "Who you're drawing with.", NULL,
+ properties[PROP_ID] = g_param_spec_string( + "The ID of the whiteboard.", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
properties[PROP_DRAW_LIST] = g_param_spec_pointer(
@@ -257,14 +249,14 @@
-purple_whiteboard_get_who(PurpleWhiteboard *whiteboard) {
+purple_whiteboard_get_id(PurpleWhiteboard *whiteboard) { PurpleWhiteboardPrivate *priv = NULL;
g_return_val_if_fail(PURPLE_IS_WHITEBOARD(whiteboard), NULL);
priv = purple_whiteboard_get_instance_private(whiteboard);
@@ -296,24 +288,6 @@
purple_whiteboard_ui_ops_create(whiteboard);
-purple_whiteboard_get_session(PurpleAccount *account, const gchar *who) {
- PurpleWhiteboard *whiteboard = NULL;
- PurpleWhiteboardPrivate *priv = NULL;
- for(l = wb_list; l != NULL; l = l->next) {
- whiteboard = PURPLE_WHITEBOARD(l->data);
- priv = purple_whiteboard_get_instance_private(whiteboard);
- if(priv->account == account && purple_strequal(priv->who, who)) {
purple_whiteboard_draw_list_destroy(GList *draw_list) {
@@ -491,12 +465,12 @@
-purple_whiteboard_new(PurpleAccount *account, const gchar *who, gint state) {
+purple_whiteboard_new(PurpleAccount *account, const gchar *id, gint state) { PurpleWhiteboard *whiteboard = NULL;
PurpleProtocol *protocol = NULL;
g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
- g_return_val_if_fail(who != NULL, NULL);
+ g_return_val_if_fail(id != NULL, NULL); protocol = purple_account_get_protocol(account);
@@ -504,12 +478,12 @@
if(PURPLE_IS_PROTOCOL_FACTORY(protocol)) {
whiteboard = purple_protocol_factory_whiteboard_new(
- PURPLE_PROTOCOL_FACTORY(protocol), account, who, state);
+ PURPLE_PROTOCOL_FACTORY(protocol), account, id, state); whiteboard = g_object_new(PURPLE_TYPE_WHITEBOARD,
@@ -517,3 +491,20 @@
+purple_whiteboard_equal(PurpleWhiteboard *whiteboard1, + PurpleWhiteboard *whiteboard2) + PurpleWhiteboardPrivate *priv1 = NULL, *priv2 = NULL; + if(whiteboard1 == NULL) { + return (whiteboard2 == NULL); + } else if(whiteboard2 == NULL) { + priv1 = purple_whiteboard_get_instance_private(whiteboard1); + priv2 = purple_whiteboard_get_instance_private(whiteboard2); + return purple_strequal(priv1->id, priv2->id); --- a/libpurple/purplewhiteboard.h Thu Sep 02 21:22:55 2021 -0500
+++ b/libpurple/purplewhiteboard.h Thu Sep 02 21:28:40 2021 -0500
@@ -94,14 +94,14 @@
* @account: A #PurpleAccount instance.
- * @who: Who you're drawing with.
+ * @id: The identifier of the whiteboard. * Creates a new whiteboard.
* Returns: (transfer full): The new #PurpleWhiteboard instance.
-PurpleWhiteboard *purple_whiteboard_new(PurpleAccount *account, const gchar *who, gint state);
+PurpleWhiteboard *purple_whiteboard_new(PurpleAccount *account, const gchar *id, gint state); * purple_whiteboard_get_account:
@@ -114,14 +114,16 @@
PurpleAccount *purple_whiteboard_get_account(PurpleWhiteboard *whiteboard);
- * purple_whiteboard_get_who:
+ * purple_whiteboard_get_id: * @whiteboard: The #PurpleWhiteboard instance.
- * Gets the name of who you're drawing with.
+ * Gets the id of @whiteboard. + * Returns: The id of @whiteboard. - * Returns: The name of who you're drawing with.
-const gchar *purple_whiteboard_get_who(PurpleWhiteboard *whiteboard);
+const gchar *purple_whiteboard_get_id(PurpleWhiteboard *whiteboard); * purple_whiteboard_set_state:
@@ -151,18 +153,6 @@
void purple_whiteboard_start(PurpleWhiteboard *whiteboard);
- * purple_whiteboard_get_session:
- * @account: A #PurpleAccount instance.
- * @who: The name of the user you're drawing with.
- * Finds a whiteboard from @account and @who.
- * Returns: (transfer none): The #PurpleWhiteboard instance if found, otherwise
-PurpleWhiteboard *purple_whiteboard_get_session(PurpleAccount *account, const gchar *who);
* purple_whiteboard_draw_list_destroy:
* @draw_list: (element-type gint): The drawing list.
@@ -313,6 +303,20 @@
gpointer purple_whiteboard_get_protocol_data(PurpleWhiteboard *whiteboard);
+ * purple_whiteboard_equal: + * @whiteboard1: The first #PurpleWhiteboard instance to check. + * @whiteboard2: The second #PurpleWhiteboard instance to check. + * Checks the id's for @whiteboard1 and @whiteboard2 and return whether or not + * Returns: %TRUE if the id's of @whiteboard1 and @whiteboard2 are equal. +gboolean purple_whiteboard_equal(PurpleWhiteboard *whiteboard1, PurpleWhiteboard *whiteboard2); #endif /* PURPLE_WHITEBOARD_H */
--- a/meson.build Thu Sep 02 21:22:55 2021 -0500
+++ b/meson.build Thu Sep 02 21:28:40 2021 -0500
@@ -230,7 +230,7 @@
# #######################################################################
# # Check for GLib 2.44 (required)
# #######################################################################
-glib = dependency('glib-2.0', version : '>= 2.52.0')
+glib = dependency('glib-2.0', version : '>= 2.64.0') gio = dependency('gio-2.0')
gobject = dependency('gobject-2.0')
gthread = dependency('gthread-2.0')
--- a/pidgin/gtkwhiteboard.c Thu Sep 02 21:22:55 2021 -0500
+++ b/pidgin/gtkwhiteboard.c Thu Sep 02 21:28:40 2021 -0500
@@ -588,13 +588,13 @@
buddy = purple_blist_find_buddy(purple_whiteboard_get_account(wb),
- purple_whiteboard_get_who(wb));
+ purple_whiteboard_get_id(wb)); gtk_window_set_title(GTK_WINDOW(gtkwb),
? purple_buddy_get_contact_alias(buddy)
- : purple_whiteboard_get_who(wb));
- gtk_widget_set_name(GTK_WIDGET(gtkwb), purple_whiteboard_get_who(wb));
+ : purple_whiteboard_get_id(wb)); + gtk_widget_set_name(GTK_WIDGET(gtkwb), purple_whiteboard_get_id(wb)); gtk_widget_set_size_request(GTK_WIDGET(gtkwb->drawing_area),
gtkwb->width, gtkwb->height);
--- a/po/POTFILES.in Thu Sep 02 21:22:55 2021 -0500
+++ b/po/POTFILES.in Thu Sep 02 21:28:40 2021 -0500
@@ -268,6 +268,7 @@
libpurple/purpleprotocolserver.c
libpurple/purplewhiteboard.c
+libpurple/purplewhiteboardmanager.c libpurple/purplewhiteboarduiops.c
libpurple/queuedoutputstream.c