libpurple/protocols/ircv3/purpleircv3messagehandlers.c

Sat, 12 Nov 2022 15:37:03 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Sat, 12 Nov 2022 15:37:03 -0600
changeset 41912
3bc50beccf03
parent 41870
7668d023ae05
child 41916
4ee9cb957595
permissions
-rw-r--r--

Remove the Novell GroupWise protocol plugin

We haven't been able to test this in forever, and as such, it hasn't received
any real maintenance. So rather than continue this cycle we're going to cut our
loses.

Testing Done:
Compiled and greped everything. I've left the man pages for now as they need their own overhaul.

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

41796
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * (at your option) any later version.
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 *
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * GNU General Public License for more details.
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 *
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * along with this program; if not, see <https://www.gnu.org/licenses/>.
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 */
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #include "purpleircv3messagehandlers.h"
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 #include "purpleircv3connection.h"
41807
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
22 #include "purpleircv3core.h"
41796
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23
41807
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
24 /******************************************************************************
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
25 * Fallback
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
26 *****************************************************************************/
41796
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 gboolean
41821
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
28 purple_ircv3_message_handler_fallback(GHashTable *tags, const char *source,
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
29 const char *command, guint n_params,
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
30 GStrv params, GError **error,
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
31 gpointer data)
41796
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 {
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 gchar *joined = g_strjoinv(" ", params);
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 g_message("-- unhandled message --");
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 g_message("source: %s", source);
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 g_message("command: %s", command);
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 g_message("params: %s", joined);
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 g_message("-- end of unhandled message --");
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 g_free(joined);
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 return TRUE;
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 }
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45
41807
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
46 /******************************************************************************
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
47 * Capabilities
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
48 *****************************************************************************/
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
49 static gboolean
41821
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
50 purple_ircv3_message_handler_cap_list(guint n_params, GStrv params,
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
51 GError **error, gpointer data)
41807
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
52 {
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
53 PurpleIRCv3Connection *connection = data;
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
54
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
55 /* Check if we have more messages coming. */
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
56 if(n_params > 1 && purple_strequal(params[0], "*")) {
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
57 purple_ircv3_connection_append_capabilities(connection, params[1]);
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
58 } else {
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
59 purple_ircv3_connection_append_capabilities(connection, params[0]);
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
60
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
61 g_message("**** capabilities-list: %s",
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
62 purple_ircv3_connection_get_capabilities(connection));
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
63
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
64 purple_ircv3_connection_writef(connection, "CAP END");
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
65 }
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
66
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
67 return TRUE;
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
68 }
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
69
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
70 gboolean
41821
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
71 purple_ircv3_message_handler_cap(GHashTable *tags, const char *source,
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
72 const char *command, guint n_params,
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
73 GStrv params, GError **error, gpointer data)
41807
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
74 {
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
75 const char *subcommand = NULL;
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
76 guint n_subparams = 0;
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
77 GStrv subparams = NULL;
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
78
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
79 if(n_params < 2) {
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
80 return FALSE;
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
81 }
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
82
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
83 /* Initialize some variables to make it easier to call our sub command
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
84 * handlers.
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
85 *
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
86 * params[0] is the nick or * if it hasn't been negotiated yet, we don't
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
87 * have a need for this, so we ignore it.
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
88 *
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
89 * params[1] is the CAP subcommand sent from the server. We use it here
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
90 * purely for dispatching to our subcommand handlers.
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
91 *
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
92 * params[2] and higher are the parameters to the subcommand. To make the
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
93 * code a bit easier all around, we subtract 2 from n_params to remove
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
94 * references to the nick and subcommand name. Like wise, we add 2 to the
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
95 * params GStrv which will now point to the second item in the array again
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
96 * ignoring the nick and subcommand.
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
97 */
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
98 subcommand = params[1];
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
99 n_subparams = n_params - 2;
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
100 subparams = params + 2;
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
101
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
102 /* Dispatch the subcommand. */
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
103 if(purple_strequal(subcommand, "LS") ||
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
104 purple_strequal(subcommand, "LIST"))
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
105 {
41821
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
106 return purple_ircv3_message_handler_cap_list(n_subparams, subparams,
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
107 error, data);
41807
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
108 }
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
109
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
110 g_set_error(error, PURPLE_IRCV3_DOMAIN, 0,
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
111 "No handler for CAP subcommand %s", subcommand);
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
112
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
113 return FALSE;
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
114 }
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
115
41821
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
116 /******************************************************************************
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
117 * General Commands
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
118 *****************************************************************************/
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
119 gboolean
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
120 purple_ircv3_message_handler_ping(GHashTable *tags, const char *source,
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
121 const char *command, guint n_params,
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
122 GStrv params, GError **error,
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
123 gpointer data)
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
124 {
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
125 PurpleIRCv3Connection *connection = data;
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
126
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
127 if(n_params == 1) {
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
128 purple_ircv3_connection_writef(connection, "PONG %s", params[0]);
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
129 } else {
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
130 purple_ircv3_connection_writef(connection, "PONG");
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
131 }
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
132
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
133 return TRUE;
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
134 }
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
135
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
136 gboolean
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
137 purple_ircv3_message_handler_privmsg(G_GNUC_UNUSED GHashTable *tags,
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
138 const char *source,
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
139 const char *command,
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
140 guint n_params,
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
141 GStrv params,
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
142 G_GNUC_UNUSED GError **error,
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
143 gpointer data)
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
144 {
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
145 PurpleIRCv3Connection *connection = data;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
146 PurpleAccount *account = NULL;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
147 PurpleContact *contact = NULL;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
148 PurpleContactManager *contact_manager = NULL;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
149 PurpleConversation *conversation = NULL;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
150 PurpleConversationManager *conversation_manager = NULL;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
151 PurpleMessage *message = NULL;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
152 PurpleMessageFlags flags = PURPLE_MESSAGE_RECV;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
153 const char *target = NULL;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
154
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
155 if(n_params != 2) {
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
156 char *body = g_strjoinv(" ", params);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
157 g_warning("unknown privmsg message format: '%s'", body);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
158 g_free(body);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
159
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
160 return FALSE;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
161 }
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
162
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41842
diff changeset
163 account = purple_connection_get_account(PURPLE_CONNECTION(connection));
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
164
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
165 contact_manager = purple_contact_manager_get_default();
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
166 contact = purple_contact_manager_find_with_username(contact_manager,
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
167 account,
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
168 source);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
169 if(!PURPLE_IS_CONTACT(contact)) {
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
170 contact = purple_contact_new(account, NULL);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
171 purple_contact_set_username(contact, source);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
172 purple_contact_manager_add(contact_manager, contact);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
173 }
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
174
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
175 target = params[0];
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
176 conversation_manager = purple_conversation_manager_get_default();
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
177 conversation = purple_conversation_manager_find(conversation_manager,
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
178 account, target);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
179 if(!PURPLE_IS_CONVERSATION(conversation)) {
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
180 if(target[0] == '#') {
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
181 conversation = purple_chat_conversation_new(account, target);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
182 } else {
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
183 conversation = purple_im_conversation_new(account, target);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
184 }
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
185
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
186 purple_conversation_manager_register(conversation_manager,
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
187 conversation);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
188 }
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
189
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
190 if(purple_strequal(command, "NOTICE")) {
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
191 flags |= PURPLE_MESSAGE_NOTIFY;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
192 }
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
193
41842
69ad8747a701 ircv3: Fix flags on NOTICE messages
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41821
diff changeset
194 message = purple_message_new_incoming(source, params[1], flags, 0);
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
195
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
196 purple_conversation_write_message(conversation, message);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
197
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
198 g_clear_object(&message);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
199 g_clear_object(&conversation);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
200
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
201 return TRUE;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
202 }

mercurial