Wed, 04 Sep 2024 00:27:44 -0500
Add support for CTCP ACTION
Testing Done:
Received a `CTCP ACTION` in a chat and verified it was styled properly. Also received a `CTCP VERSION` to verify it was rendered like a normal message.
Bugs closed: PIDGIN-17921
Reviewed at https://reviews.imfreedom.org/r/3462/
|
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 | { |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
37 | PurpleContactInfo *info = PURPLE_CONTACT_INFO(contact); |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
38 | PurpleConversationMember *member = NULL; |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
39 | PurpleConversationMembers *members = NULL; |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
40 | |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
41 | members = purple_conversation_get_members(conversation); |
|
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
42 | |
|
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
43 | member = purple_conversation_members_find_member(members, info); |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
44 | if(!PURPLE_IS_CONVERSATION_MEMBER(member)) { |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
45 | purple_conversation_members_add_member(members, info, TRUE, NULL); |
|
42780
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; |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
100 | PurpleConversationMembers *members = NULL; |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
101 | GStrv params = NULL; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
102 | guint n_params = 0; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
103 | char *reason = NULL; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
104 | const char *conversation_name = NULL; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
105 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
106 | params = ibis_message_get_params(message); |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
107 | if(g_strv_length(params) == 0) { |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
108 | /* 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
|
109 | return TRUE; |
|
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 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
112 | /* 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
|
113 | * 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
|
114 | */ |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
115 | conversation_name = params[0]; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
116 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
117 | 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
|
118 | manager = purple_conversation_manager_get_default(); |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
119 | 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
|
120 | conversation_name); |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
121 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
122 | if(!PURPLE_IS_CONVERSATION(conversation)) { |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
123 | /* TODO: write status message unknown channel. */ |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
124 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
125 | return TRUE; |
|
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 | |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
128 | members = purple_conversation_get_members(conversation); |
|
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
129 | |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
130 | /* 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
|
131 | * 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
|
132 | */ |
|
42815
95bb2ae83de7
IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42780
diff
changeset
|
133 | 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
|
134 | message); |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
135 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
136 | /* 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
|
137 | */ |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
138 | if(n_params > 1) { |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
139 | reason = g_strjoinv(" ", params + 1); |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
140 | } |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
141 | |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
142 | purple_conversation_members_remove_member(members, |
|
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
143 | PURPLE_CONTACT_INFO(contact), |
|
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
144 | TRUE, reason); |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
145 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
146 | g_clear_pointer(&reason, g_free); |
|
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 | return TRUE; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
149 | } |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
150 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
151 | gboolean |
|
42896
5c8f4a455d3c
IRCv3: Use Ibis.Client.is_channel instead of our old version
Gary Kramlich <grim@reaperworld.com>
parents:
42893
diff
changeset
|
152 | purple_ircv3_message_handler_tagmsg(IbisClient *client, |
|
42883
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
153 | G_GNUC_UNUSED const char *command, |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
154 | IbisMessage *ibis_message, gpointer data) |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
155 | { |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
156 | PurpleIRCv3Connection *connection = data; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
157 | PurpleContact *contact = NULL; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
158 | PurpleConversation *conversation = NULL; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
159 | GStrv params = NULL; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
160 | IbisTags *tags = NULL; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
161 | const char *target = NULL; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
162 | const char *value = NULL; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
163 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
164 | params = ibis_message_get_params(ibis_message); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
165 | tags = ibis_message_get_tags(ibis_message); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
166 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
167 | if(params == NULL) { |
|
42920
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
168 | g_warning("tagmsg received with no parameters"); |
|
42883
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
169 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
170 | return FALSE; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
171 | } |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
172 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
173 | if(g_strv_length(params) != 1) { |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
174 | char *body = g_strjoinv(" ", params); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
175 | g_warning("unknown tagmsg message format: '%s'", body); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
176 | g_free(body); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
177 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
178 | return FALSE; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
179 | } |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
180 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
181 | /* Find or create the contact. */ |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
182 | contact = purple_ircv3_connection_find_or_create_contact(connection, |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
183 | ibis_message); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
184 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
185 | /* Find or create the conversation. */ |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
186 | target = params[0]; |
|
42896
5c8f4a455d3c
IRCv3: Use Ibis.Client.is_channel instead of our old version
Gary Kramlich <grim@reaperworld.com>
parents:
42893
diff
changeset
|
187 | if(!ibis_client_is_channel(client, target)) { |
|
42883
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
188 | target = purple_contact_info_get_id(PURPLE_CONTACT_INFO(contact)); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
189 | } |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
190 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
191 | conversation = purple_ircv3_connection_find_or_create_conversation(connection, |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
192 | target); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
193 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
194 | purple_ircv3_add_contact_to_conversation(contact, conversation); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
195 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
196 | /* Handle typing notifications. */ |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
197 | value = ibis_tags_lookup(tags, IBIS_TAG_TYPING); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
198 | if(!purple_strempty(value)) { |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
199 | PurpleConversationMember *member = NULL; |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
200 | PurpleConversationMembers *members = NULL; |
|
42883
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
201 | PurpleTypingState state = PURPLE_TYPING_STATE_NONE; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
202 | guint timeout = 1; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
203 | |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
204 | members = purple_conversation_get_members(conversation); |
|
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
205 | member = purple_conversation_members_find_member(members, |
|
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
206 | PURPLE_CONTACT_INFO(contact)); |
|
42883
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
207 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
208 | if(purple_strequal(value, IBIS_TYPING_ACTIVE)) { |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
209 | state = PURPLE_TYPING_STATE_TYPING; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
210 | timeout = 6; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
211 | } else if(purple_strequal(value, IBIS_TYPING_PAUSED)) { |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
212 | state = PURPLE_TYPING_STATE_PAUSED; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
213 | timeout = 30; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
214 | } |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
215 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
216 | purple_conversation_member_set_typing_state(member, state, timeout); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
217 | } |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
218 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
219 | return TRUE; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
220 | } |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
221 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
222 | gboolean |
|
42896
5c8f4a455d3c
IRCv3: Use Ibis.Client.is_channel instead of our old version
Gary Kramlich <grim@reaperworld.com>
parents:
42893
diff
changeset
|
223 | purple_ircv3_message_handler_privmsg(IbisClient *client, const char *command, |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
224 | 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
|
225 | { |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
226 | PurpleIRCv3Connection *connection = data; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
227 | PurpleContact *contact = NULL; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
228 | PurpleConversation *conversation = NULL; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
229 | PurpleMessage *message = NULL; |
|
42056
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
230 | GDateTime *dt = NULL; |
|
42920
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
231 | IbisCTCPMessage *ctcp_message = NULL; |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
232 | IbisTags *tags = NULL; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
233 | GStrv params = NULL; |
|
41813
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
234 | 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
|
235 | |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
236 | params = ibis_message_get_params(ibis_message); |
|
42920
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
237 | ctcp_message = ibis_message_get_ctcp_message(ibis_message); |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
238 | 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
|
239 | |
|
42382
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
240 | if(params == NULL) { |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
241 | g_warning("privmsg received with no parameters"); |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
242 | |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
243 | return FALSE; |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
244 | } |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
245 | |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
246 | 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
|
247 | 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
|
248 | 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
|
249 | g_free(body); |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
250 | |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
251 | return FALSE; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
252 | } |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
253 | |
|
42815
95bb2ae83de7
IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42780
diff
changeset
|
254 | /* 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
|
255 | 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
|
256 | ibis_message); |
|
42345
e01084003f50
IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
257 | |
|
42513
482ba61e5123
IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
258 | /* 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
|
259 | target = params[0]; |
|
42896
5c8f4a455d3c
IRCv3: Use Ibis.Client.is_channel instead of our old version
Gary Kramlich <grim@reaperworld.com>
parents:
42893
diff
changeset
|
260 | if(!ibis_client_is_channel(client, target)) { |
|
42815
95bb2ae83de7
IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42780
diff
changeset
|
261 | 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
|
262 | } |
|
42815
95bb2ae83de7
IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42780
diff
changeset
|
263 | |
|
42494
4d6baa511e52
IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42382
diff
changeset
|
264 | 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
|
265 | target); |
|
42513
482ba61e5123
IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
266 | |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
267 | 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
|
268 | |
|
42920
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
269 | if(IBIS_IS_CTCP_MESSAGE(ctcp_message)) { |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
270 | if(ibis_ctcp_message_is_command(ctcp_message, IBIS_CTCP_ACTION)) { |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
271 | GStrv ctcp_params = NULL; |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
272 | char *ctcp_body = NULL; |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
273 | char *stripped = NULL; |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
274 | |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
275 | ctcp_params = ibis_ctcp_message_get_params(ctcp_message); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
276 | ctcp_body = g_strjoinv(" ", ctcp_params); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
277 | stripped = ibis_formatting_strip(ctcp_body); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
278 | g_free(ctcp_body); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
279 | |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
280 | message = purple_message_new(PURPLE_CONTACT_INFO(contact), |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
281 | stripped); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
282 | g_free(stripped); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
283 | |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
284 | purple_message_set_action(message, TRUE); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
285 | } |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
286 | } |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
287 | |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
288 | if(!PURPLE_IS_MESSAGE(message)) { |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
289 | char *stripped = NULL; |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
290 | |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
291 | stripped = ibis_formatting_strip(params[1]); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
292 | message = purple_message_new(PURPLE_CONTACT_INFO(contact), stripped); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
293 | g_clear_pointer(&stripped, g_free); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
294 | } |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
295 | |
|
42815
95bb2ae83de7
IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42780
diff
changeset
|
296 | |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
297 | 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
|
298 | 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
|
299 | } |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
300 | |
|
42775
98b71fc8a330
Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents:
42769
diff
changeset
|
301 | 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
|
302 | 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
|
303 | |
|
42775
98b71fc8a330
Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents:
42769
diff
changeset
|
304 | /* 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
|
305 | 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
|
306 | 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
|
307 | 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
|
308 | } |
|
42294
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
309 | |
|
42775
98b71fc8a330
Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents:
42769
diff
changeset
|
310 | /* 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
|
311 | 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
|
312 | if(!purple_strempty(raw_tag)) { |
|
98b71fc8a330
Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents:
42769
diff
changeset
|
313 | 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
|
314 | |
|
42775
98b71fc8a330
Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents:
42769
diff
changeset
|
315 | 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
|
316 | g_time_zone_unref(tz); |
|
42294
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
317 | |
|
42815
95bb2ae83de7
IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42780
diff
changeset
|
318 | 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
|
319 | 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
|
320 | } |
|
42294
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
321 | } |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
322 | |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
323 | /* 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
|
324 | 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
|
325 | 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
|
326 | } |
|
42056
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
327 | |
|
42530
55b30ce86f17
IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents:
42518
diff
changeset
|
328 | /* 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
|
329 | 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
|
330 | /* 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
|
331 | } |
|
41813
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
332 | |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
333 | 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
|
334 | |
|
41813
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
335 | 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
|
336 | |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
337 | return TRUE; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
338 | } |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
339 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
340 | gboolean |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
341 | 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
|
342 | const char *command, IbisMessage *message, |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
343 | gpointer data) |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
344 | { |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
345 | PurpleIRCv3Connection *connection = data; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
346 | PurpleConversation *conversation = NULL; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
347 | GStrv params = NULL; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
348 | const char *channel = NULL; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
349 | const char *topic = NULL; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
350 | guint n_params = 0; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
351 | |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
352 | params = ibis_message_get_params(message); |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
353 | n_params = g_strv_length(params); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
354 | |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
355 | if(purple_strequal(command, IBIS_MSG_TOPIC)) { |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
356 | 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
|
357 | 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
|
358 | n_params); |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
359 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
360 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
361 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
362 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
363 | channel = params[0]; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
364 | topic = params[1]; |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
365 | } 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
|
366 | 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
|
367 | 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
|
368 | n_params); |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
369 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
370 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
371 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
372 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
373 | channel = params[1]; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
374 | topic = ""; |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
375 | } 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
|
376 | 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
|
377 | 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
|
378 | n_params); |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
379 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
380 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
381 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
382 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
383 | channel = params[1]; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
384 | topic = params[2]; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
385 | } else { |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
386 | g_message("unexpected command %s", command); |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
387 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
388 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
389 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
390 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
391 | 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
|
392 | channel); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
393 | 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
|
394 | 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
|
395 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
396 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
397 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
398 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
399 | purple_conversation_set_topic(conversation, topic); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
400 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
401 | return TRUE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
402 | } |