protocols/ircv3/purpleircv3protocol.c

Thu, 17 Jul 2025 20:28:54 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 17 Jul 2025 20:28:54 -0500
changeset 43290
01edcfbfebaa
parent 43126
5b5a883528e0
permissions
-rw-r--r--

IRCv3: Implement the /me command

This was kind of forgotten about, but it's here now.

Testing Done:
Watched a packet dump to verify it was sent correct and asked people in #pidgin on libera if it came through correctly.

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

41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
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: 42469
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: 42469
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: 42469
diff changeset
7 * source distribution.
31e8c7c92e2f Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents: 42469
diff changeset
8 *
31e8c7c92e2f Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents: 42469
diff changeset
9 * This library is free software; you can redistribute it and/or modify
41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
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: 42469
diff changeset
14 * This library is distributed in the hope that it will be useful,
41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
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: 42469
diff changeset
20 * along with this library; if not, see <https://www.gnu.org/licenses/>.
41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n-lib.h>
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include "purpleircv3protocol.h"
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
43097
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
27 #include "purpleircv3commands.h"
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41772
diff changeset
28 #include "purpleircv3connection.h"
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41772
diff changeset
29 #include "purpleircv3core.h"
42320
21cab78fb7d2 IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42044
diff changeset
30 #include "purpleircv3protocolconversation.h"
41772
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
31
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
32 struct _PurpleIRCv3Protocol {
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
33 PurpleProtocol parent;
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
34 };
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
35
41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 /******************************************************************************
42646
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
37 * Callbacks
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
38 *****************************************************************************/
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
39 static void
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
40 purple_ircv3_protocol_can_reach_cb(GObject *self, GAsyncResult *result,
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
41 gpointer data)
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
42 {
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
43 GError *error = NULL;
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
44 GTask *task = data;
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
45 gboolean can_reach = FALSE;
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
46
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
47 /* task and result share a cancellable, so either can be used here. */
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
48 if(g_task_return_error_if_cancelled(task)) {
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
49 g_clear_object(&task);
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
50
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
51 return;
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
52 }
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
53
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
54 can_reach = g_network_monitor_can_reach_finish(G_NETWORK_MONITOR(self), result,
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
55 &error);
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
56
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
57 if(error != NULL) {
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
58 g_task_return_error(task, error);
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
59 } else if(!can_reach) {
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
60 g_task_return_new_error(task, PURPLE_IRCV3_DOMAIN, 0,
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
61 _("Unknown network error."));
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
62 } else {
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
63 g_task_return_boolean(task, TRUE);
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
64 }
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
65
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
66 g_clear_object(&task);
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
67 }
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
68
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
69 /******************************************************************************
41772
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
70 * PurpleProtocol Implementation
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
71 *****************************************************************************/
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
72 static GList *
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
73 purple_ircv3_protocol_get_user_splits(G_GNUC_UNUSED PurpleProtocol *protocol) {
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
74 PurpleAccountUserSplit *split = NULL;
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
75 GList *splits = NULL;
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
76
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41772
diff changeset
77 split = purple_account_user_split_new(_("Server"),
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41772
diff changeset
78 PURPLE_IRCV3_DEFAULT_SERVER,
41772
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
79 '@');
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
80 splits = g_list_append(splits, split);
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
81
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
82 return splits;
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
83 }
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
84
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
85 static GList *
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
86 purple_ircv3_protocol_get_account_options(G_GNUC_UNUSED PurpleProtocol *protocol)
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
87 {
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
88 PurpleAccountOption *option;
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
89 GList *options = NULL;
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
90
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
91 option = purple_account_option_int_new(_("Port"), "port",
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41772
diff changeset
92 PURPLE_IRCV3_DEFAULT_TLS_PORT);
41772
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
93 options = g_list_append(options, option);
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
94
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
95 option = purple_account_option_bool_new(_("Use TLS"), "use-tls", TRUE);
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
96 options = g_list_append(options, option);
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
97
41955
d3117aac63b3 Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41941
diff changeset
98 option = purple_account_option_string_new(_("Server password"),
d3117aac63b3 Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41941
diff changeset
99 "server-password", "");
42469
b789ce8f43e2 IRCv3: Mask the server password in account options
Gary Kramlich <grim@reaperworld.com>
parents: 42320
diff changeset
100 purple_account_option_string_set_masked(option, TRUE);
41955
d3117aac63b3 Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41941
diff changeset
101 options = g_list_append(options, option);
d3117aac63b3 Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41941
diff changeset
102
41772
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
103 option = purple_account_option_string_new(_("Ident name"), "ident", "");
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
104 options = g_list_append(options, option);
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
105
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
106 option = purple_account_option_string_new(_("Real name"), "real-name", "");
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
107 options = g_list_append(options, option);
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
108
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
109 option = purple_account_option_string_new(_("SASL login name"),
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
110 "sasl-login-name", "");
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
111 options = g_list_append(options, option);
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
112
42044
37eaa6065a9a IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents: 41977
diff changeset
113 option = purple_account_option_string_new(_("SASL mechanisms"),
37eaa6065a9a IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents: 41977
diff changeset
114 "sasl-mechanisms", "");
37eaa6065a9a IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents: 41977
diff changeset
115 options = g_list_append(options, option);
37eaa6065a9a IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents: 41977
diff changeset
116
41772
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
117 option = purple_account_option_bool_new(_("Allow plaintext SASL auth over "
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
118 "unencrypted connection"),
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
119 "plain-sasl-in-clear", FALSE);
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
120 options = g_list_append(options, option);
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
121
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
122 option = purple_account_option_int_new(_("Seconds between sending "
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
123 "messages"),
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
124 "rate-limit-interval", 2);
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
125 options = g_list_append(options, option);
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
126
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
127 option = purple_account_option_int_new(_("Maximum messages to send at "
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
128 "once"),
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
129 "rate-limit-burst", 5);
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
130 options = g_list_append(options, option);
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
131
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
132 return options;
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
133 }
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
134
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
135 static PurpleConnection *
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
136 purple_ircv3_protocol_create_connection(PurpleProtocol *protocol,
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
137 PurpleAccount *account,
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
138 const char *password,
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
139 GError **error)
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41772
diff changeset
140 {
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
141 const char *username = NULL;
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
142
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
143 g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol), NULL);
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
144 g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41772
diff changeset
145
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
146 /* Make sure the username (which includes the servername via usersplits),
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
147 * does not contain any whitespace.
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
148 */
42803
984f8dfabb47 Update the protocols to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents: 42697
diff changeset
149 username = purple_account_get_username(account);
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
150 if(strpbrk(username, " \t\v\r\n") != NULL) {
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
151 g_set_error(error,
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
152 PURPLE_CONNECTION_ERROR,
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
153 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
154 _("IRC nick and server may not contain whitespace"));
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41772
diff changeset
155
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
156 return NULL;
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41772
diff changeset
157 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41772
diff changeset
158
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
159 return g_object_new(
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
160 PURPLE_IRCV3_TYPE_CONNECTION,
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
161 "protocol", protocol,
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
162 "account", account,
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
163 "password", password,
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
164 NULL);
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41772
diff changeset
165 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41772
diff changeset
166
42646
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
167 static void
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
168 purple_ircv3_protocol_can_connect_async(PurpleProtocol *protocol,
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
169 PurpleAccount *account,
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
170 GCancellable *cancellable,
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
171 GAsyncReadyCallback callback,
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
172 gpointer data)
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
173 {
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
174 GNetworkMonitor *monitor = NULL;
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
175 GSocketConnectable *connectable = NULL;
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
176 GStrv parts = NULL;
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
177 GTask *task = NULL;
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
178 const char *username = NULL;
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
179 int port = 0;
42646
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
180
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
181 task = g_task_new(protocol, cancellable, callback, data);
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
182
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
183 monitor = g_network_monitor_get_default();
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
184
42803
984f8dfabb47 Update the protocols to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents: 42697
diff changeset
185 username = purple_account_get_username(account);
42646
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
186 parts = g_strsplit(username, "@", 2);
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
187 port = purple_account_get_int(account, "port",
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
188 PURPLE_IRCV3_DEFAULT_TLS_PORT);
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
189
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
190 connectable = g_network_address_new(parts[1], (guint16)port);
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
191 g_strfreev(parts);
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
192
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
193 g_network_monitor_can_reach_async(monitor, connectable, cancellable,
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
194 purple_ircv3_protocol_can_reach_cb,
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
195 task);
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
196 g_clear_object(&connectable);
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
197 }
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
198
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
199 static gboolean
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
200 purple_ircv3_protocol_can_connect_finish(G_GNUC_UNUSED PurpleProtocol *protocol,
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
201 GAsyncResult *result,
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
202 GError **error)
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
203 {
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
204 return g_task_propagate_boolean(G_TASK(result), error);
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
205 }
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
206
41772
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
207 /******************************************************************************
41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 * GObject Implementation
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 *****************************************************************************/
41916
4ee9cb957595 Implement sending im's for IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41870
diff changeset
210 G_DEFINE_DYNAMIC_TYPE_EXTENDED(
4ee9cb957595 Implement sending im's for IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41870
diff changeset
211 PurpleIRCv3Protocol,
4ee9cb957595 Implement sending im's for IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41870
diff changeset
212 purple_ircv3_protocol,
4ee9cb957595 Implement sending im's for IRCv3
Gary Kramlich <grim@reaperworld.com>
parents: 41870
diff changeset
213 PURPLE_TYPE_PROTOCOL,
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
214 G_TYPE_FLAG_FINAL,
42320
21cab78fb7d2 IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42044
diff changeset
215 G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_CONVERSATION,
21cab78fb7d2 IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42044
diff changeset
216 purple_ircv3_protocol_conversation_init))
41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 static void
43097
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
219 purple_ircv3_protocol_finalize(GObject *obj) {
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
220 PurpleCommandManager *manager = NULL;
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
221
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
222 manager = purple_command_manager_get_default();
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
223 purple_command_manager_remove_all_with_source(manager,
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
224 PURPLE_IRCV3_PROTOCOL_ID);
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
225
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
226 G_OBJECT_CLASS(purple_ircv3_protocol_parent_class)->finalize(obj);
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
227 }
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
228
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
229 static void
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
230 purple_ircv3_protocol_init(PurpleIRCv3Protocol *protocol) {
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
231 PurpleCommand *command = NULL;
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
232 PurpleCommandManager *manager = NULL;
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
233 PurpleTags *tags = NULL;
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
234
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
235 manager = purple_command_manager_get_default();
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
236
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
237 command = purple_command_new("query", "IRCv3", 1000);
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
238 purple_command_set_summary(command,
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
239 _("Open a conversation with the given nick"));
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
240 tags = purple_command_get_tags(command);
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
241 purple_tags_add(tags, "protocol-id:" PURPLE_IRCV3_PROTOCOL_ID);
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
242 g_signal_connect_object(command, "executed",
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
243 G_CALLBACK(purple_ircv3_command_query_cb),
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
244 protocol, G_CONNECT_DEFAULT);
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
245 purple_command_manager_add(manager, command);
43126
5b5a883528e0 IRCv3: Add the quote command to send raw messages
Gary Kramlich <grim@reaperworld.com>
parents: 43097
diff changeset
246
5b5a883528e0 IRCv3: Add the quote command to send raw messages
Gary Kramlich <grim@reaperworld.com>
parents: 43097
diff changeset
247 command = purple_command_new("quote", "IRCv3", 1000);
5b5a883528e0 IRCv3: Add the quote command to send raw messages
Gary Kramlich <grim@reaperworld.com>
parents: 43097
diff changeset
248 purple_command_set_summary(command,
5b5a883528e0 IRCv3: Add the quote command to send raw messages
Gary Kramlich <grim@reaperworld.com>
parents: 43097
diff changeset
249 _("Sends the command directly to the server"));
5b5a883528e0 IRCv3: Add the quote command to send raw messages
Gary Kramlich <grim@reaperworld.com>
parents: 43097
diff changeset
250 tags = purple_command_get_tags(command);
5b5a883528e0 IRCv3: Add the quote command to send raw messages
Gary Kramlich <grim@reaperworld.com>
parents: 43097
diff changeset
251 purple_tags_add(tags, "protocol-id:" PURPLE_IRCV3_PROTOCOL_ID);
5b5a883528e0 IRCv3: Add the quote command to send raw messages
Gary Kramlich <grim@reaperworld.com>
parents: 43097
diff changeset
252 g_signal_connect_object(command, "executed",
5b5a883528e0 IRCv3: Add the quote command to send raw messages
Gary Kramlich <grim@reaperworld.com>
parents: 43097
diff changeset
253 G_CALLBACK(purple_ircv3_command_quote_cb),
5b5a883528e0 IRCv3: Add the quote command to send raw messages
Gary Kramlich <grim@reaperworld.com>
parents: 43097
diff changeset
254 protocol, G_CONNECT_DEFAULT);
5b5a883528e0 IRCv3: Add the quote command to send raw messages
Gary Kramlich <grim@reaperworld.com>
parents: 43097
diff changeset
255 purple_command_manager_add(manager, command);
43290
01edcfbfebaa IRCv3: Implement the /me command
Gary Kramlich <grim@reaperworld.com>
parents: 43126
diff changeset
256
01edcfbfebaa IRCv3: Implement the /me command
Gary Kramlich <grim@reaperworld.com>
parents: 43126
diff changeset
257 command = purple_command_new("me", "IRCv3", 1000);
01edcfbfebaa IRCv3: Implement the /me command
Gary Kramlich <grim@reaperworld.com>
parents: 43126
diff changeset
258 purple_command_set_summary(command,
01edcfbfebaa IRCv3: Implement the /me command
Gary Kramlich <grim@reaperworld.com>
parents: 43126
diff changeset
259 _("Sends the text to the target as an action"));
01edcfbfebaa IRCv3: Implement the /me command
Gary Kramlich <grim@reaperworld.com>
parents: 43126
diff changeset
260 tags = purple_command_get_tags(command);
01edcfbfebaa IRCv3: Implement the /me command
Gary Kramlich <grim@reaperworld.com>
parents: 43126
diff changeset
261 purple_tags_add(tags, "protocol-id:" PURPLE_IRCV3_PROTOCOL_ID);
01edcfbfebaa IRCv3: Implement the /me command
Gary Kramlich <grim@reaperworld.com>
parents: 43126
diff changeset
262 g_signal_connect_object(command, "executed",
01edcfbfebaa IRCv3: Implement the /me command
Gary Kramlich <grim@reaperworld.com>
parents: 43126
diff changeset
263 G_CALLBACK(purple_ircv3_command_action_cb),
01edcfbfebaa IRCv3: Implement the /me command
Gary Kramlich <grim@reaperworld.com>
parents: 43126
diff changeset
264 protocol, G_CONNECT_DEFAULT);
01edcfbfebaa IRCv3: Implement the /me command
Gary Kramlich <grim@reaperworld.com>
parents: 43126
diff changeset
265 purple_command_manager_add(manager, command);
41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 }
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 static void
41941
355bd17297f0 Set the C standard to C99 and set warning_level to 2 for the IRCv3 Protocol Plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41926
diff changeset
269 purple_ircv3_protocol_class_finalize(G_GNUC_UNUSED PurpleIRCv3ProtocolClass *klass) {
41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 }
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 static void
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 purple_ircv3_protocol_class_init(PurpleIRCv3ProtocolClass *klass) {
43097
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
274 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
41772
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
275 PurpleProtocolClass *protocol_class = PURPLE_PROTOCOL_CLASS(klass);
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
276
43097
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
277 obj_class->finalize = purple_ircv3_protocol_finalize;
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
278
41772
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
279 protocol_class->get_user_splits = purple_ircv3_protocol_get_user_splits;
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
280 protocol_class->get_account_options =
e393090804c1 Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41750
diff changeset
281 purple_ircv3_protocol_get_account_options;
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
282 protocol_class->create_connection =
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
283 purple_ircv3_protocol_create_connection;
42646
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
284 protocol_class->can_connect_async =
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
285 purple_ircv3_protocol_can_connect_async;
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
286 protocol_class->can_connect_finish =
b82b5609c044 Use PurpleProtocol.can_connect_async in the login process
Gary Kramlich <grim@reaperworld.com>
parents: 42568
diff changeset
287 purple_ircv3_protocol_can_connect_finish;
41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 }
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 /******************************************************************************
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 * GObject Implementation
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 *****************************************************************************/
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 void
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 purple_ircv3_protocol_register(GPluginNativePlugin *plugin) {
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 purple_ircv3_protocol_register_type(G_TYPE_MODULE(plugin));
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 }
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 PurpleProtocol *
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 purple_ircv3_protocol_new(void) {
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 return g_object_new(
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 PURPLE_IRCV3_TYPE_PROTOCOL,
43097
757575456cc2 IRCv3: Implement the query command
Gary Kramlich <grim@reaperworld.com>
parents: 43082
diff changeset
302 "id", PURPLE_IRCV3_PROTOCOL_ID,
41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303 "name", "IRCv3",
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 "description", _("Version 3 of Internet Relay Chat (IRC)."),
43028
dda093fe275e IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents: 42879
diff changeset
305 "icon-name", PURPLE_IRCV3_ICON_NAME,
43082
0248f784950d Make protocol resource paths more consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 43028
diff changeset
306 "icon-resource-path", "/im/pidgin/libpurple/protocols/ircv3/icons",
41750
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 "options", OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL |
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 OPT_PROTO_SLASH_COMMANDS_NATIVE,
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 NULL);
7ab7d79ac0c5 Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 }

mercurial