protocols/ircv3/purpleircv3messagehandlers.c

Mon, 05 Aug 2024 23:30:22 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 05 Aug 2024 23:30:22 -0500
changeset 42828
fbfb9dbdb87c
parent 42815
95bb2ae83de7
child 42883
51a0fe1e2500
permissions
-rw-r--r--

Make the demo notifications look a bit better

Testing Done:
Used the demo protocol plugin to spam some generic notifications.

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

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"
41807
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41796
diff changeset
28 #include "purpleircv3core.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 /******************************************************************************
42780
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
31 * Helpers
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
32 *****************************************************************************/
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
33 static void
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
34 purple_ircv3_add_contact_to_conversation(PurpleContact *contact,
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
35 PurpleConversation *conversation)
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
36 {
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
37 PurpleConversationMember *member = NULL;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
38
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
39 member = purple_conversation_find_member(conversation,
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
40 PURPLE_CONTACT_INFO(contact));
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
41
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
42 if(!PURPLE_IS_CONVERSATION_MEMBER(member)) {
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
43 purple_conversation_add_member(conversation,
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
44 PURPLE_CONTACT_INFO(contact),
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
45 TRUE, NULL);
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
46 }
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
47 }
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
48
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
49 /******************************************************************************
41821
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
50 * General Commands
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
51 *****************************************************************************/
ec766a6f010a Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents: 41815
diff changeset
52 gboolean
42780
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
53 purple_ircv3_message_handler_join(G_GNUC_UNUSED IbisClient *client,
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
54 G_GNUC_UNUSED const char *command,
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
55 IbisMessage *message,
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
56 gpointer data)
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
57 {
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
58 PurpleIRCv3Connection *connection = data;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
59 PurpleContact *contact = NULL;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
60 PurpleConversation *conversation = NULL;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
61 GStrv params = NULL;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
62 guint n_params = 0;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
63 const char *conversation_name = NULL;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
64
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
65 contact = purple_ircv3_connection_find_or_create_contact(connection,
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
66 message);
42780
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
67
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
68 params = ibis_message_get_params(message);
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
69 n_params = g_strv_length(params);
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
70
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
71 /* A normal join command has the channel as the only parameter. */
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
72 if(n_params == 1) {
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
73 conversation_name = params[0];
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
74 } else {
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
75 /* TODO: write this to join to the status window saying we didn't know
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
76 * how to parse it.
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
77 */
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
78
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
79 return TRUE;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
80 }
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
81
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
82 conversation = purple_ircv3_connection_find_or_create_conversation(connection,
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
83 conversation_name);
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
84 purple_ircv3_add_contact_to_conversation(contact, conversation);
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
85
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
86 return TRUE;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
87 }
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
88
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
89 gboolean
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
90 purple_ircv3_message_handler_part(G_GNUC_UNUSED IbisClient *client,
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
91 G_GNUC_UNUSED const char *command,
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
92 IbisMessage *message,
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
93 gpointer data)
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
94 {
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
95 PurpleIRCv3Connection *connection = data;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
96 PurpleAccount *account = NULL;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
97 PurpleContact *contact = NULL;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
98 PurpleConversation *conversation = NULL;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
99 PurpleConversationManager *manager = NULL;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
100 GStrv params = NULL;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
101 guint n_params = 0;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
102 char *reason = NULL;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
103 const char *conversation_name = NULL;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
104
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
105 params = ibis_message_get_params(message);
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
106 if(g_strv_length(params) == 0) {
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
107 /* TODO: mention unparsable message in the status window. */
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
108 return TRUE;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
109 }
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
110
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
111 /* TODO: The spec says servers _SHOULD NOT_ send a comma separated list of
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
112 * channels, but we should support that at some point just in case.
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
113 */
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
114 conversation_name = params[0];
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
115
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
116 account = purple_connection_get_account(PURPLE_CONNECTION(connection));
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
117 manager = purple_conversation_manager_get_default();
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
118 conversation = purple_conversation_manager_find_with_id(manager, account,
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
119 conversation_name);
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
120
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
121 if(!PURPLE_IS_CONVERSATION(conversation)) {
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
122 /* TODO: write status message unknown channel. */
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
123
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
124 return TRUE;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
125 }
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
126
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
127 /* We do want to find or create the contact, even on a part, because we
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
128 * could have connected to a BNC and we weren't told about the contact yet.
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
129 */
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
130 contact = purple_ircv3_connection_find_or_create_contact(connection,
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
131 message);
42780
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
132
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
133 /* If a part message was given, join the remaining parameters with a space.
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
134 */
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
135 if(n_params > 1) {
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
136 reason = g_strjoinv(" ", params + 1);
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
137 }
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
138
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
139 purple_conversation_remove_member(conversation,
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
140 PURPLE_CONTACT_INFO(contact), TRUE,
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
141 reason);
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
142
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
143 g_clear_pointer(&reason, g_free);
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
144
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
145 return TRUE;
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
146 }
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
147
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
148 gboolean
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
149 purple_ircv3_message_handler_privmsg(G_GNUC_UNUSED IbisClient *client,
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
150 const char *command,
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
151 IbisMessage *ibis_message, gpointer data)
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
152 {
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
153 PurpleIRCv3Connection *connection = data;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
154 PurpleContact *contact = NULL;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
155 PurpleConversation *conversation = NULL;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
156 PurpleMessage *message = NULL;
42056
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
157 GDateTime *dt = NULL;
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
158 IbisTags *tags = NULL;
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
159 GStrv params = NULL;
42505
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42503
diff changeset
160 char *stripped = NULL;
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
161 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
162
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
163 params = ibis_message_get_params(ibis_message);
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
164 tags = ibis_message_get_tags(ibis_message);
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
165
42382
343e30628383 IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42378
diff changeset
166 if(params == NULL) {
343e30628383 IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42378
diff changeset
167 g_warning("privmsg received with no parameters");
343e30628383 IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42378
diff changeset
168
343e30628383 IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42378
diff changeset
169 return FALSE;
343e30628383 IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42378
diff changeset
170 }
343e30628383 IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42378
diff changeset
171
343e30628383 IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents: 42378
diff changeset
172 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
173 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
174 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
175 g_free(body);
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
176
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
177 return FALSE;
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
178 }
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
179
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
180 /* Find or create the contact. */
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
181 contact = purple_ircv3_connection_find_or_create_contact(connection,
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
182 ibis_message);
42345
e01084003f50 IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
183
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
184 /* 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
185 target = params[0];
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42382
diff changeset
186 if(!purple_ircv3_connection_is_channel(connection, target)) {
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
187 target = purple_contact_info_get_id(PURPLE_CONTACT_INFO(contact));
42345
e01084003f50 IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
188 }
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
189
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42382
diff changeset
190 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
191 target);
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42510
diff changeset
192
42780
c1af98cbd43a IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents: 42775
diff changeset
193 purple_ircv3_add_contact_to_conversation(contact, conversation);
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
194
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
195 stripped = ibis_formatting_strip(params[1]);
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
196 message = purple_message_new(PURPLE_CONTACT_INFO(contact), stripped);
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
197 g_clear_pointer(&stripped, g_free);
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
198
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
199 if(purple_strequal(command, IBIS_MSG_NOTICE)) {
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
200 purple_message_set_notice(message, TRUE);
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
201 }
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
202
42775
98b71fc8a330 Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents: 42769
diff changeset
203 if(IBIS_IS_TAGS(tags)) {
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
204 const char *raw_tag = NULL;
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
205
42775
98b71fc8a330 Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents: 42769
diff changeset
206 /* Grab the msgid if one was provided. */
98b71fc8a330 Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents: 42769
diff changeset
207 raw_tag = ibis_tags_lookup(tags, "msgid");
98b71fc8a330 Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents: 42769
diff changeset
208 if(!purple_strempty(raw_tag)) {
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
209 purple_message_set_id(message, raw_tag);
42775
98b71fc8a330 Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents: 42769
diff changeset
210 }
42294
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
211
42775
98b71fc8a330 Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents: 42769
diff changeset
212 /* Determine the timestamp of the message. */
98b71fc8a330 Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents: 42769
diff changeset
213 raw_tag = ibis_tags_lookup(tags, "time");
98b71fc8a330 Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents: 42769
diff changeset
214 if(!purple_strempty(raw_tag)) {
98b71fc8a330 Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents: 42769
diff changeset
215 GTimeZone *tz = g_time_zone_new_utc();
42294
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
216
42775
98b71fc8a330 Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents: 42769
diff changeset
217 dt = g_date_time_new_from_iso8601(raw_tag, tz);
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
218 g_time_zone_unref(tz);
42294
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
219
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
220 purple_message_set_timestamp(message, dt);
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
221 g_date_time_unref(dt);
42775
98b71fc8a330 Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents: 42769
diff changeset
222 }
42294
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
223 }
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
224
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
225 /* 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
226 if(dt == NULL) {
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
227 purple_message_set_timestamp_now(message);
42294
462317d1382d IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents: 42275
diff changeset
228 }
42056
ced07483f66a IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents: 42048
diff changeset
229
42530
55b30ce86f17 IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents: 42518
diff changeset
230 /* Check if this is a CTCP message. */
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
231 if(ibis_message_get_ctcp(ibis_message)) {
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
232 /* TODO: later... */
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
233 }
41813
86302ce7e3c1 Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents: 41807
diff changeset
234
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
235 purple_conversation_write_message(conversation, message);
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
236
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
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
243 purple_ircv3_message_handler_topic(G_GNUC_UNUSED IbisClient *client,
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
244 const char *command, IbisMessage *message,
42503
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 *topic = NULL;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
252 guint n_params = 0;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
253
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
254 params = ibis_message_get_params(message);
42503
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
255 n_params = g_strv_length(params);
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
256
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
257 if(purple_strequal(command, IBIS_MSG_TOPIC)) {
42503
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
258 if(n_params != 2) {
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
259 g_message("received TOPIC with %u parameters, expected 2",
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
260 n_params);
42503
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
261
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
262 return FALSE;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
263 }
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 channel = params[0];
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
266 topic = params[1];
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
267 } else if(purple_strequal(command, IBIS_RPL_NOTOPIC)) {
42503
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
268 if(n_params != 3) {
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
269 g_message("received RPL_NOTOPIC with %u parameters, expected 3",
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
270 n_params);
42503
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 return FALSE;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
273 }
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
274
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
275 channel = params[1];
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
276 topic = "";
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
277 } else if(purple_strequal(command, IBIS_RPL_TOPIC)) {
42503
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
278 if(n_params != 3) {
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
279 g_message("received RPL_TOPIC with %u parameters, expected 3",
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
280 n_params);
42503
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 return FALSE;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
283 }
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
284
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
285 channel = params[1];
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
286 topic = params[2];
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
287 } else {
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
288 g_message("unexpected command %s", command);
42503
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 return FALSE;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
291 }
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 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
294 channel);
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
295 if(!PURPLE_IS_CONVERSATION(conversation)) {
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
296 g_message("failed to find or create channel '%s'", channel);
42503
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 return FALSE;
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
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
301 purple_conversation_set_topic(conversation, topic);
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 return TRUE;
55eff782a478 IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
304 }

mercurial