libpurple/protocols/ircv3/purpleircv3core.c

Mon, 31 Oct 2022 23:00:12 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 31 Oct 2022 23:00:12 -0500
changeset 41870
7668d023ae05
parent 41783
5ea6c18ef7a8
child 41941
355bd17297f0
permissions
-rw-r--r--

Update the IRCv3 protocol plugin to the new connection setup

Testing Done:
Connected and disconnected an IRCv3 account and verified that it worked and that there were no `g_warnings`.

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

41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * (at your option) any later version.
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 *
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * GNU General Public License for more details.
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 *
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * along with this program; if not, see <https://www.gnu.org/licenses/>.
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 */
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #include <glib.h>
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 #include <glib/gi18n-lib.h>
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 #include <gplugin.h>
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <gplugin-native.h>
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include <purple.h>
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
41774
170078e728c0 Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
27 #include "purpleircv3core.h"
170078e728c0 Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
28
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41774
diff changeset
29 #include "purpleircv3connection.h"
41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 #include "purpleircv3protocol.h"
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 /******************************************************************************
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 * Globals
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 *****************************************************************************/
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 static PurpleProtocol *ircv3_protocol = NULL;
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 /******************************************************************************
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 * GPlugin Exports
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 *****************************************************************************/
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 static GPluginPluginInfo *
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 purple_ircv3_query(G_GNUC_UNUSED GError **error) {
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 PurplePluginInfoFlags flags = PURPLE_PLUGIN_INFO_FLAGS_INTERNAL |
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD;
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 const gchar * const authors[] = {
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 "Pidgin Developers <devel@pidgin.im>",
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 NULL
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 };
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 return purple_plugin_info_new(
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 "id", "prpl-ircv3",
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 "name", "IRCv3 Protocol",
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 "authors", authors,
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 "version", DISPLAY_VERSION,
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 "category", N_("Protocol"),
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 "summary", N_("IRCv3 Protocol Plugin"),
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 "description", N_("Modern IRC Support"),
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 "website", PURPLE_WEBSITE,
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 "abi-version", PURPLE_ABI_VERSION,
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 "flags", flags,
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 NULL);
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 }
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 static gboolean
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 purple_ircv3_load(GPluginPlugin *plugin, GError **error) {
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 PurpleProtocolManager *manager = NULL;
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 if(PURPLE_IS_PROTOCOL(ircv3_protocol)) {
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0,
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 "plugin was not cleaned up properly");
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 return FALSE;
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 }
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 purple_ircv3_protocol_register(GPLUGIN_NATIVE_PLUGIN(plugin));
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41774
diff changeset
75 purple_ircv3_connection_register(GPLUGIN_NATIVE_PLUGIN(plugin));
41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 manager = purple_protocol_manager_get_default();
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 ircv3_protocol = purple_ircv3_protocol_new();
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 if(!purple_protocol_manager_register(manager, ircv3_protocol, error)) {
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 g_clear_object(&ircv3_protocol);
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 return FALSE;
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 }
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 return TRUE;
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 }
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 static gboolean
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 purple_ircv3_unload(GPluginPlugin *plugin, gboolean shutdown, GError **error) {
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 PurpleProtocolManager *manager = NULL;
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 if(!PURPLE_IS_PROTOCOL(ircv3_protocol)) {
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0,
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 "plugin was not setup properly");
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 return FALSE;
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 }
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 manager = purple_protocol_manager_get_default();
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 if(!purple_protocol_manager_unregister(manager, ircv3_protocol, error)) {
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 return FALSE;
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 }
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 g_clear_object(&ircv3_protocol);
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 return TRUE;
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 }
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 GPLUGIN_NATIVE_PLUGIN_DECLARE(purple_ircv3)

mercurial