Tue, 08 Jan 2008 03:03:15 +0000
Adjust some network error fatalities and things
| 5563 | 1 | /** |
| 2 | * @file connection.c Connection API | |
| 3 | * @ingroup core | |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19897
diff
changeset
|
4 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19897
diff
changeset
|
5 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19897
diff
changeset
|
6 | /* purple |
| 5563 | 7 | * |
| 15884 | 8 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
| 5631 | 11 | * |
| 5563 | 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19832
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 5563 | 25 | */ |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
26 | #include "internal.h" |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
27 | #include "account.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
28 | #include "blist.h" |
| 5563 | 29 | #include "connection.h" |
|
11146
c56333373e3c
[gaim-migrate @ 13217]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents:
11033
diff
changeset
|
30 | #include "dbus-maybe.h" |
| 5717 | 31 | #include "debug.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
32 | #include "log.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
33 | #include "notify.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
34 | #include "prefs.h" |
|
14900
4af8b81519b6
[gaim-migrate @ 17607]
Mark Doliner <markdoliner@pidgin.im>
parents:
14814
diff
changeset
|
35 | #include "proxy.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
36 | #include "request.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
37 | #include "server.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
38 | #include "signals.h" |
|
6106
1dc08be40f0a
[gaim-migrate @ 6567]
Mark Doliner <markdoliner@pidgin.im>
parents:
6076
diff
changeset
|
39 | #include "util.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
40 | |
|
21865
59b1c56633d1
De-magic number the prpl_info->keepalive interval, and document it.
Will Thompson <resiak@pidgin.im>
parents:
21831
diff
changeset
|
41 | #define KEEPALIVE_INTERVAL 30 |
|
59b1c56633d1
De-magic number the prpl_info->keepalive interval, and document it.
Will Thompson <resiak@pidgin.im>
parents:
21831
diff
changeset
|
42 | |
| 5563 | 43 | static GList *connections = NULL; |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
44 | static GList *connections_connecting = NULL; |
| 15884 | 45 | static PurpleConnectionUiOps *connection_ui_ops = NULL; |
| 5563 | 46 | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
47 | static int connections_handle; |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
48 | |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
49 | static gboolean |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
50 | send_keepalive(gpointer data) |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
51 | { |
| 15884 | 52 | PurpleConnection *gc = data; |
| 53 | PurplePluginProtocolInfo *prpl_info = NULL; | |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
54 | |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
55 | if (gc != NULL && gc->prpl != NULL) |
| 15884 | 56 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
57 | |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
58 | if (prpl_info && prpl_info->keepalive) |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
59 | prpl_info->keepalive(gc); |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
60 | |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
61 | return TRUE; |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
62 | } |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
63 | |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
64 | static void |
| 15884 | 65 | update_keepalive(PurpleConnection *gc, gboolean on) |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
66 | { |
| 15884 | 67 | PurplePluginProtocolInfo *prpl_info = NULL; |
|
14545
f8b45a0ddac5
[gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
68 | |
|
f8b45a0ddac5
[gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
69 | if (gc != NULL && gc->prpl != NULL) |
| 15884 | 70 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
|
14545
f8b45a0ddac5
[gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
71 | |
|
f8b45a0ddac5
[gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
72 | if (!prpl_info || !prpl_info->keepalive) |
|
f8b45a0ddac5
[gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
73 | return; |
|
f8b45a0ddac5
[gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
74 | |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
75 | if (on && !gc->keepalive) |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
76 | { |
| 15884 | 77 | purple_debug_info("connection", "Activating keepalive.\n"); |
|
21865
59b1c56633d1
De-magic number the prpl_info->keepalive interval, and document it.
Will Thompson <resiak@pidgin.im>
parents:
21831
diff
changeset
|
78 | gc->keepalive = purple_timeout_add_seconds(KEEPALIVE_INTERVAL, send_keepalive, gc); |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
79 | } |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
80 | else if (!on && gc->keepalive > 0) |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
81 | { |
| 15884 | 82 | purple_debug_info("connection", "Deactivating keepalive.\n"); |
| 83 | purple_timeout_remove(gc->keepalive); | |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
84 | gc->keepalive = 0; |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
85 | } |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
86 | } |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
87 | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
88 | void |
| 15884 | 89 | purple_connection_new(PurpleAccount *account, gboolean regist, const char *password) |
| 5563 | 90 | { |
| 15884 | 91 | PurpleConnection *gc; |
| 92 | PurplePlugin *prpl; | |
| 93 | PurplePluginProtocolInfo *prpl_info; | |
| 5563 | 94 | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
95 | g_return_if_fail(account != NULL); |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
96 | |
| 15884 | 97 | if (!purple_account_is_disconnected(account)) |
|
10755
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10754
diff
changeset
|
98 | return; |
|
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10754
diff
changeset
|
99 | |
| 15884 | 100 | prpl = purple_find_prpl(purple_account_get_protocol_id(account)); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
101 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
102 | if (prpl != NULL) |
| 15884 | 103 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
104 | else { |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
105 | gchar *message; |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
106 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
107 | message = g_strdup_printf(_("Missing protocol plugin for %s"), |
| 15884 | 108 | purple_account_get_username(account)); |
| 109 | purple_notify_error(NULL, regist ? _("Registration Error") : | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
110 | _("Connection Error"), message, NULL); |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
111 | g_free(message); |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
112 | return; |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
113 | } |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
114 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
115 | if (regist) |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
116 | { |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
117 | if (prpl_info->register_user == NULL) |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
118 | return; |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
119 | } |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
120 | else |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
121 | { |
|
10751
e15f4f5927ce
[gaim-migrate @ 12354]
Mark Doliner <markdoliner@pidgin.im>
parents:
10745
diff
changeset
|
122 | if (((password == NULL) || (*password == '\0')) && |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
123 | !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
124 | !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
125 | { |
| 15884 | 126 | purple_debug_error("connection", "Can not connect to account %s without " |
| 127 | "a password.\n", purple_account_get_username(account)); | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
128 | return; |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
129 | } |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
130 | } |
| 5563 | 131 | |
| 15884 | 132 | gc = g_new0(PurpleConnection, 1); |
| 133 | PURPLE_DBUS_REGISTER_POINTER(gc, PurpleConnection); | |
|
11146
c56333373e3c
[gaim-migrate @ 13217]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents:
11033
diff
changeset
|
134 | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
135 | gc->prpl = prpl; |
|
10751
e15f4f5927ce
[gaim-migrate @ 12354]
Mark Doliner <markdoliner@pidgin.im>
parents:
10745
diff
changeset
|
136 | if ((password != NULL) && (*password != '\0')) |
|
e15f4f5927ce
[gaim-migrate @ 12354]
Mark Doliner <markdoliner@pidgin.im>
parents:
10745
diff
changeset
|
137 | gc->password = g_strdup(password); |
| 15884 | 138 | purple_connection_set_account(gc, account); |
| 139 | purple_connection_set_state(gc, PURPLE_CONNECTING); | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
140 | connections = g_list_append(connections, gc); |
| 15884 | 141 | purple_account_set_connection(account, gc); |
| 5563 | 142 | |
| 15884 | 143 | purple_signal_emit(purple_connections_get_handle(), "signing-on", gc); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
144 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
145 | if (regist) |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
146 | { |
| 15884 | 147 | purple_debug_info("connection", "Registering. gc = %p\n", gc); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
148 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
149 | /* set this so we don't auto-reconnect after registering */ |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
150 | gc->wants_to_die = TRUE; |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
151 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
152 | prpl_info->register_user(account); |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
153 | } |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
154 | else |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
155 | { |
| 15884 | 156 | purple_debug_info("connection", "Connecting. gc = %p\n", gc); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
157 | |
| 15884 | 158 | purple_signal_emit(purple_accounts_get_handle(), "account-connecting", account); |
|
11837
2f1206084fef
[gaim-migrate @ 14128]
Mark Doliner <markdoliner@pidgin.im>
parents:
11698
diff
changeset
|
159 | prpl_info->login(account); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
160 | } |
| 5563 | 161 | } |
| 162 | ||
| 163 | void | |
|
18994
310e9d853e2b
Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents:
18912
diff
changeset
|
164 | purple_connection_new_unregister(PurpleAccount *account, const char *password, PurpleAccountUnregistrationCb cb, void *user_data) |
|
18912
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
165 | { |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
166 | /* Lots of copy/pasted code to avoid API changes. You might want to integrate that into the previous function when posssible. */ |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
167 | PurpleConnection *gc; |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
168 | PurplePlugin *prpl; |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
169 | PurplePluginProtocolInfo *prpl_info; |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
170 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
171 | g_return_if_fail(account != NULL); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
172 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
173 | prpl = purple_find_prpl(purple_account_get_protocol_id(account)); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
174 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
175 | if (prpl != NULL) |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
176 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
177 | else { |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
178 | gchar *message; |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
179 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
180 | message = g_strdup_printf(_("Missing protocol plugin for %s"), |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
181 | purple_account_get_username(account)); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
182 | purple_notify_error(NULL, _("Unregistration Error"), message, NULL); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
183 | g_free(message); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
184 | return; |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
185 | } |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
186 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
187 | if (!purple_account_is_disconnected(account)) { |
|
18994
310e9d853e2b
Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents:
18912
diff
changeset
|
188 | prpl_info->unregister_user(account, cb, user_data); |
|
18912
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
189 | return; |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
190 | } |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
191 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
192 | if (((password == NULL) || (*password == '\0')) && |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
193 | !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
194 | !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
195 | { |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
196 | purple_debug_error("connection", "Can not connect to account %s without " |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
197 | "a password.\n", purple_account_get_username(account)); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
198 | return; |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
199 | } |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
200 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
201 | gc = g_new0(PurpleConnection, 1); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
202 | PURPLE_DBUS_REGISTER_POINTER(gc, PurpleConnection); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
203 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
204 | gc->prpl = prpl; |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
205 | if ((password != NULL) && (*password != '\0')) |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
206 | gc->password = g_strdup(password); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
207 | purple_connection_set_account(gc, account); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
208 | purple_connection_set_state(gc, PURPLE_CONNECTING); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
209 | connections = g_list_append(connections, gc); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
210 | purple_account_set_connection(account, gc); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
211 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
212 | purple_signal_emit(purple_connections_get_handle(), "signing-on", gc); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
213 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
214 | purple_debug_info("connection", "Unregistering. gc = %p\n", gc); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
215 | |
|
18994
310e9d853e2b
Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents:
18912
diff
changeset
|
216 | prpl_info->unregister_user(account, cb, user_data); |
|
18912
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
217 | } |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
218 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18186
diff
changeset
|
219 | void |
| 15884 | 220 | purple_connection_destroy(PurpleConnection *gc) |
| 5563 | 221 | { |
| 15884 | 222 | PurpleAccount *account; |
|
16863
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16478
diff
changeset
|
223 | GSList *buddies; |
| 15884 | 224 | PurplePluginProtocolInfo *prpl_info = NULL; |
|
11507
1a6c8ccce2a9
[gaim-migrate @ 13752]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11305
diff
changeset
|
225 | gboolean remove = FALSE; |
|
5741
0a52405f402f
[gaim-migrate @ 6165]
Christian Hammond <chipx86@chipx86.com>
parents:
5740
diff
changeset
|
226 | |
| 5563 | 227 | g_return_if_fail(gc != NULL); |
| 228 | ||
| 15884 | 229 | account = purple_connection_get_account(gc); |
|
5926
f0c5bbf16793
[gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents:
5905
diff
changeset
|
230 | |
| 15884 | 231 | purple_debug_info("connection", "Disconnecting connection %p\n", gc); |
|
10754
d5f1ddb4146f
[gaim-migrate @ 12357]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
232 | |
| 15884 | 233 | if (purple_connection_get_state(gc) != PURPLE_CONNECTING) |
|
11507
1a6c8ccce2a9
[gaim-migrate @ 13752]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11305
diff
changeset
|
234 | remove = TRUE; |
|
5926
f0c5bbf16793
[gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents:
5905
diff
changeset
|
235 | |
| 15884 | 236 | purple_signal_emit(purple_connections_get_handle(), "signing-off", gc); |
|
5930
cdd2e5397cd3
[gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents:
5926
diff
changeset
|
237 | |
|
10754
d5f1ddb4146f
[gaim-migrate @ 12357]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
238 | while (gc->buddy_chats) |
|
d5f1ddb4146f
[gaim-migrate @ 12357]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
239 | { |
| 15884 | 240 | PurpleConversation *b = gc->buddy_chats->data; |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
241 | |
|
10754
d5f1ddb4146f
[gaim-migrate @ 12357]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
242 | gc->buddy_chats = g_slist_remove(gc->buddy_chats, b); |
| 15884 | 243 | purple_conv_chat_left(PURPLE_CONV_CHAT(b)); |
|
10754
d5f1ddb4146f
[gaim-migrate @ 12357]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
244 | } |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
245 | |
|
10754
d5f1ddb4146f
[gaim-migrate @ 12357]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
246 | update_keepalive(gc, FALSE); |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
247 | |
| 15884 | 248 | purple_proxy_connect_cancel_with_handle(gc); |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
249 | |
| 15884 | 250 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
|
14900
4af8b81519b6
[gaim-migrate @ 17607]
Mark Doliner <markdoliner@pidgin.im>
parents:
14814
diff
changeset
|
251 | if (prpl_info->close) |
|
4af8b81519b6
[gaim-migrate @ 17607]
Mark Doliner <markdoliner@pidgin.im>
parents:
14814
diff
changeset
|
252 | (prpl_info->close)(gc); |
| 5563 | 253 | |
|
14814
479ac60fb641
[gaim-migrate @ 17509]
Daniel Atallah <datallah@pidgin.im>
parents:
14669
diff
changeset
|
254 | /* Clear out the proto data that was freed in the prpl close method*/ |
| 15884 | 255 | buddies = purple_find_buddies(account, NULL); |
|
16863
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16478
diff
changeset
|
256 | while (buddies != NULL) { |
|
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16478
diff
changeset
|
257 | PurpleBuddy *buddy = buddies->data; |
|
14814
479ac60fb641
[gaim-migrate @ 17509]
Daniel Atallah <datallah@pidgin.im>
parents:
14669
diff
changeset
|
258 | buddy->proto_data = NULL; |
|
16863
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16478
diff
changeset
|
259 | buddies = g_slist_delete_link(buddies, buddies); |
|
14814
479ac60fb641
[gaim-migrate @ 17509]
Daniel Atallah <datallah@pidgin.im>
parents:
14669
diff
changeset
|
260 | } |
|
479ac60fb641
[gaim-migrate @ 17509]
Daniel Atallah <datallah@pidgin.im>
parents:
14669
diff
changeset
|
261 | |
|
10754
d5f1ddb4146f
[gaim-migrate @ 12357]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
262 | connections = g_list_remove(connections, gc); |
| 5563 | 263 | |
| 15884 | 264 | purple_connection_set_state(gc, PURPLE_DISCONNECTED); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
265 | |
|
11507
1a6c8ccce2a9
[gaim-migrate @ 13752]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11305
diff
changeset
|
266 | if (remove) |
| 15884 | 267 | purple_blist_remove_account(account); |
|
11507
1a6c8ccce2a9
[gaim-migrate @ 13752]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11305
diff
changeset
|
268 | |
| 15884 | 269 | purple_signal_emit(purple_connections_get_handle(), "signed-off", gc); |
|
5615
2eb715cbbd9b
[gaim-migrate @ 6022]
Christian Hammond <chipx86@chipx86.com>
parents:
5581
diff
changeset
|
270 | |
| 15884 | 271 | purple_account_request_close_with_account(account); |
| 272 | purple_request_close_with_handle(gc); | |
| 273 | purple_notify_close_with_handle(gc); | |
| 5563 | 274 | |
| 15884 | 275 | purple_debug_info("connection", "Destroying connection %p\n", gc); |
|
10742
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
276 | |
| 15884 | 277 | purple_account_set_connection(account, NULL); |
|
10742
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
278 | |
|
13976
2543396bd00e
[gaim-migrate @ 16414]
Mark Doliner <markdoliner@pidgin.im>
parents:
13508
diff
changeset
|
279 | g_free(gc->password); |
|
2543396bd00e
[gaim-migrate @ 16414]
Mark Doliner <markdoliner@pidgin.im>
parents:
13508
diff
changeset
|
280 | g_free(gc->display_name); |
|
9848
708a47f26faa
[gaim-migrate @ 10726]
Dave West <kat@users.sourceforge.net>
parents:
9699
diff
changeset
|
281 | |
|
10742
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
282 | if (gc->disconnect_timeout) |
| 15884 | 283 | purple_timeout_remove(gc->disconnect_timeout); |
|
6029
85d6afa168fb
[gaim-migrate @ 6479]
Mark Doliner <markdoliner@pidgin.im>
parents:
6018
diff
changeset
|
284 | |
| 15884 | 285 | PURPLE_DBUS_UNREGISTER_POINTER(gc); |
|
10742
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
286 | g_free(gc); |
|
6029
85d6afa168fb
[gaim-migrate @ 6479]
Mark Doliner <markdoliner@pidgin.im>
parents:
6018
diff
changeset
|
287 | } |
|
85d6afa168fb
[gaim-migrate @ 6479]
Mark Doliner <markdoliner@pidgin.im>
parents:
6018
diff
changeset
|
288 | |
| 5563 | 289 | /* |
|
8130
58e4e51f514b
[gaim-migrate @ 8835]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
290 | * d:)->-< |
| 5563 | 291 | * |
| 292 | * d:O-\-< | |
|
8130
58e4e51f514b
[gaim-migrate @ 8835]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
293 | * |
| 5563 | 294 | * d:D-/-< |
| 295 | * | |
| 296 | * d8D->-< DANCE! | |
| 297 | */ | |
| 298 | ||
| 299 | void | |
| 15884 | 300 | purple_connection_set_state(PurpleConnection *gc, PurpleConnectionState state) |
| 5563 | 301 | { |
| 15884 | 302 | PurpleConnectionUiOps *ops; |
|
5885
223ac977eed2
[gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents:
5883
diff
changeset
|
303 | |
| 5563 | 304 | g_return_if_fail(gc != NULL); |
| 305 | ||
|
5784
4c9046760b5b
[gaim-migrate @ 6209]
Christian Hammond <chipx86@chipx86.com>
parents:
5741
diff
changeset
|
306 | if (gc->state == state) |
|
4c9046760b5b
[gaim-migrate @ 6209]
Christian Hammond <chipx86@chipx86.com>
parents:
5741
diff
changeset
|
307 | return; |
|
4c9046760b5b
[gaim-migrate @ 6209]
Christian Hammond <chipx86@chipx86.com>
parents:
5741
diff
changeset
|
308 | |
| 5563 | 309 | gc->state = state; |
| 310 | ||
| 15884 | 311 | ops = purple_connections_get_ui_ops(); |
|
5885
223ac977eed2
[gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents:
5883
diff
changeset
|
312 | |
| 15884 | 313 | if (gc->state == PURPLE_CONNECTING) { |
|
5905
62a6bdbc09b7
[gaim-migrate @ 6337]
Robert McQueen <robot101@debian.org>
parents:
5885
diff
changeset
|
314 | connections_connecting = g_list_append(connections_connecting, gc); |
|
62a6bdbc09b7
[gaim-migrate @ 6337]
Robert McQueen <robot101@debian.org>
parents:
5885
diff
changeset
|
315 | } |
|
62a6bdbc09b7
[gaim-migrate @ 6337]
Robert McQueen <robot101@debian.org>
parents:
5885
diff
changeset
|
316 | else { |
|
5885
223ac977eed2
[gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents:
5883
diff
changeset
|
317 | connections_connecting = g_list_remove(connections_connecting, gc); |
|
5905
62a6bdbc09b7
[gaim-migrate @ 6337]
Robert McQueen <robot101@debian.org>
parents:
5885
diff
changeset
|
318 | } |
|
5885
223ac977eed2
[gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents:
5883
diff
changeset
|
319 | |
| 15884 | 320 | if (gc->state == PURPLE_CONNECTED) { |
| 321 | PurpleAccount *account; | |
| 322 | PurplePresence *presence; | |
|
10052
329dad7e2da3
[gaim-migrate @ 11013]
Dave West <kat@users.sourceforge.net>
parents:
9944
diff
changeset
|
323 | |
| 15884 | 324 | account = purple_connection_get_account(gc); |
| 325 | presence = purple_account_get_presence(account); | |
| 5563 | 326 | |
| 327 | /* Set the time the account came online */ | |
| 15884 | 328 | purple_presence_set_login_time(presence, time(NULL)); |
| 5563 | 329 | |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
15890
diff
changeset
|
330 | if (purple_prefs_get_bool("/purple/logging/log_system")) |
|
11698
afbf0d8bdacf
[gaim-migrate @ 13989]
Mark Doliner <markdoliner@pidgin.im>
parents:
11562
diff
changeset
|
331 | { |
| 15884 | 332 | PurpleLog *log = purple_account_get_log(account, TRUE); |
|
13508
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
333 | |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
334 | if (log != NULL) |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
335 | { |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
336 | char *msg = g_strdup_printf(_("+++ %s signed on"), |
| 15884 | 337 | purple_account_get_username(account)); |
| 338 | purple_log_write(log, PURPLE_MESSAGE_SYSTEM, | |
| 339 | purple_account_get_username(account), | |
| 340 | purple_presence_get_login_time(presence), | |
|
13508
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
341 | msg); |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
342 | g_free(msg); |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
343 | } |
|
10301
fd24ab69574a
[gaim-migrate @ 11486]
Mark Doliner <markdoliner@pidgin.im>
parents:
10193
diff
changeset
|
344 | } |
|
fd24ab69574a
[gaim-migrate @ 11486]
Mark Doliner <markdoliner@pidgin.im>
parents:
10193
diff
changeset
|
345 | |
| 5563 | 346 | if (ops != NULL && ops->connected != NULL) |
| 347 | ops->connected(gc); | |
| 348 | ||
| 15884 | 349 | purple_blist_add_account(account); |
| 5563 | 350 | |
| 15884 | 351 | purple_signal_emit(purple_connections_get_handle(), "signed-on", gc); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
352 | |
| 5563 | 353 | serv_set_permit_deny(gc); |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
354 | |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
355 | update_keepalive(gc, TRUE); |
| 5563 | 356 | } |
| 15884 | 357 | else if (gc->state == PURPLE_DISCONNECTED) { |
| 358 | PurpleAccount *account = purple_connection_get_account(gc); | |
| 8573 | 359 | |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
15890
diff
changeset
|
360 | if (purple_prefs_get_bool("/purple/logging/log_system")) |
|
11698
afbf0d8bdacf
[gaim-migrate @ 13989]
Mark Doliner <markdoliner@pidgin.im>
parents:
11562
diff
changeset
|
361 | { |
| 15884 | 362 | PurpleLog *log = purple_account_get_log(account, FALSE); |
|
13508
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
363 | |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
364 | if (log != NULL) |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
365 | { |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
366 | char *msg = g_strdup_printf(_("+++ %s signed off"), |
| 15884 | 367 | purple_account_get_username(account)); |
| 368 | purple_log_write(log, PURPLE_MESSAGE_SYSTEM, | |
| 369 | purple_account_get_username(account), time(NULL), | |
|
13508
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
370 | msg); |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
371 | g_free(msg); |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
372 | } |
| 8573 | 373 | } |
| 374 | ||
| 15884 | 375 | purple_account_destroy_log(account); |
| 8573 | 376 | |
|
5885
223ac977eed2
[gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents:
5883
diff
changeset
|
377 | if (ops != NULL && ops->disconnected != NULL) |
| 9190 | 378 | ops->disconnected(gc); |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
379 | } |
| 5563 | 380 | } |
| 381 | ||
| 382 | void | |
| 15884 | 383 | purple_connection_set_account(PurpleConnection *gc, PurpleAccount *account) |
| 5563 | 384 | { |
| 385 | g_return_if_fail(gc != NULL); | |
| 386 | g_return_if_fail(account != NULL); | |
| 387 | ||
| 388 | gc->account = account; | |
| 389 | } | |
| 390 | ||
| 391 | void | |
| 15884 | 392 | purple_connection_set_display_name(PurpleConnection *gc, const char *name) |
| 5563 | 393 | { |
| 394 | g_return_if_fail(gc != NULL); | |
| 395 | ||
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14035
diff
changeset
|
396 | g_free(gc->display_name); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14035
diff
changeset
|
397 | gc->display_name = g_strdup(name); |
| 5563 | 398 | } |
| 399 | ||
| 15884 | 400 | PurpleConnectionState |
| 401 | purple_connection_get_state(const PurpleConnection *gc) | |
| 5563 | 402 | { |
| 15884 | 403 | g_return_val_if_fail(gc != NULL, PURPLE_DISCONNECTED); |
| 5563 | 404 | |
| 405 | return gc->state; | |
| 406 | } | |
| 407 | ||
| 15884 | 408 | PurpleAccount * |
| 409 | purple_connection_get_account(const PurpleConnection *gc) | |
| 5563 | 410 | { |
| 411 | g_return_val_if_fail(gc != NULL, NULL); | |
| 412 | ||
| 413 | return gc->account; | |
| 414 | } | |
| 415 | ||
| 416 | const char * | |
| 15884 | 417 | purple_connection_get_password(const PurpleConnection *gc) |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
418 | { |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
419 | g_return_val_if_fail(gc != NULL, NULL); |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
420 | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
421 | return gc->password ? gc->password : gc->account->password; |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
422 | } |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
423 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
424 | const char * |
| 15884 | 425 | purple_connection_get_display_name(const PurpleConnection *gc) |
| 5563 | 426 | { |
| 427 | g_return_val_if_fail(gc != NULL, NULL); | |
| 428 | ||
| 429 | return gc->display_name; | |
| 430 | } | |
| 431 | ||
| 432 | void | |
| 15884 | 433 | purple_connection_update_progress(PurpleConnection *gc, const char *text, |
| 5563 | 434 | size_t step, size_t count) |
| 435 | { | |
| 15884 | 436 | PurpleConnectionUiOps *ops; |
| 5563 | 437 | |
| 438 | g_return_if_fail(gc != NULL); | |
| 439 | g_return_if_fail(text != NULL); | |
| 440 | g_return_if_fail(step < count); | |
| 441 | g_return_if_fail(count > 1); | |
| 442 | ||
| 15884 | 443 | ops = purple_connections_get_ui_ops(); |
| 5563 | 444 | |
| 445 | if (ops != NULL && ops->connect_progress != NULL) | |
| 446 | ops->connect_progress(gc, text, step, count); | |
| 447 | } | |
| 448 | ||
| 449 | void | |
| 15884 | 450 | purple_connection_notice(PurpleConnection *gc, const char *text) |
|
5571
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
451 | { |
| 15884 | 452 | PurpleConnectionUiOps *ops; |
|
5571
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
453 | |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
454 | g_return_if_fail(gc != NULL); |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
455 | g_return_if_fail(text != NULL); |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
456 | |
| 15884 | 457 | ops = purple_connections_get_ui_ops(); |
|
5571
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
458 | |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
459 | if (ops != NULL && ops->notice != NULL) |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
460 | ops->notice(gc, text); |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
461 | } |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
462 | |
|
12412
8abe3226695e
[gaim-migrate @ 14719]
Richard Laager <rlaager@pidgin.im>
parents:
12272
diff
changeset
|
463 | static gboolean |
| 15884 | 464 | purple_connection_disconnect_cb(gpointer data) |
|
10742
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
465 | { |
| 15884 | 466 | PurpleAccount *account = data; |
| 467 | char *password = g_strdup(purple_account_get_password(account)); | |
| 468 | purple_account_disconnect(account); | |
| 469 | purple_account_set_password(account, password); | |
| 11562 | 470 | g_free(password); |
|
10742
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
471 | return FALSE; |
|
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
472 | } |
|
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
473 | |
|
5571
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
474 | void |
| 15884 | 475 | purple_connection_error(PurpleConnection *gc, const char *text) |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
476 | { |
|
21154
be1799decdb7
Clarify the documentation of the return value of
Will Thompson <resiak@pidgin.im>
parents:
21153
diff
changeset
|
477 | /* prpls that have not been updated to use disconnection reasons will |
|
be1799decdb7
Clarify the documentation of the return value of
Will Thompson <resiak@pidgin.im>
parents:
21153
diff
changeset
|
478 | * be setting wants_to_die before calling this function, so choose |
| 21279 | 479 | * PURPLE_CONNECTION_ERROR_OTHER_ERROR (which is fatal) if it's true, |
| 480 | * and PURPLE_CONNECTION_ERROR_NETWORK_ERROR (which isn't) if not. See | |
| 481 | * the documentation in connection.h. | |
|
21154
be1799decdb7
Clarify the documentation of the return value of
Will Thompson <resiak@pidgin.im>
parents:
21153
diff
changeset
|
482 | */ |
| 21279 | 483 | PurpleConnectionError reason = gc->wants_to_die |
| 484 | ? PURPLE_CONNECTION_ERROR_OTHER_ERROR | |
| 485 | : PURPLE_CONNECTION_ERROR_NETWORK_ERROR; | |
|
21149
160a0845b527
rlaager pointed out that purple_connection_error_reason should be setting
Will Thompson <resiak@pidgin.im>
parents:
20882
diff
changeset
|
486 | purple_connection_error_reason (gc, reason, text); |
|
20430
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
487 | } |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
488 | |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
489 | void |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
490 | purple_connection_error_reason (PurpleConnection *gc, |
| 21279 | 491 | PurpleConnectionError reason, |
|
20430
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
492 | const char *description) |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
493 | { |
| 15884 | 494 | PurpleConnectionUiOps *ops; |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
495 | |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
496 | g_return_if_fail(gc != NULL); |
| 21279 | 497 | /* This sanity check relies on PURPLE_CONNECTION_ERROR_OTHER_ERROR |
| 498 | * being the last member of the PurpleConnectionError enum in | |
| 499 | * connection.h; if other reasons are added after it, this check should | |
| 500 | * be updated. | |
|
21278
19f6ce8ee4ad
rlaager suggested using the last element of the PurpleDisconnectReason enum
Will Thompson <resiak@pidgin.im>
parents:
21154
diff
changeset
|
501 | */ |
| 21279 | 502 | if (reason > PURPLE_CONNECTION_ERROR_OTHER_ERROR) { |
|
21278
19f6ce8ee4ad
rlaager suggested using the last element of the PurpleDisconnectReason enum
Will Thompson <resiak@pidgin.im>
parents:
21154
diff
changeset
|
503 | purple_debug_error("connection", |
|
19f6ce8ee4ad
rlaager suggested using the last element of the PurpleDisconnectReason enum
Will Thompson <resiak@pidgin.im>
parents:
21154
diff
changeset
|
504 | "purple_connection_error_reason: reason %u isn't a " |
|
19f6ce8ee4ad
rlaager suggested using the last element of the PurpleDisconnectReason enum
Will Thompson <resiak@pidgin.im>
parents:
21154
diff
changeset
|
505 | "valid reason\n", reason); |
| 21279 | 506 | reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; |
|
21278
19f6ce8ee4ad
rlaager suggested using the last element of the PurpleDisconnectReason enum
Will Thompson <resiak@pidgin.im>
parents:
21154
diff
changeset
|
507 | } |
|
15848
44463a06e833
Change connection.c:gaim_connection_error() to still work even if the
Mark Doliner <markdoliner@pidgin.im>
parents:
15537
diff
changeset
|
508 | |
|
20430
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
509 | if (description == NULL) { |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
510 | purple_debug_error("connection", "purple_connection_error_reason: check `description != NULL' failed\n"); |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
511 | description = _("Unknown error"); |
|
15848
44463a06e833
Change connection.c:gaim_connection_error() to still work even if the
Mark Doliner <markdoliner@pidgin.im>
parents:
15537
diff
changeset
|
512 | } |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
513 | |
| 6393 | 514 | /* If we've already got one error, we don't need any more */ |
|
6460
fc288e7221ca
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6393
diff
changeset
|
515 | if (gc->disconnect_timeout) |
| 6393 | 516 | return; |
| 517 | ||
| 21279 | 518 | gc->wants_to_die = purple_connection_error_is_fatal (reason); |
|
21149
160a0845b527
rlaager pointed out that purple_connection_error_reason should be setting
Will Thompson <resiak@pidgin.im>
parents:
20882
diff
changeset
|
519 | |
| 15884 | 520 | ops = purple_connections_get_ui_ops(); |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
521 | |
|
20430
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
522 | if (ops != NULL) |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
523 | { |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
524 | if (ops->report_disconnect_reason != NULL) |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
525 | ops->report_disconnect_reason (gc, reason, description); |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
526 | if (ops->report_disconnect != NULL) |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
527 | ops->report_disconnect (gc, description); |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
528 | } |
| 5727 | 529 | |
|
21285
ca8cb8706802
I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents:
21279
diff
changeset
|
530 | purple_signal_emit(purple_connections_get_handle(), "connection-error", |
|
ca8cb8706802
I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents:
21279
diff
changeset
|
531 | gc, reason, description); |
| 5727 | 532 | |
| 15884 | 533 | gc->disconnect_timeout = purple_timeout_add(0, purple_connection_disconnect_cb, |
| 534 | purple_connection_get_account(gc)); | |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
535 | } |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
536 | |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
537 | void |
|
20443
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
538 | purple_connection_ssl_error (PurpleConnection *gc, |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
539 | PurpleSslErrorType ssl_error) |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
540 | { |
| 21279 | 541 | PurpleConnectionError reason; |
|
20443
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
542 | |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
543 | switch (ssl_error) { |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
544 | case PURPLE_SSL_HANDSHAKE_FAILED: |
|
22162
1e0f1dbe89da
Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21865
diff
changeset
|
545 | reason = PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR; |
|
1e0f1dbe89da
Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21865
diff
changeset
|
546 | break; |
|
20443
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
547 | case PURPLE_SSL_CONNECT_FAILED: |
|
22162
1e0f1dbe89da
Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21865
diff
changeset
|
548 | reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
|
20443
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
549 | break; |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
550 | case PURPLE_SSL_CERTIFICATE_INVALID: |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
551 | /* TODO: maybe PURPLE_SSL_* should be more specific? */ |
|
22162
1e0f1dbe89da
Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21865
diff
changeset
|
552 | reason = PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR: |
|
20443
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
553 | break; |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
554 | default: |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
555 | g_assert_not_reached (); |
|
22162
1e0f1dbe89da
Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21865
diff
changeset
|
556 | reason = PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR: |
|
20443
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
557 | } |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
558 | |
| 21279 | 559 | purple_connection_error_reason (gc, reason, |
| 560 | purple_ssl_strerror(ssl_error)); | |
|
20443
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
561 | } |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
562 | |
|
20431
49979e453876
Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents:
20430
diff
changeset
|
563 | gboolean |
| 21279 | 564 | purple_connection_error_is_fatal (PurpleConnectionError reason) |
|
20431
49979e453876
Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents:
20430
diff
changeset
|
565 | { |
|
49979e453876
Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents:
20430
diff
changeset
|
566 | switch (reason) |
|
49979e453876
Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents:
20430
diff
changeset
|
567 | { |
| 21279 | 568 | case PURPLE_CONNECTION_ERROR_NETWORK_ERROR: |
|
22162
1e0f1dbe89da
Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21865
diff
changeset
|
569 | case PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR: |
|
21508
0ae51085309d
Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents:
21507
diff
changeset
|
570 | return FALSE; |
|
0ae51085309d
Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents:
21507
diff
changeset
|
571 | case PURPLE_CONNECTION_ERROR_INVALID_USERNAME: |
|
0ae51085309d
Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents:
21507
diff
changeset
|
572 | case PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED: |
| 21279 | 573 | case PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE: |
|
21508
0ae51085309d
Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents:
21507
diff
changeset
|
574 | case PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT: |
|
0ae51085309d
Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents:
21507
diff
changeset
|
575 | case PURPLE_CONNECTION_ERROR_NAME_IN_USE: |
|
0ae51085309d
Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents:
21507
diff
changeset
|
576 | case PURPLE_CONNECTION_ERROR_INVALID_SETTINGS: |
|
0ae51085309d
Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents:
21507
diff
changeset
|
577 | case PURPLE_CONNECTION_ERROR_OTHER_ERROR: |
| 21279 | 578 | case PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED: |
| 579 | case PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED: | |
| 580 | case PURPLE_CONNECTION_ERROR_CERT_EXPIRED: | |
| 581 | case PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED: | |
| 582 | case PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH: | |
| 583 | case PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH: | |
| 584 | case PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED: | |
| 585 | case PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR: | |
|
20431
49979e453876
Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents:
20430
diff
changeset
|
586 | return TRUE; |
|
21153
610a45545a40
datallah pointed out that using g_return_if_fail() is preferable to
Will Thompson <resiak@pidgin.im>
parents:
21149
diff
changeset
|
587 | default: |
|
610a45545a40
datallah pointed out that using g_return_if_fail() is preferable to
Will Thompson <resiak@pidgin.im>
parents:
21149
diff
changeset
|
588 | g_return_val_if_reached(TRUE); |
|
20431
49979e453876
Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents:
20430
diff
changeset
|
589 | } |
|
49979e453876
Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents:
20430
diff
changeset
|
590 | } |
|
49979e453876
Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents:
20430
diff
changeset
|
591 | |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
592 | void |
| 15884 | 593 | purple_connections_disconnect_all(void) |
| 5563 | 594 | { |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
595 | GList *l; |
| 15884 | 596 | PurpleConnection *gc; |
| 5563 | 597 | |
| 15884 | 598 | while ((l = purple_connections_get_all()) != NULL) { |
|
6113
5bc7394e69ea
[gaim-migrate @ 6575]
Mark Doliner <markdoliner@pidgin.im>
parents:
6111
diff
changeset
|
599 | gc = l->data; |
|
5bc7394e69ea
[gaim-migrate @ 6575]
Mark Doliner <markdoliner@pidgin.im>
parents:
6111
diff
changeset
|
600 | gc->wants_to_die = TRUE; |
| 15884 | 601 | purple_account_disconnect(gc->account); |
|
6113
5bc7394e69ea
[gaim-migrate @ 6575]
Mark Doliner <markdoliner@pidgin.im>
parents:
6111
diff
changeset
|
602 | } |
| 5563 | 603 | } |
| 604 | ||
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
605 | GList * |
| 15884 | 606 | purple_connections_get_all(void) |
| 5563 | 607 | { |
| 608 | return connections; | |
| 609 | } | |
| 610 | ||
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
611 | GList * |
| 15884 | 612 | purple_connections_get_connecting(void) |
|
5788
dd6e33a59151
[gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents:
5784
diff
changeset
|
613 | { |
|
dd6e33a59151
[gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents:
5784
diff
changeset
|
614 | return connections_connecting; |
|
dd6e33a59151
[gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents:
5784
diff
changeset
|
615 | } |
|
dd6e33a59151
[gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents:
5784
diff
changeset
|
616 | |
| 5563 | 617 | void |
| 15884 | 618 | purple_connections_set_ui_ops(PurpleConnectionUiOps *ops) |
|
7035
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
619 | { |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
620 | connection_ui_ops = ops; |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
621 | } |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
622 | |
| 15884 | 623 | PurpleConnectionUiOps * |
| 624 | purple_connections_get_ui_ops(void) | |
|
7035
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
625 | { |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
626 | return connection_ui_ops; |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
627 | } |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
628 | |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
629 | void |
| 15884 | 630 | purple_connections_init(void) |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
631 | { |
| 15884 | 632 | void *handle = purple_connections_get_handle(); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
633 | |
| 15884 | 634 | purple_signal_register(handle, "signing-on", |
| 635 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 636 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 637 | PURPLE_SUBTYPE_CONNECTION)); | |
|
6564
a7a2c1927544
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6533
diff
changeset
|
638 | |
| 15884 | 639 | purple_signal_register(handle, "signed-on", |
| 640 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 641 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 642 | PURPLE_SUBTYPE_CONNECTION)); | |
|
6564
a7a2c1927544
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6533
diff
changeset
|
643 | |
| 15884 | 644 | purple_signal_register(handle, "signing-off", |
| 645 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 646 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 647 | PURPLE_SUBTYPE_CONNECTION)); | |
|
6564
a7a2c1927544
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6533
diff
changeset
|
648 | |
| 15884 | 649 | purple_signal_register(handle, "signed-off", |
| 650 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 651 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 652 | PURPLE_SUBTYPE_CONNECTION)); | |
|
21285
ca8cb8706802
I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents:
21279
diff
changeset
|
653 | |
|
ca8cb8706802
I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents:
21279
diff
changeset
|
654 | purple_signal_register(handle, "connection-error", |
|
21576
cba0bab065e9
Register the correct number of values for the "connection-error" signal.
Daniel Atallah <datallah@pidgin.im>
parents:
21509
diff
changeset
|
655 | purple_marshal_VOID__POINTER_INT_POINTER, NULL, 3, |
|
21285
ca8cb8706802
I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents:
21279
diff
changeset
|
656 | purple_value_new(PURPLE_TYPE_SUBTYPE, |
|
ca8cb8706802
I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents:
21279
diff
changeset
|
657 | PURPLE_SUBTYPE_CONNECTION), |
|
ca8cb8706802
I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents:
21279
diff
changeset
|
658 | purple_value_new(PURPLE_TYPE_ENUM), |
|
ca8cb8706802
I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents:
21279
diff
changeset
|
659 | purple_value_new(PURPLE_TYPE_STRING)); |
|
ca8cb8706802
I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents:
21279
diff
changeset
|
660 | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
661 | } |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
662 | |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
663 | void |
| 15884 | 664 | purple_connections_uninit(void) |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
665 | { |
| 15884 | 666 | purple_signals_unregister_by_instance(purple_connections_get_handle()); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
667 | } |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
668 | |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
669 | void * |
| 15884 | 670 | purple_connections_get_handle(void) |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
671 | { |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
672 | return &connections_handle; |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
673 | } |