Thu, 11 Apr 2024 21:32:59 -0500
Remove PurpleConnectionUiOps as they are no longer used
Testing Done:
Checked in with the turtles.
Reviewed at https://reviews.imfreedom.org/r/3090/
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
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:
42544
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:
42544
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:
42544
diff
changeset
|
7 | * source distribution. |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42544
diff
changeset
|
8 | * |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42544
diff
changeset
|
9 | * This library is free software; you can redistribute it and/or modify |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * it under the terms of the GNU General Public License as published by |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * the Free Software Foundation; either version 2 of the License, or |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * (at your option) any later version. |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
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:
42544
diff
changeset
|
14 | * This library is distributed in the hope that it will be useful, |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | * GNU General Public License for more details. |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
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:
42544
diff
changeset
|
20 | * along with this library; if not, see <https://www.gnu.org/licenses/>. |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include <glib/gi18n-lib.h> |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | #include "purpleircv3ctcp.h" |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | #include "purpleircv3constants.h" |
|
42544
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
28 | #include "purpleircv3source.h" |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
29 | |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
30 | /****************************************************************************** |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
31 | * Helpers |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
32 | *****************************************************************************/ |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
33 | static void |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
34 | purple_ircv3_ctcp_respond(PurpleIRCv3Connection *connection, |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
35 | PurpleMessage *message, |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
36 | const char *response) |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
37 | { |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
38 | const char *author = NULL; |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
39 | char *nick = NULL; |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
40 | |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
41 | author = purple_message_get_author(message); |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
42 | purple_ircv3_source_parse(author, &nick, NULL, NULL); |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
43 | if(!purple_strempty(nick)) { |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
44 | PurpleContact *contact = NULL; |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
45 | |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
46 | contact = purple_ircv3_connection_find_or_create_contact(connection, |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
47 | nick); |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
48 | |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
49 | if(PURPLE_IS_CONTACT(contact)) { |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
50 | const char *id = NULL; |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
51 | |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
52 | id = purple_contact_info_get_id(PURPLE_CONTACT_INFO(contact)); |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
53 | |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
54 | purple_ircv3_connection_writef(connection, "%s %s :%s", |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
55 | PURPLE_IRCV3_MSG_NOTICE, |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
56 | id, |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
57 | response); |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
58 | } |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
59 | } |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
60 | |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
61 | g_clear_pointer(&nick, g_free); |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
62 | } |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
63 | |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
64 | /****************************************************************************** |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
65 | * Callbacks |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
66 | *****************************************************************************/ |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
67 | static gboolean |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
68 | purple_ircv3_ctcp_handler(PurpleIRCv3Connection *connection, |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
69 | PurpleConversation *conversation, |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
70 | PurpleMessage *message, |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
71 | const char *command, |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
72 | const char *params, |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
73 | G_GNUC_UNUSED gpointer data) |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
74 | { |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
75 | if(purple_strequal(command, PURPLE_IRCV3_CTCP_ACTION)) { |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
76 | purple_message_set_contents(message, params); |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
77 | purple_message_set_action(message, TRUE); |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
78 | |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
79 | purple_conversation_write_message(conversation, message); |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
80 | |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
81 | return TRUE; |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
82 | } else if(purple_strequal(command, PURPLE_IRCV3_CTCP_VERSION)) { |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
83 | purple_ircv3_ctcp_respond(connection, message, "Purple3 IRCv3"); |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
84 | } |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
85 | |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
86 | return FALSE; |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
87 | } |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | /****************************************************************************** |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | * Internal API |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | *****************************************************************************/ |
|
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
|
92 | gboolean |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | purple_ircv3_ctcp_handle(PurpleIRCv3Connection *connection, |
|
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
|
94 | PurpleConversation *conversation, |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | PurpleMessage *message) |
|
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | { |
|
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
|
97 | PurpleMessageFlags flags; |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
98 | char *command = NULL; |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
99 | char *params = NULL; |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
100 | char *ptr = NULL; |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
101 | const char *contents = NULL; |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
102 | gboolean ret = FALSE; |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | |
|
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
|
104 | g_return_val_if_fail(PURPLE_IRCV3_IS_CONNECTION(connection), FALSE); |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
105 | g_return_val_if_fail(PURPLE_IS_CONVERSATION(conversation), FALSE); |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
106 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), FALSE); |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | |
|
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
|
108 | contents = purple_message_get_contents(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
|
109 | if(contents == NULL || contents[0] != PURPLE_IRCV3_CTCP_DELIMITER) { |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
110 | return FALSE; |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
111 | } |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | |
|
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
|
113 | /* Move past the delimiter. */ |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
114 | contents += 1; |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | |
|
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
|
116 | /* Find the delimiter for the command. */ |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
117 | ptr = g_strstr_len(contents, -1, " "); |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
118 | |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
119 | /* If we don't have a space, then we have no parameters. */ |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
120 | if(ptr == NULL) { |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
121 | size_t len = strlen(contents); |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | |
|
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
|
123 | command = g_strdup(contents); |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
124 | if(command[len - 1] == PURPLE_IRCV3_CTCP_DELIMITER) { |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
125 | command[len - 1] = '\0'; |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
126 | } |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
127 | } else { |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
128 | size_t len = 0; |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | |
|
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
|
130 | command = g_strndup(contents, ptr - contents); |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
131 | |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
132 | params = g_strdup(ptr + 1); |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
133 | len = strlen(params); |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
134 | if(params[len - 1] == PURPLE_IRCV3_CTCP_DELIMITER) { |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
135 | params[len - 1] = '\0'; |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
136 | } |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
137 | } |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | |
|
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
|
139 | flags = purple_message_get_flags(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
|
140 | if(flags & PURPLE_MESSAGE_NOTIFY) { |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
141 | ret = purple_ircv3_connection_emit_ctcp_response(connection, |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
142 | 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
|
143 | command, params); |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
144 | } else { |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
145 | ret = purple_ircv3_connection_emit_ctcp_request(connection, conversation, |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
146 | message, command, |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
147 | params); |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
148 | } |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | |
|
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
|
150 | g_clear_pointer(&command, g_free); |
|
6dcf672547fe
IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents:
42530
diff
changeset
|
151 | g_clear_pointer(¶ms, g_free); |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | |
|
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
|
153 | return ret; |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | } |
|
42544
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
155 | |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
156 | void |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
157 | purple_ircv3_ctcp_add_default_handlers(PurpleIRCv3Connection *connection) { |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
158 | g_signal_connect(connection, "ctcp-request", |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
159 | G_CALLBACK(purple_ircv3_ctcp_handler), NULL); |
|
95d36c221e21
Implement CTCP ACTION and VERSION
Gary Kramlich <grim@reaperworld.com>
parents:
42543
diff
changeset
|
160 | } |