protocols/xmpp/purplexmppconnection.c

Fri, 04 Oct 2024 01:08:05 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 04 Oct 2024 01:08:05 -0500
changeset 42998
9fae31173eb3
parent 42803
984f8dfabb47
child 43002
1fc2409c8bd2
permissions
-rw-r--r--

Remove Purple.Connection.error and its friends

This change means you need to call Purple.Account.set_error followed by
Purple.Account.disconnect. This will probably be cleaned up a bit in the future
but for now this lets us clean up a lot of old API.

Testing Done:
Connected demo and irc accounts. Verified that disconnects worked via the demo actions. Call in the turtles.

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

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) {
42998
9fae31173eb3 Remove Purple.Connection.error and its friends
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
52 PurpleAccount *account = NULL;
9fae31173eb3 Remove Purple.Connection.error and its friends
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
53 PurpleConnectionErrorInfo *error_info = NULL;
9fae31173eb3 Remove Purple.Connection.error and its friends
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
54
9fae31173eb3 Remove Purple.Connection.error and its friends
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
55 account = purple_connection_get_account(PURPLE_CONNECTION(connection));
9fae31173eb3 Remove Purple.Connection.error and its friends
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
56 error_info = purple_connection_error_info_new(PURPLE_CONNECTION_ERROR_OTHER_ERROR,
9fae31173eb3 Remove Purple.Connection.error and its friends
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
57 error->message);
9fae31173eb3 Remove Purple.Connection.error and its friends
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
58 purple_account_set_error(account, error_info);
9fae31173eb3 Remove Purple.Connection.error and its friends
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
59 purple_account_disconnect(account);
42546
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 return;
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 connection->output = output;
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 purple_connection_set_state(PURPLE_CONNECTION(connection),
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 PURPLE_CONNECTION_STATE_CONNECTED);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 }
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 /******************************************************************************
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 * PurpleConnection Implementation
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 *****************************************************************************/
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 static gboolean
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 purple_xmpp_connection_connect(PurpleConnection *purple_connection,
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 GError **error)
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 {
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 PurpleXmppConnection *connection = NULL;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 PurpleAccount *account = NULL;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 XemeInputStream *input = NULL;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 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
81 GCancellable *cancellable = NULL;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 GError *local_error = NULL;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 GProxyResolver *resolver = NULL;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 const char *resource = NULL;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 const char *server = NULL;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 const char *tls_mode = NULL;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 const char *username = NULL;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 guint16 port = PURPLE_XMPP_DEFAULT_PORT_TLS;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 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
91
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 purple_connection_set_state(purple_connection,
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 PURPLE_CONNECTION_STATE_CONNECTING);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 connection = PURPLE_XMPP_CONNECTION(purple_connection);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 cancellable = purple_connection_get_cancellable(purple_connection);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 account = purple_connection_get_account(purple_connection);
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 /* Figure out what proxy resolver to use. */
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 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
101 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
102 if(local_error == NULL) {
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 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
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 g_propagate_error(error, local_error);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 g_clear_object(&resolver);
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 return FALSE;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 }
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 /* Grab some more information that we need. */
42803
984f8dfabb47 Update the protocols to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents: 42794
diff changeset
114 username = purple_account_get_username(account);
42546
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 connection->xeme_connection = xeme_connection_new(username);
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 resource, tell the xeme connection about it. */
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 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
119 NULL);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 if(!purple_strempty(resource)) {
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 xeme_connection_set_resource(connection->xeme_connection, resource);
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 /* 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
125 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
126 NULL);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 if(!purple_strempty(server)) {
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 xeme_connection_set_server(connection->xeme_connection, server);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 }
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 /* 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
132 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
133 PURPLE_XMPP_DEFAULT_PORT_TLS);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 xeme_connection_set_port(connection->xeme_connection, port);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 /* 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
137 * 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
138 * using. Doing so should avoid possible accidental leaks.
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 */
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 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
141 PURPLE_XMPP_TLS_DIRECT);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 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
143 xeme_tls_mode = XEME_TLS_MODE_DIRECT_TLS;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 } 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
145 xeme_tls_mode = XEME_TLS_MODE_START_TLS;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 } 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
147 xeme_tls_mode = XEME_TLS_MODE_NONE;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 }
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 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
151
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 input = xeme_input_stream_new();
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 /* Finally start connecting!! */
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 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
156 cancellable, purple_xmpp_connection_connect_cb,
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 connection);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 g_clear_object(&input);
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 return TRUE;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 }
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 static gboolean
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 purple_xmpp_connection_disconnect(PurpleConnection *purple_connection,
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 GError **error)
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 PurpleXmppConnection *connection = NULL;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 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
171
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 connection = PURPLE_XMPP_CONNECTION(purple_connection);
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 return xeme_connection_close(connection->xeme_connection, error);
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
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 * GObject Implementation
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 *****************************************************************************/
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 static void
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 purple_xmpp_connection_dispose(GObject *obj) {
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 PurpleXmppConnection *connection = PURPLE_XMPP_CONNECTION(obj);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 g_clear_object(&connection->xeme_connection);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 g_clear_object(&connection->output);
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 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
188 }
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 static void
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 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
192 }
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 static void
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 purple_xmpp_connection_class_init(PurpleXmppConnectionClass *klass) {
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 PurpleConnectionClass *connection_class = PURPLE_CONNECTION_CLASS(klass);
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 obj_class->dispose = purple_xmpp_connection_dispose;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 connection_class->connect = purple_xmpp_connection_connect;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 connection_class->disconnect = purple_xmpp_connection_disconnect;
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 }
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 static void
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 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
207 }
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208
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 * Internal API
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 *****************************************************************************/
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 void
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 purple_xmpp_connection_register(GPluginNativePlugin *plugin) {
a8a644e3e561 start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 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
215 }

mercurial