libpurple/protocols/ircv3/purpleircv3messagehandlers.c

Mon, 04 Dec 2023 02:21:08 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 04 Dec 2023 02:21:08 -0600
changeset 42544
95d36c221e21
parent 42543
6dcf672547fe
child 42568
31e8c7c92e2f
permissions
-rw-r--r--

Implement CTCP ACTION and VERSION

Testing Done:
Used irssi to send `CTCP VERSION` to a channel and the pidgin3 user directly and verified the response was sent and that the default message was still displayed.

Bugs closed: PIDGIN-17721

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

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
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
19 #include <glib/gi18n-lib.h>
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
20
41796
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 #include "purpleircv3messagehandlers.h"
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "purpleircv3connection.h"
42503
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
24 #include "purpleircv3constants.h"
41807
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
25 #include "purpleircv3core.h"
42530
55b30ce86f17 IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents: 42518
diff changeset
26 #include "purpleircv3ctcp.h"
42505
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42503
diff changeset
27 #include "purpleircv3formatting.h"
42345
e01084003f50 IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
28 #include "purpleircv3source.h"
41796
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29
41807
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
30 /******************************************************************************
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
31 * Fallback
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
32 *****************************************************************************/
41796
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 gboolean
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
34 purple_ircv3_message_handler_fallback(PurpleIRCv3Message *message,
41941
355bd17297f0 Set the C standard to C99 and set warning_level to 2 for the IRCv3 Protocol Plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41916
diff changeset
35 G_GNUC_UNUSED GError **error,
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
36 gpointer data)
41796
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 {
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
38 PurpleIRCv3Connection *connection = data;
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
39 char *new_command = NULL;
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
40 const char *command = NULL;
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
41
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
42 command = purple_ircv3_message_get_command(message);
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
43
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
44 new_command = g_strdup_printf(_("unknown command '%s'"), command);
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
45 purple_ircv3_message_set_command(message, new_command);
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
46 purple_ircv3_connection_add_status_message(connection, message);
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
47
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
48 g_clear_pointer(&new_command, g_free);
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
49
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
50 return TRUE;
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
51 }
41796
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
53 /******************************************************************************
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
54 * Status Messages
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
55 *****************************************************************************/
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
56 gboolean
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
57 purple_ircv3_message_handler_status(PurpleIRCv3Message *message,
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
58 G_GNUC_UNUSED GError **error,
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
59 gpointer data)
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
60 {
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
61 purple_ircv3_connection_add_status_message(data, message);
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
62
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
63 return TRUE;
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
64 }
41796
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
66 gboolean
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
67 purple_ircv3_message_handler_status_ignore_param0(PurpleIRCv3Message *message,
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
68 GError **error,
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
69 gpointer data)
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
70 {
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
71 GStrv params = NULL;
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
72 GStrv new_params = NULL;
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
73 guint n_params = 0;
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
74
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
75 params = purple_ircv3_message_get_params(message);
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
76 if(params != NULL) {
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
77 n_params = g_strv_length(params);
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
78 }
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
79
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
80 if(n_params <= 1) {
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
81 g_set_error(error, PURPLE_IRCV3_DOMAIN, 0,
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
82 "expected n_params > 1, got %u", n_params);
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
83
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
84 return FALSE;
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
85 }
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42179
diff changeset
86
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
87 /* We need to make a copy because otherwise we'd get a use after free in
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
88 * set_params.
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
89 */
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
90 new_params = g_strdupv(params + 1);
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
91 purple_ircv3_message_set_params(message, new_params);
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
92 g_clear_pointer(&new_params, g_strfreev);
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
93
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
94 purple_ircv3_connection_add_status_message(data, message);
41796
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 return TRUE;
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 }
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98
41807
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
99 /******************************************************************************
41821
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
100 * General Commands
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
101 *****************************************************************************/
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
102 gboolean
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
103 purple_ircv3_message_handler_ping(PurpleIRCv3Message *message,
41941
355bd17297f0 Set the C standard to C99 and set warning_level to 2 for the IRCv3 Protocol Plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41916
diff changeset
104 G_GNUC_UNUSED GError **error,
41821
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
105 gpointer data)
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
106 {
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
107 PurpleIRCv3Connection *connection = data;
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
108 GStrv params = NULL;
41821
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
109
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
110 params = purple_ircv3_message_get_params(message);
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
111
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
112 if(params != NULL && g_strv_length(params) == 1) {
41821
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
113 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
114 } else {
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
115 purple_ircv3_connection_writef(connection, "PONG");
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
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
118 return TRUE;
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
119 }
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
120
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
121 gboolean
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
122 purple_ircv3_message_handler_privmsg(PurpleIRCv3Message *v3_message,
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
123 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
124 gpointer data)
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
125 {
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
126 PurpleIRCv3Connection *connection = data;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
127 PurpleContact *contact = NULL;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
128 PurpleConversation *conversation = NULL;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
129 PurpleMessage *message = NULL;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
130 PurpleMessageFlags flags = PURPLE_MESSAGE_RECV;
42056
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
131 GDateTime *dt = NULL;
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
132 GHashTable *tags = NULL;
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
133 GStrv params = NULL;
42056
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
134 gpointer raw_id = NULL;
42294
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
135 gpointer raw_timestamp = NULL;
42345
e01084003f50 IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
136 char *nick = NULL;
42505
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42503
diff changeset
137 char *stripped = NULL;
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
138 const char *command = NULL;
42056
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
139 const char *id = NULL;
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
140 const char *source = NULL;
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
141 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
142
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
143 command = purple_ircv3_message_get_command(v3_message);
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
144 params = purple_ircv3_message_get_params(v3_message);
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
145 source = purple_ircv3_message_get_source(v3_message);
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
146 tags = purple_ircv3_message_get_tags(v3_message);
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
147
42382
343e30628383 IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42378
diff changeset
148 if(params == NULL) {
343e30628383 IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42378
diff changeset
149 g_warning("privmsg received with no parameters");
343e30628383 IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42378
diff changeset
150
343e30628383 IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42378
diff changeset
151 return FALSE;
343e30628383 IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42378
diff changeset
152 }
343e30628383 IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42378
diff changeset
153
343e30628383 IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42378
diff changeset
154 if(g_strv_length(params) != 2) {
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
155 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
156 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
157 g_free(body);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
158
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
159 return FALSE;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
160 }
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
161
42345
e01084003f50 IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
162 purple_ircv3_source_parse(source, &nick, NULL, NULL);
e01084003f50 IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
163
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
164 /* Find or create the conversation. */
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
165 target = params[0];
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42382
diff changeset
166 if(!purple_ircv3_connection_is_channel(connection, target)) {
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42382
diff changeset
167 target = nick;
42345
e01084003f50 IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
168 }
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42382
diff changeset
169 conversation = purple_ircv3_connection_find_or_create_conversation(connection,
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42382
diff changeset
170 target);
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
171 /* Find or create the contact. */
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
172 contact = purple_ircv3_connection_find_or_create_contact(connection, nick);
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
173 if(PURPLE_IS_CONTACT(contact)) {
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
174 PurpleConversationMember *member = NULL;
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
175
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
176 /* Update the contact's sid as it may have changed. */
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
177 purple_contact_info_set_sid(PURPLE_CONTACT_INFO(contact), source);
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
178
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
179 /* Make sure the contact is in the conversation. */
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
180 member = purple_conversation_find_member(conversation,
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
181 PURPLE_CONTACT_INFO(contact));
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
182 if(!PURPLE_IS_CONVERSATION_MEMBER(member)) {
42518
a49b3c031794 Remove a dead assignment that scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42513
diff changeset
183 purple_conversation_add_member(conversation,
a49b3c031794 Remove a dead assignment that scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42513
diff changeset
184 PURPLE_CONTACT_INFO(contact),
a49b3c031794 Remove a dead assignment that scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42513
diff changeset
185 FALSE, NULL);
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
186 }
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
187 }
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
188
42056
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
189 /* Grab the msgid if one was provided. */
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
190 if(g_hash_table_lookup_extended(tags, "msgid", NULL, &raw_id)) {
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
191 if(!purple_strempty(raw_id)) {
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
192 id = raw_id;
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
193 }
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
194 }
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
195
42510
fe16c4d773b4 IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
196 if(purple_strequal(command, PURPLE_IRCV3_MSG_NOTICE)) {
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
197 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
198 }
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
199
42294
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
200 /* Determine the timestamp of the message. */
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
201 if(g_hash_table_lookup_extended(tags, "time", NULL, &raw_timestamp)) {
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
202 const char *timestamp = raw_timestamp;
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
203
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
204 if(!purple_strempty(timestamp)) {
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
205 GTimeZone *tz = g_time_zone_new_utc();
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
206
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
207 dt = g_date_time_new_from_iso8601(timestamp, tz);
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
208
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
209 g_time_zone_unref(tz);
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
210 }
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
211 }
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
212
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
213 /* If the server didn't provide a time, use the current local time. */
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
214 if(dt == NULL) {
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
215 dt = g_date_time_new_now_local();
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
216 }
42056
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
217
42505
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42503
diff changeset
218 stripped = purple_ircv3_formatting_strip(params[1]);
42056
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
219 message = g_object_new(
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
220 PURPLE_TYPE_MESSAGE,
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
221 "author", source,
42505
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42503
diff changeset
222 "contents", stripped,
42056
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
223 "flags", flags,
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
224 "id", id,
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
225 "timestamp", dt,
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
226 NULL);
42505
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42503
diff changeset
227 g_free(stripped);
42056
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
228
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
229 g_date_time_unref(dt);
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
230
42530
55b30ce86f17 IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents: 42518
diff changeset
231 /* Check if this is a CTCP message. */
42543
6dcf672547fe IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents: 42530
diff changeset
232 if(!purple_ircv3_ctcp_handle(connection, conversation, message)) {
6dcf672547fe IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents: 42530
diff changeset
233 purple_conversation_write_message(conversation, message);
6dcf672547fe IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents: 42530
diff changeset
234 }
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
235
42345
e01084003f50 IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
236 g_clear_pointer(&nick, g_free);
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
237 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
238
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
239 return TRUE;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
240 }
42503
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
241
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
242 gboolean
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
243 purple_ircv3_message_handler_topic(PurpleIRCv3Message *message,
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
244 GError **error,
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
245 gpointer data)
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
246 {
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
247 PurpleIRCv3Connection *connection = data;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
248 PurpleConversation *conversation = NULL;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
249 GStrv params = NULL;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
250 const char *channel = NULL;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
251 const char *command = NULL;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
252 const char *topic = NULL;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
253 guint n_params = 0;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
254
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
255 command = purple_ircv3_message_get_command(message);
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
256 params = purple_ircv3_message_get_params(message);
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
257 n_params = g_strv_length(params);
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
258
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
259 if(purple_strequal(command, PURPLE_IRCV3_MSG_TOPIC)) {
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
260 if(n_params != 2) {
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
261 g_set_error(error, PURPLE_IRCV3_DOMAIN, 0,
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
262 "received TOPIC with %u parameters, expected 2",
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
263 n_params);
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
264
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
265 return FALSE;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
266 }
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
267
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
268 channel = params[0];
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
269 topic = params[1];
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
270 } else if(purple_strequal(command, PURPLE_IRCV3_RPL_NOTOPIC)) {
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
271 if(n_params != 3) {
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
272 g_set_error(error, PURPLE_IRCV3_DOMAIN, 0,
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
273 "received RPL_NOTOPIC with %u parameters, expected 3",
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
274 n_params);
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
275
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
276 return FALSE;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
277 }
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
278
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
279 channel = params[1];
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
280 topic = "";
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
281 } else if(purple_strequal(command, PURPLE_IRCV3_RPL_TOPIC)) {
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
282 if(n_params != 3) {
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
283 g_set_error(error, PURPLE_IRCV3_DOMAIN, 0,
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
284 "received RPL_TOPIC with %u parameters, expected 3",
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
285 n_params);
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
286
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
287 return FALSE;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
288 }
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
289
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
290 channel = params[1];
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
291 topic = params[2];
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
292 } else {
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
293 g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, "unexpected command %s",
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
294 command);
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
295
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
296 return FALSE;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
297 }
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
298
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
299 conversation = purple_ircv3_connection_find_or_create_conversation(connection,
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
300 channel);
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
301 if(!PURPLE_IS_CONVERSATION(conversation)) {
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
302 g_set_error(error, PURPLE_IRCV3_DOMAIN, 0,
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
303 "failed to find or create channel '%s'", channel);
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
304
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
305 return FALSE;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
306 }
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
307
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
308 purple_conversation_set_topic(conversation, topic);
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
309
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
310 return TRUE;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
311 }

mercurial