protocols/demo/purpledemoplugin.c

Thu, 09 May 2024 20:50:45 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 09 May 2024 20:50:45 -0500
changeset 42763
e73dd56b68f1
parent 42652
225762d4e206
child 43036
bb4db2d67c61
permissions
-rw-r--r--

Remove the media implementation from the Demo protocol plugin

This API will be rewritten in the future, but keeping the old version around
isn't helping anything.

Testing Done:
Dialed TMNT

Reviewed at https://reviews.imfreedom.org/r/3174/

41224
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 *
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * Lesser General Public License for more details.
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 *
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 */
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #include <glib.h>
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 #include <glib/gi18n-lib.h>
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 #include <gplugin.h>
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <gplugin-native.h>
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include <purple.h>
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "purpledemoplugin.h"
41999
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41224
diff changeset
28
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41224
diff changeset
29 #include "purpledemoconnection.h"
41224
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 #include "purpledemoprotocol.h"
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 /******************************************************************************
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 * Globals
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 *****************************************************************************/
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 static PurpleProtocol *demo_protocol = NULL;
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 /******************************************************************************
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 * GPlugin Implementation
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 *****************************************************************************/
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 static GPluginPluginInfo *
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 purple_demo_plugin_query(G_GNUC_UNUSED GError **error) {
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 const gchar *authors[] = {
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 "Pidgin Developers <devel@pidgin.im>",
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 NULL
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 };
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 return purple_plugin_info_new(
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 "id", "prpl-demo",
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 "name", "Demo Protocol Plugin",
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 "authors", authors,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 "version", PURPLE_VERSION,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 "category", N_("Protocol"),
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 "summary", N_("A protocol plugin used for demos."),
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 "description", N_("A protocol plugin that helps to demonstrate "
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 "features of libpurple and clients."),
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 "website", PURPLE_WEBSITE,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 "abi-version", PURPLE_ABI_VERSION,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL |
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 NULL
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 );
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 }
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 static gboolean
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 purple_demo_plugin_load(GPluginPlugin *plugin, GError **error) {
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 PurpleProtocolManager *manager = NULL;
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 if(PURPLE_IS_PROTOCOL(demo_protocol)) {
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 g_set_error_literal(error, PURPLE_DEMO_DOMAIN, 0,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 "plugin was not cleaned up properly");
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 return FALSE;
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 }
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
41999
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41224
diff changeset
75 purple_demo_connection_register(GPLUGIN_NATIVE_PLUGIN(plugin));
41224
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 purple_demo_protocol_register(GPLUGIN_NATIVE_PLUGIN(plugin));
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 manager = purple_protocol_manager_get_default();
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 demo_protocol = purple_demo_protocol_new();
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 if(!purple_protocol_manager_register(manager, demo_protocol, error)) {
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 g_clear_object(&demo_protocol);
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 return FALSE;
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 }
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 return TRUE;
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 }
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 static gboolean
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 purple_demo_plugin_unload(G_GNUC_UNUSED GPluginPlugin *plugin,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 G_GNUC_UNUSED gboolean shutdown,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 GError **error)
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 {
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 PurpleProtocolManager *manager = purple_protocol_manager_get_default();
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 if(!PURPLE_IS_PROTOCOL(demo_protocol)) {
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 g_set_error_literal(error, PURPLE_DEMO_DOMAIN, 0,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 "plugin was not setup properly");
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 return FALSE;
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 }
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 if(!purple_protocol_manager_unregister(manager, demo_protocol, error)) {
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 return FALSE;
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 }
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 g_clear_object(&demo_protocol);
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 return TRUE;
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 }
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 GPLUGIN_NATIVE_PLUGIN_DECLARE(purple_demo_plugin)

mercurial