Sun, 14 Jan 2024 20:08:13 -0600
Make sure all of the license headers for IRCv3 are GPLv2
Testing Done:
Ran `licensecheck` from debian in the following way.
```
$ licensecheck *.[ch] | cut -d: -f 2 | sort | uniq -c
27 GNU General Public License v2.0 or later
```
Reviewed at https://reviews.imfreedom.org/r/2913/
|
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 | * |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
5 | * Purple is the legal property of its developers, whose names are too numerous |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
7 | * source distribution. |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
8 | * |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
9 | * This library is free software; you can redistribute it and/or modify |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * 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
|
11 | * 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
|
12 | * (at your option) any later version. |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
14 | * This library is distributed in the hope that it will be useful, |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * 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
|
16 | * 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
|
17 | * 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
|
18 | * |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
20 | * along with this library; if not, see <https://www.gnu.org/licenses/>. |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
42275
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
23 | #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
|
24 | |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | #include "purpleircv3messagehandlers.h" |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | #include "purpleircv3connection.h" |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
28 | #include "purpleircv3constants.h" |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41796
diff
changeset
|
29 | #include "purpleircv3core.h" |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
42518
diff
changeset
|
30 | #include "purpleircv3ctcp.h" |
|
42505
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
31 | #include "purpleircv3formatting.h" |
|
42345
e01084003f50
IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
32 | #include "purpleircv3source.h" |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41796
diff
changeset
|
34 | /****************************************************************************** |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41796
diff
changeset
|
35 | * Fallback |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41796
diff
changeset
|
36 | *****************************************************************************/ |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
38 | 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
|
39 | 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
|
40 | gpointer data) |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | { |
|
42275
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
42 | PurpleIRCv3Connection *connection = data; |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
43 | char *new_command = NULL; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
44 | const char *command = NULL; |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
45 | |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
46 | 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
|
47 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
48 | 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
|
49 | 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
|
50 | 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
|
51 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
52 | 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
|
53 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
54 | return TRUE; |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
55 | } |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | |
|
42275
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
57 | /****************************************************************************** |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
58 | * Status Messages |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
59 | *****************************************************************************/ |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
60 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
61 | 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
|
62 | 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
|
63 | gpointer data) |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
64 | { |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
65 | 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
|
66 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
67 | return TRUE; |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
68 | } |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | |
|
42275
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
70 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
71 | 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
|
72 | GError **error, |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
73 | gpointer data) |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
74 | { |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
75 | GStrv params = NULL; |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
76 | GStrv new_params = NULL; |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
77 | guint n_params = 0; |
|
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 | 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
|
80 | if(params != NULL) { |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
81 | n_params = g_strv_length(params); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
82 | } |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
83 | |
|
42275
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
84 | if(n_params <= 1) { |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
85 | 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
|
86 | "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
|
87 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
88 | return FALSE; |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
89 | } |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42179
diff
changeset
|
90 | |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
91 | /* 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
|
92 | * set_params. |
|
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 | new_params = g_strdupv(params + 1); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
95 | 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
|
96 | 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
|
97 | |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
98 | 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
|
99 | |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | return TRUE; |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | } |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41796
diff
changeset
|
103 | /****************************************************************************** |
|
41821
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
104 | * General Commands |
|
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
105 | *****************************************************************************/ |
|
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
106 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
107 | 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
|
108 | G_GNUC_UNUSED GError **error, |
|
41821
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
109 | gpointer data) |
|
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
110 | { |
|
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
111 | PurpleIRCv3Connection *connection = data; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
112 | GStrv params = NULL; |
|
41821
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
113 | |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
114 | 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
|
115 | |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
116 | 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
|
117 | 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
|
118 | } else { |
|
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
119 | purple_ircv3_connection_writef(connection, "PONG"); |
|
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
120 | } |
|
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
121 | |
|
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
122 | return TRUE; |
|
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
123 | } |
|
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
124 | |
|
41813
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
125 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
126 | 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
|
127 | 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
|
128 | gpointer data) |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
129 | { |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
130 | PurpleIRCv3Connection *connection = data; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
131 | PurpleContact *contact = NULL; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
132 | PurpleConversation *conversation = NULL; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
133 | PurpleMessage *message = NULL; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
134 | PurpleMessageFlags flags = PURPLE_MESSAGE_RECV; |
|
42056
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
135 | GDateTime *dt = NULL; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
136 | GHashTable *tags = NULL; |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
137 | GStrv params = NULL; |
|
42056
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
138 | gpointer raw_id = NULL; |
|
42294
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
139 | gpointer raw_timestamp = NULL; |
|
42345
e01084003f50
IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
140 | char *nick = NULL; |
|
42505
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
141 | char *stripped = NULL; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
142 | const char *command = NULL; |
|
42056
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
143 | const char *id = NULL; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
144 | 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
|
145 | 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
|
146 | |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
147 | 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
|
148 | 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
|
149 | 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
|
150 | 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
|
151 | |
|
42382
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
152 | if(params == NULL) { |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
153 | g_warning("privmsg received with no parameters"); |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
154 | |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
155 | return FALSE; |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
156 | } |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
157 | |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
158 | 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
|
159 | 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
|
160 | 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
|
161 | g_free(body); |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
162 | |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
163 | return FALSE; |
|
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 | |
|
42345
e01084003f50
IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
166 | 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
|
167 | |
|
42513
482ba61e5123
IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
168 | /* 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
|
169 | target = params[0]; |
|
42494
4d6baa511e52
IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42382
diff
changeset
|
170 | 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
|
171 | target = nick; |
|
42345
e01084003f50
IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
172 | } |
|
42494
4d6baa511e52
IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42382
diff
changeset
|
173 | 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
|
174 | target); |
|
42513
482ba61e5123
IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
175 | /* Find or create the contact. */ |
|
482ba61e5123
IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
176 | 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
|
177 | if(PURPLE_IS_CONTACT(contact)) { |
|
482ba61e5123
IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
178 | PurpleConversationMember *member = NULL; |
|
482ba61e5123
IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
179 | |
|
482ba61e5123
IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
180 | /* 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
|
181 | 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
|
182 | |
|
482ba61e5123
IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
183 | /* 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
|
184 | 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
|
185 | PURPLE_CONTACT_INFO(contact)); |
|
482ba61e5123
IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
186 | if(!PURPLE_IS_CONVERSATION_MEMBER(member)) { |
|
42518
a49b3c031794
Remove a dead assignment that scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42513
diff
changeset
|
187 | purple_conversation_add_member(conversation, |
|
a49b3c031794
Remove a dead assignment that scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42513
diff
changeset
|
188 | PURPLE_CONTACT_INFO(contact), |
|
a49b3c031794
Remove a dead assignment that scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42513
diff
changeset
|
189 | FALSE, NULL); |
|
42513
482ba61e5123
IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
190 | } |
|
482ba61e5123
IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
191 | } |
|
41813
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
192 | |
|
42056
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
193 | /* Grab the msgid if one was provided. */ |
|
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
194 | 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
|
195 | if(!purple_strempty(raw_id)) { |
|
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
196 | id = raw_id; |
|
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
197 | } |
|
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
198 | } |
|
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
199 | |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42505
diff
changeset
|
200 | 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
|
201 | 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
|
202 | } |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
203 | |
|
42294
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
204 | /* Determine the timestamp of the message. */ |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
205 | 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
|
206 | const char *timestamp = raw_timestamp; |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
207 | |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
208 | if(!purple_strempty(timestamp)) { |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
209 | 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
|
210 | |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
211 | 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
|
212 | |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
213 | g_time_zone_unref(tz); |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
214 | } |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
215 | } |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
216 | |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
217 | /* 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
|
218 | if(dt == NULL) { |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
219 | 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
|
220 | } |
|
42056
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
221 | |
|
42505
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
222 | 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
|
223 | message = g_object_new( |
|
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
224 | PURPLE_TYPE_MESSAGE, |
|
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
225 | "author", source, |
|
42505
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
226 | "contents", stripped, |
|
42056
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
227 | "flags", flags, |
|
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
228 | "id", id, |
|
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
229 | "timestamp", dt, |
|
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
230 | NULL); |
|
42505
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
231 | g_free(stripped); |
|
42056
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
232 | |
|
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
233 | 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
|
234 | |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
42518
diff
changeset
|
235 | /* 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
|
236 | 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
|
237 | 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
|
238 | } |
|
41813
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
239 | |
|
42345
e01084003f50
IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
240 | 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
|
241 | 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
|
242 | |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
243 | return TRUE; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
244 | } |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
245 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
246 | gboolean |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
247 | purple_ircv3_message_handler_topic(PurpleIRCv3Message *message, |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
248 | GError **error, |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
249 | gpointer data) |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
250 | { |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
251 | PurpleIRCv3Connection *connection = data; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
252 | PurpleConversation *conversation = NULL; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
253 | GStrv params = NULL; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
254 | const char *channel = NULL; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
255 | const char *command = NULL; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
256 | const char *topic = NULL; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
257 | guint n_params = 0; |
|
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 | command = purple_ircv3_message_get_command(message); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
260 | params = purple_ircv3_message_get_params(message); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
261 | n_params = g_strv_length(params); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
262 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
263 | if(purple_strequal(command, PURPLE_IRCV3_MSG_TOPIC)) { |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
264 | if(n_params != 2) { |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
265 | g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
266 | "received TOPIC with %u parameters, expected 2", |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
267 | n_params); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
268 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
269 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
270 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
271 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
272 | channel = params[0]; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
273 | topic = params[1]; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
274 | } 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
|
275 | if(n_params != 3) { |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
276 | g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
277 | "received RPL_NOTOPIC with %u parameters, expected 3", |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
278 | n_params); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
279 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
280 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
281 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
282 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
283 | channel = params[1]; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
284 | topic = ""; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
285 | } 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
|
286 | if(n_params != 3) { |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
287 | g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
288 | "received RPL_TOPIC with %u parameters, expected 3", |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
289 | n_params); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
290 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
291 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
292 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
293 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
294 | channel = params[1]; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
295 | topic = params[2]; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
296 | } else { |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
297 | 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
|
298 | command); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
299 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
300 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
301 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
302 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
303 | 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
|
304 | channel); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
305 | if(!PURPLE_IS_CONVERSATION(conversation)) { |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
306 | g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
307 | "failed to find or create channel '%s'", channel); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
308 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
309 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
310 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
311 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
312 | purple_conversation_set_topic(conversation, topic); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
313 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
314 | return TRUE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
315 | } |