pidgin/pidgin

Parents 785c4056ce54
Children bcfc2c9e5213
Create PurpleProtocolWhiteboard and remove PurpleProtocolFactory

Testing Done:
Compiled

Reviewed at https://reviews.imfreedom.org/r/1809/
--- a/libpurple/connection.c Tue Sep 20 02:24:00 2022 -0500
+++ b/libpurple/connection.c Tue Sep 20 02:43:20 2022 -0500
@@ -31,7 +31,6 @@
#include "purpleenums.h"
#include "purpleprivate.h"
#include "purpleprotocolserver.h"
-#include "purpleprotocolfactory.h"
#include "request.h"
#include "server.h"
#include "signals.h"
--- a/libpurple/meson.build Tue Sep 20 02:24:00 2022 -0500
+++ b/libpurple/meson.build Tue Sep 20 02:43:20 2022 -0500
@@ -73,13 +73,13 @@
'purpleprotocolactions.c',
'purpleprotocolchat.c',
'purpleprotocolclient.c',
- 'purpleprotocolfactory.c',
'purpleprotocolim.c',
'purpleprotocolmanager.c',
'purpleprotocolmedia.c',
'purpleprotocolprivacy.c',
'purpleprotocolroomlist.c',
'purpleprotocolserver.c',
+ 'purpleprotocolwhiteboard.c',
'purpleproxyinfo.c',
'purpleroomlistroom.c',
'purplesqlitehistoryadapter.c',
@@ -175,13 +175,13 @@
'purpleprotocolactions.h',
'purpleprotocolchat.h',
'purpleprotocolclient.h',
- 'purpleprotocolfactory.h',
'purpleprotocolim.h',
'purpleprotocolmedia.h',
'purpleprotocolmanager.h',
'purpleprotocolprivacy.h',
'purpleprotocolroomlist.h',
'purpleprotocolserver.h',
+ 'purpleprotocolwhiteboard.h',
'purpleproxyinfo.h',
'purpleroomlistroom.h',
'purplesqlitehistoryadapter.h',
--- a/libpurple/purpleprotocolfactory.c Tue Sep 20 02:24:00 2022 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#include "purpleprotocolfactory.h"
-
-G_DEFINE_INTERFACE(PurpleProtocolFactory, purple_protocol_factory,
- PURPLE_TYPE_PROTOCOL);
-
-/******************************************************************************
- * GInterface Implementation
- *****************************************************************************/
-static void
-purple_protocol_factory_default_init(PurpleProtocolFactoryInterface *iface) {
-}
-
-/******************************************************************************
- * Public API
- *****************************************************************************/
-PurpleWhiteboard *
-purple_protocol_factory_whiteboard_new(PurpleProtocolFactory *factory,
- PurpleAccount *account,
- const gchar *who,
- gint state)
-{
- PurpleProtocolFactoryInterface *iface = NULL;
-
- g_return_val_if_fail(PURPLE_IS_PROTOCOL_FACTORY(factory), NULL);
- g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
- g_return_val_if_fail(who, NULL);
-
- iface = PURPLE_PROTOCOL_FACTORY_GET_IFACE(factory);
- if(iface && iface->whiteboard_new) {
- return iface->whiteboard_new(factory, account, who, state);
- }
-
- return NULL;
-}
--- a/libpurple/purpleprotocolfactory.h Tue Sep 20 02:24:00 2022 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-/*
- * Purple - Internet Messaging Library
- * Copyright (C) Pidgin Developers <devel@pidgin.im>
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <https://www.gnu.org/licenses/>.
- */
-
-#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
-# error "only <purple.h> may be included directly"
-#endif
-
-#ifndef PURPLE_PROTOCOL_FACTORY_H
-#define PURPLE_PROTOCOL_FACTORY_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include <libpurple/account.h>
-
-G_BEGIN_DECLS
-
-#define PURPLE_TYPE_PROTOCOL_FACTORY (purple_protocol_factory_iface_get_type())
-
-/**
- * PurpleProtocolFactory:
- *
- * An interface where protocols can expose subclasses of libpurple objects.
- *
- * Since: 3.0.0
- */
-G_DECLARE_INTERFACE(PurpleProtocolFactory, purple_protocol_factory, PURPLE,
- PROTOCOL_FACTORY, PurpleProtocol)
-
-/**
- * PurpleProtocolFactoryInterface:
- * @connection_new: Creates a new protocol-specific connection object that
- * subclasses #PurpleConnection.
- * @roomlist_new: Creates a new protocol-specific room list object that
- * subclasses #PurpleRoomlist.
- * @whiteboard_new: Creates a new protocol-specific whiteboard object that
- * subclasses #PurpleWhiteboard.
- *
- * The protocol factory interface.
- *
- * This interface provides callbacks for construction of protocol-specific
- * subclasses of some purple objects.
- */
-struct _PurpleProtocolFactoryInterface {
- /*< private >*/
- GTypeInterface parent_iface;
-
- /*< public >*/
- PurpleWhiteboard *(*whiteboard_new)(PurpleProtocolFactory *factory,
- PurpleAccount *account,
- const gchar *who,
- gint state);
-};
-
-/**
- * purple_protocol_factory_get_type:
- *
- * The standard `_get_type` function for #PurpleProtocolFactory.
- *
- * Returns: The #GType for the protocol factory interface.
- *
- * Since: 3.0.0
- */
-
-/**
- * purple_protocol_factory_whiteboard_new:
- * @factory: The #PurpleProtocolFactory instance.
- * @account: The #PurpleAccount instance to create a whiteboard for.
- * @who: The name of the contact to create a whiteboard with.
- * @state: NFI.
- *
- * Creates a new protocol-specific #PurpleWhiteboard subclass.
- *
- * Returns: (transfer full): The new #PurpleWhiteboard subclass for @account
- * and @who.
- *
- * Since: 3.0.0
- */
-PurpleWhiteboard *purple_protocol_factory_whiteboard_new(PurpleProtocolFactory *factory,
- PurpleAccount *account, const gchar *who, gint state);
-
-G_END_DECLS
-
-#endif /* PURPLE_PROTOCOL_FACTORY_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/purpleprotocolwhiteboard.c Tue Sep 20 02:43:20 2022 -0500
@@ -0,0 +1,54 @@
+/*
+ * Purple - Internet Messaging Library
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "purpleprotocolwhiteboard.h"
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+G_DEFINE_INTERFACE(PurpleProtocolWhiteboard, purple_protocol_whiteboard,
+ PURPLE_TYPE_PROTOCOL)
+
+static void
+purple_protocol_whiteboard_default_init(PurpleProtocolWhiteboardInterface *iface)
+{
+}
+
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+PurpleWhiteboard *
+purple_protocol_whiteboard_create(PurpleProtocolWhiteboard *whiteboard,
+ PurpleAccount *account, const gchar *who,
+ gint state)
+{
+ PurpleProtocolWhiteboardInterface *iface = NULL;
+
+ g_return_val_if_fail(PURPLE_IS_PROTOCOL_WHITEBOARD(whiteboard), NULL);
+
+ iface = PURPLE_PROTOCOL_WHITEBOARD_GET_IFACE(whiteboard);
+ if(iface != NULL && iface->create != NULL) {
+ return iface->create(whiteboard, account, who, state);
+ }
+
+ return NULL;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/purpleprotocolwhiteboard.h Tue Sep 20 02:43:20 2022 -0500
@@ -0,0 +1,89 @@
+/*
+ * Purple - Internet Messaging Library
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
+# error "only <purple.h> may be included directly"
+#endif
+
+#ifndef PURPLE_PROTOCOL_WHITEBOARD_H
+#define PURPLE_PROTOCOL_WHITEBOARD_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libpurple/account.h>
+#include <libpurple/purplewhiteboard.h>
+
+#define PURPLE_TYPE_PROTOCOL_WHITEBOARD (purple_protocol_whiteboard_get_type())
+G_DECLARE_INTERFACE(PurpleProtocolWhiteboard, purple_protocol_whiteboard, PURPLE,
+ PROTOCOL_WHITEBOARD, PurpleProtocol)
+
+/**
+ * PurpleProtocolWhiteboard:
+ *
+ * The #PurpleProtocolWhiteboard interface defines the behavior of a protocol's
+ * whiteboard interface.
+ *
+ * Since: 3.0.0
+ */
+
+/**
+ * PurpleProtocolWhiteboardInterface:
+ * @create: Creates a new whiteboard.
+ *
+ * The protocol whiteboard interface.
+ *
+ * This interface provides a gateway between purple and the protocol.
+ *
+ * Since: 3.0.0
+ */
+struct _PurpleProtocolWhiteboardInterface {
+ /*< private >*/
+ GTypeInterface parent;
+
+ /*< public >*/
+ PurpleWhiteboard *(*create)(PurpleProtocolWhiteboard *whiteboard, PurpleAccount *account, const gchar *who, gint state);
+
+ /*< private >*/
+ gpointer reserved[4];
+};
+
+G_BEGIN_DECLS
+
+/**
+ * purple_protocol_whiteboard_create:
+ * @whiteboard: The instance.
+ * @account: The [class@Purple.Account].
+ * @who: The username of the contact who the whiteboard is being created for.
+ * @state: The initial state of the whiteboard.
+ *
+ * Creates a new [class@Purple.Whiteboard].
+ *
+ * Returns: (transfer full): The new whiteboard instance.
+ *
+ * Since: 3.0.0
+ */
+PurpleWhiteboard *purple_protocol_whiteboard_create(PurpleProtocolWhiteboard *actions, PurpleAccount *account, const gchar *who, gint state);
+
+G_END_DECLS
+
+#endif /* PURPLE_PROTOCOL_WHITEBOARD_H */
--- a/libpurple/purplewhiteboard.c Tue Sep 20 02:24:00 2022 -0500
+++ b/libpurple/purplewhiteboard.c Tue Sep 20 02:43:20 2022 -0500
@@ -24,7 +24,7 @@
#include "purplewhiteboard.h"
#include "purpleprotocol.h"
-#include "purpleprotocolfactory.h"
+#include "purpleprotocolwhiteboard.h"
#include "purplewhiteboarduiops.h"
#include "util.h"
@@ -475,9 +475,9 @@
g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol), NULL);
- if(PURPLE_IS_PROTOCOL_FACTORY(protocol)) {
- whiteboard = purple_protocol_factory_whiteboard_new(
- PURPLE_PROTOCOL_FACTORY(protocol), account, id, state);
+ if(PURPLE_IS_PROTOCOL_WHITEBOARD(protocol)) {
+ whiteboard = purple_protocol_whiteboard_create(
+ PURPLE_PROTOCOL_WHITEBOARD(protocol), account, id, state);
} else {
whiteboard = g_object_new(PURPLE_TYPE_WHITEBOARD,
"account", account,
--- a/libpurple/roomlist.c Tue Sep 20 02:24:00 2022 -0500
+++ b/libpurple/roomlist.c Tue Sep 20 02:43:20 2022 -0500
@@ -22,7 +22,6 @@
#include "account.h"
#include "connection.h"
#include "debug.h"
-#include "purpleprotocolfactory.h"
#include "roomlist.h"
#include "server.h"
--- a/po/POTFILES.in Tue Sep 20 02:24:00 2022 -0500
+++ b/po/POTFILES.in Tue Sep 20 02:43:20 2022 -0500
@@ -265,13 +265,13 @@
libpurple/purpleprotocol.c
libpurple/purpleprotocolchat.c
libpurple/purpleprotocolclient.c
-libpurple/purpleprotocolfactory.c
libpurple/purpleprotocolim.c
libpurple/purpleprotocolmanager.c
libpurple/purpleprotocolmedia.c
libpurple/purpleprotocolprivacy.c
libpurple/purpleprotocolroomlist.c
libpurple/purpleprotocolserver.c
+libpurple/purpleprotocolwhiteboard.c
libpurple/purplesqlitehistoryadapter.c
libpurple/purpleuiinfo.c
libpurple/purplewhiteboard.c