libpurple/connection.c

Thu, 25 Aug 2022 23:25:12 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 25 Aug 2022 23:25:12 -0500
branch
gtk4
changeset 41598
2b34cd990c16
parent 41463
6b13615303cc
child 41677
7c01d55a8aeb
permissions
-rw-r--r--

Replace the style-updated signal with GtkIconTheme:changed

Testing Done:
Ran and make sure the `GWarning` went away.

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

20147
66f05a854eee applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents: 19897
diff changeset
1 /* purple
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
3 * Purple is the legal property of its developers, whose names are too numerous
8046
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7956
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7956
diff changeset
5 * source distribution.
5631
7f510b22ccf5 [gaim-migrate @ 6038]
Nathan Walp <nwalp@pidgin.im>
parents: 5624
diff changeset
6 *
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * (at your option) any later version.
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 *
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * GNU General Public License for more details.
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 *
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * 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
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 */
24569
5dbd0617a27d Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents: 22336
diff changeset
21
40441
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
22 #include <glib/gi18n-lib.h>
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
23
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
24 #include "internal.h"
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
25
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
26 #include "account.h"
34706
02cb08146888 Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents: 34645
diff changeset
27 #include "buddylist.h"
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 #include "connection.h"
5717
2f3a377de638 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents: 5676
diff changeset
29 #include "debug.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
30 #include "notify.h"
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
31 #include "prefs.h"
14900
4af8b81519b6 [gaim-migrate @ 17607]
Mark Doliner <markdoliner@pidgin.im>
parents: 14814
diff changeset
32 #include "proxy.h"
41007
90d2dee9b3dc Fix the includes for the purpleenums rename
Gary Kramlich <grim@reaperworld.com>
parents: 40813
diff changeset
33 #include "purpleenums.h"
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
34 #include "purpleprivate.h"
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40654
diff changeset
35 #include "purpleprotocolserver.h"
40339
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40195
diff changeset
36 #include "purpleprotocolfactory.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
37 #include "request.h"
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
38 #include "server.h"
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
39 #include "signals.h"
6106
1dc08be40f0a [gaim-migrate @ 6567]
Mark Doliner <markdoliner@pidgin.im>
parents: 6076
diff changeset
40 #include "util.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
41
39549
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
42 /**
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
43 * PurpleConnection:
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
44 *
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
45 * Represents an active connection on an account.
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
46 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
47 struct _PurpleConnection {
39549
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
48 GObject gparent;
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
49
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
50 gchar *id;
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
51
37069
22bf5ea00006 Merge gtkdoc-conversion
Ankit Vani <a@nevitus.org>
parents: 37066 35458
diff changeset
52 PurpleProtocol *protocol; /* The protocol. */
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
53 PurpleConnectionFlags flags; /* Connection flags. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
54
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
55 PurpleConnectionState state; /* The connection state. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
56
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
57 PurpleAccount *account; /* The account being connected to. */
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
58 char *password; /* The password used. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
59
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
60 GSList *active_chats; /* A list of active chats
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
61 (#PurpleChatConversation structs). */
35097
0d6a2ff4f776 Minor comment fiddling.
Mark Doliner <mark@kingant.net>
parents: 35085
diff changeset
62
0d6a2ff4f776 Minor comment fiddling.
Mark Doliner <mark@kingant.net>
parents: 35085
diff changeset
63 /* TODO Remove this and use protocol-specific subclasses. */
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
64 void *proto_data; /* Protocol-specific data. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
65
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
66 char *display_name; /* How you appear to other people. */
39520
7f9952eeb6a7 libpurple: Refactor keepalive mechanism to use GSource pointers
Petteri Pitkänen <petepitk@gmail.com>
parents: 39518
diff changeset
67 GSource *keepalive; /* Keep-alive. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
68
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
69 /* Wants to Die state. This is set when the user chooses to log out, or
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
70 * when the protocol is disconnected and should not be automatically
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36626
diff changeset
71 * reconnected (incorrect password, etc.). Protocols should rely on
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
72 * purple_connection_error() to set this for them rather than
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
73 * setting it themselves.
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
74 * See purple_connection_error_is_fatal()
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
75 */
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
76 gboolean wants_to_die;
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
77
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
78 gboolean is_finalizing; /* The object is being destroyed. */
35130
2033f0755d68 Fix a glib warning, by not calling g_object_notify while the connection object is being destroyed. There may be a better fix possible, though
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35097
diff changeset
79
41083
590d533cf290 Fix several typos in libpurple
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41007
diff changeset
80 /* The connection error and its description if an error occurred. */
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
81 PurpleConnectionErrorInfo *error_info;
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
82
41083
590d533cf290 Fix several typos in libpurple
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41007
diff changeset
83 guint disconnect_timeout; /* Timer used for nasty stack tricks. */
39549
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
84 } PurpleConnectionPrivate;
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
85
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
86 enum {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
87 PROP_0,
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
88 PROP_ID,
36366
202c60d1300f Refactored connection, conversation, conversationtypes to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents: 36362
diff changeset
89 PROP_PROTOCOL,
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
90 PROP_FLAGS,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
91 PROP_STATE,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
92 PROP_ACCOUNT,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
93 PROP_PASSWORD,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
94 PROP_DISPLAY_NAME,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
95 PROP_LAST
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
96 };
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
97
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
98 static GParamSpec *properties[PROP_LAST] = {NULL, };
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
99
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 static GList *connections = NULL;
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
101 static GList *connections_connecting = NULL;
40369
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
102 static GList *connections_connected = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
103 static PurpleConnectionUiOps *connection_ui_ops = NULL;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
105 static int connections_handle;
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
106
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
107 static PurpleConnectionErrorInfo *
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
108 purple_connection_error_info_new(PurpleConnectionError type,
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
109 const gchar *description);
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
110
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
111 G_DEFINE_TYPE(PurpleConnection, purple_connection, G_TYPE_OBJECT)
39433
f033955d125a Use G_DEFINE_TYPE_WITH_PRIVATE for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39352
diff changeset
112
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
113 /**************************************************************************
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
114 * Connection API
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
115 **************************************************************************/
10745
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
116 static gboolean
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
117 send_keepalive(gpointer data)
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
118 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
119 PurpleConnection *gc = data;
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
120
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
121 purple_protocol_server_keepalive(PURPLE_PROTOCOL_SERVER(gc->protocol), gc);
10745
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
122
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
123 return TRUE;
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
124 }
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
125
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
126 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
127 update_keepalive(PurpleConnection *gc, gboolean on)
10745
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
128 {
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
129 if(!PURPLE_PROTOCOL_IMPLEMENTS(gc->protocol, SERVER, keepalive)) {
14545
f8b45a0ddac5 [gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
130 return;
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
131 }
14545
f8b45a0ddac5 [gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
132
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
133 if(on && !gc->keepalive) {
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
134 int interval = purple_protocol_server_get_keepalive_interval(PURPLE_PROTOCOL_SERVER(gc->protocol));
39518
6141cf90e5b8 libpurple: Make keepalive interval configurable
Petteri Pitkänen <petepitk@gmail.com>
parents: 39517
diff changeset
135 purple_debug_info("connection", "Activating keepalive to %d seconds.", interval);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
136 gc->keepalive = g_main_context_find_source_by_id(NULL, g_timeout_add_seconds(interval, send_keepalive, gc));
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
137 } else if (!on && gc->keepalive) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
138 purple_debug_info("connection", "Deactivating keepalive.\n");
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
139 g_source_destroy(gc->keepalive);
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
140 gc->keepalive = NULL;
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
141 }
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 /*
8130
58e4e51f514b [gaim-migrate @ 8835]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
145 * d:)->-<
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 *
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 * d:O-\-<
8130
58e4e51f514b [gaim-migrate @ 8835]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
148 *
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 * d:D-/-<
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 *
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 * d8D->-< DANCE!
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 */
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
155 purple_connection_set_state(PurpleConnection *gc, PurpleConnectionState state)
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
157 PurpleConnectionUiOps *ops;
5885
223ac977eed2 [gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents: 5883
diff changeset
158
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
159 g_return_if_fail(PURPLE_IS_CONNECTION(gc));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
160
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
161 if(gc->state == state) {
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
162 return;
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
163 }
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
165 gc->state = state;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
167 ops = purple_connections_get_ui_ops();
5885
223ac977eed2 [gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents: 5883
diff changeset
168
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
169 if(gc->state == PURPLE_CONNECTION_CONNECTING) {
5905
62a6bdbc09b7 [gaim-migrate @ 6337]
Robert McQueen <robot101@debian.org>
parents: 5885
diff changeset
170 connections_connecting = g_list_append(connections_connecting, gc);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
171 } else {
5885
223ac977eed2 [gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents: 5883
diff changeset
172 connections_connecting = g_list_remove(connections_connecting, gc);
5905
62a6bdbc09b7 [gaim-migrate @ 6337]
Robert McQueen <robot101@debian.org>
parents: 5885
diff changeset
173 }
5885
223ac977eed2 [gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents: 5883
diff changeset
174
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
175 if(gc->state == PURPLE_CONNECTION_CONNECTED) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
176 PurpleAccount *account;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
177 PurplePresence *presence;
40369
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
178 gboolean emit_online = FALSE;
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
179 gpointer handle = NULL;
10052
329dad7e2da3 [gaim-migrate @ 11013]
Dave West <kat@users.sourceforge.net>
parents: 9944
diff changeset
180
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
181 account = purple_connection_get_account(gc);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
182 presence = purple_account_get_presence(account);
40369
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
183 handle = purple_connections_get_handle();
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 /* Set the time the account came online */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
186 purple_presence_set_login_time(presence, time(NULL));
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
188 if(ops != NULL && ops->connected != NULL) {
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 ops->connected(gc);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
190 }
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
192 purple_blist_add_account(account);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193
40369
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
194 purple_signal_emit(handle, "signed-on", gc);
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
195 purple_signal_emit_return_1(handle, "autojoin", gc);
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
196
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35458
diff changeset
197 purple_serv_set_permit_deny(gc);
10745
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
198
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
199 update_keepalive(gc, TRUE);
40369
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
200
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
201 /* check if connections_connected is NULL, if so we need to emit the
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
202 * online signal.
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
203 */
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
204 if(connections_connected == NULL) {
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
205 emit_online = TRUE;
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
206 }
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
207
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
208 connections_connected = g_list_append(connections_connected, gc);
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
209
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
210 if(emit_online) {
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
211 purple_signal_emit(handle, "online");
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
212 }
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
213 } else if(gc->state == PURPLE_CONNECTION_DISCONNECTED) {
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
214 if(ops != NULL && ops->disconnected != NULL) {
9190
251729887ad8 [gaim-migrate @ 9985]
Evan Schoenberg <evands@pidgin.im>
parents: 9019
diff changeset
215 ops->disconnected(gc);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
216 }
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
217 }
35012
e07a9b9c6bda Cleaned up properties and added g_object_notify calls for PurpleConnection and PurpleConversation's
Ankit Vani <a@nevitus.org>
parents: 35000
diff changeset
218
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
219 if(!gc->is_finalizing) {
35130
2033f0755d68 Fix a glib warning, by not calling g_object_notify while the connection object is being destroyed. There may be a better fix possible, though
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35097
diff changeset
220 g_object_notify_by_pspec(G_OBJECT(gc), properties[PROP_STATE]);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
221 }
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 void
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
225 purple_connection_set_flags(PurpleConnection *gc, PurpleConnectionFlags flags)
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
226 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
227 g_return_if_fail(PURPLE_IS_CONNECTION(gc));
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
228
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
229 gc->flags = flags;
35012
e07a9b9c6bda Cleaned up properties and added g_object_notify calls for PurpleConnection and PurpleConversation's
Ankit Vani <a@nevitus.org>
parents: 35000
diff changeset
230
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
231 if(!gc->is_finalizing) {
36059
c568fcefdb82 Imgupload: hook newly created connections
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35597
diff changeset
232 g_object_notify_by_pspec(G_OBJECT(gc), properties[PROP_FLAGS]);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
233 }
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
234 }
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
235
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
236 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
237 purple_connection_set_display_name(PurpleConnection *gc, const gchar *name) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
238 g_return_if_fail(PURPLE_IS_CONNECTION(gc));
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
239
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
240 g_free(gc->display_name);
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
241 gc->display_name = g_strdup(name);
35012
e07a9b9c6bda Cleaned up properties and added g_object_notify calls for PurpleConnection and PurpleConversation's
Ankit Vani <a@nevitus.org>
parents: 35000
diff changeset
242
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
243 g_object_notify_by_pspec(G_OBJECT(gc), properties[PROP_DISPLAY_NAME]);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245
24937
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
246 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
247 purple_connection_set_protocol_data(PurpleConnection *gc, void *proto_data) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
248 g_return_if_fail(PURPLE_IS_CONNECTION(gc));
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
249
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
250 gc->proto_data = proto_data;
24937
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
251 }
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
252
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
253 PurpleConnectionState
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
254 purple_connection_get_state(PurpleConnection *gc) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
255 g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), PURPLE_CONNECTION_DISCONNECTED);
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
256
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
257 return gc->state;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
260 PurpleConnectionFlags
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
261 purple_connection_get_flags(PurpleConnection *gc) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
262 g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), 0);
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
263
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
264 return gc->flags;
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
265 }
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
266
36067
df9f5de00ea2 PurpleSocket: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36059
diff changeset
267 gboolean
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
268 purple_connection_is_disconnecting(PurpleConnection *gc) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
269 g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), TRUE);
36067
df9f5de00ea2 PurpleSocket: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36059
diff changeset
270
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
271 return gc->is_finalizing;
36067
df9f5de00ea2 PurpleSocket: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36059
diff changeset
272 }
df9f5de00ea2 PurpleSocket: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36059
diff changeset
273
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
274 PurpleAccount *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
275 purple_connection_get_account(PurpleConnection *gc) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
276 g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), NULL);
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
277
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
278 return gc->account;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
281 const gchar *
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
282 purple_connection_get_id(PurpleConnection *connection) {
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
283 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), NULL);
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
284
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
285 return connection->id;
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
286 }
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
287
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36477
diff changeset
288 PurpleProtocol *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
289 purple_connection_get_protocol(PurpleConnection *gc) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
290 g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), NULL);
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
291
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
292 return gc->protocol;
22336
ac905bb0a8ec Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22324
diff changeset
293 }
ac905bb0a8ec Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22324
diff changeset
294
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 const char *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
296 purple_connection_get_password(PurpleConnection *gc) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
297 g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), NULL);
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
298
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
299 return gc->password;
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
300 }
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
301
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
302 GSList *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
303 purple_connection_get_active_chats(PurpleConnection *gc) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
304 g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), NULL);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
305
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
306 return gc->active_chats;
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
307 }
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
308
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
309 const char *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
310 purple_connection_get_display_name(PurpleConnection *gc) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
311 g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), NULL);
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
312
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
313 return gc->display_name;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
315
24937
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
316 void *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
317 purple_connection_get_protocol_data(PurpleConnection *gc) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
318 g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), NULL);
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
319
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
320 return gc->proto_data;
24937
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
321 }
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
322
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
324 _purple_connection_add_active_chat(PurpleConnection *gc,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
325 PurpleChatConversation *chat)
34755
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
326 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
327 g_return_if_fail(PURPLE_IS_CONNECTION(gc));
34755
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
328
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
329 gc->active_chats = g_slist_append(gc->active_chats, chat);
34755
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
330 }
24937
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
331
34755
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
332 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
333 _purple_connection_remove_active_chat(PurpleConnection *gc,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
334 PurpleChatConversation *chat)
34755
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
335 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
336 g_return_if_fail(PURPLE_IS_CONNECTION(gc));
34755
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
337
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
338 gc->active_chats = g_slist_remove(gc->active_chats, chat);
34755
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
339 }
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
340
34877
5b3c720b9077 Added missing internal function, used by account.c
Ankit Vani <a@nevitus.org>
parents: 34866
diff changeset
341 gboolean
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
342 _purple_connection_wants_to_die(PurpleConnection *gc) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
343 g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), FALSE);
34877
5b3c720b9077 Added missing internal function, used by account.c
Ankit Vani <a@nevitus.org>
parents: 34866
diff changeset
344
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
345 return gc->wants_to_die;
24937
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
346 }
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
347
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
349 purple_connection_update_progress(PurpleConnection *gc, const char *text,
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
350 size_t step, size_t count)
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
352 PurpleConnectionUiOps *ops;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34967
diff changeset
354 g_return_if_fail(PURPLE_IS_CONNECTION(gc));
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355 g_return_if_fail(text != NULL);
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
356 g_return_if_fail(step < count);
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357 g_return_if_fail(count > 1);
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
359 ops = purple_connections_get_ui_ops();
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
360
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
361 if(ops != NULL && ops->connect_progress != NULL) {
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 ops->connect_progress(gc, text, step, count);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
363 }
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
367 purple_connection_notice(PurpleConnection *gc, const char *text) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
368 PurpleConnectionUiOps *ops;
5571
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
369
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34967
diff changeset
370 g_return_if_fail(PURPLE_IS_CONNECTION(gc));
5571
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
371 g_return_if_fail(text != NULL);
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
372
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
373 ops = purple_connections_get_ui_ops();
5571
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
374
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
375 if(ops != NULL && ops->notice != NULL) {
5571
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
376 ops->notice(gc, text);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
377 }
5571
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
378 }
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
379
12412
8abe3226695e [gaim-migrate @ 14719]
Richard Laager <rlaager@pidgin.im>
parents: 12272
diff changeset
380 static gboolean
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
381 purple_connection_disconnect_cb(gpointer data) {
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
382 PurpleAccount *account = data;
27336
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
383 PurpleConnection *gc;
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
384
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
385 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
386
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
387 if(PURPLE_IS_CONNECTION(gc)) {
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
388 gc->disconnect_timeout = 0;
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
389 }
27336
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
390
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
391 purple_account_disconnect(account);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
392
10742
2783135f0ecf [gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents: 10740
diff changeset
393 return FALSE;
2783135f0ecf [gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents: 10740
diff changeset
394 }
2783135f0ecf [gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents: 10740
diff changeset
395
5571
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
396 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
397 purple_connection_error(PurpleConnection *gc,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
398 PurpleConnectionError reason,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
399 const char *description)
20430
bb30dff3da21 Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents: 19897
diff changeset
400 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
401 PurpleConnectionUiOps *ops;
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
402
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
403 g_return_if_fail(PURPLE_IS_CONNECTION(gc));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
404
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
405 /* This sanity check relies on PURPLE_CONNECTION_ERROR_OTHER_ERROR
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
406 * being the last member of the PurpleConnectionError enum in
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
407 * connection.h; if other reasons are added after it, this check should
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
408 * be updated.
21278
19f6ce8ee4ad rlaager suggested using the last element of the PurpleDisconnectReason enum
Will Thompson <resiak@pidgin.im>
parents: 21154
diff changeset
409 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
410 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
411 purple_debug_error("connection",
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32156
diff changeset
412 "purple_connection_error: reason %u isn't a "
21278
19f6ce8ee4ad rlaager suggested using the last element of the PurpleDisconnectReason enum
Will Thompson <resiak@pidgin.im>
parents: 21154
diff changeset
413 "valid reason\n", reason);
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
414 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
415 }
15848
44463a06e833 Change connection.c:gaim_connection_error() to still work even if the
Mark Doliner <markdoliner@pidgin.im>
parents: 15537
diff changeset
416
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
417 if(description == NULL) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32156
diff changeset
418 purple_debug_error("connection", "purple_connection_error called with NULL description\n");
20430
bb30dff3da21 Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents: 19897
diff changeset
419 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
420 }
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
421
6393
b845f8d02597 [gaim-migrate @ 6898]
Nathan Walp <nwalp@pidgin.im>
parents: 6297
diff changeset
422 /* If we've already got one error, we don't need any more */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
423 if(purple_connection_get_error_info(gc)) {
6393
b845f8d02597 [gaim-migrate @ 6898]
Nathan Walp <nwalp@pidgin.im>
parents: 6297
diff changeset
424 return;
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
425 }
6393
b845f8d02597 [gaim-migrate @ 6898]
Nathan Walp <nwalp@pidgin.im>
parents: 6297
diff changeset
426
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
427 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
428
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
429 purple_debug_info("connection",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
430 "Connection error on %p (reason: %u description: %s)\n",
28091
03d2cecdb234 Log the reason for disconnection to the debug log, so that we might
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 27336
diff changeset
431 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
432
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
433 ops = purple_connections_get_ui_ops();
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
434
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
435 if(ops && ops->report_disconnect) {
32153
121f15699f88 Rename the report_disconnect_reason cb function to report_disconnect
Mark Doliner <markdoliner@pidgin.im>
parents: 32152
diff changeset
436 ops->report_disconnect(gc, reason, description);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
437 }
5727
883d5bc2eb0d [gaim-migrate @ 6150]
Nathan Walp <nwalp@pidgin.im>
parents: 5725
diff changeset
438
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
439 gc->error_info = purple_connection_error_info_new(reason, description);
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
440
21285
ca8cb8706802 I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents: 21279
diff changeset
441 purple_signal_emit(purple_connections_get_handle(), "connection-error",
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
442 gc, reason, description);
5727
883d5bc2eb0d [gaim-migrate @ 6150]
Nathan Walp <nwalp@pidgin.im>
parents: 5725
diff changeset
443
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
444 gc->disconnect_timeout = g_timeout_add(0, purple_connection_disconnect_cb,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
445 purple_connection_get_account(gc));
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
446 }
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
447
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
448 PurpleConnectionErrorInfo *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
449 purple_connection_get_error_info(PurpleConnection *gc) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
450 g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), NULL);
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
451
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
452 return gc->error_info;
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
453 }
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
454
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
455 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
456 purple_connection_ssl_error(PurpleConnection *gc,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
457 PurpleSslErrorType ssl_error)
20443
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
458 {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
459 PurpleConnectionError reason;
40347
1d7bfb35d82f Move SSL connection error codes in connection.h.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40339
diff changeset
460 const gchar *message;
20443
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
461
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
462 switch (ssl_error) {
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
463 case PURPLE_SSL_HANDSHAKE_FAILED:
40347
1d7bfb35d82f Move SSL connection error codes in connection.h.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40339
diff changeset
464 message = _("SSL Handshake Failed");
22162
1e0f1dbe89da Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21865
diff changeset
465 reason = PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR;
1e0f1dbe89da Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21865
diff changeset
466 break;
20443
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
467 case PURPLE_SSL_CONNECT_FAILED:
40347
1d7bfb35d82f Move SSL connection error codes in connection.h.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40339
diff changeset
468 message = _("SSL Connection Failed");
22162
1e0f1dbe89da Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21865
diff changeset
469 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
470 break;
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
471 case PURPLE_SSL_CERTIFICATE_INVALID:
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
472 /* TODO: maybe PURPLE_SSL_* should be more specific? */
40347
1d7bfb35d82f Move SSL connection error codes in connection.h.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40339
diff changeset
473 message = _("SSL peer presented an invalid certificate");
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
474 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
475 break;
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
476 default:
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
477 g_assert_not_reached ();
40347
1d7bfb35d82f Move SSL connection error codes in connection.h.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40339
diff changeset
478 message = _("Unknown SSL error");
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
479 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
480 }
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
481
40347
1d7bfb35d82f Move SSL connection error codes in connection.h.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40339
diff changeset
482 purple_connection_error(gc, reason, message);
20443
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
483 }
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
484
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
485 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
486 purple_connection_g_error(PurpleConnection *pc, const GError *error) {
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
487 PurpleConnectionError reason;
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
488
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
489 if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
490 /* Not a connection error. Ignore. */
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
491 return;
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
492 }
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
493
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
494 if(error->domain == G_TLS_ERROR) {
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
495 switch (error->code) {
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
496 case G_TLS_ERROR_UNAVAILABLE:
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
497 reason = PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT;
37669
13cf92fa0198 connection: Taking breaks when coding helps reduce errors
Mike Ruprecht <cmaiku@gmail.com>
parents: 37666
diff changeset
498 break;
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
499 case G_TLS_ERROR_NOT_TLS:
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
500 case G_TLS_ERROR_HANDSHAKE:
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
501 reason = PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR;
37669
13cf92fa0198 connection: Taking breaks when coding helps reduce errors
Mike Ruprecht <cmaiku@gmail.com>
parents: 37666
diff changeset
502 break;
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
503 case G_TLS_ERROR_BAD_CERTIFICATE:
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
504 case G_TLS_ERROR_CERTIFICATE_REQUIRED:
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
505 reason = PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR;
37669
13cf92fa0198 connection: Taking breaks when coding helps reduce errors
Mike Ruprecht <cmaiku@gmail.com>
parents: 37666
diff changeset
506 break;
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
507 case G_TLS_ERROR_EOF:
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
508 case G_TLS_ERROR_MISC:
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
509 default:
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
510 reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
511 }
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
512 } else if (error->domain == G_IO_ERROR) {
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
513 reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
37961
2ee4c67768f4 connection: Support PurpleConnectionError GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents: 37959
diff changeset
514 } else if (error->domain == PURPLE_CONNECTION_ERROR) {
2ee4c67768f4 connection: Support PurpleConnectionError GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents: 37959
diff changeset
515 reason = error->code;
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
516 } else {
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
517 reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
518 }
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
519
37958
e03cbceed96a connection: Drop description argument from purple_connection_g_error()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37669
diff changeset
520 purple_connection_error(pc, reason, error->message);
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
521 }
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
522
37959
e76677ed819c connection: Add purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37958
diff changeset
523 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
524 purple_connection_take_error(PurpleConnection *pc, GError *error) {
37959
e76677ed819c connection: Add purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37958
diff changeset
525 purple_connection_g_error(pc, error);
e76677ed819c connection: Add purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37958
diff changeset
526 g_error_free(error);
e76677ed819c connection: Add purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37958
diff changeset
527 }
e76677ed819c connection: Add purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37958
diff changeset
528
20431
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
529 gboolean
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
530 purple_connection_error_is_fatal(PurpleConnectionError reason) {
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
531 switch (reason) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
532 case PURPLE_CONNECTION_ERROR_NETWORK_ERROR:
22162
1e0f1dbe89da Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21865
diff changeset
533 case PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR:
41463
6b13615303cc Add some custom connection errors
Gary Kramlich <grim@reaperworld.com>
parents: 41429
diff changeset
534 case PURPLE_CONNECTION_ERROR_CUSTOM_TEMPORARY:
21508
0ae51085309d Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents: 21507
diff changeset
535 return FALSE;
0ae51085309d Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents: 21507
diff changeset
536 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
537 case PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED:
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
538 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
539 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
540 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
541 case PURPLE_CONNECTION_ERROR_INVALID_SETTINGS:
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
542 case PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
543 case PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
544 case PURPLE_CONNECTION_ERROR_CERT_EXPIRED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
545 case PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
546 case PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
547 case PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
548 case PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
549 case PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR:
41463
6b13615303cc Add some custom connection errors
Gary Kramlich <grim@reaperworld.com>
parents: 41429
diff changeset
550 case PURPLE_CONNECTION_ERROR_CUSTOM_FATAL:
6b13615303cc Add some custom connection errors
Gary Kramlich <grim@reaperworld.com>
parents: 41429
diff changeset
551 case PURPLE_CONNECTION_ERROR_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
552 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
553 default:
610a45545a40 datallah pointed out that using g_return_if_fail() is preferable to
Will Thompson <resiak@pidgin.im>
parents: 21149
diff changeset
554 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
555 }
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
556 }
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
557
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
558 void
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
559 purple_connection_update_last_received(PurpleConnection *gc) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
560 g_return_if_fail(PURPLE_IS_CONNECTION(gc));
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
561
39517
dd799b5d4e50 libpurple: Keepalive mechanism fixes
Petteri Pitkänen <petepitk@gmail.com>
parents: 39436
diff changeset
562 /*
dd799b5d4e50 libpurple: Keepalive mechanism fixes
Petteri Pitkänen <petepitk@gmail.com>
parents: 39436
diff changeset
563 * For safety, actually this function shouldn't be called when the
dd799b5d4e50 libpurple: Keepalive mechanism fixes
Petteri Pitkänen <petepitk@gmail.com>
parents: 39436
diff changeset
564 * keepalive mechanism is inactive.
dd799b5d4e50 libpurple: Keepalive mechanism fixes
Petteri Pitkänen <petepitk@gmail.com>
parents: 39436
diff changeset
565 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
566 if(gc->keepalive) {
39863
60a4930ea197 Fix some doc comments and move the comment about purple_timeout_reset to it's new home
Gary Kramlich <grim@reaperworld.com>
parents: 39860
diff changeset
567 /* The #GTimeoutSource API doesn't expose a function to reset when a
60a4930ea197 Fix some doc comments and move the comment about purple_timeout_reset to it's new home
Gary Kramlich <grim@reaperworld.com>
parents: 39860
diff changeset
568 * #GTimeoutSource will dispatch the next time, but because it works to
60a4930ea197 Fix some doc comments and move the comment about purple_timeout_reset to it's new home
Gary Kramlich <grim@reaperworld.com>
parents: 39860
diff changeset
569 * directly call g_source_set_ready_time() on a #GTimeoutSource, and since
60a4930ea197 Fix some doc comments and move the comment about purple_timeout_reset to it's new home
Gary Kramlich <grim@reaperworld.com>
parents: 39860
diff changeset
570 * it seems unlikely that the implementation will change, we just do that
60a4930ea197 Fix some doc comments and move the comment about purple_timeout_reset to it's new home
Gary Kramlich <grim@reaperworld.com>
parents: 39860
diff changeset
571 * for now as a workaround for this API shortcoming.
60a4930ea197 Fix some doc comments and move the comment about purple_timeout_reset to it's new home
Gary Kramlich <grim@reaperworld.com>
parents: 39860
diff changeset
572 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
573 gint64 seconds_from_now = purple_protocol_server_get_keepalive_interval(PURPLE_PROTOCOL_SERVER(gc->protocol));
39860
10031444a7c6 remove purple_timeout_reset and put it's implementation in the one place it was used
Gary Kramlich <grim@reaperworld.com>
parents: 39782
diff changeset
574
10031444a7c6 remove purple_timeout_reset and put it's implementation in the one place it was used
Gary Kramlich <grim@reaperworld.com>
parents: 39782
diff changeset
575 g_source_set_ready_time(
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
576 gc->keepalive,
39860
10031444a7c6 remove purple_timeout_reset and put it's implementation in the one place it was used
Gary Kramlich <grim@reaperworld.com>
parents: 39782
diff changeset
577 g_get_monotonic_time() + (seconds_from_now * G_USEC_PER_SEC)
10031444a7c6 remove purple_timeout_reset and put it's implementation in the one place it was used
Gary Kramlich <grim@reaperworld.com>
parents: 39782
diff changeset
578 );
39517
dd799b5d4e50 libpurple: Keepalive mechanism fixes
Petteri Pitkänen <petepitk@gmail.com>
parents: 39436
diff changeset
579 }
32679
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
580 }
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
581
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
582 static PurpleConnectionErrorInfo *
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
583 purple_connection_error_info_new(PurpleConnectionError type,
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
584 const gchar *description)
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
585 {
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
586 PurpleConnectionErrorInfo *err;
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
587
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
588 g_return_val_if_fail(description != NULL, NULL);
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
589
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
590 err = g_new(PurpleConnectionErrorInfo, 1);
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
591
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
592 err->type = type;
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
593 err->description = g_strdup(description);
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
594
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
595 return err;
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
596 }
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
597
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
598 /**************************************************************************
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
599 * GBoxed code
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
600 **************************************************************************/
35572
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
601 static PurpleConnectionUiOps *
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
602 purple_connection_ui_ops_copy(PurpleConnectionUiOps *ops)
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
603 {
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
604 PurpleConnectionUiOps *ops_new;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
605
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
606 g_return_val_if_fail(ops != NULL, NULL);
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
607
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
608 ops_new = g_new(PurpleConnectionUiOps, 1);
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
609 *ops_new = *ops;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
610
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
611 return ops_new;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
612 }
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
613
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
614 GType
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
615 purple_connection_ui_ops_get_type(void) {
35572
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
616 static GType type = 0;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
617
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
618 if(type == 0) {
35572
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
619 type = g_boxed_type_register_static("PurpleConnectionUiOps",
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
620 (GBoxedCopyFunc)purple_connection_ui_ops_copy,
35597
7fcfcf147b99 Use g_free as UiOps structures GBoxed free function
Ankit Vani <a@nevitus.org>
parents: 35572
diff changeset
621 (GBoxedFreeFunc)g_free);
35572
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
622 }
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
623
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
624 return type;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
625 }
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
626
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
627 static PurpleConnectionErrorInfo *
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
628 purple_connection_error_info_copy(PurpleConnectionErrorInfo *err)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
629 {
34787
d736bcb6c5a1 Check for NULL value in GBoxed functions
Ankit Vani <a@nevitus.org>
parents: 34786
diff changeset
630 g_return_val_if_fail(err != NULL, NULL);
d736bcb6c5a1 Check for NULL value in GBoxed functions
Ankit Vani <a@nevitus.org>
parents: 34786
diff changeset
631
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
632 return purple_connection_error_info_new(err->type, err->description);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
633 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
634
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
635 static void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
636 purple_connection_error_info_free(PurpleConnectionErrorInfo *err) {
34787
d736bcb6c5a1 Check for NULL value in GBoxed functions
Ankit Vani <a@nevitus.org>
parents: 34786
diff changeset
637 g_return_if_fail(err != NULL);
d736bcb6c5a1 Check for NULL value in GBoxed functions
Ankit Vani <a@nevitus.org>
parents: 34786
diff changeset
638
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
639 g_free(err->description);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
640 g_free(err);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
641 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
642
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
643 GType
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
644 purple_connection_error_info_get_type(void) {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
645 static GType type = 0;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
646
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
647 if (type == 0) {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
648 type = g_boxed_type_register_static("PurpleConnectionErrorInfo",
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
649 (GBoxedCopyFunc)purple_connection_error_info_copy,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
650 (GBoxedFreeFunc)purple_connection_error_info_free);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
651 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
652
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
653 return type;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
654 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
655
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
656
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
657 /**************************************************************************
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
658 * Helpers
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
659 **************************************************************************/
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
660 static void
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
661 purple_connection_set_id(PurpleConnection *connection, const gchar *id) {
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
662 g_free(connection->id);
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
663 connection->id = g_strdup(id);
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
664
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
665 g_object_notify_by_pspec(G_OBJECT(connection), properties[PROP_ID]);
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
666 }
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
667
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
668 /**************************************************************************
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
669 * GObject code
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
670 **************************************************************************/
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
671
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
672 static void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
673 purple_connection_set_property(GObject *obj, guint param_id,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
674 const GValue *value, GParamSpec *pspec)
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
675 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
676 PurpleConnection *gc = PURPLE_CONNECTION(obj);
32679
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
677
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
678 switch (param_id) {
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
679 case PROP_ID:
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
680 purple_connection_set_id(gc, g_value_get_string(value));
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
681 break;
36366
202c60d1300f Refactored connection, conversation, conversationtypes to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents: 36362
diff changeset
682 case PROP_PROTOCOL:
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
683 gc->protocol = g_value_get_object(value);
34756
7a11ecbb92d3 Added setting of property "prpl" in PurpleConnection -- only settable during construction
Ankit Vani <a@nevitus.org>
parents: 34755
diff changeset
684 break;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
685 case PROP_FLAGS:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
686 purple_connection_set_flags(gc, g_value_get_flags(value));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
687 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
688 case PROP_STATE:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
689 purple_connection_set_state(gc, g_value_get_enum(value));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
690 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
691 case PROP_ACCOUNT:
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
692 gc->account = g_value_get_object(value);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
693 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
694 case PROP_PASSWORD:
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
695 g_free(gc->password);
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
696 gc->password = g_value_dup_string(value);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
697 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
698 case PROP_DISPLAY_NAME:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
699 purple_connection_set_display_name(gc, g_value_get_string(value));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
700 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
701 default:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
702 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
703 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
704 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
705 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
706
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
707 static void
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
708 purple_connection_get_property(GObject *obj, guint param_id, GValue *value,
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
709 GParamSpec *pspec)
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
710 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
711 PurpleConnection *gc = PURPLE_CONNECTION(obj);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
712
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
713 switch (param_id) {
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
714 case PROP_ID:
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
715 g_value_set_string(value, purple_connection_get_id(gc));
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
716 break;
36366
202c60d1300f Refactored connection, conversation, conversationtypes to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents: 36362
diff changeset
717 case PROP_PROTOCOL:
36623
caaadef03507 Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents: 36621
diff changeset
718 g_value_set_object(value, purple_connection_get_protocol(gc));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
719 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
720 case PROP_FLAGS:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
721 g_value_set_flags(value, purple_connection_get_flags(gc));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
722 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
723 case PROP_STATE:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
724 g_value_set_enum(value, purple_connection_get_state(gc));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
725 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
726 case PROP_ACCOUNT:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
727 g_value_set_object(value, purple_connection_get_account(gc));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
728 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
729 case PROP_PASSWORD:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
730 g_value_set_string(value, purple_connection_get_password(gc));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
731 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
732 case PROP_DISPLAY_NAME:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
733 g_value_set_string(value, purple_connection_get_display_name(gc));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
734 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
735 default:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
736 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
737 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
738 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
739 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
740
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
741 static void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
742 purple_connection_init(PurpleConnection *gc) {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
743 purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTING);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
744 connections = g_list_append(connections, gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
745 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
746
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
747 static void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
748 purple_connection_constructed(GObject *object) {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
749 PurpleConnection *gc = PURPLE_CONNECTION(object);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
750
39433
f033955d125a Use G_DEFINE_TYPE_WITH_PRIVATE for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39352
diff changeset
751 G_OBJECT_CLASS(purple_connection_parent_class)->constructed(object);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
752
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
753 if(gc->id == NULL) {
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
754 gchar *uuid = g_uuid_string_random();
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
755
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
756 purple_connection_set_id(gc, uuid);
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
757
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
758 g_free(uuid);
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
759 }
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
760
41429
1f1a3fbb2759 Make PurpleAccount take ownership of the connection that was set.
Gary Kramlich <grim@reaperworld.com>
parents: 41300
diff changeset
761 purple_account_set_connection(gc->account, gc);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
762
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
763 purple_signal_emit(purple_connections_get_handle(), "signing-on", gc);
32679
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
764 }
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
765
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
766 static void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
767 purple_connection_finalize(GObject *object) {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
768 PurpleConnection *gc = PURPLE_CONNECTION(object);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
769 PurpleAccount *account;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
770 GSList *buddies;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
771 gboolean remove = FALSE;
40369
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
772 gpointer handle;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
773
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
774 gc->is_finalizing = TRUE;
35130
2033f0755d68 Fix a glib warning, by not calling g_object_notify while the connection object is being destroyed. There may be a better fix possible, though
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35097
diff changeset
775
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
776 account = purple_connection_get_account(gc);
40369
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
777 handle = purple_connections_get_handle();
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
778
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
779 purple_debug_info("connection", "Disconnecting connection %p\n", gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
780
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
781 if (purple_connection_get_state(gc) != PURPLE_CONNECTION_CONNECTING)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
782 remove = TRUE;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
783
40369
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
784 purple_signal_emit(handle, "signing-off", gc);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
785
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
786 g_slist_free_full(gc->active_chats,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
787 (GDestroyNotify)purple_chat_conversation_leave);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
788
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
789 update_keepalive(gc, FALSE);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
790
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
791 purple_protocol_close(gc->protocol, gc);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
792
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36626
diff changeset
793 /* Clear out the proto data that was freed in the protocol's close method */
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
794 buddies = purple_blist_find_buddies(account, NULL);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
795 while (buddies != NULL) {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
796 PurpleBuddy *buddy = buddies->data;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
797 purple_buddy_set_protocol_data(buddy, NULL);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
798 buddies = g_slist_delete_link(buddies, buddies);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
799 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
800
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
801 connections = g_list_remove(connections, gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
802
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
803 purple_connection_set_state(gc, PURPLE_CONNECTION_DISCONNECTED);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
804
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
805 if(remove) {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
806 purple_blist_remove_account(account);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
807 }
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
808
40369
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
809 purple_signal_emit(handle, "signed-off", gc);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
810
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
811 purple_account_request_close_with_account(account);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
812 purple_request_close_with_handle(gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
813 purple_notify_close_with_handle(gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
814
40369
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
815 connections_connected = g_list_remove(connections_connected, gc);
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
816 if(connections_connected == NULL) {
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
817 purple_signal_emit(handle, "offline");
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
818 }
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
819
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
820 purple_debug_info("connection", "Destroying connection %p\n", gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
821
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
822 purple_account_set_connection(account, NULL);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
823
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
824 if(gc->error_info) {
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
825 purple_connection_error_info_free(gc->error_info);
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
826 }
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
827
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
828 if(gc->disconnect_timeout > 0) {
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
829 g_source_remove(gc->disconnect_timeout);
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
830 }
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
831
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
832 purple_str_wipe(gc->password);
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
833 g_free(gc->display_name);
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
834 g_free(gc->id);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
835
39433
f033955d125a Use G_DEFINE_TYPE_WITH_PRIVATE for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39352
diff changeset
836 G_OBJECT_CLASS(purple_connection_parent_class)->finalize(object);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
837 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
838
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
839 static void
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
840 purple_connection_class_init(PurpleConnectionClass *klass) {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
841 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
842
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
843 obj_class->get_property = purple_connection_get_property;
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
844 obj_class->set_property = purple_connection_set_property;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
845 obj_class->finalize = purple_connection_finalize;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
846 obj_class->constructed = purple_connection_constructed;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
847
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
848 properties[PROP_ID] = g_param_spec_string(
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
849 "id", "id",
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
850 "The identifier of the account",
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
851 NULL,
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
852 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
853
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
854 properties[PROP_PROTOCOL] = g_param_spec_object(
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
855 "protocol", "Protocol",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
856 "The protocol that the connection is using.",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
857 PURPLE_TYPE_PROTOCOL,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
858 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
859
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
860 properties[PROP_FLAGS] = g_param_spec_flags(
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
861 "flags", "Connection flags",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
862 "The flags of the connection.",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
863 PURPLE_TYPE_CONNECTION_FLAGS, 0,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
864 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
865
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
866 properties[PROP_STATE] = g_param_spec_enum(
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
867 "state", "Connection state",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
868 "The current state of the connection.",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
869 PURPLE_TYPE_CONNECTION_STATE, PURPLE_CONNECTION_DISCONNECTED,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
870 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
871
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
872 properties[PROP_ACCOUNT] = g_param_spec_object(
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
873 "account", "Account",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
874 "The account using the connection.", PURPLE_TYPE_ACCOUNT,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
875 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
876
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
877 properties[PROP_PASSWORD] = g_param_spec_string(
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
878 "password", "Password",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
879 "The password used for connection.", NULL,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
880 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
881
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
882 properties[PROP_DISPLAY_NAME] = g_param_spec_string(
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
883 "display-name", "Display name",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
884 "Your name that appears to other people.", NULL,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
885 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
886
35085
abab0adfa0ec libpurple: use g_object_class_install_properties instead of repeated g_object_class_install_property
Ankit Vani <a@nevitus.org>
parents: 35080
diff changeset
887 g_object_class_install_properties(obj_class, PROP_LAST, properties);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
888 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
889
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
890 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
891 _purple_connection_new(PurpleAccount *account, gboolean is_registration,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
892 const gchar *password)
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
893 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
894 PurpleConnection *gc;
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36477
diff changeset
895 PurpleProtocol *protocol;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
896
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34967
diff changeset
897 g_return_if_fail(PURPLE_IS_ACCOUNT(account));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
898
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
899 if(!purple_account_is_disconnected(account)) {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
900 return;
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
901 }
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
902
40804
5496016b3c00 Port libpurple from purple_protocols_ to purple_protocol_manager_
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
903 protocol = purple_account_get_protocol(account);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
904
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
905 if(protocol == NULL) {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
906 gchar *message;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
907
36691
92122af1f083 Some documentation updates with regard to 'protocol plugins' and 'protocols'
Ankit Vani <a@nevitus.org>
parents: 36688
diff changeset
908 message = g_strdup_printf(_("Missing protocol for %s"),
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
909 purple_account_get_username(account));
41083
590d533cf290 Fix several typos in libpurple
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41007
diff changeset
910 purple_notify_error(NULL, is_registration ? _("Registration Error") :
34955
854143116575 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34923 34449
diff changeset
911 _("Connection Error"), message, NULL,
854143116575 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34923 34449
diff changeset
912 purple_request_cpar_from_account(account));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
913 g_free(message);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
914
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
915 return;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
916 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
917
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
918 if(is_registration) {
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
919 if(!PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER, register_user)) {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
920 return;
41083
590d533cf290 Fix several typos in libpurple
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41007
diff changeset
921 }
590d533cf290 Fix several typos in libpurple
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41007
diff changeset
922 } else {
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
923 if(((password == NULL) || (*password == '\0')) &&
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
924 !(purple_protocol_get_options(protocol) & OPT_PROTO_NO_PASSWORD) &&
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
925 !(purple_protocol_get_options(protocol) & OPT_PROTO_PASSWORD_OPTIONAL))
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
926 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
927 purple_debug_error("connection", "Cannot connect to account %s without "
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
928 "a password.\n", purple_account_get_username(account));
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
929
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
930 return;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
931 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
932 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
933
40339
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40195
diff changeset
934 if(PURPLE_IS_PROTOCOL_FACTORY(protocol)) {
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
935 PurpleProtocolFactory *factory = PURPLE_PROTOCOL_FACTORY(protocol);
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
936
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
937 gc = purple_protocol_factory_connection_new(factory, account,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
938 password);
40339
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40195
diff changeset
939 } else {
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
940 gc = g_object_new(
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
941 PURPLE_TYPE_CONNECTION,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
942 "protocol", protocol,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
943 "account", account,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
944 "password", password,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
945 NULL);
40339
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40195
diff changeset
946 }
36728
313d07370a7b Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents: 36720
diff changeset
947
313d07370a7b Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents: 36720
diff changeset
948 g_return_if_fail(gc != NULL);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
949
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
950 if(is_registration) {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
951 purple_debug_info("connection", "Registering. gc = %p\n", gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
952
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
953 /* set this so we don't auto-reconnect after registering */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
954 gc->wants_to_die = TRUE;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
955
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40654
diff changeset
956 purple_protocol_server_register_user(PURPLE_PROTOCOL_SERVER(protocol),
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40654
diff changeset
957 account);
41083
590d533cf290 Fix several typos in libpurple
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41007
diff changeset
958 } else {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
959 purple_debug_info("connection", "Connecting. gc = %p\n", gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
960
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
961 purple_signal_emit(purple_accounts_get_handle(), "account-connecting",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
962 account);
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40804
diff changeset
963 purple_protocol_login(protocol, account);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
964 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
965 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
966
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
967 void
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
968 _purple_connection_new_unregister(PurpleAccount *account, const char *password,
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
969 PurpleAccountUnregistrationCb cb,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
970 gpointer user_data)
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
971 {
41083
590d533cf290 Fix several typos in libpurple
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41007
diff changeset
972 /* Lots of copy/pasted code to avoid API changes. You might want to integrate that into the previous function when possible. */
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
973 PurpleConnection *gc;
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36477
diff changeset
974 PurpleProtocol *protocol;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
975
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34967
diff changeset
976 g_return_if_fail(PURPLE_IS_ACCOUNT(account));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
977
40804
5496016b3c00 Port libpurple from purple_protocols_ to purple_protocol_manager_
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
978 protocol = purple_account_get_protocol(account);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
979
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
980 if(protocol == NULL) {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
981 gchar *message;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
982
36691
92122af1f083 Some documentation updates with regard to 'protocol plugins' and 'protocols'
Ankit Vani <a@nevitus.org>
parents: 36688
diff changeset
983 message = g_strdup_printf(_("Missing protocol for %s"),
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
984 purple_account_get_username(account));
34955
854143116575 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34923 34449
diff changeset
985 purple_notify_error(NULL, _("Unregistration Error"), message,
854143116575 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34923 34449
diff changeset
986 NULL, purple_request_cpar_from_account(account));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
987 g_free(message);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
988 return;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
989 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
990
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
991 if(!purple_account_is_disconnected(account)) {
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40654
diff changeset
992 purple_protocol_server_unregister_user(PURPLE_PROTOCOL_SERVER(protocol),
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40654
diff changeset
993 account, cb, user_data);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
994 return;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
995 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
996
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
997 if(((password == NULL) || (*password == '\0')) &&
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
998 !(purple_protocol_get_options(protocol) & OPT_PROTO_NO_PASSWORD) &&
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
999 !(purple_protocol_get_options(protocol) & OPT_PROTO_PASSWORD_OPTIONAL))
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1000 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1001 purple_debug_error("connection", "Cannot connect to account %s without "
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1002 "a password.\n", purple_account_get_username(account));
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1003
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1004 return;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1005 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1006
40339
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40195
diff changeset
1007 if(PURPLE_IS_PROTOCOL_FACTORY(protocol)) {
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1008 PurpleProtocolFactory *factory = PURPLE_PROTOCOL_FACTORY(protocol);
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1009 gc = purple_protocol_factory_connection_new(factory, account,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1010 password);
40339
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40195
diff changeset
1011 } else {
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1012 gc = g_object_new(
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1013 PURPLE_TYPE_CONNECTION,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1014 "protocol", protocol,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1015 "account", account,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1016 "password", password,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1017 NULL);
40339
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40195
diff changeset
1018 }
36728
313d07370a7b Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents: 36720
diff changeset
1019
313d07370a7b Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents: 36720
diff changeset
1020 g_return_if_fail(gc != NULL);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1021
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1022 purple_debug_info("connection", "Unregistering. gc = %p\n", gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1023
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40654
diff changeset
1024 purple_protocol_server_unregister_user(PURPLE_PROTOCOL_SERVER(protocol),
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40654
diff changeset
1025 account, cb, user_data);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1026 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1027
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1028 /**************************************************************************
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1029 * Connections API
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1030 **************************************************************************/
36068
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36067
diff changeset
1031
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36067
diff changeset
1032 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1033 _purple_assert_connection_is_valid(PurpleConnection *gc, const gchar *file,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1034 int line)
36068
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36067
diff changeset
1035 {
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1036 if(gc && g_list_find(purple_connections_get_all(), gc)) {
36068
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36067
diff changeset
1037 return;
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1038 }
36068
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36067
diff changeset
1039
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36067
diff changeset
1040 purple_debug_fatal("connection", "PURPLE_ASSERT_CONNECTION_IS_VALID(%p)"
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36067
diff changeset
1041 " failed at %s:%d", gc, file, line);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1042
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1043 /* ugh - gk 2021-10-28 */
36068
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36067
diff changeset
1044 exit(-1);
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36067
diff changeset
1045 }
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36067
diff changeset
1046
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1047 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1048 purple_connections_disconnect_all(void) {
18122
9bf9970c1b6a disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents: 18121
diff changeset
1049 GList *l;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1050 PurpleConnection *gc;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1051
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1052 while((l = purple_connections_get_all()) != NULL) {
6113
5bc7394e69ea [gaim-migrate @ 6575]
Mark Doliner <markdoliner@pidgin.im>
parents: 6111
diff changeset
1053 gc = l->data;
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1054 gc->wants_to_die = TRUE;
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1055 purple_account_disconnect(gc->account);
6113
5bc7394e69ea [gaim-migrate @ 6575]
Mark Doliner <markdoliner@pidgin.im>
parents: 6111
diff changeset
1056 }
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1057 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1058
18122
9bf9970c1b6a disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents: 18121
diff changeset
1059 GList *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1060 purple_connections_get_all(void) {
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1061 return connections;
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1062 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1063
18122
9bf9970c1b6a disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents: 18121
diff changeset
1064 GList *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1065 purple_connections_get_connecting(void) {
5788
dd6e33a59151 [gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents: 5784
diff changeset
1066 return connections_connecting;
dd6e33a59151 [gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents: 5784
diff changeset
1067 }
dd6e33a59151 [gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents: 5784
diff changeset
1068
40369
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
1069 gboolean
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
1070 purple_connections_is_online(void) {
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
1071 return (connections_connected != NULL);
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
1072 }
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
1073
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1074 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1075 purple_connections_set_ui_ops(PurpleConnectionUiOps *ops) {
7035
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1076 connection_ui_ops = ops;
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1077 }
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1078
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1079 PurpleConnectionUiOps *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1080 purple_connections_get_ui_ops(void) {
7035
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1081 return connection_ui_ops;
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1082 }
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1083
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1084 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1085 purple_connections_init(void) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1086 void *handle = purple_connections_get_handle();
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1087
40369
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
1088 purple_signal_register(handle, "online", purple_marshal_VOID, G_TYPE_NONE,
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
1089 0);
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
1090
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
1091 purple_signal_register(handle, "offline", purple_marshal_VOID, G_TYPE_NONE,
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
1092 0);
41733d530d58 Add online and offline signals that are emitted when the first account goes and the last account go offline.
Gary Kramlich <grim@reaperworld.com>
parents: 40347
diff changeset
1093
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1094 purple_signal_register(handle, "signing-on",
34814
759ea31715dd Refactored cmds and connection to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34788
diff changeset
1095 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
759ea31715dd Refactored cmds and connection to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34788
diff changeset
1096 PURPLE_TYPE_CONNECTION);
6564
a7a2c1927544 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6533
diff changeset
1097
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1098 purple_signal_register(handle, "signed-on",
34814
759ea31715dd Refactored cmds and connection to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34788
diff changeset
1099 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
759ea31715dd Refactored cmds and connection to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34788
diff changeset
1100 PURPLE_TYPE_CONNECTION);
6564
a7a2c1927544 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6533
diff changeset
1101
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1102 purple_signal_register(handle, "signing-off",
34814
759ea31715dd Refactored cmds and connection to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34788
diff changeset
1103 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
759ea31715dd Refactored cmds and connection to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34788
diff changeset
1104 PURPLE_TYPE_CONNECTION);
6564
a7a2c1927544 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6533
diff changeset
1105
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1106 purple_signal_register(handle, "signed-off",
34814
759ea31715dd Refactored cmds and connection to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34788
diff changeset
1107 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
759ea31715dd Refactored cmds and connection to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34788
diff changeset
1108 PURPLE_TYPE_CONNECTION);
21285
ca8cb8706802 I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents: 21279
diff changeset
1109
ca8cb8706802 I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents: 21279
diff changeset
1110 purple_signal_register(handle, "connection-error",
34814
759ea31715dd Refactored cmds and connection to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34788
diff changeset
1111 purple_marshal_VOID__POINTER_INT_POINTER,
759ea31715dd Refactored cmds and connection to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34788
diff changeset
1112 G_TYPE_NONE, 3, PURPLE_TYPE_CONNECTION,
759ea31715dd Refactored cmds and connection to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34788
diff changeset
1113 PURPLE_TYPE_CONNECTION_ERROR, G_TYPE_STRING);
21285
ca8cb8706802 I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents: 21279
diff changeset
1114
30039
9cd7672bae4f Add an autojoin connection signal
Richard Laager <rlaager@pidgin.im>
parents: 28577
diff changeset
1115 purple_signal_register(handle, "autojoin",
34814
759ea31715dd Refactored cmds and connection to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34788
diff changeset
1116 purple_marshal_BOOLEAN__POINTER, G_TYPE_NONE, 1,
759ea31715dd Refactored cmds and connection to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34788
diff changeset
1117 PURPLE_TYPE_CONNECTION);
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1118 }
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1119
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1120 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1121 purple_connections_uninit(void) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1122 purple_signals_unregister_by_instance(purple_connections_get_handle());
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1123 }
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1124
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1125 void *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1126 purple_connections_get_handle(void) {
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1127 return &connections_handle;
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1128 }

mercurial