Wed, 19 Jul 2023 23:26:58 -0500
Fix a warn_unused_result in ircv3connection.c
Testing Done:
Compiled and verified the warning was gone.
Reviewed at https://reviews.imfreedom.org/r/2530/
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * This program is free software; you can redistribute it and/or modify |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation; either version 2 of the License, or |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | */ |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | #include <glib/gi18n-lib.h> |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | #include "purpleircv3connection.h" |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include "purpleircv3core.h" |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41793
diff
changeset
|
24 | #include "purpleircv3parser.h" |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | enum { |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | PROP_0, |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | PROP_CANCELLABLE, |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
29 | PROP_CAPABILITIES, |
|
42013
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
30 | PROP_REGISTERED, |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | N_PROPERTIES, |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | }; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | static GParamSpec *properties[N_PROPERTIES] = {NULL, }; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | |
|
41954
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
35 | enum { |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
36 | SIG_REGISTRATION_COMPLETE, |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
37 | N_SIGNALS, |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
38 | }; |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
39 | static guint signals[N_SIGNALS] = {0, }; |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
40 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
41 | typedef struct { |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | GSocketConnection *connection; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | GCancellable *cancellable; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | gchar *server_name; |
|
42013
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
46 | gboolean registered; |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | GDataInputStream *input; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | PurpleQueuedOutputStream *output; |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41793
diff
changeset
|
50 | |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41793
diff
changeset
|
51 | PurpleIRCv3Parser *parser; |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
52 | |
|
41951
00c472cd0fff
Create PurpleIRCv3Capabilities for managing capabilities for each connection
Gary Kramlich <grim@reaperworld.com>
parents:
41941
diff
changeset
|
53 | PurpleIRCv3Capabilities *capabilities; |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
54 | } PurpleIRCv3ConnectionPrivate; |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
56 | G_DEFINE_DYNAMIC_TYPE_EXTENDED(PurpleIRCv3Connection, |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
57 | purple_ircv3_connection, |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
58 | PURPLE_TYPE_CONNECTION, |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
59 | 0, |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
60 | G_ADD_PRIVATE_DYNAMIC(PurpleIRCv3Connection)) |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | /****************************************************************************** |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | * Helpers |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | *****************************************************************************/ |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | static void |
|
41955
d3117aac63b3
Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41954
diff
changeset
|
66 | purple_ircv3_connection_send_pass_command(PurpleIRCv3Connection *connection) { |
|
d3117aac63b3
Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41954
diff
changeset
|
67 | PurpleAccount *account = NULL; |
|
d3117aac63b3
Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41954
diff
changeset
|
68 | const char *password = NULL; |
|
d3117aac63b3
Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41954
diff
changeset
|
69 | |
|
d3117aac63b3
Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41954
diff
changeset
|
70 | account = purple_connection_get_account(PURPLE_CONNECTION(connection)); |
|
d3117aac63b3
Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41954
diff
changeset
|
71 | |
|
d3117aac63b3
Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41954
diff
changeset
|
72 | password = purple_account_get_string(account, "server-password", ""); |
|
d3117aac63b3
Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41954
diff
changeset
|
73 | if(password != NULL && *password != '\0') { |
|
d3117aac63b3
Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41954
diff
changeset
|
74 | purple_ircv3_connection_writef(connection, "PASS %s", password); |
|
d3117aac63b3
Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41954
diff
changeset
|
75 | } |
|
d3117aac63b3
Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41954
diff
changeset
|
76 | } |
|
d3117aac63b3
Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41954
diff
changeset
|
77 | |
|
d3117aac63b3
Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41954
diff
changeset
|
78 | static void |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
79 | purple_ircv3_connection_send_user_command(PurpleIRCv3Connection *connection) { |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
80 | PurpleAccount *account = NULL; |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
81 | const char *identname = NULL; |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
82 | const char *nickname = NULL; |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
83 | const char *realname = NULL; |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
84 | |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
85 | nickname = |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
86 | purple_connection_get_display_name(PURPLE_CONNECTION(connection)); |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
87 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
88 | account = purple_connection_get_account(PURPLE_CONNECTION(connection)); |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
89 | |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
90 | /* The stored value could be an empty string, so pass a default of empty |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
91 | * string and then if it was empty, set our correct fallback. |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
92 | */ |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
93 | identname = purple_account_get_string(account, "ident", ""); |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
94 | if(identname == NULL || *identname == '\0') { |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
95 | identname = nickname; |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
96 | } |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
97 | |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
98 | realname = purple_account_get_string(account, "real-name", ""); |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
99 | if(realname == NULL || *realname == '\0') { |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
100 | realname = nickname; |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
101 | } |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
102 | |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
103 | purple_ircv3_connection_writef(connection, "USER %s 0 * :%s", identname, |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
104 | realname); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
105 | } |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
106 | |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
107 | static void |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
108 | purple_ircv3_connection_send_nick_command(PurpleIRCv3Connection *connection) { |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
109 | const char *nickname = NULL; |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
110 | |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
111 | nickname = |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
112 | purple_connection_get_display_name(PURPLE_CONNECTION(connection)); |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
113 | |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
114 | purple_ircv3_connection_writef(connection, "NICK %s", nickname); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
115 | } |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
116 | |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | /****************************************************************************** |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | * Callbacks |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | *****************************************************************************/ |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | static void |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | purple_ircv3_connection_read_cb(GObject *source, GAsyncResult *result, |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | gpointer data) |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | { |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
124 | PurpleIRCv3Connection *connection = data; |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
125 | PurpleIRCv3ConnectionPrivate *priv = NULL; |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | GDataInputStream *istream = G_DATA_INPUT_STREAM(source); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | GError *error = NULL; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | gchar *line = NULL; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | gsize length; |
|
41951
00c472cd0fff
Create PurpleIRCv3Capabilities for managing capabilities for each connection
Gary Kramlich <grim@reaperworld.com>
parents:
41941
diff
changeset
|
130 | gboolean parsed = FALSE; |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | line = g_data_input_stream_read_line_finish(istream, result, &length, |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | &error); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
134 | if(line == NULL || error != NULL) { |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
135 | if(PURPLE_IS_CONNECTION(connection)) { |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
136 | if(error == NULL) { |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
137 | g_set_error_literal(&error, PURPLE_CONNECTION_ERROR, |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
138 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
139 | _("Server closed the connection")); |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
140 | } else { |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
141 | g_prefix_error(&error, "%s", _("Lost connection with server: ")); |
|
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 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
144 | purple_connection_take_error(PURPLE_CONNECTION(connection), error); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | /* In the off chance that line was returned, make sure we free it. */ |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | g_free(line); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
150 | return; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
153 | priv = purple_ircv3_connection_get_instance_private(connection); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
154 | |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
155 | parsed = purple_ircv3_parser_parse(priv->parser, line, &error, |
|
41951
00c472cd0fff
Create PurpleIRCv3Capabilities for managing capabilities for each connection
Gary Kramlich <grim@reaperworld.com>
parents:
41941
diff
changeset
|
156 | connection); |
|
00c472cd0fff
Create PurpleIRCv3Capabilities for managing capabilities for each connection
Gary Kramlich <grim@reaperworld.com>
parents:
41941
diff
changeset
|
157 | if(!parsed) { |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
42013
diff
changeset
|
158 | g_warning("failed to handle '%s': %s", line, |
|
41951
00c472cd0fff
Create PurpleIRCv3Capabilities for managing capabilities for each connection
Gary Kramlich <grim@reaperworld.com>
parents:
41941
diff
changeset
|
159 | error != NULL ? error->message : "unknown error"); |
|
00c472cd0fff
Create PurpleIRCv3Capabilities for managing capabilities for each connection
Gary Kramlich <grim@reaperworld.com>
parents:
41941
diff
changeset
|
160 | } |
|
00c472cd0fff
Create PurpleIRCv3Capabilities for managing capabilities for each connection
Gary Kramlich <grim@reaperworld.com>
parents:
41941
diff
changeset
|
161 | g_clear_error(&error); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | g_free(line); |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41793
diff
changeset
|
164 | |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41793
diff
changeset
|
165 | /* Call read_line_async again to continue reading lines. */ |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
166 | g_data_input_stream_read_line_async(priv->input, |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41793
diff
changeset
|
167 | G_PRIORITY_DEFAULT, |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
168 | priv->cancellable, |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41793
diff
changeset
|
169 | purple_ircv3_connection_read_cb, |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
170 | connection); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
172 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
173 | static void |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
174 | purple_ircv3_connection_write_cb(GObject *source, GAsyncResult *result, |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
175 | gpointer data) |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
176 | { |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
177 | PurpleIRCv3Connection *connection = data; |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
178 | PurpleQueuedOutputStream *stream = PURPLE_QUEUED_OUTPUT_STREAM(source); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
179 | GError *error = NULL; |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
180 | gboolean success = FALSE; |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
181 | |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
182 | success = purple_queued_output_stream_push_bytes_finish(stream, result, |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
183 | &error); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
184 | |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
185 | if(!success) { |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
186 | purple_queued_output_stream_clear_queue(stream); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
187 | |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
188 | g_prefix_error(&error, "%s", _("Lost connection with server: ")); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
189 | |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
190 | purple_connection_take_error(PURPLE_CONNECTION(connection), error); |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
191 | |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
192 | return; |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
193 | } |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
194 | } |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
195 | |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
196 | static void |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | purple_ircv3_connection_connected_cb(GObject *source, GAsyncResult *result, |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | gpointer data) |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | { |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
200 | PurpleIRCv3Connection *connection = data; |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
201 | PurpleIRCv3ConnectionPrivate *priv = NULL; |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | GError *error = NULL; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
203 | GInputStream *istream = NULL; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | GOutputStream *ostream = NULL; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | GSocketClient *client = G_SOCKET_CLIENT(source); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | GSocketConnection *conn = NULL; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
207 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
208 | priv = purple_ircv3_connection_get_instance_private(connection); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
209 | |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
210 | /* Finish the async method. */ |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | conn = g_socket_client_connect_to_host_finish(client, result, &error); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
212 | if(conn == NULL || error != NULL) { |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | g_prefix_error(&error, "%s", _("Unable to connect: ")); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
214 | |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
215 | purple_connection_take_error(PURPLE_CONNECTION(connection), error); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
216 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | return; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
218 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
219 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
220 | g_message("Successfully connected to %s", priv->server_name); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
221 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
222 | /* Save our connection and setup our input and outputs. */ |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
223 | priv->connection = conn; |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
224 | |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41793
diff
changeset
|
225 | /* Create our parser. */ |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
226 | priv->parser = purple_ircv3_parser_new(); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
227 | purple_ircv3_parser_add_default_handlers(priv->parser); |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41793
diff
changeset
|
228 | |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
229 | ostream = g_io_stream_get_output_stream(G_IO_STREAM(conn)); |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
230 | priv->output = purple_queued_output_stream_new(ostream); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
231 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | istream = g_io_stream_get_input_stream(G_IO_STREAM(conn)); |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
233 | priv->input = g_data_input_stream_new(istream); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
234 | g_data_input_stream_set_newline_type(G_DATA_INPUT_STREAM(priv->input), |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41793
diff
changeset
|
235 | G_DATA_STREAM_NEWLINE_TYPE_CR_LF); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | /* Add our read callback. */ |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
238 | g_data_input_stream_read_line_async(priv->input, |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | G_PRIORITY_DEFAULT, |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
240 | priv->cancellable, |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
241 | purple_ircv3_connection_read_cb, |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
242 | connection); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
243 | |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
244 | /* Send our registration commands. */ |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
245 | purple_ircv3_capabilities_start(priv->capabilities); |
|
41955
d3117aac63b3
Add support for server passwords to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41954
diff
changeset
|
246 | purple_ircv3_connection_send_pass_command(connection); |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
247 | purple_ircv3_connection_send_user_command(connection); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
248 | purple_ircv3_connection_send_nick_command(connection); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
249 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
250 | |
|
41954
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
251 | static void |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
252 | purple_ircv3_connection_caps_done_cb(G_GNUC_UNUSED PurpleIRCv3Capabilities *caps, |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
253 | gpointer data) |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
254 | { |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
255 | PurpleIRCv3Connection *connection = data; |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
256 | PurpleIRCv3ConnectionPrivate *priv = NULL; |
|
41954
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
257 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
258 | priv = purple_ircv3_connection_get_instance_private(connection); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
259 | |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
260 | priv->registered = TRUE; |
|
42013
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
261 | |
|
41954
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
262 | g_signal_emit(connection, signals[SIG_REGISTRATION_COMPLETE], 0); |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
263 | } |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
264 | |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
265 | /****************************************************************************** |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
266 | * PurpleConnection Implementation |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
267 | *****************************************************************************/ |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
268 | static gboolean |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
269 | purple_ircv3_connection_connect(PurpleConnection *purple_connection, |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
270 | GError **error) |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
271 | { |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
272 | PurpleIRCv3Connection *connection = NULL; |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
273 | PurpleIRCv3ConnectionPrivate *priv = NULL; |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
274 | PurpleAccount *account = NULL; |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
275 | GSocketClient *client = NULL; |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
276 | gint default_port = PURPLE_IRCV3_DEFAULT_TLS_PORT; |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
277 | gint port = 0; |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
278 | gboolean use_tls = TRUE; |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
279 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
280 | g_return_val_if_fail(PURPLE_IRCV3_IS_CONNECTION(purple_connection), FALSE); |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
281 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
282 | connection = PURPLE_IRCV3_CONNECTION(purple_connection); |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
283 | priv = purple_ircv3_connection_get_instance_private(connection); |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
284 | account = purple_connection_get_account(purple_connection); |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
285 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
286 | client = purple_gio_socket_client_new(account, error); |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
287 | if(!G_IS_SOCKET_CLIENT(client)) { |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
288 | if(error != NULL && *error != NULL) { |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
289 | purple_connection_take_error(purple_connection, *error); |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
290 | } |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
291 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
292 | return FALSE; |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
293 | } |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
294 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
295 | /* Turn on TLS if requested. */ |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
296 | use_tls = purple_account_get_bool(account, "use-tls", TRUE); |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
297 | g_socket_client_set_tls(client, use_tls); |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
298 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
299 | /* If TLS is not being used, set the default port to the plain port. */ |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
300 | if(!use_tls) { |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
301 | default_port = PURPLE_IRCV3_DEFAULT_PLAIN_PORT; |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
302 | } |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
303 | port = purple_account_get_int(account, "port", default_port); |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
304 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
305 | /* Finally start the async connection. */ |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
306 | g_socket_client_connect_to_host_async(client, priv->server_name, |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
307 | port, priv->cancellable, |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
308 | purple_ircv3_connection_connected_cb, |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
309 | connection); |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
310 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
311 | g_clear_object(&client); |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
312 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
313 | return TRUE; |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
314 | } |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
315 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
316 | static gboolean |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
317 | purple_ircv3_connection_disconnect(PurpleConnection *purple_connection, |
|
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:
41870
diff
changeset
|
318 | G_GNUC_UNUSED GError **error) |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
319 | { |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
320 | PurpleIRCv3Connection *connection = NULL; |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
321 | PurpleIRCv3ConnectionPrivate *priv = NULL; |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
322 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
323 | g_return_val_if_fail(PURPLE_IRCV3_IS_CONNECTION(purple_connection), FALSE); |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
324 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
325 | connection = PURPLE_IRCV3_CONNECTION(purple_connection); |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
326 | priv = purple_ircv3_connection_get_instance_private(connection); |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
327 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
328 | /* TODO: send QUIT command. */ |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
329 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
330 | /* Cancel the cancellable to tell everyone we're shutting down. */ |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
331 | if(G_IS_CANCELLABLE(priv->cancellable)) { |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
332 | g_cancellable_cancel(priv->cancellable); |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
333 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
334 | g_clear_object(&priv->cancellable); |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
335 | } |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
336 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
337 | if(G_IS_SOCKET_CONNECTION(priv->connection)) { |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
338 | GInputStream *istream = G_INPUT_STREAM(priv->input); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
339 | GOutputStream *ostream = G_OUTPUT_STREAM(priv->output); |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
340 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
341 | purple_gio_graceful_close(G_IO_STREAM(priv->connection), |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
342 | istream, ostream); |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
343 | } |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
344 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
345 | g_clear_object(&priv->input); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
346 | g_clear_object(&priv->output); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
347 | g_clear_object(&priv->connection); |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
348 | |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
349 | return TRUE; |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
350 | } |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
351 | |
|
41954
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
352 | static void |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
353 | purple_ircv3_connection_registration_complete_cb(PurpleIRCv3Connection *connection) { |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
354 | /* Don't set our connection state to connected until we've completed |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
355 | * registration as connected implies that we can start chatting or join |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
356 | * rooms and other "online" activities. |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
357 | */ |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
358 | purple_connection_set_state(PURPLE_CONNECTION(connection), |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
359 | PURPLE_CONNECTION_STATE_CONNECTED); |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
360 | } |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
361 | |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
362 | /****************************************************************************** |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
363 | * GObject Implementation |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
364 | *****************************************************************************/ |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
365 | static void |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
366 | purple_ircv3_connection_get_property(GObject *obj, guint param_id, |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
367 | GValue *value, GParamSpec *pspec) |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
368 | { |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
369 | PurpleIRCv3Connection *connection = PURPLE_IRCV3_CONNECTION(obj); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
370 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
371 | switch(param_id) { |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
372 | case PROP_CANCELLABLE: |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
373 | g_value_set_object(value, |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
374 | purple_ircv3_connection_get_cancellable(connection)); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
375 | break; |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
376 | case PROP_CAPABILITIES: |
|
41951
00c472cd0fff
Create PurpleIRCv3Capabilities for managing capabilities for each connection
Gary Kramlich <grim@reaperworld.com>
parents:
41941
diff
changeset
|
377 | g_value_set_object(value, |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
378 | purple_ircv3_connection_get_capabilities(connection)); |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
379 | break; |
|
42013
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
380 | case PROP_REGISTERED: |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
381 | g_value_set_boolean(value, |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
382 | purple_ircv3_connection_get_registered(connection)); |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
383 | break; |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
384 | default: |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
385 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
386 | break; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
387 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
388 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
389 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
390 | static void |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
391 | purple_ircv3_connection_dispose(GObject *obj) { |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
392 | PurpleIRCv3Connection *connection = PURPLE_IRCV3_CONNECTION(obj); |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
393 | PurpleIRCv3ConnectionPrivate *priv = NULL; |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
394 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
395 | priv = purple_ircv3_connection_get_instance_private(connection); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
396 | |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
397 | g_clear_object(&priv->cancellable); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
398 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
399 | g_clear_object(&priv->input); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
400 | g_clear_object(&priv->output); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
401 | g_clear_object(&priv->connection); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
402 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
403 | g_clear_object(&priv->capabilities); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
404 | g_clear_object(&priv->parser); |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41793
diff
changeset
|
405 | |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
406 | G_OBJECT_CLASS(purple_ircv3_connection_parent_class)->dispose(obj); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
407 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
408 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
409 | static void |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
410 | purple_ircv3_connection_finalize(GObject *obj) { |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
411 | PurpleIRCv3Connection *connection = PURPLE_IRCV3_CONNECTION(obj); |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
412 | PurpleIRCv3ConnectionPrivate *priv = NULL; |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
413 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
414 | priv = purple_ircv3_connection_get_instance_private(connection); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
415 | |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
416 | g_clear_pointer(&priv->server_name, g_free); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
417 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
418 | G_OBJECT_CLASS(purple_ircv3_connection_parent_class)->finalize(obj); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
419 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
420 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
421 | static void |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
422 | purple_ircv3_connection_constructed(GObject *obj) { |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
423 | PurpleIRCv3Connection *connection = PURPLE_IRCV3_CONNECTION(obj); |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
424 | PurpleIRCv3ConnectionPrivate *priv = NULL; |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
425 | PurpleAccount *account = NULL; |
|
42133
e9a794bfe183
IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents:
42030
diff
changeset
|
426 | char **userparts = NULL; |
|
e9a794bfe183
IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents:
42030
diff
changeset
|
427 | const char *sasl_name = NULL; |
|
e9a794bfe183
IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents:
42030
diff
changeset
|
428 | const char *username = NULL; |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
429 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
430 | G_OBJECT_CLASS(purple_ircv3_connection_parent_class)->constructed(obj); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
431 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
432 | priv = purple_ircv3_connection_get_instance_private(connection); |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
433 | account = purple_connection_get_account(PURPLE_CONNECTION(connection)); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
434 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
435 | /* Split the username into nick and server and store the values. */ |
|
41977
bade7303795a
Update all protocol except gg and xmpp for the account api deprecations
Gary Kramlich <grim@reaperworld.com>
parents:
41955
diff
changeset
|
436 | username = purple_contact_info_get_username(PURPLE_CONTACT_INFO(account)); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
437 | userparts = g_strsplit(username, "@", 2); |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
438 | purple_connection_set_display_name(PURPLE_CONNECTION(connection), |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
439 | userparts[0]); |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
440 | priv->server_name = g_strdup(userparts[1]); |
|
42133
e9a794bfe183
IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents:
42030
diff
changeset
|
441 | |
|
e9a794bfe183
IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents:
42030
diff
changeset
|
442 | /* Check if the SASL login name is not set. If it isn't set, set it to the |
|
e9a794bfe183
IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents:
42030
diff
changeset
|
443 | * current nick. |
|
e9a794bfe183
IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents:
42030
diff
changeset
|
444 | */ |
|
e9a794bfe183
IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents:
42030
diff
changeset
|
445 | sasl_name = purple_account_get_string(account, "sasl-login-name", ""); |
|
e9a794bfe183
IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents:
42030
diff
changeset
|
446 | if(purple_strempty(sasl_name)) { |
|
e9a794bfe183
IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents:
42030
diff
changeset
|
447 | purple_account_set_string(account, "sasl-login-name", userparts[0]); |
|
e9a794bfe183
IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents:
42030
diff
changeset
|
448 | } |
|
e9a794bfe183
IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents:
42030
diff
changeset
|
449 | |
|
e9a794bfe183
IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents:
42030
diff
changeset
|
450 | /* Free the userparts vector. */ |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
451 | g_strfreev(userparts); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
452 | |
|
41951
00c472cd0fff
Create PurpleIRCv3Capabilities for managing capabilities for each connection
Gary Kramlich <grim@reaperworld.com>
parents:
41941
diff
changeset
|
453 | /* Finally create our objects. */ |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
454 | priv->cancellable = g_cancellable_new(); |
|
41954
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
455 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
456 | priv->capabilities = purple_ircv3_capabilities_new(connection); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
457 | g_signal_connect_object(priv->capabilities, "done", |
|
41954
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
458 | G_CALLBACK(purple_ircv3_connection_caps_done_cb), |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
459 | connection, 0); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
460 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
461 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
462 | 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:
41870
diff
changeset
|
463 | purple_ircv3_connection_init(G_GNUC_UNUSED PurpleIRCv3Connection *connection) { |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
464 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
465 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
466 | 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:
41870
diff
changeset
|
467 | purple_ircv3_connection_class_finalize(G_GNUC_UNUSED PurpleIRCv3ConnectionClass *klass) { |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
468 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
469 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
470 | static void |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
471 | purple_ircv3_connection_class_init(PurpleIRCv3ConnectionClass *klass) { |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
472 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
473 | PurpleConnectionClass *connection_class = PURPLE_CONNECTION_CLASS(klass); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
474 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
475 | obj_class->get_property = purple_ircv3_connection_get_property; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
476 | obj_class->constructed = purple_ircv3_connection_constructed; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
477 | obj_class->dispose = purple_ircv3_connection_dispose; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
478 | obj_class->finalize = purple_ircv3_connection_finalize; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
479 | |
|
41870
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
480 | connection_class->connect = purple_ircv3_connection_connect; |
|
7668d023ae05
Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents:
41814
diff
changeset
|
481 | connection_class->disconnect = purple_ircv3_connection_disconnect; |
|
41814
f8940ebd4eee
Back out the PurpleProtocol->login change that returned a PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents:
41812
diff
changeset
|
482 | |
|
f8940ebd4eee
Back out the PurpleProtocol->login change that returned a PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents:
41812
diff
changeset
|
483 | /** |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
484 | * PurpleIRCv3Connection:cancellable: |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
485 | * |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
486 | * The [class@Gio.Cancellable] for this connection. |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
487 | * |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
488 | * Since: 3.0.0 |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
489 | */ |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
490 | properties[PROP_CANCELLABLE] = g_param_spec_object( |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
491 | "cancellable", "cancellable", |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
492 | "The cancellable for this connection", |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
493 | G_TYPE_CANCELLABLE, |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
494 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
495 | |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
496 | /** |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
497 | * PurpleIRCv3Connection:capabilities: |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
498 | * |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
499 | * The capabilities that the server supports. |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
500 | * |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
501 | * This is created during registration of the connection and is useful for |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
502 | * troubleshooting or just reporting them to end users. |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
503 | * |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
504 | * Since: 3.0.0 |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
505 | */ |
|
41951
00c472cd0fff
Create PurpleIRCv3Capabilities for managing capabilities for each connection
Gary Kramlich <grim@reaperworld.com>
parents:
41941
diff
changeset
|
506 | properties[PROP_CAPABILITIES] = g_param_spec_object( |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
507 | "capabilities", "capabilities", |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
508 | "The capabilities that the server supports", |
|
41951
00c472cd0fff
Create PurpleIRCv3Capabilities for managing capabilities for each connection
Gary Kramlich <grim@reaperworld.com>
parents:
41941
diff
changeset
|
509 | PURPLE_IRCV3_TYPE_CAPABILITIES, |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
510 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
511 | |
|
42013
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
512 | /** |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
513 | * PurpleIRCv3Connection:registered: |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
514 | * |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
515 | * Whether or not the connection has finished the registration portion of |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
516 | * the connection. |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
517 | * |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
518 | * Since: 3.0.0 |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
519 | */ |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
520 | properties[PROP_REGISTERED] = g_param_spec_boolean( |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
521 | "registered", "registered", |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
522 | "Whether or not the connection has finished registration.", |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
523 | FALSE, |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
524 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
525 | |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
526 | g_object_class_install_properties(obj_class, N_PROPERTIES, properties); |
|
41954
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
527 | |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
528 | /* Signals */ |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
529 | |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
530 | /** |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
531 | * PurpleIRCv3Connection::registration-complete: |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
532 | * @connection: The instance. |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
533 | * |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
534 | * This signal is emitted after the registration process has been |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
535 | * completed. Plugins can use this to perform additional actions before |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
536 | * any channels are auto joined or similar. |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
537 | * |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
538 | * Since: 3.0.0 |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
539 | */ |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
540 | signals[SIG_REGISTRATION_COMPLETE] = g_signal_new_class_handler( |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
541 | "registration-complete", |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
542 | G_OBJECT_CLASS_TYPE(klass), |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
543 | G_SIGNAL_RUN_LAST, |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
544 | G_CALLBACK(purple_ircv3_connection_registration_complete_cb), |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
545 | NULL, |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
546 | NULL, |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
547 | NULL, |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
548 | G_TYPE_NONE, |
|
558106ebf999
Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
549 | 0); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
550 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
551 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
552 | /****************************************************************************** |
|
42000
0b26ebc842db
Make purple_ircv3_connection_writef public
Gary Kramlich <grim@reaperworld.com>
parents:
41977
diff
changeset
|
553 | * Internal API |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
554 | *****************************************************************************/ |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
555 | void |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
556 | purple_ircv3_connection_register(GPluginNativePlugin *plugin) { |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
557 | purple_ircv3_connection_register_type(G_TYPE_MODULE(plugin)); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
558 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
559 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
560 | GCancellable * |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
561 | purple_ircv3_connection_get_cancellable(PurpleIRCv3Connection *connection) { |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
562 | PurpleIRCv3ConnectionPrivate *priv = NULL; |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
563 | |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
564 | g_return_val_if_fail(PURPLE_IRCV3_IS_CONNECTION(connection), NULL); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
565 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
566 | priv = purple_ircv3_connection_get_instance_private(connection); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
567 | |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
568 | return priv->cancellable; |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
569 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
570 | |
|
42000
0b26ebc842db
Make purple_ircv3_connection_writef public
Gary Kramlich <grim@reaperworld.com>
parents:
41977
diff
changeset
|
571 | /****************************************************************************** |
|
0b26ebc842db
Make purple_ircv3_connection_writef public
Gary Kramlich <grim@reaperworld.com>
parents:
41977
diff
changeset
|
572 | * Public API |
|
0b26ebc842db
Make purple_ircv3_connection_writef public
Gary Kramlich <grim@reaperworld.com>
parents:
41977
diff
changeset
|
573 | *****************************************************************************/ |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
574 | void |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
575 | purple_ircv3_connection_writef(PurpleIRCv3Connection *connection, |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
576 | const char *format, ...) |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
577 | { |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
578 | PurpleIRCv3ConnectionPrivate *priv = NULL; |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
579 | GBytes *bytes = NULL; |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
580 | GString *msg = NULL; |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
581 | va_list vargs; |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
582 | |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
583 | g_return_if_fail(PURPLE_IRCV3_IS_CONNECTION(connection)); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
584 | g_return_if_fail(format != NULL); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
585 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
586 | priv = purple_ircv3_connection_get_instance_private(connection); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
587 | |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
588 | /* Create our string and append our format to it. */ |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
589 | msg = g_string_new(""); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
590 | |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
591 | va_start(vargs, format); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
592 | g_string_vprintf(msg, format, vargs); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
593 | va_end(vargs); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
594 | |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
595 | /* Next add the trailing carriage return line feed. */ |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
596 | g_string_append(msg, "\r\n"); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
597 | |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
598 | /* Finally turn the string into bytes and send it! */ |
|
42250
c2c0eb8398da
Fix a warn_unused_result in ircv3connection.c
Gary Kramlich <grim@reaperworld.com>
parents:
42133
diff
changeset
|
599 | bytes = g_string_free_to_bytes(msg); |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
600 | purple_queued_output_stream_push_bytes_async(priv->output, bytes, |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
601 | G_PRIORITY_DEFAULT, |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
602 | priv->cancellable, |
|
41793
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
603 | purple_ircv3_connection_write_cb, |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
604 | connection); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
605 | |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
606 | g_bytes_unref(bytes); |
|
2e6f09066f94
Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
607 | } |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
608 | |
|
41951
00c472cd0fff
Create PurpleIRCv3Capabilities for managing capabilities for each connection
Gary Kramlich <grim@reaperworld.com>
parents:
41941
diff
changeset
|
609 | PurpleIRCv3Capabilities * |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
610 | purple_ircv3_connection_get_capabilities(PurpleIRCv3Connection *connection) { |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
611 | PurpleIRCv3ConnectionPrivate *priv = NULL; |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
612 | |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
613 | g_return_val_if_fail(PURPLE_IRCV3_IS_CONNECTION(connection), NULL); |
|
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
614 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
615 | priv = purple_ircv3_connection_get_instance_private(connection); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
616 | |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
617 | return priv->capabilities; |
|
41807
66d473190e94
Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41805
diff
changeset
|
618 | } |
|
42013
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
619 | |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
620 | gboolean |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
621 | purple_ircv3_connection_get_registered(PurpleIRCv3Connection *connection) { |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
622 | PurpleIRCv3ConnectionPrivate *priv = NULL; |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
623 | |
|
42013
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
624 | g_return_val_if_fail(PURPLE_IRCV3_IS_CONNECTION(connection), FALSE); |
|
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
625 | |
|
42030
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
626 | priv = purple_ircv3_connection_get_instance_private(connection); |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
627 | |
|
7af8ab97086d
Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
628 | return priv->registered; |
|
42013
5634642aca06
Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents:
42000
diff
changeset
|
629 | } |