Mon, 14 Oct 2024 22:58:04 -0500
Update the protocols now that Purple.Account:error is a GLib.Error
Testing Done:
Reaped a connection with the demo protocol plugin and called in the turtles.
Bugs closed: PIDGIN-17985
Reviewed at https://reviews.imfreedom.org/r/3577/
|
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 | |
|
9fae31173eb3
Remove Purple.Connection.error and its friends
Gary Kramlich <grim@reaperworld.com>
parents:
42803
diff
changeset
|
54 | account = purple_connection_get_account(PURPLE_CONNECTION(connection)); |
|
43006
b9cbf5cb2003
Update the protocols now that Purple.Account:error is a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
43002
diff
changeset
|
55 | |
|
b9cbf5cb2003
Update the protocols now that Purple.Account:error is a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
43002
diff
changeset
|
56 | purple_account_disconnect_with_error(account, error); |
|
42546
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | return; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | } |
|
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 | connection->output = output; |
|
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 | purple_connection_set_state(PURPLE_CONNECTION(connection), |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | PURPLE_CONNECTION_STATE_CONNECTED); |
|
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 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | /****************************************************************************** |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | * PurpleConnection Implementation |
|
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 | static gboolean |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | purple_xmpp_connection_connect(PurpleConnection *purple_connection, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | GError **error) |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | PurpleXmppConnection *connection = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | PurpleAccount *account = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | XemeInputStream *input = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | 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
|
78 | GCancellable *cancellable = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | GError *local_error = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | GProxyResolver *resolver = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | const char *resource = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | const char *server = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | const char *tls_mode = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | const char *username = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | guint16 port = PURPLE_XMPP_DEFAULT_PORT_TLS; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | 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
|
88 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | purple_connection_set_state(purple_connection, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | PURPLE_CONNECTION_STATE_CONNECTING); |
|
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 | connection = PURPLE_XMPP_CONNECTION(purple_connection); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | cancellable = purple_connection_get_cancellable(purple_connection); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | account = purple_connection_get_account(purple_connection); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | /* Figure out what proxy resolver to use. */ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | 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
|
98 | 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
|
99 | if(local_error == NULL) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | 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
|
101 | } |
|
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 | g_propagate_error(error, local_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 | g_clear_object(&resolver); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | return FALSE; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | } |
|
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 | /* 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
|
111 | username = purple_account_get_username(account); |
|
42546
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | connection->xeme_connection = xeme_connection_new(username); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | /* 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
|
115 | 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
|
116 | NULL); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | if(!purple_strempty(resource)) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | xeme_connection_set_resource(connection->xeme_connection, resource); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | /* 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
|
122 | 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
|
123 | NULL); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | if(!purple_strempty(server)) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | xeme_connection_set_server(connection->xeme_connection, server); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | } |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | /* 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
|
129 | 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
|
130 | PURPLE_XMPP_DEFAULT_PORT_TLS); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | xeme_connection_set_port(connection->xeme_connection, port); |
|
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 | /* 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
|
134 | * 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
|
135 | * using. Doing so should avoid possible accidental leaks. |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | */ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | 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
|
138 | PURPLE_XMPP_TLS_DIRECT); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | 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
|
140 | xeme_tls_mode = XEME_TLS_MODE_DIRECT_TLS; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | } 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
|
142 | xeme_tls_mode = XEME_TLS_MODE_START_TLS; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | } 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
|
144 | xeme_tls_mode = XEME_TLS_MODE_NONE; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | } |
|
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 | 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
|
148 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | input = xeme_input_stream_new(); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
150 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | /* Finally start connecting!! */ |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | 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
|
153 | cancellable, purple_xmpp_connection_connect_cb, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | connection); |
|
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 | g_clear_object(&input); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | return TRUE; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | } |
|
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 | static gboolean |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | purple_xmpp_connection_disconnect(PurpleConnection *purple_connection, |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | GError **error) |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | PurpleXmppConnection *connection = NULL; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | 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
|
168 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
169 | connection = PURPLE_XMPP_CONNECTION(purple_connection); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | return xeme_connection_close(connection->xeme_connection, error); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
172 | } |
|
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 | * GObject Implementation |
|
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 | static void |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | purple_xmpp_connection_dispose(GObject *obj) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
179 | PurpleXmppConnection *connection = PURPLE_XMPP_CONNECTION(obj); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | g_clear_object(&connection->xeme_connection); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | g_clear_object(&connection->output); |
|
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_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
|
185 | } |
|
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 | static void |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | 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
|
189 | } |
|
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 | static void |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | purple_xmpp_connection_class_init(PurpleXmppConnectionClass *klass) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | PurpleConnectionClass *connection_class = PURPLE_CONNECTION_CLASS(klass); |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | obj_class->dispose = purple_xmpp_connection_dispose; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | connection_class->connect = purple_xmpp_connection_connect; |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | connection_class->disconnect = purple_xmpp_connection_disconnect; |
|
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 | |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | static void |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
203 | 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
|
204 | } |
|
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 | * Internal API |
|
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 | void |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
210 | purple_xmpp_connection_register(GPluginNativePlugin *plugin) { |
|
a8a644e3e561
start of the new xmpp's connection
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | 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
|
212 | } |