libpurple/connection.c

Fri, 20 Oct 2023 02:10:54 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Fri, 20 Oct 2023 02:10:54 -0500
changeset 42376
c6aa66fec38a
parent 42344
c51d37734155
child 42542
1407a0aac0bf
permissions
-rw-r--r--

Prefix version.h with purple

And split constants into a separate file as in hasl.

Testing Done:
Compiled.

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

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
34706
02cb08146888 Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents: 34645
diff changeset
24 #include "buddylist.h"
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include "connection.h"
5717
2f3a377de638 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents: 5676
diff changeset
26 #include "debug.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
27 #include "notify.h"
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
28 #include "prefs.h"
14900
4af8b81519b6 [gaim-migrate @ 17607]
Mark Doliner <markdoliner@pidgin.im>
parents: 14814
diff changeset
29 #include "proxy.h"
42344
c51d37734155 Rename account.[ch] to purpleaccount.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 42175
diff changeset
30 #include "purpleaccount.h"
41007
90d2dee9b3dc Fix the includes for the purpleenums rename
Gary Kramlich <grim@reaperworld.com>
parents: 40813
diff changeset
31 #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
32 #include "purpleprivate.h"
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40654
diff changeset
33 #include "purpleprotocolserver.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
34 #include "request.h"
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
35 #include "server.h"
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
36 #include "signals.h"
6106
1dc08be40f0a [gaim-migrate @ 6567]
Mark Doliner <markdoliner@pidgin.im>
parents: 6076
diff changeset
37 #include "util.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
38
39549
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
39 /**
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
40 * PurpleConnection:
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
41 *
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
42 * Represents an active connection on an account.
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
43 */
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
44 typedef struct {
39549
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
45 GObject gparent;
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
46
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
47 gchar *id;
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
48
37069
22bf5ea00006 Merge gtkdoc-conversion
Ankit Vani <a@nevitus.org>
parents: 37066 35458
diff changeset
49 PurpleProtocol *protocol; /* The protocol. */
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
50 PurpleConnectionFlags flags; /* Connection flags. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
51
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
52 PurpleConnectionState state; /* The connection state. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
53
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
54 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
55 char *password; /* The password used. */
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 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
58 (#PurpleChatConversation structs). */
35097
0d6a2ff4f776 Minor comment fiddling.
Mark Doliner <mark@kingant.net>
parents: 35085
diff changeset
59
0d6a2ff4f776 Minor comment fiddling.
Mark Doliner <mark@kingant.net>
parents: 35085
diff changeset
60 /* 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
61 void *proto_data; /* Protocol-specific data. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
62
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
63 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
64 GSource *keepalive; /* Keep-alive. */
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 /* 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
67 * 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
68 * 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
69 * 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
70 * setting it themselves.
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
71 * See purple_connection_error_is_fatal()
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
72 */
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
73 gboolean wants_to_die;
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
74
41083
590d533cf290 Fix several typos in libpurple
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41007
diff changeset
75 /* 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
76 PurpleConnectionErrorInfo *error_info;
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
77
41083
590d533cf290 Fix several typos in libpurple
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41007
diff changeset
78 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
79 } PurpleConnectionPrivate;
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
80
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
81 enum {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
82 PROP_0,
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
83 PROP_ID,
36366
202c60d1300f Refactored connection, conversation, conversationtypes to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents: 36362
diff changeset
84 PROP_PROTOCOL,
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
85 PROP_FLAGS,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
86 PROP_STATE,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
87 PROP_ACCOUNT,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
88 PROP_PASSWORD,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
89 PROP_DISPLAY_NAME,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
90 PROP_LAST
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
91 };
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
92
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
93 static GParamSpec *properties[PROP_LAST] = {NULL, };
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
94
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 static GList *connections = 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
96 static GList *connections_connected = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
97 static PurpleConnectionUiOps *connection_ui_ops = NULL;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
99 static int connections_handle;
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
100
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
101 G_DEFINE_TYPE_WITH_PRIVATE(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
102
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
103 /**************************************************************************
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
104 * Connection API
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
105 **************************************************************************/
10745
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
106 static gboolean
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
107 send_keepalive(gpointer data) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
108 PurpleConnection *connection = data;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
109 PurpleConnectionPrivate *priv = NULL;
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
110
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
111 priv = purple_connection_get_instance_private(data);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
112
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
113 purple_protocol_server_keepalive(PURPLE_PROTOCOL_SERVER(priv->protocol),
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
114 connection);
10745
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
115
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
116 return TRUE;
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
117 }
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
118
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
119 static void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
120 update_keepalive(PurpleConnection *connection, gboolean on) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
121 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
122 PurpleProtocolServer *server = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
123
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
124 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
125
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
126 if(!PURPLE_PROTOCOL_IMPLEMENTS(priv->protocol, SERVER, keepalive)) {
14545
f8b45a0ddac5 [gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
127 return;
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
128 }
14545
f8b45a0ddac5 [gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
129
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
130 server = PURPLE_PROTOCOL_SERVER(priv->protocol);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
131
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
132 if(on && !priv->keepalive) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
133 int interval = purple_protocol_server_get_keepalive_interval(server);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
134 int source = 0;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
135
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
136 purple_debug_info("connection", "Activating keepalive to %d seconds.",
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
137 interval);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
138
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
139 source = g_timeout_add_seconds(interval, send_keepalive, connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
140 priv->keepalive = g_main_context_find_source_by_id(NULL, source);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
141 } else if (!on && priv->keepalive) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
142 purple_debug_info("connection", "Deactivating keepalive.\n");
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
143
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
144 g_source_destroy(priv->keepalive);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
145
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
146 priv->keepalive = NULL;
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
147 }
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 /*
8130
58e4e51f514b [gaim-migrate @ 8835]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
151 * d:)->-<
5563
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 * d:O-\-<
8130
58e4e51f514b [gaim-migrate @ 8835]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
154 *
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 * d:D-/-<
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 *
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 * d8D->-< DANCE!
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 */
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
161 purple_connection_set_state(PurpleConnection *connection,
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
162 PurpleConnectionState state)
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
164 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
165 PurpleConnectionUiOps *ops = NULL;
5885
223ac977eed2 [gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents: 5883
diff changeset
166
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
167 g_return_if_fail(PURPLE_IS_CONNECTION(connection));
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
168
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
169 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
170
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
171 if(priv->state == state) {
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
172 return;
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
173 }
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
175 priv->state = state;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
177 ops = purple_connections_get_ui_ops();
5885
223ac977eed2 [gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents: 5883
diff changeset
178
41812
c3cd920261b6 Fix the namespace of the PurpleConnectionState enum constants
Gary Kramlich <grim@reaperworld.com>
parents: 41799
diff changeset
179 if(priv->state == PURPLE_CONNECTION_STATE_CONNECTED) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
180 PurplePresence *presence;
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41958
diff changeset
181 GDateTime *timestamp = 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
182 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
183 gpointer handle = NULL;
10052
329dad7e2da3 [gaim-migrate @ 11013]
Dave West <kat@users.sourceforge.net>
parents: 9944
diff changeset
184
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
185 presence = purple_account_get_presence(priv->account);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 /* Set the time the account came online */
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41958
diff changeset
188 timestamp = g_date_time_new_now_utc();
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41958
diff changeset
189 purple_presence_set_login_time(presence, timestamp);
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41958
diff changeset
190 g_date_time_unref(timestamp);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
192 if(ops != NULL && ops->connected != NULL) {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
193 ops->connected(connection);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
194 }
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
196 purple_blist_add_account(priv->account);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
197
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
198 handle = purple_connections_get_handle();
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
199 purple_signal_emit(handle, "signed-on", connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
200 purple_signal_emit_return_1(handle, "autojoin", connection);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
202 update_keepalive(connection, 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
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 /* 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
205 * 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
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 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
208 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
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
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
211 connections_connected = g_list_append(connections_connected,
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
212 connection);
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
213
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
214 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
215 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
216 }
41812
c3cd920261b6 Fix the namespace of the PurpleConnectionState enum constants
Gary Kramlich <grim@reaperworld.com>
parents: 41799
diff changeset
217 } else if(priv->state == PURPLE_CONNECTION_STATE_DISCONNECTED) {
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
218 if(ops != NULL && ops->disconnected != NULL) {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
219 ops->disconnected(connection);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
220 }
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
221 }
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
222
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
223 g_object_notify_by_pspec(G_OBJECT(connection), properties[PROP_STATE]);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
227 purple_connection_set_flags(PurpleConnection *connection,
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
228 PurpleConnectionFlags flags)
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
229 {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
230 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
231
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
232 g_return_if_fail(PURPLE_IS_CONNECTION(connection));
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
233
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
234 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
235
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
236 priv->flags = flags;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
237
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
238 g_object_notify_by_pspec(G_OBJECT(connection), properties[PROP_FLAGS]);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
239 }
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
240
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
241 void
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
242 purple_connection_set_display_name(PurpleConnection *connection,
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
243 const gchar *name)
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
244 {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
245 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
246
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
247 g_return_if_fail(PURPLE_IS_CONNECTION(connection));
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
248
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
249 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
250
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
251 g_clear_pointer(&priv->display_name, g_free);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
252 priv->display_name = g_strdup(name);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
253
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
254 g_object_notify_by_pspec(G_OBJECT(connection),
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
255 properties[PROP_DISPLAY_NAME]);
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
256 }
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
257
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
258 void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
259 purple_connection_set_protocol_data(PurpleConnection *connection,
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
260 void *proto_data)
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
261 {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
262 PurpleConnectionPrivate *priv = NULL;
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
263
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
264 g_return_if_fail(PURPLE_IS_CONNECTION(connection));
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
266 priv = purple_connection_get_instance_private(connection);
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
267
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
268 priv->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
269 }
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
270
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
271 PurpleConnectionState
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
272 purple_connection_get_state(PurpleConnection *connection) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
273 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
274
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
275 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection),
41812
c3cd920261b6 Fix the namespace of the PurpleConnectionState enum constants
Gary Kramlich <grim@reaperworld.com>
parents: 41799
diff changeset
276 PURPLE_CONNECTION_STATE_DISCONNECTED);
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
277
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
278 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
279
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
280 return priv->state;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
283 PurpleConnectionFlags
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
284 purple_connection_get_flags(PurpleConnection *connection) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
285 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
286
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
287 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), 0);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
288
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
289 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
290
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
291 return priv->flags;
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
292 }
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
293
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
294 PurpleAccount *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
295 purple_connection_get_account(PurpleConnection *connection) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
296 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
297
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
298 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), NULL);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
299
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
300 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
301
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
302 return priv->account;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
305 const gchar *
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
306 purple_connection_get_id(PurpleConnection *connection) {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
307 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
308
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
309 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
310
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
311 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
312
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
313 return priv->id;
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
314 }
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
315
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36477
diff changeset
316 PurpleProtocol *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
317 purple_connection_get_protocol(PurpleConnection *connection) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
318 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
319
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
320 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), NULL);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
321
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
322 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
323
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
324 return priv->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
325 }
ac905bb0a8ec Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22324
diff changeset
326
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327 const char *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
328 purple_connection_get_password(PurpleConnection *connection) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
329 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
330
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
331 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), NULL);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
332
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
333 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
334
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
335 return priv->password;
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
336 }
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
337
41850
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
338 void
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
339 purple_connection_set_password(PurpleConnection *connection,
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
340 const char *password)
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
341 {
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
342 PurpleConnectionPrivate *priv = NULL;
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
343
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
344 g_return_if_fail(PURPLE_IS_CONNECTION(connection));
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
345
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
346 priv = purple_connection_get_instance_private(connection);
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
347
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
348 purple_str_wipe(priv->password);
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
349 priv->password = g_strdup(password);
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
350
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
351 g_object_notify_by_pspec(G_OBJECT(connection), properties[PROP_PASSWORD]);
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
352 }
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
353
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
354 GSList *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
355 purple_connection_get_active_chats(PurpleConnection *connection) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
356 PurpleConnectionPrivate *priv = NULL;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
357
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
358 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), NULL);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
359
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
360 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
361
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
362 return priv->active_chats;
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
363 }
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
364
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
365 const char *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
366 purple_connection_get_display_name(PurpleConnection *connection) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
367 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
368
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
369 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), NULL);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
370
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
371 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
372
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
373 return priv->display_name;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
374 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375
24937
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
376 void *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
377 purple_connection_get_protocol_data(PurpleConnection *connection) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
378 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
379
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
380 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), NULL);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
381
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
382 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
383
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
384 return priv->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
385 }
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
386
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
387 void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
388 _purple_connection_add_active_chat(PurpleConnection *connection,
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
389 PurpleChatConversation *chat)
34755
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
390 {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
391 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
392
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
393 g_return_if_fail(PURPLE_IS_CONNECTION(connection));
34755
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
394
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
395 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
396
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
397 priv->active_chats = g_slist_append(priv->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
398 }
24937
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
399
34755
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
400 void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
401 _purple_connection_remove_active_chat(PurpleConnection *connection,
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
402 PurpleChatConversation *chat)
34755
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
403 {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
404 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
405
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
406 g_return_if_fail(PURPLE_IS_CONNECTION(connection));
34755
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
407
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
408 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
409
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
410 priv->active_chats = g_slist_remove(priv->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
411 }
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
412
34877
5b3c720b9077 Added missing internal function, used by account.c
Ankit Vani <a@nevitus.org>
parents: 34866
diff changeset
413 gboolean
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
414 _purple_connection_wants_to_die(PurpleConnection *connection) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
415 PurpleConnectionPrivate *priv = NULL;
34877
5b3c720b9077 Added missing internal function, used by account.c
Ankit Vani <a@nevitus.org>
parents: 34866
diff changeset
416
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
417 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), FALSE);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
418
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
419 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
420
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
421 return priv->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
422 }
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
423
12412
8abe3226695e [gaim-migrate @ 14719]
Richard Laager <rlaager@pidgin.im>
parents: 12272
diff changeset
424 static gboolean
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
425 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
426 PurpleAccount *account = data;
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
427 PurpleConnection *connection;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
428
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
429 connection = purple_account_get_connection(account);
27336
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
430
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
431 if(PURPLE_IS_CONNECTION(connection)) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
432 PurpleConnectionPrivate *priv = NULL;
27336
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
433
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
434 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
435
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
436 priv->disconnect_timeout = 0;
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
437
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
438 if(priv->state != PURPLE_CONNECTION_STATE_DISCONNECTED) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
439 /* If the connection is not disconnected, disconnect it. */
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
440 purple_account_disconnect(account);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
441 } else {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
442 /* Otherwise assume the connection was already disconnected or in
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
443 * the process of being disconnected and we just need to finish our
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
444 * cleanup.
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
445 */
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
446 GError *error = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
447
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
448 if(!purple_connection_disconnect(connection, &error)) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
449 const char *message = "unknown error";
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
450
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
451 if(error != NULL) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
452 message = error->message;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
453 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
454
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
455 purple_debug_warning("connections",
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
456 "failed to disconnect %p : %s",
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
457 connection, message);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
458 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
459
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
460 g_clear_error(&error);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
461
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
462 purple_account_set_connection(account, NULL);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
463 }
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
464 }
27336
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
465
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
466 return G_SOURCE_REMOVE;
10742
2783135f0ecf [gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents: 10740
diff changeset
467 }
2783135f0ecf [gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents: 10740
diff changeset
468
5571
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
469 void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
470 purple_connection_error(PurpleConnection *connection,
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
471 PurpleConnectionError reason,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
472 const char *description)
20430
bb30dff3da21 Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents: 19897
diff changeset
473 {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
474 PurpleConnectionPrivate *priv = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
475 PurpleConnectionUiOps *ops;
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
476
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
477 g_return_if_fail(PURPLE_IS_CONNECTION(connection));
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
478
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
479 priv = purple_connection_get_instance_private(connection);
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
480
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
481 /* This sanity check relies on PURPLE_CONNECTION_ERROR_OTHER_ERROR
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
482 * being the last member of the PurpleConnectionError enum in
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
483 * connection.h; if other reasons are added after it, this check should
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
484 * be updated.
21278
19f6ce8ee4ad rlaager suggested using the last element of the PurpleDisconnectReason enum
Will Thompson <resiak@pidgin.im>
parents: 21154
diff changeset
485 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
486 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
487 purple_debug_error("connection",
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32156
diff changeset
488 "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
489 "valid reason\n", reason);
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
490 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
491 }
15848
44463a06e833 Change connection.c:gaim_connection_error() to still work even if the
Mark Doliner <markdoliner@pidgin.im>
parents: 15537
diff changeset
492
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
493 if(description == NULL) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32156
diff changeset
494 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
495 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
496 }
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
497
6393
b845f8d02597 [gaim-migrate @ 6898]
Nathan Walp <nwalp@pidgin.im>
parents: 6297
diff changeset
498 /* If we've already got one error, we don't need any more */
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
499 if(priv->error_info != NULL) {
6393
b845f8d02597 [gaim-migrate @ 6898]
Nathan Walp <nwalp@pidgin.im>
parents: 6297
diff changeset
500 return;
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
501 }
6393
b845f8d02597 [gaim-migrate @ 6898]
Nathan Walp <nwalp@pidgin.im>
parents: 6297
diff changeset
502
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
503 priv->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
504
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
505 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
506 "Connection error on %p (reason: %u description: %s)\n",
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
507 connection, reason, description);
28091
03d2cecdb234 Log the reason for disconnection to the debug log, so that we might
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 27336
diff changeset
508
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
509 ops = purple_connections_get_ui_ops();
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
510
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
511 if(ops && ops->report_disconnect) {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
512 ops->report_disconnect(connection, reason, description);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
513 }
5727
883d5bc2eb0d [gaim-migrate @ 6150]
Nathan Walp <nwalp@pidgin.im>
parents: 5725
diff changeset
514
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
515 priv->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
516
21285
ca8cb8706802 I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents: 21279
diff changeset
517 purple_signal_emit(purple_connections_get_handle(), "connection-error",
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
518 connection, reason, description);
5727
883d5bc2eb0d [gaim-migrate @ 6150]
Nathan Walp <nwalp@pidgin.im>
parents: 5725
diff changeset
519
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
520 priv->disconnect_timeout = g_timeout_add(0, purple_connection_disconnect_cb,
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
521 priv->account);
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
522 }
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
523
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
524 PurpleConnectionErrorInfo *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
525 purple_connection_get_error_info(PurpleConnection *connection) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
526 PurpleConnectionPrivate *priv = NULL;
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
527
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
528 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), NULL);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
529
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
530 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
531
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
532 return priv->error_info;
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
533 }
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
534
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
535 void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
536 purple_connection_g_error(PurpleConnection *connection, 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
537 PurpleConnectionError reason;
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
538
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
539 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
540 /* 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
541 return;
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
542 }
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
543
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
544 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
545 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
546 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
547 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
548 break;
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
549 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
550 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
551 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
552 break;
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
553 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
554 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
555 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
556 break;
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
557 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
558 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
559 default:
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
560 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
561 }
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
562 } 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
563 reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
37961
2ee4c67768f4 connection: Support PurpleConnectionError GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents: 37959
diff changeset
564 } else if (error->domain == PURPLE_CONNECTION_ERROR) {
2ee4c67768f4 connection: Support PurpleConnectionError GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents: 37959
diff changeset
565 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
566 } else {
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
567 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
568 }
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
569
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
570 purple_connection_error(connection, 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
571 }
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
572
37959
e76677ed819c connection: Add purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37958
diff changeset
573 void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
574 purple_connection_take_error(PurpleConnection *connection, GError *error) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
575 purple_connection_g_error(connection, error);
37959
e76677ed819c connection: Add purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37958
diff changeset
576 g_error_free(error);
e76677ed819c connection: Add purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37958
diff changeset
577 }
e76677ed819c connection: Add purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37958
diff changeset
578
20431
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
579 gboolean
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
580 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
581 switch (reason) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
582 case PURPLE_CONNECTION_ERROR_NETWORK_ERROR:
22162
1e0f1dbe89da Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21865
diff changeset
583 case PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR:
41463
6b13615303cc Add some custom connection errors
Gary Kramlich <grim@reaperworld.com>
parents: 41429
diff changeset
584 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
585 return FALSE;
0ae51085309d Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents: 21507
diff changeset
586 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
587 case PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED:
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
588 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
589 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
590 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
591 case PURPLE_CONNECTION_ERROR_INVALID_SETTINGS:
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
592 case PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
593 case PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
594 case PURPLE_CONNECTION_ERROR_CERT_EXPIRED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
595 case PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
596 case PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
597 case PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
598 case PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
599 case PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR:
41463
6b13615303cc Add some custom connection errors
Gary Kramlich <grim@reaperworld.com>
parents: 41429
diff changeset
600 case PURPLE_CONNECTION_ERROR_CUSTOM_FATAL:
6b13615303cc Add some custom connection errors
Gary Kramlich <grim@reaperworld.com>
parents: 41429
diff changeset
601 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
602 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
603 default:
610a45545a40 datallah pointed out that using g_return_if_fail() is preferable to
Will Thompson <resiak@pidgin.im>
parents: 21149
diff changeset
604 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
605 }
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
606 }
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
607
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
608 void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
609 purple_connection_update_last_received(PurpleConnection *connection) {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
610 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
611
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
612 g_return_if_fail(PURPLE_IS_CONNECTION(connection));
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
613
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
614 priv = purple_connection_get_instance_private(connection);
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
615
39517
dd799b5d4e50 libpurple: Keepalive mechanism fixes
Petteri Pitkänen <petepitk@gmail.com>
parents: 39436
diff changeset
616 /*
dd799b5d4e50 libpurple: Keepalive mechanism fixes
Petteri Pitkänen <petepitk@gmail.com>
parents: 39436
diff changeset
617 * 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
618 * keepalive mechanism is inactive.
dd799b5d4e50 libpurple: Keepalive mechanism fixes
Petteri Pitkänen <petepitk@gmail.com>
parents: 39436
diff changeset
619 */
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
620 if(priv->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
621 /* 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
622 * #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
623 * 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
624 * 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
625 * 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
626 */
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
627 gint64 seconds_from_now = purple_protocol_server_get_keepalive_interval(PURPLE_PROTOCOL_SERVER(priv->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
628
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
629 g_source_set_ready_time(
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
630 priv->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
631 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
632 );
39517
dd799b5d4e50 libpurple: Keepalive mechanism fixes
Petteri Pitkänen <petepitk@gmail.com>
parents: 39436
diff changeset
633 }
32679
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
634 }
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
635
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
636 /**************************************************************************
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
637 * GBoxed code
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
638 **************************************************************************/
35572
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
639 static PurpleConnectionUiOps *
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
640 purple_connection_ui_ops_copy(PurpleConnectionUiOps *ops)
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
641 {
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
642 PurpleConnectionUiOps *ops_new;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
643
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
644 g_return_val_if_fail(ops != NULL, NULL);
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
645
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
646 ops_new = g_new(PurpleConnectionUiOps, 1);
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
647 *ops_new = *ops;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
648
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
649 return ops_new;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
650 }
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
651
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
652 GType
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
653 purple_connection_ui_ops_get_type(void) {
35572
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
654 static GType type = 0;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
655
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
656 if(type == 0) {
35572
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
657 type = g_boxed_type_register_static("PurpleConnectionUiOps",
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
658 (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
659 (GBoxedFreeFunc)g_free);
35572
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
660 }
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
661
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
662 return type;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
663 }
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
664
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
665 /**************************************************************************
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
666 * Helpers
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
667 **************************************************************************/
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
668 static void
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
669 purple_connection_set_id(PurpleConnection *connection, const gchar *id) {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
670 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
671
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
672 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
673
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
674 g_free(priv->id);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
675 priv->id = g_strdup(id);
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
676
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
677 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
678 }
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
679
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
680 static void
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
681 purple_connection_set_account(PurpleConnection *connection,
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
682 PurpleAccount *account)
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
683 {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
684 PurpleConnectionPrivate *priv = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
685
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
686 priv = purple_connection_get_instance_private(connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
687
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
688 if(g_set_object(&priv->account, account)) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
689 g_object_notify_by_pspec(G_OBJECT(connection),
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
690 properties[PROP_ACCOUNT]);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
691 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
692 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
693
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
694 /**************************************************************************
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
695 * PurpleConnection Implementation
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
696 **************************************************************************/
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
697 static gboolean
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
698 purple_connection_default_connect(PurpleConnection *connection,
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
699 G_GNUC_UNUSED GError **error)
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
700 {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
701 PurpleConnectionPrivate *priv = NULL;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
702
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
703 priv = purple_connection_get_instance_private(connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
704
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
705 purple_protocol_login(priv->protocol, priv->account);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
706
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
707 return TRUE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
708 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
709
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
710 static gboolean
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
711 purple_connection_default_disconnect(PurpleConnection *connection,
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
712 G_GNUC_UNUSED GError **error)
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
713 {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
714 PurpleConnectionPrivate *priv = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
715
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
716 priv = purple_connection_get_instance_private(connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
717
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
718 purple_protocol_close(priv->protocol, connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
719
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
720 return TRUE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
721 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
722
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
723 /**************************************************************************
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
724 * GObject Implementation
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
725 **************************************************************************/
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
726 static void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
727 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
728 const GValue *value, GParamSpec *pspec)
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
729 {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
730 PurpleConnection *connection = PURPLE_CONNECTION(obj);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
731 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
732
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
733 priv = purple_connection_get_instance_private(connection);
32679
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
734
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
735 switch (param_id) {
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
736 case PROP_ID:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
737 purple_connection_set_id(connection, g_value_get_string(value));
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
738 break;
36366
202c60d1300f Refactored connection, conversation, conversationtypes to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents: 36362
diff changeset
739 case PROP_PROTOCOL:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
740 priv->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
741 break;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
742 case PROP_FLAGS:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
743 purple_connection_set_flags(connection, g_value_get_flags(value));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
744 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
745 case PROP_STATE:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
746 purple_connection_set_state(connection, g_value_get_enum(value));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
747 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
748 case PROP_ACCOUNT:
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
749 purple_connection_set_account(connection,
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
750 g_value_get_object(value));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
751 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
752 case PROP_PASSWORD:
41850
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
753 purple_connection_set_password(connection,
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
754 g_value_get_string(value));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
755 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
756 case PROP_DISPLAY_NAME:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
757 purple_connection_set_display_name(connection,
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
758 g_value_get_string(value));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
759 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
760 default:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
761 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
762 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
763 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
764 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
765
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
766 static void
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
767 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
768 GParamSpec *pspec)
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
769 {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
770 PurpleConnection *connection = PURPLE_CONNECTION(obj);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
771
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
772 switch (param_id) {
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
773 case PROP_ID:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
774 g_value_set_string(value, purple_connection_get_id(connection));
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
775 break;
36366
202c60d1300f Refactored connection, conversation, conversationtypes to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents: 36362
diff changeset
776 case PROP_PROTOCOL:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
777 g_value_set_object(value,
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
778 purple_connection_get_protocol(connection));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
779 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
780 case PROP_FLAGS:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
781 g_value_set_flags(value, purple_connection_get_flags(connection));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
782 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
783 case PROP_STATE:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
784 g_value_set_enum(value, purple_connection_get_state(connection));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
785 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
786 case PROP_ACCOUNT:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
787 g_value_set_object(value,
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
788 purple_connection_get_account(connection));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
789 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
790 case PROP_PASSWORD:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
791 g_value_set_string(value,
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
792 purple_connection_get_password(connection));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
793 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
794 case PROP_DISPLAY_NAME:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
795 g_value_set_string(value,
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
796 purple_connection_get_display_name(connection));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
797 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
798 default:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
799 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
800 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
801 }
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
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
804 static void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
805 purple_connection_init(PurpleConnection *connection) {
41812
c3cd920261b6 Fix the namespace of the PurpleConnectionState enum constants
Gary Kramlich <grim@reaperworld.com>
parents: 41799
diff changeset
806 purple_connection_set_state(connection, PURPLE_CONNECTION_STATE_CONNECTING);
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
807 connections = g_list_append(connections, connection);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
808 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
809
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
810 static void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
811 purple_connection_constructed(GObject *object) {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
812 PurpleConnection *connection = PURPLE_CONNECTION(object);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
813 PurpleConnectionPrivate *priv = NULL;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
814
39433
f033955d125a Use G_DEFINE_TYPE_WITH_PRIVATE for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39352
diff changeset
815 G_OBJECT_CLASS(purple_connection_parent_class)->constructed(object);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
816
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
817 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
818
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
819 if(priv->id == NULL) {
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
820 gchar *uuid = g_uuid_string_random();
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
821
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
822 purple_connection_set_id(connection, uuid);
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
823
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
824 g_free(uuid);
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
825 }
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
826
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
827 purple_signal_emit(purple_connections_get_handle(), "signing-on",
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
828 connection);
32679
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
829 }
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
830
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
831 static void
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
832 purple_connection_dispose(GObject *obj) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
833 PurpleConnection *connection = PURPLE_CONNECTION(obj);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
834 PurpleConnectionPrivate *priv = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
835
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
836 priv = purple_connection_get_instance_private(connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
837
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
838 g_clear_object(&priv->account);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
839
42175
4185b4043214 Use g_clear_handle_id everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41976
diff changeset
840 g_clear_handle_id(&priv->disconnect_timeout, g_source_remove);
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
841
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
842 G_OBJECT_CLASS(purple_connection_parent_class)->dispose(obj);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
843 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
844
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
845 static void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
846 purple_connection_finalize(GObject *object) {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
847 PurpleConnection *connection = PURPLE_CONNECTION(object);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
848 PurpleConnectionPrivate *priv = NULL;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
849
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
850 priv = purple_connection_get_instance_private(connection);
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
851
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
852 g_clear_pointer(&priv->error_info, purple_connection_error_info_free);
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
853
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
854 purple_str_wipe(priv->password);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
855 g_free(priv->display_name);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
856 g_free(priv->id);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
857
39433
f033955d125a Use G_DEFINE_TYPE_WITH_PRIVATE for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39352
diff changeset
858 G_OBJECT_CLASS(purple_connection_parent_class)->finalize(object);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
859 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
860
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
861 static void
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
862 purple_connection_class_init(PurpleConnectionClass *klass) {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
863 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
864
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
865 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
866 obj_class->set_property = purple_connection_set_property;
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
867 obj_class->dispose = purple_connection_dispose;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
868 obj_class->finalize = purple_connection_finalize;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
869 obj_class->constructed = purple_connection_constructed;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
870
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
871 klass->connect = purple_connection_default_connect;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
872 klass->disconnect = purple_connection_default_disconnect;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
873
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
874 properties[PROP_ID] = g_param_spec_string(
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
875 "id", "id",
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
876 "The identifier of the account",
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
877 NULL,
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
878 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
879
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
880 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
881 "protocol", "Protocol",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
882 "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
883 PURPLE_TYPE_PROTOCOL,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
884 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
885
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
886 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
887 "flags", "Connection flags",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
888 "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
889 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
890 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
891
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
892 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
893 "state", "Connection state",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
894 "The current state of the connection.",
41812
c3cd920261b6 Fix the namespace of the PurpleConnectionState enum constants
Gary Kramlich <grim@reaperworld.com>
parents: 41799
diff changeset
895 PURPLE_TYPE_CONNECTION_STATE, PURPLE_CONNECTION_STATE_DISCONNECTED,
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
896 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
897
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
898 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
899 "account", "Account",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
900 "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
901 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
902
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
903 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
904 "password", "Password",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
905 "The password used for connection.", NULL,
41850
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
906 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
907
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
908 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
909 "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
910 "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
911 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
912
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
913 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
914 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
915
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
916 gboolean
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
917 purple_connection_connect(PurpleConnection *connection, GError **error) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
918 PurpleConnectionClass *klass = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
919 PurpleConnectionPrivate *priv = NULL;
41976
49969fa9a664 Update libpurple for the deprecations in the account api
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
920 PurpleContactInfo *info = NULL;
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
921
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
922 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), FALSE);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
923
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
924 priv = purple_connection_get_instance_private(connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
925
41976
49969fa9a664 Update libpurple for the deprecations in the account api
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
926 info = PURPLE_CONTACT_INFO(priv->account);
49969fa9a664 Update libpurple for the deprecations in the account api
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
927
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
928 if(!purple_account_is_disconnected(priv->account)) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
929 g_set_error(error, PURPLE_CONNECTION_ERROR, 0,
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
930 "account %s is not disconnected",
41976
49969fa9a664 Update libpurple for the deprecations in the account api
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
931 purple_contact_info_get_username(info));
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
932
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
933 return TRUE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
934 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
935
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
936 if(((priv->password == NULL) || (*priv->password == '\0')) &&
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
937 !(purple_protocol_get_options(priv->protocol) & OPT_PROTO_NO_PASSWORD) &&
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
938 !(purple_protocol_get_options(priv->protocol) & OPT_PROTO_PASSWORD_OPTIONAL))
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
939 {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
940 g_set_error(error, PURPLE_CONNECTION_ERROR, 0,
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
941 "Cannot connect to account %s without a password.",
41976
49969fa9a664 Update libpurple for the deprecations in the account api
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
942 purple_contact_info_get_username(info));
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
943
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
944 return FALSE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
945 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
946
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
947 purple_debug_info("connection", "Connecting. connection = %p",
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
948 connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
949
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
950 klass = PURPLE_CONNECTION_GET_CLASS(connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
951 if(klass != NULL && klass->connect != NULL) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
952 return klass->connect(connection, error);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
953 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
954
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
955 g_set_error(error, PURPLE_CONNECTION_ERROR, 0,
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
956 "The connection for %s did not implement the connect method",
41976
49969fa9a664 Update libpurple for the deprecations in the account api
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
957 purple_contact_info_get_username(info));
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
958
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
959 return FALSE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
960 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
961
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
962 gboolean
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
963 purple_connection_disconnect(PurpleConnection *connection, GError **error) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
964 PurpleConnectionClass *klass = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
965 PurpleConnectionPrivate *priv = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
966 GSList *buddies = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
967 gboolean remove = FALSE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
968 gboolean ret = TRUE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
969 gpointer handle = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
970
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
971 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), FALSE);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
972
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
973 /* We don't check if the connection's state is connected as everything
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
974 * should be idempotent when doing cleanup.
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
975 */
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
976
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
977 priv = purple_connection_get_instance_private(connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
978
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
979 /* If we're not connecting, we'll need to remove stuff from our contacts
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
980 * from the buddy list.
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
981 */
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
982 if(priv->state != PURPLE_CONNECTION_STATE_CONNECTING) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
983 remove = TRUE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
984 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
985
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
986 handle = purple_connections_get_handle();
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
987
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
988 purple_debug_info("connection", "Disconnecting connection %p", connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
989 purple_connection_set_state(connection,
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
990 PURPLE_CONNECTION_STATE_DISCONNECTING);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
991 purple_signal_emit(handle, "signing-off", connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
992
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
993 g_slist_free_full(priv->active_chats,
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
994 (GDestroyNotify)purple_chat_conversation_leave);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
995
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
996 update_keepalive(connection, FALSE);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
997
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
998 /* Dispatch to the connection's disconnect method. */
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
999 klass = PURPLE_CONNECTION_GET_CLASS(connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1000 if(klass != NULL && klass->disconnect != NULL) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1001 ret = klass->disconnect(connection, error);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1002 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1003
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1004 /* Clear out the proto data that was freed in the protocol's close method */
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1005 buddies = purple_blist_find_buddies(priv->account, NULL);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1006 while (buddies != NULL) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1007 PurpleBuddy *buddy = buddies->data;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1008 purple_buddy_set_protocol_data(buddy, NULL);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1009 buddies = g_slist_delete_link(buddies, buddies);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1010 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1011
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1012 /* Do the rest of our cleanup. */
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1013 connections = g_list_remove(connections, connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1014
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1015 purple_connection_set_state(connection,
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1016 PURPLE_CONNECTION_STATE_DISCONNECTED);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1017
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1018 if(remove) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1019 purple_blist_remove_account(priv->account);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1020 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1021
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1022 purple_signal_emit(handle, "signed-off", connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1023
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1024 purple_account_request_close_with_account(priv->account);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1025 purple_request_close_with_handle(connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1026 purple_notify_close_with_handle(connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1027
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1028 connections_connected = g_list_remove(connections_connected, connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1029 if(connections_connected == NULL) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1030 purple_signal_emit(handle, "offline");
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1031 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1032
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1033 purple_debug_info("connection", "Destroying connection %p", connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1034
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1035 return ret;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1036 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
1037
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1038 /**************************************************************************
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1039 * Connections API
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1040 **************************************************************************/
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
1041
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36067
diff changeset
1042 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1043 _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
1044 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
1045 {
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1046 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
1047 return;
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1048 }
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
1049
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36067
diff changeset
1050 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
1051 " 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
1052
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1053 /* 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
1054 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
1055 }
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36067
diff changeset
1056
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1057 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1058 purple_connections_disconnect_all(void) {
18122
9bf9970c1b6a disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents: 18121
diff changeset
1059 GList *l;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1060
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1061 while((l = purple_connections_get_all()) != NULL) {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
1062 PurpleConnection *connection = l->data;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
1063 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
1064
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
1065 priv = purple_connection_get_instance_private(connection);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
1066
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
1067 priv->wants_to_die = TRUE;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
1068
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
1069 purple_account_disconnect(priv->account);
6113
5bc7394e69ea [gaim-migrate @ 6575]
Mark Doliner <markdoliner@pidgin.im>
parents: 6111
diff changeset
1070 }
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1071 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1072
18122
9bf9970c1b6a disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents: 18121
diff changeset
1073 GList *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1074 purple_connections_get_all(void) {
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1075 return connections;
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1076 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1077
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
1078 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
1079 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
1080 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
1081 }
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
1082
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1083 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1084 purple_connections_set_ui_ops(PurpleConnectionUiOps *ops) {
7035
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1085 connection_ui_ops = ops;
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1086 }
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1087
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1088 PurpleConnectionUiOps *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1089 purple_connections_get_ui_ops(void) {
7035
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1090 return connection_ui_ops;
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1091 }
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1092
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1093 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1094 purple_connections_init(void) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1095 void *handle = purple_connections_get_handle();
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1096
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
1097 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
1098 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
1099
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
1100 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
1101 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
1102
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1103 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
1104 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
1105 PURPLE_TYPE_CONNECTION);
6564
a7a2c1927544 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6533
diff changeset
1106
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1107 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
1108 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
1109 PURPLE_TYPE_CONNECTION);
6564
a7a2c1927544 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6533
diff changeset
1110
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1111 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
1112 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
1113 PURPLE_TYPE_CONNECTION);
6564
a7a2c1927544 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6533
diff changeset
1114
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1115 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
1116 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
1117 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
1118
ca8cb8706802 I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents: 21279
diff changeset
1119 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
1120 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
1121 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
1122 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
1123
30039
9cd7672bae4f Add an autojoin connection signal
Richard Laager <rlaager@pidgin.im>
parents: 28577
diff changeset
1124 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
1125 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
1126 PURPLE_TYPE_CONNECTION);
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1127 }
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1128
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1129 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1130 purple_connections_uninit(void) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1131 purple_signals_unregister_by_instance(purple_connections_get_handle());
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1132 }
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1133
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1134 void *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
1135 purple_connections_get_handle(void) {
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1136 return &connections_handle;
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1137 }

mercurial