Tue, 04 Aug 2009 01:23:45 +0000
Log the reason for disconnection to the debug log, so that we might
actually see it in debug logs. hopefully. I meant to do this many moons ago.
| 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 | */ |
|
24569
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
26 | #define _PURPLE_CONNECTION_C_ |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
27 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
28 | #include "internal.h" |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
29 | #include "account.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
30 | #include "blist.h" |
| 5563 | 31 | #include "connection.h" |
|
11146
c56333373e3c
[gaim-migrate @ 13217]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents:
11033
diff
changeset
|
32 | #include "dbus-maybe.h" |
| 5717 | 33 | #include "debug.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
34 | #include "log.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
35 | #include "notify.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
36 | #include "prefs.h" |
|
14900
4af8b81519b6
[gaim-migrate @ 17607]
Mark Doliner <markdoliner@pidgin.im>
parents:
14814
diff
changeset
|
37 | #include "proxy.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
38 | #include "request.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
39 | #include "server.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
40 | #include "signals.h" |
|
6106
1dc08be40f0a
[gaim-migrate @ 6567]
Mark Doliner <markdoliner@pidgin.im>
parents:
6076
diff
changeset
|
41 | #include "util.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
42 | |
|
21865
59b1c56633d1
De-magic number the prpl_info->keepalive interval, and document it.
Will Thompson <resiak@pidgin.im>
parents:
21831
diff
changeset
|
43 | #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
|
44 | |
| 5563 | 45 | static GList *connections = NULL; |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
46 | static GList *connections_connecting = NULL; |
| 15884 | 47 | static PurpleConnectionUiOps *connection_ui_ops = NULL; |
| 5563 | 48 | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
49 | static int connections_handle; |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
50 | |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
51 | static gboolean |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
52 | send_keepalive(gpointer data) |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
53 | { |
| 15884 | 54 | PurpleConnection *gc = data; |
| 55 | PurplePluginProtocolInfo *prpl_info = NULL; | |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
56 | |
|
22277
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
22163
diff
changeset
|
57 | if (gc == NULL) |
|
22324
ca786d5fa291
send_keepalive needs to return TRUE to ensure it'll get called again, and
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22277
diff
changeset
|
58 | return TRUE; |
|
22277
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
22163
diff
changeset
|
59 | |
|
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
22163
diff
changeset
|
60 | /* Only send keep-alives if we haven't heard from the |
|
22324
ca786d5fa291
send_keepalive needs to return TRUE to ensure it'll get called again, and
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22277
diff
changeset
|
61 | * server in a while. |
|
ca786d5fa291
send_keepalive needs to return TRUE to ensure it'll get called again, and
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22277
diff
changeset
|
62 | */ |
|
22277
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
22163
diff
changeset
|
63 | if ((time(NULL) - gc->last_received) < KEEPALIVE_INTERVAL) |
|
22324
ca786d5fa291
send_keepalive needs to return TRUE to ensure it'll get called again, and
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22277
diff
changeset
|
64 | return TRUE; |
|
22277
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
22163
diff
changeset
|
65 | |
|
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
22163
diff
changeset
|
66 | if (gc->prpl == NULL) |
|
22324
ca786d5fa291
send_keepalive needs to return TRUE to ensure it'll get called again, and
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22277
diff
changeset
|
67 | return TRUE; |
|
22277
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
22163
diff
changeset
|
68 | |
|
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
22163
diff
changeset
|
69 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
70 | |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
71 | if (prpl_info && prpl_info->keepalive) |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
72 | prpl_info->keepalive(gc); |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
73 | |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
74 | return TRUE; |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
75 | } |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
76 | |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
77 | static void |
| 15884 | 78 | update_keepalive(PurpleConnection *gc, gboolean on) |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
79 | { |
| 15884 | 80 | PurplePluginProtocolInfo *prpl_info = NULL; |
|
14545
f8b45a0ddac5
[gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
81 | |
|
f8b45a0ddac5
[gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
82 | if (gc != NULL && gc->prpl != NULL) |
| 15884 | 83 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
|
14545
f8b45a0ddac5
[gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
84 | |
|
f8b45a0ddac5
[gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
85 | if (!prpl_info || !prpl_info->keepalive) |
|
f8b45a0ddac5
[gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
86 | return; |
|
f8b45a0ddac5
[gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
87 | |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
88 | if (on && !gc->keepalive) |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
89 | { |
| 15884 | 90 | 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
|
91 | 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
|
92 | } |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
93 | else if (!on && gc->keepalive > 0) |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
94 | { |
| 15884 | 95 | purple_debug_info("connection", "Deactivating keepalive.\n"); |
| 96 | purple_timeout_remove(gc->keepalive); | |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
97 | gc->keepalive = 0; |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
98 | } |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
99 | } |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
100 | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
101 | void |
| 15884 | 102 | purple_connection_new(PurpleAccount *account, gboolean regist, const char *password) |
| 5563 | 103 | { |
|
24569
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
104 | _purple_connection_new(account, regist, password); |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
105 | } |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
106 | |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
107 | void |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
108 | _purple_connection_new(PurpleAccount *account, gboolean regist, const char *password) |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
109 | { |
| 15884 | 110 | PurpleConnection *gc; |
| 111 | PurplePlugin *prpl; | |
| 112 | PurplePluginProtocolInfo *prpl_info; | |
| 5563 | 113 | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
114 | g_return_if_fail(account != NULL); |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
115 | |
| 15884 | 116 | if (!purple_account_is_disconnected(account)) |
|
10755
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10754
diff
changeset
|
117 | return; |
|
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10754
diff
changeset
|
118 | |
| 15884 | 119 | prpl = purple_find_prpl(purple_account_get_protocol_id(account)); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
120 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
121 | if (prpl != NULL) |
| 15884 | 122 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
123 | else { |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
124 | gchar *message; |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
125 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
126 | message = g_strdup_printf(_("Missing protocol plugin for %s"), |
| 15884 | 127 | purple_account_get_username(account)); |
| 128 | purple_notify_error(NULL, regist ? _("Registration Error") : | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
129 | _("Connection Error"), message, NULL); |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
130 | g_free(message); |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
131 | return; |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
132 | } |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
133 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
134 | if (regist) |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
135 | { |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
136 | if (prpl_info->register_user == NULL) |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
137 | return; |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
138 | } |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
139 | else |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
140 | { |
|
10751
e15f4f5927ce
[gaim-migrate @ 12354]
Mark Doliner <markdoliner@pidgin.im>
parents:
10745
diff
changeset
|
141 | if (((password == NULL) || (*password == '\0')) && |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
142 | !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
143 | !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
144 | { |
| 15884 | 145 | purple_debug_error("connection", "Can not connect to account %s without " |
| 146 | "a password.\n", purple_account_get_username(account)); | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
147 | return; |
|
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 | } |
| 5563 | 150 | |
| 15884 | 151 | gc = g_new0(PurpleConnection, 1); |
| 152 | PURPLE_DBUS_REGISTER_POINTER(gc, PurpleConnection); | |
|
11146
c56333373e3c
[gaim-migrate @ 13217]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents:
11033
diff
changeset
|
153 | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
154 | gc->prpl = prpl; |
|
10751
e15f4f5927ce
[gaim-migrate @ 12354]
Mark Doliner <markdoliner@pidgin.im>
parents:
10745
diff
changeset
|
155 | if ((password != NULL) && (*password != '\0')) |
|
e15f4f5927ce
[gaim-migrate @ 12354]
Mark Doliner <markdoliner@pidgin.im>
parents:
10745
diff
changeset
|
156 | gc->password = g_strdup(password); |
| 15884 | 157 | purple_connection_set_account(gc, account); |
| 158 | purple_connection_set_state(gc, PURPLE_CONNECTING); | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
159 | connections = g_list_append(connections, gc); |
| 15884 | 160 | purple_account_set_connection(account, gc); |
| 5563 | 161 | |
| 15884 | 162 | purple_signal_emit(purple_connections_get_handle(), "signing-on", gc); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
163 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
164 | if (regist) |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
165 | { |
| 15884 | 166 | purple_debug_info("connection", "Registering. gc = %p\n", gc); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
167 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
168 | /* set this so we don't auto-reconnect after registering */ |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
169 | gc->wants_to_die = TRUE; |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
170 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
171 | prpl_info->register_user(account); |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
172 | } |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
173 | else |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
174 | { |
| 15884 | 175 | purple_debug_info("connection", "Connecting. gc = %p\n", gc); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
176 | |
| 15884 | 177 | purple_signal_emit(purple_accounts_get_handle(), "account-connecting", account); |
|
11837
2f1206084fef
[gaim-migrate @ 14128]
Mark Doliner <markdoliner@pidgin.im>
parents:
11698
diff
changeset
|
178 | prpl_info->login(account); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
179 | } |
| 5563 | 180 | } |
|
24569
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
181 | void |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
182 | purple_connection_new_unregister(PurpleAccount *account, const char *password, PurpleAccountUnregistrationCb cb, void *user_data) |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
183 | { |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
184 | _purple_connection_new_unregister(account, password, cb, user_data); |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
185 | } |
| 5563 | 186 | |
| 187 | void | |
|
24569
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
188 | _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
|
189 | { |
|
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 | /* 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
|
191 | 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
|
192 | 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
|
193 | PurplePluginProtocolInfo *prpl_info; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25874
diff
changeset
|
194 | |
|
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
|
195 | g_return_if_fail(account != NULL); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25874
diff
changeset
|
196 | |
|
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
|
197 | prpl = purple_find_prpl(purple_account_get_protocol_id(account)); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25874
diff
changeset
|
198 | |
|
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
|
199 | 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
|
200 | 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
|
201 | 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
|
202 | gchar *message; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25874
diff
changeset
|
203 | |
|
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
|
204 | 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
|
205 | 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
|
206 | 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
|
207 | 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
|
208 | 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
|
209 | } |
|
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 | |
|
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 | 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
|
212 | 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
|
213 | 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
|
214 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25874
diff
changeset
|
215 | |
|
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
|
216 | 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
|
217 | !(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
|
218 | !(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
|
219 | { |
|
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
|
220 | 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
|
221 | "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
|
222 | 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
|
223 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25874
diff
changeset
|
224 | |
|
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
|
225 | 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
|
226 | PURPLE_DBUS_REGISTER_POINTER(gc, PurpleConnection); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25874
diff
changeset
|
227 | |
|
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
|
228 | 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
|
229 | 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
|
230 | 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
|
231 | 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
|
232 | 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
|
233 | 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
|
234 | purple_account_set_connection(account, gc); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25874
diff
changeset
|
235 | |
|
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
|
236 | purple_signal_emit(purple_connections_get_handle(), "signing-on", gc); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25874
diff
changeset
|
237 | |
|
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
|
238 | purple_debug_info("connection", "Unregistering. gc = %p\n", gc); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25874
diff
changeset
|
239 | |
|
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
|
240 | 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
|
241 | } |
|
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
|
242 | |
|
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
|
243 | void |
| 15884 | 244 | purple_connection_destroy(PurpleConnection *gc) |
| 5563 | 245 | { |
|
24569
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
246 | _purple_connection_destroy(gc); |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
247 | } |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
248 | |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
249 | void |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
250 | _purple_connection_destroy(PurpleConnection *gc) |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
22336
diff
changeset
|
251 | { |
| 15884 | 252 | 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
|
253 | GSList *buddies; |
| 15884 | 254 | PurplePluginProtocolInfo *prpl_info = NULL; |
|
11507
1a6c8ccce2a9
[gaim-migrate @ 13752]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11305
diff
changeset
|
255 | gboolean remove = FALSE; |
|
5741
0a52405f402f
[gaim-migrate @ 6165]
Christian Hammond <chipx86@chipx86.com>
parents:
5740
diff
changeset
|
256 | |
| 5563 | 257 | g_return_if_fail(gc != NULL); |
| 258 | ||
| 15884 | 259 | account = purple_connection_get_account(gc); |
|
5926
f0c5bbf16793
[gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents:
5905
diff
changeset
|
260 | |
| 15884 | 261 | purple_debug_info("connection", "Disconnecting connection %p\n", gc); |
|
10754
d5f1ddb4146f
[gaim-migrate @ 12357]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
262 | |
| 15884 | 263 | if (purple_connection_get_state(gc) != PURPLE_CONNECTING) |
|
11507
1a6c8ccce2a9
[gaim-migrate @ 13752]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11305
diff
changeset
|
264 | remove = TRUE; |
|
5926
f0c5bbf16793
[gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents:
5905
diff
changeset
|
265 | |
| 15884 | 266 | purple_signal_emit(purple_connections_get_handle(), "signing-off", gc); |
|
5930
cdd2e5397cd3
[gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents:
5926
diff
changeset
|
267 | |
|
10754
d5f1ddb4146f
[gaim-migrate @ 12357]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
268 | while (gc->buddy_chats) |
|
d5f1ddb4146f
[gaim-migrate @ 12357]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
269 | { |
| 15884 | 270 | PurpleConversation *b = gc->buddy_chats->data; |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
271 | |
|
10754
d5f1ddb4146f
[gaim-migrate @ 12357]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
272 | gc->buddy_chats = g_slist_remove(gc->buddy_chats, b); |
| 15884 | 273 | purple_conv_chat_left(PURPLE_CONV_CHAT(b)); |
|
10754
d5f1ddb4146f
[gaim-migrate @ 12357]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
274 | } |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
275 | |
|
10754
d5f1ddb4146f
[gaim-migrate @ 12357]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
276 | update_keepalive(gc, FALSE); |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
277 | |
| 15884 | 278 | purple_proxy_connect_cancel_with_handle(gc); |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
279 | |
| 15884 | 280 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
|
14900
4af8b81519b6
[gaim-migrate @ 17607]
Mark Doliner <markdoliner@pidgin.im>
parents:
14814
diff
changeset
|
281 | if (prpl_info->close) |
|
4af8b81519b6
[gaim-migrate @ 17607]
Mark Doliner <markdoliner@pidgin.im>
parents:
14814
diff
changeset
|
282 | (prpl_info->close)(gc); |
| 5563 | 283 | |
|
14814
479ac60fb641
[gaim-migrate @ 17509]
Daniel Atallah <datallah@pidgin.im>
parents:
14669
diff
changeset
|
284 | /* Clear out the proto data that was freed in the prpl close method*/ |
| 15884 | 285 | 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
|
286 | 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
|
287 | PurpleBuddy *buddy = buddies->data; |
|
24937
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
288 | purple_buddy_set_protocol_data(buddy, NULL); |
|
16863
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16478
diff
changeset
|
289 | buddies = g_slist_delete_link(buddies, buddies); |
|
14814
479ac60fb641
[gaim-migrate @ 17509]
Daniel Atallah <datallah@pidgin.im>
parents:
14669
diff
changeset
|
290 | } |
|
479ac60fb641
[gaim-migrate @ 17509]
Daniel Atallah <datallah@pidgin.im>
parents:
14669
diff
changeset
|
291 | |
|
10754
d5f1ddb4146f
[gaim-migrate @ 12357]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
292 | connections = g_list_remove(connections, gc); |
| 5563 | 293 | |
| 15884 | 294 | purple_connection_set_state(gc, PURPLE_DISCONNECTED); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
295 | |
|
11507
1a6c8ccce2a9
[gaim-migrate @ 13752]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11305
diff
changeset
|
296 | if (remove) |
| 15884 | 297 | purple_blist_remove_account(account); |
|
11507
1a6c8ccce2a9
[gaim-migrate @ 13752]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11305
diff
changeset
|
298 | |
| 15884 | 299 | purple_signal_emit(purple_connections_get_handle(), "signed-off", gc); |
|
5615
2eb715cbbd9b
[gaim-migrate @ 6022]
Christian Hammond <chipx86@chipx86.com>
parents:
5581
diff
changeset
|
300 | |
| 15884 | 301 | purple_account_request_close_with_account(account); |
| 302 | purple_request_close_with_handle(gc); | |
| 303 | purple_notify_close_with_handle(gc); | |
| 5563 | 304 | |
| 15884 | 305 | purple_debug_info("connection", "Destroying connection %p\n", gc); |
|
10742
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
306 | |
| 15884 | 307 | purple_account_set_connection(account, NULL); |
|
10742
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
308 | |
|
13976
2543396bd00e
[gaim-migrate @ 16414]
Mark Doliner <markdoliner@pidgin.im>
parents:
13508
diff
changeset
|
309 | g_free(gc->password); |
|
2543396bd00e
[gaim-migrate @ 16414]
Mark Doliner <markdoliner@pidgin.im>
parents:
13508
diff
changeset
|
310 | g_free(gc->display_name); |
|
9848
708a47f26faa
[gaim-migrate @ 10726]
Dave West <kat@users.sourceforge.net>
parents:
9699
diff
changeset
|
311 | |
|
27336
7b4e3682e5a1
Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
312 | if (gc->disconnect_timeout > 0) |
| 15884 | 313 | purple_timeout_remove(gc->disconnect_timeout); |
|
6029
85d6afa168fb
[gaim-migrate @ 6479]
Mark Doliner <markdoliner@pidgin.im>
parents:
6018
diff
changeset
|
314 | |
| 15884 | 315 | PURPLE_DBUS_UNREGISTER_POINTER(gc); |
|
10742
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
316 | g_free(gc); |
|
6029
85d6afa168fb
[gaim-migrate @ 6479]
Mark Doliner <markdoliner@pidgin.im>
parents:
6018
diff
changeset
|
317 | } |
|
85d6afa168fb
[gaim-migrate @ 6479]
Mark Doliner <markdoliner@pidgin.im>
parents:
6018
diff
changeset
|
318 | |
| 5563 | 319 | /* |
|
8130
58e4e51f514b
[gaim-migrate @ 8835]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
320 | * d:)->-< |
| 5563 | 321 | * |
| 322 | * d:O-\-< | |
|
8130
58e4e51f514b
[gaim-migrate @ 8835]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
323 | * |
| 5563 | 324 | * d:D-/-< |
| 325 | * | |
| 326 | * d8D->-< DANCE! | |
| 327 | */ | |
| 328 | ||
| 329 | void | |
| 15884 | 330 | purple_connection_set_state(PurpleConnection *gc, PurpleConnectionState state) |
| 5563 | 331 | { |
| 15884 | 332 | PurpleConnectionUiOps *ops; |
|
5885
223ac977eed2
[gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents:
5883
diff
changeset
|
333 | |
| 5563 | 334 | g_return_if_fail(gc != NULL); |
| 335 | ||
|
5784
4c9046760b5b
[gaim-migrate @ 6209]
Christian Hammond <chipx86@chipx86.com>
parents:
5741
diff
changeset
|
336 | if (gc->state == state) |
|
4c9046760b5b
[gaim-migrate @ 6209]
Christian Hammond <chipx86@chipx86.com>
parents:
5741
diff
changeset
|
337 | return; |
|
4c9046760b5b
[gaim-migrate @ 6209]
Christian Hammond <chipx86@chipx86.com>
parents:
5741
diff
changeset
|
338 | |
| 5563 | 339 | gc->state = state; |
| 340 | ||
| 15884 | 341 | ops = purple_connections_get_ui_ops(); |
|
5885
223ac977eed2
[gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents:
5883
diff
changeset
|
342 | |
| 15884 | 343 | if (gc->state == PURPLE_CONNECTING) { |
|
5905
62a6bdbc09b7
[gaim-migrate @ 6337]
Robert McQueen <robot101@debian.org>
parents:
5885
diff
changeset
|
344 | connections_connecting = g_list_append(connections_connecting, gc); |
|
62a6bdbc09b7
[gaim-migrate @ 6337]
Robert McQueen <robot101@debian.org>
parents:
5885
diff
changeset
|
345 | } |
|
62a6bdbc09b7
[gaim-migrate @ 6337]
Robert McQueen <robot101@debian.org>
parents:
5885
diff
changeset
|
346 | else { |
|
5885
223ac977eed2
[gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents:
5883
diff
changeset
|
347 | connections_connecting = g_list_remove(connections_connecting, gc); |
|
5905
62a6bdbc09b7
[gaim-migrate @ 6337]
Robert McQueen <robot101@debian.org>
parents:
5885
diff
changeset
|
348 | } |
|
5885
223ac977eed2
[gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents:
5883
diff
changeset
|
349 | |
| 15884 | 350 | if (gc->state == PURPLE_CONNECTED) { |
| 351 | PurpleAccount *account; | |
| 352 | PurplePresence *presence; | |
|
10052
329dad7e2da3
[gaim-migrate @ 11013]
Dave West <kat@users.sourceforge.net>
parents:
9944
diff
changeset
|
353 | |
| 15884 | 354 | account = purple_connection_get_account(gc); |
| 355 | presence = purple_account_get_presence(account); | |
| 5563 | 356 | |
| 357 | /* Set the time the account came online */ | |
| 15884 | 358 | purple_presence_set_login_time(presence, time(NULL)); |
| 5563 | 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, TRUE); |
|
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 on"), |
| 15884 | 367 | purple_account_get_username(account)); |
| 368 | purple_log_write(log, PURPLE_MESSAGE_SYSTEM, | |
| 369 | purple_account_get_username(account), | |
| 370 | purple_presence_get_login_time(presence), | |
|
13508
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
371 | msg); |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
372 | g_free(msg); |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
373 | } |
|
10301
fd24ab69574a
[gaim-migrate @ 11486]
Mark Doliner <markdoliner@pidgin.im>
parents:
10193
diff
changeset
|
374 | } |
|
fd24ab69574a
[gaim-migrate @ 11486]
Mark Doliner <markdoliner@pidgin.im>
parents:
10193
diff
changeset
|
375 | |
| 5563 | 376 | if (ops != NULL && ops->connected != NULL) |
| 377 | ops->connected(gc); | |
| 378 | ||
| 15884 | 379 | purple_blist_add_account(account); |
| 5563 | 380 | |
| 15884 | 381 | purple_signal_emit(purple_connections_get_handle(), "signed-on", gc); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
382 | |
| 5563 | 383 | serv_set_permit_deny(gc); |
|
10745
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
384 | |
|
04039e970a30
[gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents:
10742
diff
changeset
|
385 | update_keepalive(gc, TRUE); |
| 5563 | 386 | } |
| 15884 | 387 | else if (gc->state == PURPLE_DISCONNECTED) { |
| 388 | PurpleAccount *account = purple_connection_get_account(gc); | |
| 8573 | 389 | |
|
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
|
390 | if (purple_prefs_get_bool("/purple/logging/log_system")) |
|
11698
afbf0d8bdacf
[gaim-migrate @ 13989]
Mark Doliner <markdoliner@pidgin.im>
parents:
11562
diff
changeset
|
391 | { |
| 15884 | 392 | PurpleLog *log = purple_account_get_log(account, FALSE); |
|
13508
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
393 | |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
394 | if (log != NULL) |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
395 | { |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
396 | char *msg = g_strdup_printf(_("+++ %s signed off"), |
| 15884 | 397 | purple_account_get_username(account)); |
| 398 | purple_log_write(log, PURPLE_MESSAGE_SYSTEM, | |
| 399 | purple_account_get_username(account), time(NULL), | |
|
13508
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
400 | msg); |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
401 | g_free(msg); |
|
3c66c5a0ca7c
[gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents:
12412
diff
changeset
|
402 | } |
| 8573 | 403 | } |
| 404 | ||
| 15884 | 405 | purple_account_destroy_log(account); |
| 8573 | 406 | |
|
5885
223ac977eed2
[gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents:
5883
diff
changeset
|
407 | if (ops != NULL && ops->disconnected != NULL) |
| 9190 | 408 | ops->disconnected(gc); |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
409 | } |
| 5563 | 410 | } |
| 411 | ||
| 412 | void | |
| 15884 | 413 | purple_connection_set_account(PurpleConnection *gc, PurpleAccount *account) |
| 5563 | 414 | { |
| 415 | g_return_if_fail(gc != NULL); | |
| 416 | g_return_if_fail(account != NULL); | |
| 417 | ||
| 418 | gc->account = account; | |
| 419 | } | |
| 420 | ||
| 421 | void | |
| 15884 | 422 | purple_connection_set_display_name(PurpleConnection *gc, const char *name) |
| 5563 | 423 | { |
| 424 | g_return_if_fail(gc != NULL); | |
| 425 | ||
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14035
diff
changeset
|
426 | g_free(gc->display_name); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14035
diff
changeset
|
427 | gc->display_name = g_strdup(name); |
| 5563 | 428 | } |
| 429 | ||
|
24937
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
430 | void |
|
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
431 | purple_connection_set_protocol_data(PurpleConnection *connection, void *proto_data) { |
|
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
432 | g_return_if_fail(connection != NULL); |
|
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
433 | |
|
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
434 | connection->proto_data = proto_data; |
|
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
435 | } |
|
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
436 | |
| 15884 | 437 | PurpleConnectionState |
| 438 | purple_connection_get_state(const PurpleConnection *gc) | |
| 5563 | 439 | { |
| 15884 | 440 | g_return_val_if_fail(gc != NULL, PURPLE_DISCONNECTED); |
| 5563 | 441 | |
| 442 | return gc->state; | |
| 443 | } | |
| 444 | ||
| 15884 | 445 | PurpleAccount * |
| 446 | purple_connection_get_account(const PurpleConnection *gc) | |
| 5563 | 447 | { |
| 448 | g_return_val_if_fail(gc != NULL, NULL); | |
| 449 | ||
| 450 | return gc->account; | |
| 451 | } | |
| 452 | ||
|
22336
ac905bb0a8ec
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22324
diff
changeset
|
453 | PurplePlugin * |
|
ac905bb0a8ec
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22324
diff
changeset
|
454 | purple_connection_get_prpl(const PurpleConnection *gc) |
|
ac905bb0a8ec
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22324
diff
changeset
|
455 | { |
|
ac905bb0a8ec
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22324
diff
changeset
|
456 | g_return_val_if_fail(gc != NULL, NULL); |
|
ac905bb0a8ec
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22324
diff
changeset
|
457 | |
|
ac905bb0a8ec
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22324
diff
changeset
|
458 | return gc->prpl; |
|
ac905bb0a8ec
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22324
diff
changeset
|
459 | } |
|
ac905bb0a8ec
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22324
diff
changeset
|
460 | |
| 5563 | 461 | const char * |
| 15884 | 462 | purple_connection_get_password(const PurpleConnection *gc) |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
463 | { |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
464 | g_return_val_if_fail(gc != NULL, NULL); |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
465 | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
466 | return gc->password ? gc->password : gc->account->password; |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
467 | } |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
468 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
469 | const char * |
| 15884 | 470 | purple_connection_get_display_name(const PurpleConnection *gc) |
| 5563 | 471 | { |
| 472 | g_return_val_if_fail(gc != NULL, NULL); | |
| 473 | ||
| 474 | return gc->display_name; | |
| 475 | } | |
| 476 | ||
|
24937
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
477 | void * |
|
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
478 | purple_connection_get_protocol_data(const PurpleConnection *connection) { |
|
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
479 | g_return_val_if_fail(connection != NULL, NULL); |
|
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
480 | |
|
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
481 | return connection->proto_data; |
|
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
482 | } |
|
3664132c36c8
Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents:
22336
diff
changeset
|
483 | |
| 5563 | 484 | void |
| 15884 | 485 | purple_connection_update_progress(PurpleConnection *gc, const char *text, |
| 5563 | 486 | size_t step, size_t count) |
| 487 | { | |
| 15884 | 488 | PurpleConnectionUiOps *ops; |
| 5563 | 489 | |
| 490 | g_return_if_fail(gc != NULL); | |
| 491 | g_return_if_fail(text != NULL); | |
| 492 | g_return_if_fail(step < count); | |
| 493 | g_return_if_fail(count > 1); | |
| 494 | ||
| 15884 | 495 | ops = purple_connections_get_ui_ops(); |
| 5563 | 496 | |
| 497 | if (ops != NULL && ops->connect_progress != NULL) | |
| 498 | ops->connect_progress(gc, text, step, count); | |
| 499 | } | |
| 500 | ||
| 501 | void | |
| 15884 | 502 | purple_connection_notice(PurpleConnection *gc, const char *text) |
|
5571
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
503 | { |
| 15884 | 504 | PurpleConnectionUiOps *ops; |
|
5571
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
505 | |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
506 | g_return_if_fail(gc != NULL); |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
507 | g_return_if_fail(text != NULL); |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
508 | |
| 15884 | 509 | ops = purple_connections_get_ui_ops(); |
|
5571
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
510 | |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
511 | if (ops != NULL && ops->notice != NULL) |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
512 | ops->notice(gc, text); |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
513 | } |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
514 | |
|
12412
8abe3226695e
[gaim-migrate @ 14719]
Richard Laager <rlaager@pidgin.im>
parents:
12272
diff
changeset
|
515 | static gboolean |
| 15884 | 516 | purple_connection_disconnect_cb(gpointer data) |
|
10742
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
517 | { |
|
27336
7b4e3682e5a1
Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
518 | PurpleAccount *account; |
|
7b4e3682e5a1
Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
519 | PurpleConnection *gc; |
|
7b4e3682e5a1
Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
520 | char *password; |
|
7b4e3682e5a1
Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
521 | |
|
7b4e3682e5a1
Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
522 | account = data; |
|
7b4e3682e5a1
Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
523 | gc = purple_account_get_connection(account); |
|
7b4e3682e5a1
Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
524 | |
|
7b4e3682e5a1
Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
525 | gc->disconnect_timeout = 0; |
|
7b4e3682e5a1
Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
526 | |
|
7b4e3682e5a1
Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
527 | password = g_strdup(purple_account_get_password(account)); |
| 15884 | 528 | purple_account_disconnect(account); |
| 529 | purple_account_set_password(account, password); | |
| 11562 | 530 | g_free(password); |
|
27336
7b4e3682e5a1
Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
531 | |
|
10742
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
532 | return FALSE; |
|
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
533 | } |
|
2783135f0ecf
[gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
534 | |
|
5571
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
535 | void |
| 15884 | 536 | purple_connection_error(PurpleConnection *gc, const char *text) |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
537 | { |
|
21154
be1799decdb7
Clarify the documentation of the return value of
Will Thompson <resiak@pidgin.im>
parents:
21153
diff
changeset
|
538 | /* 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
|
539 | * be setting wants_to_die before calling this function, so choose |
| 21279 | 540 | * PURPLE_CONNECTION_ERROR_OTHER_ERROR (which is fatal) if it's true, |
| 541 | * and PURPLE_CONNECTION_ERROR_NETWORK_ERROR (which isn't) if not. See | |
| 542 | * the documentation in connection.h. | |
|
21154
be1799decdb7
Clarify the documentation of the return value of
Will Thompson <resiak@pidgin.im>
parents:
21153
diff
changeset
|
543 | */ |
| 21279 | 544 | PurpleConnectionError reason = gc->wants_to_die |
| 545 | ? PURPLE_CONNECTION_ERROR_OTHER_ERROR | |
| 546 | : 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
|
547 | purple_connection_error_reason (gc, reason, text); |
|
20430
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
548 | } |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
549 | |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
550 | void |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
551 | purple_connection_error_reason (PurpleConnection *gc, |
| 21279 | 552 | PurpleConnectionError reason, |
|
20430
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
553 | const char *description) |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
554 | { |
| 15884 | 555 | PurpleConnectionUiOps *ops; |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
556 | |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
557 | g_return_if_fail(gc != NULL); |
| 21279 | 558 | /* This sanity check relies on PURPLE_CONNECTION_ERROR_OTHER_ERROR |
| 559 | * being the last member of the PurpleConnectionError enum in | |
| 560 | * connection.h; if other reasons are added after it, this check should | |
| 561 | * be updated. | |
|
21278
19f6ce8ee4ad
rlaager suggested using the last element of the PurpleDisconnectReason enum
Will Thompson <resiak@pidgin.im>
parents:
21154
diff
changeset
|
562 | */ |
| 21279 | 563 | 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
|
564 | purple_debug_error("connection", |
|
19f6ce8ee4ad
rlaager suggested using the last element of the PurpleDisconnectReason enum
Will Thompson <resiak@pidgin.im>
parents:
21154
diff
changeset
|
565 | "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
|
566 | "valid reason\n", reason); |
| 21279 | 567 | 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
|
568 | } |
|
15848
44463a06e833
Change connection.c:gaim_connection_error() to still work even if the
Mark Doliner <markdoliner@pidgin.im>
parents:
15537
diff
changeset
|
569 | |
|
20430
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
570 | if (description == NULL) { |
|
25456
22f5daf76fe4
Slightly improve this debug error message
Mark Doliner <markdoliner@pidgin.im>
parents:
24569
diff
changeset
|
571 | purple_debug_error("connection", "purple_connection_error_reason called with NULL description\n"); |
|
20430
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
572 | 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
|
573 | } |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
574 | |
| 6393 | 575 | /* If we've already got one error, we don't need any more */ |
|
27336
7b4e3682e5a1
Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
576 | if (gc->disconnect_timeout > 0) |
| 6393 | 577 | return; |
| 578 | ||
| 21279 | 579 | 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
|
580 | |
|
28091
03d2cecdb234
Log the reason for disconnection to the debug log, so that we might
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27336
diff
changeset
|
581 | purple_debug_info("connection", "Connection error on %p (reason: %u description: %s)\n", |
|
03d2cecdb234
Log the reason for disconnection to the debug log, so that we might
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27336
diff
changeset
|
582 | gc, reason, description); |
|
03d2cecdb234
Log the reason for disconnection to the debug log, so that we might
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27336
diff
changeset
|
583 | |
| 15884 | 584 | ops = purple_connections_get_ui_ops(); |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
585 | |
|
20430
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
586 | if (ops != NULL) |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
587 | { |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
588 | if (ops->report_disconnect_reason != NULL) |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
589 | ops->report_disconnect_reason (gc, reason, description); |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
590 | if (ops->report_disconnect != NULL) |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
591 | ops->report_disconnect (gc, description); |
|
bb30dff3da21
Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
592 | } |
| 5727 | 593 | |
|
21285
ca8cb8706802
I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents:
21279
diff
changeset
|
594 | 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
|
595 | gc, reason, description); |
| 5727 | 596 | |
| 15884 | 597 | gc->disconnect_timeout = purple_timeout_add(0, purple_connection_disconnect_cb, |
| 598 | purple_connection_get_account(gc)); | |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
599 | } |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
600 | |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
601 | void |
|
20443
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
602 | 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
|
603 | PurpleSslErrorType ssl_error) |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
604 | { |
| 21279 | 605 | PurpleConnectionError reason; |
|
20443
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
606 | |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
607 | switch (ssl_error) { |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
608 | case PURPLE_SSL_HANDSHAKE_FAILED: |
|
22162
1e0f1dbe89da
Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21865
diff
changeset
|
609 | reason = PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR; |
|
1e0f1dbe89da
Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21865
diff
changeset
|
610 | break; |
|
20443
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
611 | case PURPLE_SSL_CONNECT_FAILED: |
|
22162
1e0f1dbe89da
Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21865
diff
changeset
|
612 | 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
|
613 | break; |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
614 | case PURPLE_SSL_CERTIFICATE_INVALID: |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
615 | /* TODO: maybe PURPLE_SSL_* should be more specific? */ |
|
22163
186613d5bc34
Huh, you want to be able to compile? I clearly (or not so clearly) need new
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22162
diff
changeset
|
616 | 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
|
617 | break; |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
618 | default: |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
619 | g_assert_not_reached (); |
|
22163
186613d5bc34
Huh, you want to be able to compile? I clearly (or not so clearly) need new
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22162
diff
changeset
|
620 | 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
|
621 | } |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
622 | |
| 21279 | 623 | purple_connection_error_reason (gc, reason, |
| 624 | 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
|
625 | } |
|
7487bb69ae76
Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents:
20442
diff
changeset
|
626 | |
|
20431
49979e453876
Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents:
20430
diff
changeset
|
627 | gboolean |
| 21279 | 628 | 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
|
629 | { |
|
49979e453876
Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents:
20430
diff
changeset
|
630 | switch (reason) |
|
49979e453876
Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents:
20430
diff
changeset
|
631 | { |
| 21279 | 632 | case PURPLE_CONNECTION_ERROR_NETWORK_ERROR: |
|
22162
1e0f1dbe89da
Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21865
diff
changeset
|
633 | 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
|
634 | return FALSE; |
|
0ae51085309d
Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents:
21507
diff
changeset
|
635 | 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
|
636 | case PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED: |
| 21279 | 637 | 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
|
638 | 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
|
639 | 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
|
640 | 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
|
641 | case PURPLE_CONNECTION_ERROR_OTHER_ERROR: |
| 21279 | 642 | case PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED: |
| 643 | case PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED: | |
| 644 | case PURPLE_CONNECTION_ERROR_CERT_EXPIRED: | |
| 645 | case PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED: | |
| 646 | case PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH: | |
| 647 | case PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH: | |
| 648 | case PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED: | |
| 649 | 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
|
650 | 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
|
651 | default: |
|
610a45545a40
datallah pointed out that using g_return_if_fail() is preferable to
Will Thompson <resiak@pidgin.im>
parents:
21149
diff
changeset
|
652 | 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
|
653 | } |
|
49979e453876
Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents:
20430
diff
changeset
|
654 | } |
|
49979e453876
Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents:
20430
diff
changeset
|
655 | |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
656 | void |
| 15884 | 657 | purple_connections_disconnect_all(void) |
| 5563 | 658 | { |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
659 | GList *l; |
| 15884 | 660 | PurpleConnection *gc; |
| 5563 | 661 | |
| 15884 | 662 | while ((l = purple_connections_get_all()) != NULL) { |
|
6113
5bc7394e69ea
[gaim-migrate @ 6575]
Mark Doliner <markdoliner@pidgin.im>
parents:
6111
diff
changeset
|
663 | gc = l->data; |
|
5bc7394e69ea
[gaim-migrate @ 6575]
Mark Doliner <markdoliner@pidgin.im>
parents:
6111
diff
changeset
|
664 | gc->wants_to_die = TRUE; |
| 15884 | 665 | purple_account_disconnect(gc->account); |
|
6113
5bc7394e69ea
[gaim-migrate @ 6575]
Mark Doliner <markdoliner@pidgin.im>
parents:
6111
diff
changeset
|
666 | } |
| 5563 | 667 | } |
| 668 | ||
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
669 | GList * |
| 15884 | 670 | purple_connections_get_all(void) |
| 5563 | 671 | { |
| 672 | return connections; | |
| 673 | } | |
| 674 | ||
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
675 | GList * |
| 15884 | 676 | purple_connections_get_connecting(void) |
|
5788
dd6e33a59151
[gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents:
5784
diff
changeset
|
677 | { |
|
dd6e33a59151
[gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents:
5784
diff
changeset
|
678 | return connections_connecting; |
|
dd6e33a59151
[gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents:
5784
diff
changeset
|
679 | } |
|
dd6e33a59151
[gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents:
5784
diff
changeset
|
680 | |
| 5563 | 681 | void |
| 15884 | 682 | purple_connections_set_ui_ops(PurpleConnectionUiOps *ops) |
|
7035
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
683 | { |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
684 | connection_ui_ops = ops; |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
685 | } |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
686 | |
| 15884 | 687 | PurpleConnectionUiOps * |
| 688 | purple_connections_get_ui_ops(void) | |
|
7035
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
689 | { |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
690 | return connection_ui_ops; |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
691 | } |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
692 | |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
693 | void |
| 15884 | 694 | purple_connections_init(void) |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
695 | { |
| 15884 | 696 | void *handle = purple_connections_get_handle(); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
697 | |
| 15884 | 698 | purple_signal_register(handle, "signing-on", |
| 699 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 700 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 701 | PURPLE_SUBTYPE_CONNECTION)); | |
|
6564
a7a2c1927544
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6533
diff
changeset
|
702 | |
| 15884 | 703 | purple_signal_register(handle, "signed-on", |
| 704 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 705 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 706 | PURPLE_SUBTYPE_CONNECTION)); | |
|
6564
a7a2c1927544
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6533
diff
changeset
|
707 | |
| 15884 | 708 | purple_signal_register(handle, "signing-off", |
| 709 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 710 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 711 | PURPLE_SUBTYPE_CONNECTION)); | |
|
6564
a7a2c1927544
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6533
diff
changeset
|
712 | |
| 15884 | 713 | purple_signal_register(handle, "signed-off", |
| 714 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 715 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 716 | 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
|
717 | |
|
ca8cb8706802
I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents:
21279
diff
changeset
|
718 | 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
|
719 | 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
|
720 | 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
|
721 | 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
|
722 | 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
|
723 | 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
|
724 | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
725 | } |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
726 | |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
727 | void |
| 15884 | 728 | purple_connections_uninit(void) |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
729 | { |
| 15884 | 730 | purple_signals_unregister_by_instance(purple_connections_get_handle()); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
731 | } |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
732 | |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
733 | void * |
| 15884 | 734 | purple_connections_get_handle(void) |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
735 | { |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
736 | return &connections_handle; |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6468
diff
changeset
|
737 | } |