Sun, 03 Nov 2024 00:05:44 -0500
remove purple3-url-handler.desktop.in.in
The application that did the launching was removed long ago. Also this should
be implemented by the user interfaces and they might provide separate files to
groups schemas as well.
Testing Done:
Called in the turtles.
Reviewed at https://reviews.imfreedom.org/r/3640/
|
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" |
|
42937
34ac8ac8c7b6
Implement CTCP VERSION response
Gary Kramlich <grim@reaperworld.com>
parents:
42926
diff
changeset
|
29 | #include "purpleircv3ctcphandlers.h" |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41796
diff
changeset
|
31 | /****************************************************************************** |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
32 | * Helpers |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
33 | *****************************************************************************/ |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
34 | static void |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
35 | purple_ircv3_add_contact_to_conversation(PurpleContact *contact, |
|
43025
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
36 | PurpleConversation *conversation, |
|
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
37 | gboolean announce) |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
38 | { |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
39 | PurpleContactInfo *info = PURPLE_CONTACT_INFO(contact); |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
40 | PurpleConversationMember *member = NULL; |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
41 | PurpleConversationMembers *members = NULL; |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
42 | |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
43 | members = purple_conversation_get_members(conversation); |
|
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
44 | |
|
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
45 | 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
|
46 | if(!PURPLE_IS_CONVERSATION_MEMBER(member)) { |
|
43019
7621ef6ea06a
IRCv3: Update the join/part reasons to match the quit format
Gary Kramlich <grim@reaperworld.com>
parents:
43015
diff
changeset
|
47 | char *message = NULL; |
|
7621ef6ea06a
IRCv3: Update the join/part reasons to match the quit format
Gary Kramlich <grim@reaperworld.com>
parents:
43015
diff
changeset
|
48 | |
|
43025
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
49 | if(announce) { |
|
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
50 | message = g_strdup_printf(_("%s has joined %s"), |
|
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
51 | purple_contact_info_get_sid(info), |
|
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
52 | purple_conversation_get_title_for_display(conversation)); |
|
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
53 | } |
|
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
54 | |
|
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
55 | purple_conversation_members_add_member(members, info, announce, |
|
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
56 | message); |
|
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
57 | g_clear_pointer(&message, g_free); |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
58 | } |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
59 | } |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
60 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
61 | /****************************************************************************** |
|
41821
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
62 | * General Commands |
|
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
63 | *****************************************************************************/ |
|
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41815
diff
changeset
|
64 | gboolean |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
65 | 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
|
66 | G_GNUC_UNUSED const char *command, |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
67 | IbisMessage *message, |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
68 | gpointer data) |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
69 | { |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
70 | PurpleIRCv3Connection *connection = data; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
71 | PurpleContact *contact = NULL; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
72 | PurpleConversation *conversation = NULL; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
73 | GStrv params = NULL; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
74 | const char *conversation_name = NULL; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
75 | |
|
42815
95bb2ae83de7
IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42780
diff
changeset
|
76 | 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
|
77 | message); |
|
42780
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 | params = ibis_message_get_params(message); |
|
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 | /* A normal join command has the channel as the only parameter. */ |
|
42982
310d3d474f8c
IRCv3: Fix a bug where part messages were not being parsed correctly
Gary Kramlich <grim@reaperworld.com>
parents:
42965
diff
changeset
|
82 | if(g_strv_length(params) == 1) { |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
83 | conversation_name = params[0]; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
84 | } else { |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
85 | /* 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
|
86 | * how to parse it. |
|
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 | return TRUE; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
90 | } |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
91 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
92 | 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
|
93 | conversation_name); |
|
43025
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
94 | purple_ircv3_add_contact_to_conversation(contact, conversation, TRUE); |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
95 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
96 | return TRUE; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
97 | } |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
98 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
99 | gboolean |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
100 | 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
|
101 | G_GNUC_UNUSED const char *command, |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
102 | IbisMessage *message, |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
103 | gpointer data) |
|
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 | PurpleIRCv3Connection *connection = data; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
106 | PurpleAccount *account = NULL; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
107 | PurpleContact *contact = NULL; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
108 | PurpleConversation *conversation = NULL; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
109 | PurpleConversationManager *manager = NULL; |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
110 | PurpleConversationMembers *members = NULL; |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
111 | GStrv params = NULL; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
112 | guint n_params = 0; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
113 | char *reason = NULL; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
114 | const char *conversation_name = NULL; |
|
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 | params = ibis_message_get_params(message); |
|
42982
310d3d474f8c
IRCv3: Fix a bug where part messages were not being parsed correctly
Gary Kramlich <grim@reaperworld.com>
parents:
42965
diff
changeset
|
117 | n_params = g_strv_length(params); |
|
310d3d474f8c
IRCv3: Fix a bug where part messages were not being parsed correctly
Gary Kramlich <grim@reaperworld.com>
parents:
42965
diff
changeset
|
118 | if(n_params == 0) { |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
119 | /* 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
|
120 | return TRUE; |
|
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 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
123 | /* 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
|
124 | * 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
|
125 | */ |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
126 | conversation_name = params[0]; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
127 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
128 | 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
|
129 | manager = purple_conversation_manager_get_default(); |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
130 | 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
|
131 | conversation_name); |
|
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(!PURPLE_IS_CONVERSATION(conversation)) { |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
134 | /* TODO: write status message unknown channel. */ |
|
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 | return TRUE; |
|
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 | |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
139 | members = purple_conversation_get_members(conversation); |
|
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
140 | |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
141 | /* 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
|
142 | * 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
|
143 | */ |
|
42815
95bb2ae83de7
IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42780
diff
changeset
|
144 | 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
|
145 | message); |
|
42780
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 | /* 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
|
148 | */ |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
149 | if(n_params > 1) { |
|
43019
7621ef6ea06a
IRCv3: Update the join/part reasons to match the quit format
Gary Kramlich <grim@reaperworld.com>
parents:
43015
diff
changeset
|
150 | char *part_message = NULL; |
|
7621ef6ea06a
IRCv3: Update the join/part reasons to match the quit format
Gary Kramlich <grim@reaperworld.com>
parents:
43015
diff
changeset
|
151 | |
|
7621ef6ea06a
IRCv3: Update the join/part reasons to match the quit format
Gary Kramlich <grim@reaperworld.com>
parents:
43015
diff
changeset
|
152 | part_message = g_strjoinv(" ", params + 1); |
|
7621ef6ea06a
IRCv3: Update the join/part reasons to match the quit format
Gary Kramlich <grim@reaperworld.com>
parents:
43015
diff
changeset
|
153 | reason = g_strdup_printf(_("%s has left %s (%s)"), |
|
7621ef6ea06a
IRCv3: Update the join/part reasons to match the quit format
Gary Kramlich <grim@reaperworld.com>
parents:
43015
diff
changeset
|
154 | purple_contact_info_get_sid(PURPLE_CONTACT_INFO(contact)), |
|
7621ef6ea06a
IRCv3: Update the join/part reasons to match the quit format
Gary Kramlich <grim@reaperworld.com>
parents:
43015
diff
changeset
|
155 | purple_conversation_get_title_for_display(conversation), |
|
7621ef6ea06a
IRCv3: Update the join/part reasons to match the quit format
Gary Kramlich <grim@reaperworld.com>
parents:
43015
diff
changeset
|
156 | part_message); |
|
7621ef6ea06a
IRCv3: Update the join/part reasons to match the quit format
Gary Kramlich <grim@reaperworld.com>
parents:
43015
diff
changeset
|
157 | } else { |
|
7621ef6ea06a
IRCv3: Update the join/part reasons to match the quit format
Gary Kramlich <grim@reaperworld.com>
parents:
43015
diff
changeset
|
158 | reason = g_strdup_printf(_("%s has left %s"), |
|
7621ef6ea06a
IRCv3: Update the join/part reasons to match the quit format
Gary Kramlich <grim@reaperworld.com>
parents:
43015
diff
changeset
|
159 | purple_contact_info_get_sid(PURPLE_CONTACT_INFO(contact)), |
|
7621ef6ea06a
IRCv3: Update the join/part reasons to match the quit format
Gary Kramlich <grim@reaperworld.com>
parents:
43015
diff
changeset
|
160 | purple_conversation_get_title_for_display(conversation)); |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
161 | } |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
162 | |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
163 | purple_conversation_members_remove_member(members, |
|
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
164 | PURPLE_CONTACT_INFO(contact), |
|
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
165 | TRUE, reason); |
|
42780
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
166 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
167 | g_clear_pointer(&reason, g_free); |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
168 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
169 | return TRUE; |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
170 | } |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
171 | |
|
c1af98cbd43a
IRCv3: Implement join and part message handlers
Gary Kramlich <grim@reaperworld.com>
parents:
42775
diff
changeset
|
172 | gboolean |
|
42925
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
173 | purple_ircv3_message_handler_namreply(IbisClient *client, |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
174 | G_GNUC_UNUSED const char *command, |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
175 | IbisMessage *message, gpointer data) |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
176 | { |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
177 | PurpleIRCv3Connection *connection = data; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
178 | PurpleConversation *conversation = NULL; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
179 | GStrv params = NULL; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
180 | GStrv nicks = NULL; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
181 | const char *target = NULL; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
182 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
183 | params = ibis_message_get_params(message); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
184 | if(params == NULL) { |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
185 | g_warning("namreply received with no parameters"); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
186 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
187 | return FALSE; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
188 | } |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
189 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
190 | if(g_strv_length(params) != 4) { |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
191 | char *body = g_strjoinv(" ", params); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
192 | g_warning("unknown namreply format: '%s'", body); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
193 | g_free(body); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
194 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
195 | return FALSE; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
196 | } |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
197 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
198 | /* params[0] holds nick of the user and params[1] holds the channel type |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
199 | * (public/private) but we don't care about either of these. |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
200 | */ |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
201 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
202 | target = params[2]; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
203 | if(!ibis_client_is_channel(client, target)) { |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
204 | g_warning("received namreply for '%s' which is not a channel.", |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
205 | target); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
206 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
207 | return FALSE; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
208 | } |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
209 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
210 | conversation = purple_ircv3_connection_find_or_create_conversation(connection, |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
211 | target); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
212 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
213 | /* Split the last parameter on space to get a list of all the nicks. */ |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
214 | nicks = g_strsplit(params[3], " ", -1); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
215 | if(nicks != NULL) { |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
216 | PurpleAccount *account = NULL; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
217 | PurpleConnection *purple_connection = NULL; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
218 | PurpleContactManager *manager = purple_contact_manager_get_default(); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
219 | PurpleConversationMembers *members = NULL; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
220 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
221 | purple_connection = PURPLE_CONNECTION(connection); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
222 | account = purple_connection_get_account(purple_connection); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
223 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
224 | members = purple_conversation_get_members(conversation); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
225 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
226 | for(guint i = 0; i < g_strv_length(nicks); i++) { |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
227 | PurpleContact *contact = NULL; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
228 | const char *nick = nicks[i]; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
229 | char *stripped = NULL; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
230 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
231 | stripped = ibis_client_strip_source_prefix(client, nick); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
232 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
233 | contact = purple_contact_manager_find_with_id(manager, account, |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
234 | stripped); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
235 | if(!PURPLE_IS_CONTACT(contact)) { |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
236 | contact = purple_contact_new(account, stripped); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
237 | purple_contact_info_set_username(PURPLE_CONTACT_INFO(contact), |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
238 | stripped); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
239 | purple_contact_manager_add(manager, contact); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
240 | } |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
241 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
242 | purple_conversation_members_add_member(members, |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
243 | PURPLE_CONTACT_INFO(contact), |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
244 | FALSE, NULL); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
245 | g_free(stripped); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
246 | } |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
247 | } |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
248 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
249 | g_strfreev(nicks); |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
250 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
251 | return TRUE; |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
252 | } |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
253 | |
|
3c9b77d62b0d
IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents:
42920
diff
changeset
|
254 | gboolean |
|
42896
5c8f4a455d3c
IRCv3: Use Ibis.Client.is_channel instead of our old version
Gary Kramlich <grim@reaperworld.com>
parents:
42893
diff
changeset
|
255 | purple_ircv3_message_handler_tagmsg(IbisClient *client, |
|
42883
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
256 | G_GNUC_UNUSED const char *command, |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
257 | IbisMessage *ibis_message, gpointer data) |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
258 | { |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
259 | PurpleIRCv3Connection *connection = data; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
260 | PurpleContact *contact = NULL; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
261 | PurpleConversation *conversation = NULL; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
262 | GStrv params = NULL; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
263 | IbisTags *tags = NULL; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
264 | const char *target = NULL; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
265 | const char *value = NULL; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
266 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
267 | params = ibis_message_get_params(ibis_message); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
268 | tags = ibis_message_get_tags(ibis_message); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
269 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
270 | if(params == NULL) { |
|
42920
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
271 | g_warning("tagmsg received with no parameters"); |
|
42883
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
272 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
273 | return FALSE; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
274 | } |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
275 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
276 | if(g_strv_length(params) != 1) { |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
277 | char *body = g_strjoinv(" ", params); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
278 | g_warning("unknown tagmsg message format: '%s'", body); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
279 | g_free(body); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
280 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
281 | return FALSE; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
282 | } |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
283 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
284 | /* Find or create the contact. */ |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
285 | contact = purple_ircv3_connection_find_or_create_contact(connection, |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
286 | ibis_message); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
287 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
288 | /* Find or create the conversation. */ |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
289 | 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
|
290 | if(!ibis_client_is_channel(client, target)) { |
|
42883
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
291 | 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
|
292 | } |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
293 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
294 | conversation = purple_ircv3_connection_find_or_create_conversation(connection, |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
295 | target); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
296 | |
|
43025
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
297 | purple_ircv3_add_contact_to_conversation(contact, conversation, FALSE); |
|
42883
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
298 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
299 | /* Handle typing notifications. */ |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
300 | value = ibis_tags_lookup(tags, IBIS_TAG_TYPING); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
301 | if(!purple_strempty(value)) { |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
302 | PurpleConversationMember *member = NULL; |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
303 | PurpleConversationMembers *members = NULL; |
|
42883
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
304 | PurpleTypingState state = PURPLE_TYPING_STATE_NONE; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
305 | guint timeout = 1; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
306 | |
|
42893
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
307 | members = purple_conversation_get_members(conversation); |
|
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
308 | member = purple_conversation_members_find_member(members, |
|
d73c5851a773
IRCv3: Port to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents:
42883
diff
changeset
|
309 | PURPLE_CONTACT_INFO(contact)); |
|
42883
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
310 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
311 | if(purple_strequal(value, IBIS_TYPING_ACTIVE)) { |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
312 | state = PURPLE_TYPING_STATE_TYPING; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
313 | timeout = 6; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
314 | } else if(purple_strequal(value, IBIS_TYPING_PAUSED)) { |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
315 | state = PURPLE_TYPING_STATE_PAUSED; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
316 | timeout = 30; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
317 | } |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
318 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
319 | purple_conversation_member_set_typing_state(member, state, timeout); |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
320 | } |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
321 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
322 | return TRUE; |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
323 | } |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
324 | |
|
51a0fe1e2500
IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42815
diff
changeset
|
325 | gboolean |
|
42896
5c8f4a455d3c
IRCv3: Use Ibis.Client.is_channel instead of our old version
Gary Kramlich <grim@reaperworld.com>
parents:
42893
diff
changeset
|
326 | 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
|
327 | 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
|
328 | { |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
329 | PurpleIRCv3Connection *connection = data; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
330 | PurpleContact *contact = NULL; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
331 | PurpleConversation *conversation = NULL; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
332 | PurpleMessage *message = NULL; |
|
42056
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
333 | GDateTime *dt = NULL; |
|
42920
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
334 | 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
|
335 | IbisTags *tags = NULL; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
336 | 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
|
337 | const char *target = NULL; |
|
43025
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
338 | gboolean announce = TRUE; |
|
41813
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
339 | |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
340 | params = ibis_message_get_params(ibis_message); |
|
42920
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
341 | 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
|
342 | 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
|
343 | |
|
42382
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
344 | if(params == NULL) { |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
345 | g_warning("privmsg received with no parameters"); |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
346 | |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
347 | return FALSE; |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
348 | } |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
349 | |
|
343e30628383
IRCv3: Fix an issue scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
42378
diff
changeset
|
350 | 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
|
351 | 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
|
352 | 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
|
353 | g_free(body); |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
354 | |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
355 | return FALSE; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
356 | } |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
357 | |
|
42815
95bb2ae83de7
IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42780
diff
changeset
|
358 | /* 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
|
359 | 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
|
360 | ibis_message); |
|
42345
e01084003f50
IRCv3: Finally fix sending messages between two users
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
361 | |
|
42513
482ba61e5123
IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
362 | /* 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
|
363 | 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
|
364 | 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
|
365 | 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
|
366 | } |
|
42815
95bb2ae83de7
IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42780
diff
changeset
|
367 | |
|
43024
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
368 | if(!ibis_client_get_registered(client)) { |
|
42965
37214064f381
IRCv3: While connecting put all PRIVMSG's in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42937
diff
changeset
|
369 | conversation = purple_ircv3_connection_get_status_conversation(connection); |
|
43025
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
370 | announce = FALSE; |
|
42965
37214064f381
IRCv3: While connecting put all PRIVMSG's in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42937
diff
changeset
|
371 | } else if(IBIS_IS_CTCP_MESSAGE(ctcp_message)) { |
|
42926
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
372 | conversation = purple_ircv3_connection_get_status_conversation(connection); |
|
43025
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
373 | announce = FALSE; |
|
42926
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
374 | } else { |
|
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
375 | conversation = purple_ircv3_connection_find_or_create_conversation(connection, |
|
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
376 | target); |
|
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
377 | } |
|
42513
482ba61e5123
IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
378 | |
|
43025
2d3b2ed42f87
IRCv3: Fix pre-registration PRIVMSG not going to the status window
Gary Kramlich <grim@reaperworld.com>
parents:
43024
diff
changeset
|
379 | purple_ircv3_add_contact_to_conversation(contact, conversation, announce); |
|
41813
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
380 | |
|
42920
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
381 | if(IBIS_IS_CTCP_MESSAGE(ctcp_message)) { |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
382 | 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
|
383 | GStrv ctcp_params = NULL; |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
384 | char *ctcp_body = NULL; |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
385 | char *stripped = NULL; |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
386 | |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
387 | ctcp_params = ibis_ctcp_message_get_params(ctcp_message); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
388 | ctcp_body = g_strjoinv(" ", ctcp_params); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
389 | stripped = ibis_formatting_strip(ctcp_body); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
390 | g_free(ctcp_body); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
391 | |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
392 | message = purple_message_new(PURPLE_CONTACT_INFO(contact), |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
393 | stripped); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
394 | g_free(stripped); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
395 | |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
396 | purple_message_set_action(message, TRUE); |
|
42926
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
397 | } else { |
|
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
398 | char *body = NULL; |
|
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
399 | |
|
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
400 | body = g_strdup_printf(_("requested CTCP '%s' (to %s) from %s"), |
|
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
401 | ibis_ctcp_message_get_command(ctcp_message), |
|
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
402 | params[0], |
|
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
403 | purple_contact_info_get_id(PURPLE_CONTACT_INFO(contact))); |
|
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
404 | |
|
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
405 | message = purple_message_new(PURPLE_CONTACT_INFO(contact), body); |
|
c63faf01193e
Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents:
42925
diff
changeset
|
406 | g_free(body); |
|
42920
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
407 | } |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
408 | } |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
409 | |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
410 | if(!PURPLE_IS_MESSAGE(message)) { |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
411 | char *stripped = NULL; |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
412 | |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
413 | stripped = ibis_formatting_strip(params[1]); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
414 | message = purple_message_new(PURPLE_CONTACT_INFO(contact), stripped); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
415 | g_clear_pointer(&stripped, g_free); |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
416 | } |
|
897667cab3ce
Add support for CTCP ACTION
Gary Kramlich <grim@reaperworld.com>
parents:
42896
diff
changeset
|
417 | |
|
42815
95bb2ae83de7
IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42780
diff
changeset
|
418 | |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
419 | 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
|
420 | 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
|
421 | } |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
422 | |
|
42775
98b71fc8a330
Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents:
42769
diff
changeset
|
423 | 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
|
424 | 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
|
425 | |
|
42775
98b71fc8a330
Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents:
42769
diff
changeset
|
426 | /* 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
|
427 | 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
|
428 | 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
|
429 | 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
|
430 | } |
|
42294
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
431 | |
|
42775
98b71fc8a330
Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents:
42769
diff
changeset
|
432 | /* 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
|
433 | 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
|
434 | if(!purple_strempty(raw_tag)) { |
|
98b71fc8a330
Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents:
42769
diff
changeset
|
435 | 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
|
436 | |
|
42775
98b71fc8a330
Only check tags if we have a tags object
Gary Kramlich <grim@reaperworld.com>
parents:
42769
diff
changeset
|
437 | 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
|
438 | g_time_zone_unref(tz); |
|
42294
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
439 | |
|
42815
95bb2ae83de7
IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents:
42780
diff
changeset
|
440 | 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
|
441 | 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
|
442 | } |
|
42294
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
443 | } |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
444 | |
|
462317d1382d
IRCv3: add support for the server-time capability
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
445 | /* 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
|
446 | 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
|
447 | 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
|
448 | } |
|
42056
ced07483f66a
IRCv3: Add support for the msgid specification
Gary Kramlich <grim@reaperworld.com>
parents:
42048
diff
changeset
|
449 | |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
450 | 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
|
451 | |
|
41813
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
452 | 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
|
453 | |
|
42937
34ac8ac8c7b6
Implement CTCP VERSION response
Gary Kramlich <grim@reaperworld.com>
parents:
42926
diff
changeset
|
454 | /* If the message contained a CTCP message and was a PRIVMSG, we then need |
|
34ac8ac8c7b6
Implement CTCP VERSION response
Gary Kramlich <grim@reaperworld.com>
parents:
42926
diff
changeset
|
455 | * to attempt to handle it. |
|
34ac8ac8c7b6
Implement CTCP VERSION response
Gary Kramlich <grim@reaperworld.com>
parents:
42926
diff
changeset
|
456 | */ |
|
34ac8ac8c7b6
Implement CTCP VERSION response
Gary Kramlich <grim@reaperworld.com>
parents:
42926
diff
changeset
|
457 | if(IBIS_IS_CTCP_MESSAGE(ctcp_message) && |
|
34ac8ac8c7b6
Implement CTCP VERSION response
Gary Kramlich <grim@reaperworld.com>
parents:
42926
diff
changeset
|
458 | purple_strequal(command, IBIS_MSG_PRIVMSG)) |
|
34ac8ac8c7b6
Implement CTCP VERSION response
Gary Kramlich <grim@reaperworld.com>
parents:
42926
diff
changeset
|
459 | { |
|
34ac8ac8c7b6
Implement CTCP VERSION response
Gary Kramlich <grim@reaperworld.com>
parents:
42926
diff
changeset
|
460 | purple_ircv3_ctcp_handler(connection, client, ibis_message); |
|
34ac8ac8c7b6
Implement CTCP VERSION response
Gary Kramlich <grim@reaperworld.com>
parents:
42926
diff
changeset
|
461 | } |
|
34ac8ac8c7b6
Implement CTCP VERSION response
Gary Kramlich <grim@reaperworld.com>
parents:
42926
diff
changeset
|
462 | |
|
41813
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
463 | return TRUE; |
|
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
464 | } |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
465 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
466 | gboolean |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
467 | 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
|
468 | const char *command, IbisMessage *message, |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
469 | gpointer data) |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
470 | { |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
471 | PurpleIRCv3Connection *connection = data; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
472 | PurpleConversation *conversation = NULL; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
473 | GStrv params = NULL; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
474 | const char *channel = NULL; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
475 | const char *topic = NULL; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
476 | guint n_params = 0; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
477 | |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
478 | params = ibis_message_get_params(message); |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
479 | n_params = g_strv_length(params); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
480 | |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
481 | if(purple_strequal(command, IBIS_MSG_TOPIC)) { |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
482 | 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
|
483 | 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
|
484 | n_params); |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
485 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
486 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
487 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
488 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
489 | channel = params[0]; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
490 | topic = params[1]; |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
491 | } 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
|
492 | 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
|
493 | 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
|
494 | n_params); |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
495 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
496 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
497 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
498 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
499 | channel = params[1]; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
500 | topic = ""; |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
501 | } 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
|
502 | 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
|
503 | 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
|
504 | n_params); |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
505 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
506 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
507 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
508 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
509 | channel = params[1]; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
510 | topic = params[2]; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
511 | } else { |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
512 | g_message("unexpected command %s", command); |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
513 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
514 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
515 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
516 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
517 | 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
|
518 | channel); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
519 | 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
|
520 | 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
|
521 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
522 | return FALSE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
523 | } |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
524 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
525 | purple_conversation_set_topic(conversation, topic); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
526 | |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
527 | return TRUE; |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42494
diff
changeset
|
528 | } |
|
43007
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
529 | |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
530 | gboolean |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
531 | purple_ircv3_message_handler_quit(G_GNUC_UNUSED IbisClient *client, |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
532 | G_GNUC_UNUSED const char *command, |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
533 | IbisMessage *ibis_message, |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
534 | gpointer data) |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
535 | { |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
536 | PurpleIRCv3Connection *connection = data; |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
537 | PurpleContact *contact = NULL; |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
538 | PurpleContactInfo *info = NULL; |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
539 | PurpleConversationManager *manager = NULL; |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
540 | GList *conversations = NULL; |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
541 | GStrv params = NULL; |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
542 | guint n_params = 0; |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
543 | char *message = NULL; |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
544 | |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
545 | params = ibis_message_get_params(ibis_message); |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
546 | n_params = g_strv_length(params); |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
547 | |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
548 | contact = purple_ircv3_connection_find_or_create_contact(connection, |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
549 | ibis_message); |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
550 | info = PURPLE_CONTACT_INFO(contact); |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
551 | |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
552 | if(n_params > 0) { |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
553 | char *reason = NULL; |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
554 | |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
555 | reason = g_strjoinv(" ", params); |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
556 | message = g_strdup_printf("%s has quit (%s)", |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
557 | purple_contact_info_get_sid(info), |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
558 | reason); |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
559 | g_free(reason); |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
560 | } else { |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
561 | message = g_strdup_printf("%s has quit", |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
562 | purple_contact_info_get_sid(info)); |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
563 | } |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
564 | |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
565 | manager = purple_conversation_manager_get_default(); |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
566 | conversations = purple_conversation_manager_get_all(manager); |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
567 | while(conversations != NULL) { |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
568 | PurpleConversation *conversation = conversations->data; |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
569 | PurpleConversationMembers *members = NULL; |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
570 | |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
571 | members = purple_conversation_get_members(conversation); |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
572 | purple_conversation_members_remove_member(members, info, TRUE, |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
573 | message); |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
574 | |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
575 | conversations = g_list_delete_link(conversations, conversations); |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
576 | } |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
577 | |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
578 | g_free(message); |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
579 | |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
580 | return TRUE; |
|
e61836350fce
IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents:
42982
diff
changeset
|
581 | } |
|
43015
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
582 | |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
583 | gboolean |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
584 | purple_ircv3_message_handler_nick(G_GNUC_UNUSED IbisClient *client, |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
585 | G_GNUC_UNUSED const char *command, |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
586 | IbisMessage *ibis_message, |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
587 | gpointer data) |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
588 | { |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
589 | PurpleIRCv3Connection *connection = data; |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
590 | PurpleContact *contact = NULL; |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
591 | PurpleContactInfo *info = NULL; |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
592 | IbisTags *tags = NULL; |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
593 | GStrv params = NULL; |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
594 | guint n_params = 0; |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
595 | char *new_source = NULL; |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
596 | char *user = NULL; |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
597 | char *host = NULL; |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
598 | const char *source = NULL; |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
599 | const char *nick = NULL; |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
600 | |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
601 | params = ibis_message_get_params(ibis_message); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
602 | n_params = g_strv_length(params); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
603 | |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
604 | if(n_params != 1) { |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
605 | g_message("received NICK with %d params, expected 1", n_params); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
606 | return FALSE; |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
607 | } |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
608 | |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
609 | nick = params[0]; |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
610 | source = ibis_message_get_source(ibis_message); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
611 | ibis_source_parse(source, NULL, &user, &host); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
612 | new_source = ibis_source_serialize(nick, user, host); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
613 | g_clear_pointer(&user, g_free); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
614 | g_clear_pointer(&host, g_free); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
615 | |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
616 | contact = purple_ircv3_connection_find_or_create_contact(connection, |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
617 | ibis_message); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
618 | info = PURPLE_CONTACT_INFO(contact); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
619 | |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
620 | /* If the account tag doesn't exist, we need to update the id property of |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
621 | * the contact. |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
622 | */ |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
623 | tags = ibis_message_get_tags(ibis_message); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
624 | if(!ibis_tags_exists(tags, IBIS_TAG_ACCOUNT)) { |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
625 | purple_contact_info_set_id(info, nick); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
626 | } |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
627 | |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
628 | purple_contact_info_set_display_name(info, nick); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
629 | purple_contact_info_set_sid(info, new_source); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
630 | g_clear_pointer(&new_source, g_free); |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
631 | |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
632 | return TRUE; |
|
a743311c9c2c
IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents:
43007
diff
changeset
|
633 | } |
|
43024
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
634 | |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
635 | gboolean |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
636 | purple_ircv3_message_handler_error(IbisClient *client, |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
637 | G_GNUC_UNUSED const char *command, |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
638 | IbisMessage *ibis_message, |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
639 | gpointer data) |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
640 | { |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
641 | PurpleAccount *account = NULL; |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
642 | PurpleConnection *connection = data; |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
643 | GError *error = NULL; |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
644 | GStrv params = NULL; |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
645 | guint n_params = 0; |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
646 | char *reason = NULL; |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
647 | |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
648 | account = purple_connection_get_account(connection); |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
649 | |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
650 | params = ibis_message_get_params(ibis_message); |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
651 | n_params = g_strv_length(params); |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
652 | |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
653 | if(n_params > 0) { |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
654 | reason = g_strjoinv(" ", params); |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
655 | } else { |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
656 | reason = g_strdup(_("unknown error")); |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
657 | } |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
658 | |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
659 | error = g_error_new_literal(PURPLE_IRCV3_DOMAIN, 0, reason); |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
660 | g_clear_pointer(&reason, g_free); |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
661 | |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
662 | ibis_client_stop(client, NULL); |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
663 | |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
664 | purple_account_disconnect_with_error(account, error); |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
665 | |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
666 | return TRUE; |
|
8a7be63f83e4
IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents:
43019
diff
changeset
|
667 | } |
|
43028
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
668 | |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
669 | gboolean |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
670 | purple_ircv3_message_handler_wallops(G_GNUC_UNUSED IbisClient *client, |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
671 | G_GNUC_UNUSED const char *command, |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
672 | IbisMessage *ibis_message, |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
673 | gpointer data) |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
674 | { |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
675 | PurpleIRCv3Connection *v3_connection = data; |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
676 | PurpleAccount *account = NULL; |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
677 | PurpleConnection *connection = data; |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
678 | PurpleContact *contact = NULL; |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
679 | PurpleContactInfo *info = NULL; |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
680 | PurpleNotification *notification = NULL; |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
681 | PurpleNotificationManager *manager = NULL; |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
682 | GStrv params = NULL; |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
683 | char *wallops_title = NULL; |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
684 | guint n_params = 0; |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
685 | |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
686 | params = ibis_message_get_params(ibis_message); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
687 | n_params = g_strv_length(params); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
688 | |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
689 | if(n_params != 1) { |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
690 | g_message("received WALLOPS with %u params, expected 1", n_params); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
691 | return FALSE; |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
692 | } |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
693 | |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
694 | contact = purple_ircv3_connection_find_or_create_contact(v3_connection, |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
695 | ibis_message); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
696 | info = PURPLE_CONTACT_INFO(contact); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
697 | |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
698 | wallops_title = g_strdup_printf(_("WALLOPS from %s"), |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
699 | purple_contact_info_get_name_for_display(info)); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
700 | notification = purple_notification_new(NULL, wallops_title); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
701 | g_free(wallops_title); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
702 | |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
703 | account = purple_connection_get_account(connection); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
704 | purple_notification_set_account(notification, account); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
705 | purple_notification_set_subtitle(notification, params[0]); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
706 | purple_notification_set_icon_name(notification, PURPLE_IRCV3_ICON_NAME); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
707 | |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
708 | manager = purple_notification_manager_get_default(); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
709 | purple_notification_manager_add(manager, notification); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
710 | g_clear_object(¬ification); |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
711 | |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
712 | return TRUE; |
|
dda093fe275e
IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents:
43025
diff
changeset
|
713 | } |