Tue, 23 Jan 2024 01:06:07 -0600
Define all final types as such for protocols
Testing Done:
Ran with the turtles.
Reviewed at https://reviews.imfreedom.org/r/2931/
|
42546
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * This program is free software; you can redistribute it and/or modify |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation; either version 2 of the License, or |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | */ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | #include <glib/gi18n-lib.h> |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | #include <xeme.h> |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include "purplexmppconnection.h" |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | #include "purplexmppconstants.h" |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | #include "purplexmppcore.h" |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | struct _PurpleXmppConnection { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | PurpleConnection parent; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | XemeConnection *xeme_connection; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | XemeOutputStream *output; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | }; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | |
|
42579
f1ce6abbf4d1
Define all final types as such for protocols
Gary Kramlich <grim@reaperworld.com>
parents:
42546
diff
changeset
|
35 | G_DEFINE_DYNAMIC_TYPE_EXTENDED(PurpleXmppConnection, purple_xmpp_connection, |
|
f1ce6abbf4d1
Define all final types as such for protocols
Gary Kramlich <grim@reaperworld.com>
parents:
42546
diff
changeset
|
36 | PURPLE_TYPE_CONNECTION, G_TYPE_FLAG_FINAL, {}) |
|
42546
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | /****************************************************************************** |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | * Callbacks |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | *****************************************************************************/ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | static void |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | purple_xmpp_connection_connect_cb(GObject *source, GAsyncResult *result, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | gpointer data) |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | PurpleXmppConnection *connection = data; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | XemeOutputStream *output = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | GError *error = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | output = xeme_connection_connect_finish(XEME_CONNECTION(source), result, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | &error); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | if(error != NULL) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | purple_connection_take_error(PURPLE_CONNECTION(connection), error); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | return; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | connection->output = output; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | purple_connection_set_state(PURPLE_CONNECTION(connection), |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | PURPLE_CONNECTION_STATE_CONNECTED); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | /****************************************************************************** |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | * PurpleConnection Implementation |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | *****************************************************************************/ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | static gboolean |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | purple_xmpp_connection_connect(PurpleConnection *purple_connection, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | GError **error) |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | PurpleXmppConnection *connection = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | PurpleAccount *account = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | XemeInputStream *input = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | XemeTlsMode xeme_tls_mode = XEME_TLS_MODE_DIRECT_TLS; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | GCancellable *cancellable = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | GError *local_error = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | GProxyResolver *resolver = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | const char *resource = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | const char *server = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | const char *tls_mode = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | const char *username = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | guint16 port = PURPLE_XMPP_DEFAULT_PORT_TLS; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | g_return_val_if_fail(PURPLE_XMPP_IS_CONNECTION(purple_connection), FALSE); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | purple_connection_set_state(purple_connection, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | PURPLE_CONNECTION_STATE_CONNECTING); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | connection = PURPLE_XMPP_CONNECTION(purple_connection); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | cancellable = purple_connection_get_cancellable(purple_connection); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | account = purple_connection_get_account(purple_connection); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | /* Figure out what proxy resolver to use. */ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | resolver = purple_proxy_get_proxy_resolver(account, &local_error); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | if(!G_IS_PROXY_RESOLVER(resolver) || local_error != NULL) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | if(local_error == NULL) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | local_error = g_error_new(PURPLE_XMPP_DOMAIN, 0, "unknown error"); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | g_propagate_error(error, local_error); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | g_clear_object(&resolver); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | return FALSE; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | /* Grab some more information that we need. */ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | username = purple_contact_info_get_username(PURPLE_CONTACT_INFO(account)); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | connection->xeme_connection = xeme_connection_new(username); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | /* If we have a resource, tell the xeme connection about it. */ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | resource = purple_account_get_string(account, PURPLE_XMPP_OPTION_RESOURCE, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | NULL); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | if(!purple_strempty(resource)) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | xeme_connection_set_resource(connection->xeme_connection, resource); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | /* If we have a server, tell the xeme connection about it. */ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | server = purple_account_get_string(account, PURPLE_XMPP_OPTION_SERVER, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | NULL); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | if(!purple_strempty(server)) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | xeme_connection_set_server(connection->xeme_connection, server); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | /* Set whatever port we have on our xeme connection. */ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | port = purple_account_get_int(account, PURPLE_XMPP_OPTION_PORT, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | PURPLE_XMPP_DEFAULT_PORT_TLS); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | xeme_connection_set_port(connection->xeme_connection, port); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | /* Figure out what if any TLS we're doing. This is initialized to direct |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | * tls above, so if we don't know which to use, that's what we'll end up |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | * using. Doing so should avoid possible accidental leaks. |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | */ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | tls_mode = purple_account_get_string(account, PURPLE_XMPP_OPTION_TLS_MODE, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
134 | PURPLE_XMPP_TLS_DIRECT); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | if(purple_strequal(tls_mode, PURPLE_XMPP_TLS_DIRECT)) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | xeme_tls_mode = XEME_TLS_MODE_DIRECT_TLS; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | } else if(purple_strequal(tls_mode, PURPLE_XMPP_TLS_STARTTLS)) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | xeme_tls_mode = XEME_TLS_MODE_START_TLS; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | } else if(purple_strequal(tls_mode, PURPLE_XMPP_TLS_NONE)) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | xeme_tls_mode = XEME_TLS_MODE_NONE; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | xeme_connection_set_tls_mode(connection->xeme_connection, xeme_tls_mode); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | input = xeme_input_stream_new(); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | /* Finally start connecting!! */ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | xeme_connection_connect_async(connection->xeme_connection, input, resolver, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | cancellable, purple_xmpp_connection_connect_cb, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
150 | connection); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | g_clear_object(&input); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
153 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | return TRUE; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
155 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | static gboolean |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | purple_xmpp_connection_disconnect(PurpleConnection *purple_connection, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | GError **error) |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | PurpleXmppConnection *connection = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | PurpleConnectionClass *parent_class = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | g_return_val_if_fail(PURPLE_XMPP_IS_CONNECTION(purple_connection), FALSE); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | connection = PURPLE_XMPP_CONNECTION(purple_connection); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | /* Chain up to our parent's disconnect method. */ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
169 | parent_class = PURPLE_CONNECTION_CLASS(purple_xmpp_connection_parent_class); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | parent_class->disconnect(purple_connection, error); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
172 | return xeme_connection_close(connection->xeme_connection, error); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
173 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
174 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
175 | /****************************************************************************** |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | * GObject Implementation |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
177 | *****************************************************************************/ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | static void |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
179 | purple_xmpp_connection_dispose(GObject *obj) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | PurpleXmppConnection *connection = PURPLE_XMPP_CONNECTION(obj); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | g_clear_object(&connection->xeme_connection); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
183 | g_clear_object(&connection->output); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
184 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
185 | G_OBJECT_CLASS(purple_xmpp_connection_parent_class)->dispose(obj); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
186 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | static void |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | purple_xmpp_connection_init(G_GNUC_UNUSED PurpleXmppConnection *connection) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
191 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | static void |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | purple_xmpp_connection_class_init(PurpleXmppConnectionClass *klass) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | PurpleConnectionClass *connection_class = PURPLE_CONNECTION_CLASS(klass); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | obj_class->dispose = purple_xmpp_connection_dispose; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | connection_class->connect = purple_xmpp_connection_connect; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | connection_class->disconnect = purple_xmpp_connection_disconnect; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
203 | static void |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | purple_xmpp_connection_class_finalize(G_GNUC_UNUSED PurpleXmppConnectionClass *klass) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
207 | /****************************************************************************** |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
208 | * Internal API |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
209 | *****************************************************************************/ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
210 | void |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | purple_xmpp_connection_register(GPluginNativePlugin *plugin) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
212 | purple_xmpp_connection_register_type(G_TYPE_MODULE(plugin)); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | } |