libpurple/connection.c

Sat, 13 Apr 2024 21:21:59 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Sat, 13 Apr 2024 21:21:59 -0500
changeset 42715
f886f74847b0
parent 42706
6039c89f2f5c
child 42720
22c42a8405ad
permissions
-rw-r--r--

Remove PurpleIMConversation and PurpleProtocolIM

Both of these have been replaced and needed to be removed.

Testing Done:
Checked in with our turtle buddies.

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

42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
1 /*
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
2 * Purple - Internet Messaging Library
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
8046
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7956
diff changeset
7 * source distribution.
5631
7f510b22ccf5 [gaim-migrate @ 6038]
Nathan Walp <nwalp@pidgin.im>
parents: 5624
diff changeset
8 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
10 * under the terms of the GNU General Public License as published by the Free
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
11 * Software Foundation; either version 2 of the License, or (at your option)
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
12 * any later version.
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
14 * This library is distributed in the hope that it will be useful, but WITHOUT
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
17 * more details.
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
19 * You should have received a copy of the GNU General Public License along with
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
20 * this library; if not, see <https://www.gnu.org/licenses/>.
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 */
24569
5dbd0617a27d Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents: 22336
diff changeset
22
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
23 #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
24
34706
02cb08146888 Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents: 34645
diff changeset
25 #include "buddylist.h"
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 #include "connection.h"
5717
2f3a377de638 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents: 5676
diff changeset
27 #include "debug.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
28 #include "notify.h"
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
29 #include "prefs.h"
14900
4af8b81519b6 [gaim-migrate @ 17607]
Mark Doliner <markdoliner@pidgin.im>
parents: 14814
diff changeset
30 #include "proxy.h"
42344
c51d37734155 Rename account.[ch] to purpleaccount.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 42175
diff changeset
31 #include "purpleaccount.h"
41007
90d2dee9b3dc Fix the includes for the purpleenums rename
Gary Kramlich <grim@reaperworld.com>
parents: 40813
diff changeset
32 #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
33 #include "purpleprivate.h"
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40654
diff changeset
34 #include "purpleprotocolserver.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
35 #include "request.h"
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
36 #include "server.h"
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
37 #include "signals.h"
6106
1dc08be40f0a [gaim-migrate @ 6567]
Mark Doliner <markdoliner@pidgin.im>
parents: 6076
diff changeset
38 #include "util.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
39
39549
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
40 /**
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
41 * PurpleConnection:
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
42 *
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
43 * Represents an active connection on an account.
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
44 */
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
45 typedef struct {
39549
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
46 GObject gparent;
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
47
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
48 gchar *id;
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
49
42542
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
50 GCancellable *cancellable;
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
51
37069
22bf5ea00006 Merge gtkdoc-conversion
Ankit Vani <a@nevitus.org>
parents: 37066 35458
diff changeset
52 PurpleProtocol *protocol; /* The protocol. */
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
53 PurpleConnectionFlags flags; /* Connection flags. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
54
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
55 PurpleConnectionState state; /* The connection state. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
56
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
57 PurpleAccount *account; /* The account being connected to. */
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
58 char *password; /* The password used. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
59
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
60 char *display_name; /* How you appear to other people. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
61
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
62 /* 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
63 * 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
64 * 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
65 * 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
66 * setting it themselves.
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
67 * See purple_connection_error_is_fatal()
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
68 */
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
69 gboolean wants_to_die;
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
70
41083
590d533cf290 Fix several typos in libpurple
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41007
diff changeset
71 /* 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
72 PurpleConnectionErrorInfo *error_info;
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
73
41083
590d533cf290 Fix several typos in libpurple
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41007
diff changeset
74 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
75 } PurpleConnectionPrivate;
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
76
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
77 enum {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
78 PROP_0,
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
79 PROP_ID,
42542
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
80 PROP_CANCELLABLE,
36366
202c60d1300f Refactored connection, conversation, conversationtypes to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents: 36362
diff changeset
81 PROP_PROTOCOL,
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
82 PROP_FLAGS,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
83 PROP_STATE,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
84 PROP_ACCOUNT,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
85 PROP_PASSWORD,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
86 PROP_DISPLAY_NAME,
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42542
diff changeset
87 N_PROPERTIES,
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
88 };
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
89
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42542
diff changeset
90 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
91
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 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
93 static GList *connections_connected = NULL;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
95 static int connections_handle;
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
96
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
97 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
98
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
99 /**************************************************************************
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
100 * Connection API
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
101 **************************************************************************/
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 /*
8130
58e4e51f514b [gaim-migrate @ 8835]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
104 * d:)->-<
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 *
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 * d:O-\-<
8130
58e4e51f514b [gaim-migrate @ 8835]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
107 *
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 * d:D-/-<
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 *
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 * d8D->-< DANCE!
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 */
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
114 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
115 PurpleConnectionState state)
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
117 PurpleConnectionPrivate *priv = NULL;
5885
223ac977eed2 [gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents: 5883
diff changeset
118
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
119 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
120
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
121 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
122
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
123 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
124 return;
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
125 }
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
127 priv->state = state;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128
41812
c3cd920261b6 Fix the namespace of the PurpleConnectionState enum constants
Gary Kramlich <grim@reaperworld.com>
parents: 41799
diff changeset
129 if(priv->state == PURPLE_CONNECTION_STATE_CONNECTED) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
130 PurplePresence *presence;
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41958
diff changeset
131 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
132 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
133 gpointer handle = NULL;
10052
329dad7e2da3 [gaim-migrate @ 11013]
Dave West <kat@users.sourceforge.net>
parents: 9944
diff changeset
134
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
135 presence = purple_account_get_presence(priv->account);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 /* 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
138 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
139 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
140 g_date_time_unref(timestamp);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
142 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
143
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
144 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
145 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
146 purple_signal_emit_return_1(handle, "autojoin", connection);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147
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
148 /* 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
149 * 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
150 */
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
151 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
152 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
153 }
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
154
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
155 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
156 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
157
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
158 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
159 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
160 }
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
161 }
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
162
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
163 g_object_notify_by_pspec(G_OBJECT(connection), properties[PROP_STATE]);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
167 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
168 PurpleConnectionFlags flags)
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
169 {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
170 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
171
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
172 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
173
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
174 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
175
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
176 priv->flags = flags;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
177
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
178 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
179 }
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
180
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
181 void
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
182 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
183 const gchar *name)
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
184 {
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
185 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
186
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
187 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
188
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
189 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
190
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
191 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
192 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
193
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
194 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
195 properties[PROP_DISPLAY_NAME]);
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
196 }
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
197
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
198 PurpleConnectionState
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
199 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
200 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
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 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
203 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
204
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
205 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
206
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
207 return priv->state;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
210 PurpleConnectionFlags
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
211 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
212 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
213
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
214 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
215
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
216 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
217
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
218 return priv->flags;
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
219 }
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
220
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
221 PurpleAccount *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
222 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
223 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
224
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
225 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
226
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
227 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
228
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
229 return priv->account;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
232 const gchar *
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
233 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
234 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
235
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
236 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
237
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
238 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
239
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
240 return priv->id;
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
241 }
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
242
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36477
diff changeset
243 PurpleProtocol *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
244 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
245 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
246
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
247 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
248
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 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
252 }
ac905bb0a8ec Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22324
diff changeset
253
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 const char *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
255 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
256 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
257
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
258 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
259
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
260 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
261
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
262 return priv->password;
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
263 }
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
264
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
265 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
266 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
267 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
268 {
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
269 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
270
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
271 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
272
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
273 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
274
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
275 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
276 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
277
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
278 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
279 }
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
280
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
281 const char *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
282 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
283 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
284
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
285 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
286
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
287 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
288
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
289 return priv->display_name;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
290 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
291
34877
5b3c720b9077 Added missing internal function, used by account.c
Ankit Vani <a@nevitus.org>
parents: 34866
diff changeset
292 gboolean
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
293 _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
294 PurpleConnectionPrivate *priv = NULL;
34877
5b3c720b9077 Added missing internal function, used by account.c
Ankit Vani <a@nevitus.org>
parents: 34866
diff changeset
295
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
296 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
297
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
298 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
299
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
300 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
301 }
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
302
12412
8abe3226695e [gaim-migrate @ 14719]
Richard Laager <rlaager@pidgin.im>
parents: 12272
diff changeset
303 static gboolean
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
304 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
305 PurpleAccount *account = data;
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
306 PurpleConnection *connection;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
307
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
308 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
309
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
310 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
311 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
312
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
313 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
314
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
315 priv->disconnect_timeout = 0;
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
316
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
317 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
318 /* 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
319 purple_account_disconnect(account);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
320 } else {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
321 /* 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
322 * 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
323 * cleanup.
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
324 */
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
325 GError *error = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
326
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
327 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
328 const char *message = "unknown error";
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
329
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
330 if(error != NULL) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
331 message = error->message;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
332 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
333
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
334 purple_debug_warning("connections",
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
335 "failed to disconnect %p : %s",
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
336 connection, message);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
337 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
338
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
339 g_clear_error(&error);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
340
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
341 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
342 }
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
343 }
27336
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
344
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
345 return G_SOURCE_REMOVE;
10742
2783135f0ecf [gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents: 10740
diff changeset
346 }
2783135f0ecf [gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents: 10740
diff changeset
347
5571
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
348 void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
349 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
350 PurpleConnectionError reason,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
351 const char *description)
20430
bb30dff3da21 Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents: 19897
diff changeset
352 {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
353 PurpleConnectionPrivate *priv = NULL;
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
354
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
355 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
356
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
357 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
358
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
359 /* This sanity check relies on PURPLE_CONNECTION_ERROR_OTHER_ERROR
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
360 * being the last member of the PurpleConnectionError enum in
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
361 * connection.h; if other reasons are added after it, this check should
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
362 * be updated.
21278
19f6ce8ee4ad rlaager suggested using the last element of the PurpleDisconnectReason enum
Will Thompson <resiak@pidgin.im>
parents: 21154
diff changeset
363 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
364 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
365 purple_debug_error("connection",
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32156
diff changeset
366 "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
367 "valid reason\n", reason);
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
368 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
369 }
15848
44463a06e833 Change connection.c:gaim_connection_error() to still work even if the
Mark Doliner <markdoliner@pidgin.im>
parents: 15537
diff changeset
370
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
371 if(description == NULL) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32156
diff changeset
372 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
373 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
374 }
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
375
6393
b845f8d02597 [gaim-migrate @ 6898]
Nathan Walp <nwalp@pidgin.im>
parents: 6297
diff changeset
376 /* 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
377 if(priv->error_info != NULL) {
6393
b845f8d02597 [gaim-migrate @ 6898]
Nathan Walp <nwalp@pidgin.im>
parents: 6297
diff changeset
378 return;
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
379 }
6393
b845f8d02597 [gaim-migrate @ 6898]
Nathan Walp <nwalp@pidgin.im>
parents: 6297
diff changeset
380
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
381 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
382
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
383 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
384 "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
385 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
386
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
387 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
388
21285
ca8cb8706802 I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents: 21279
diff changeset
389 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
390 connection, reason, description);
5727
883d5bc2eb0d [gaim-migrate @ 6150]
Nathan Walp <nwalp@pidgin.im>
parents: 5725
diff changeset
391
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
392 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
393 priv->account);
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
394 }
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
395
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
396 PurpleConnectionErrorInfo *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
397 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
398 PurpleConnectionPrivate *priv = NULL;
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
399
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
400 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
401
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
402 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
403
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
404 return priv->error_info;
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
405 }
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
406
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
407 void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
408 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
409 PurpleConnectionError reason;
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
410
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
411 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
412 /* 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
413 return;
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
414 }
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
415
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
416 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
417 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
418 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
419 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
420 break;
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
421 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
422 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
423 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
424 break;
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
425 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
426 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
427 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
428 break;
37666
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
429 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
430 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
431 default:
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
432 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
433 }
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
434 } 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
435 reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
37961
2ee4c67768f4 connection: Support PurpleConnectionError GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents: 37959
diff changeset
436 } else if (error->domain == PURPLE_CONNECTION_ERROR) {
2ee4c67768f4 connection: Support PurpleConnectionError GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents: 37959
diff changeset
437 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
438 } else {
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
439 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
440 }
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
441
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
442 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
443 }
08ec2e6e0174 libpurple: Add purple_connection_g_error() to simplify handling G_IO_ERRORs
Mike Ruprecht <cmaiku@gmail.com>
parents: 37148
diff changeset
444
37959
e76677ed819c connection: Add purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37958
diff changeset
445 void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
446 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
447 purple_connection_g_error(connection, error);
37959
e76677ed819c connection: Add purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37958
diff changeset
448 g_error_free(error);
e76677ed819c connection: Add purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37958
diff changeset
449 }
e76677ed819c connection: Add purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37958
diff changeset
450
20431
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
451 gboolean
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
452 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
453 switch (reason) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
454 case PURPLE_CONNECTION_ERROR_NETWORK_ERROR:
22162
1e0f1dbe89da Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21865
diff changeset
455 case PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR:
41463
6b13615303cc Add some custom connection errors
Gary Kramlich <grim@reaperworld.com>
parents: 41429
diff changeset
456 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
457 return FALSE;
0ae51085309d Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents: 21507
diff changeset
458 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
459 case PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED:
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
460 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
461 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
462 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
463 case PURPLE_CONNECTION_ERROR_INVALID_SETTINGS:
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
464 case PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
465 case PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
466 case PURPLE_CONNECTION_ERROR_CERT_EXPIRED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
467 case PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
468 case PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
469 case PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
470 case PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
471 case PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR:
41463
6b13615303cc Add some custom connection errors
Gary Kramlich <grim@reaperworld.com>
parents: 41429
diff changeset
472 case PURPLE_CONNECTION_ERROR_CUSTOM_FATAL:
6b13615303cc Add some custom connection errors
Gary Kramlich <grim@reaperworld.com>
parents: 41429
diff changeset
473 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
474 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
475 default:
610a45545a40 datallah pointed out that using g_return_if_fail() is preferable to
Will Thompson <resiak@pidgin.im>
parents: 21149
diff changeset
476 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
477 }
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
478 }
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
479
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
480 /**************************************************************************
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
481 * Helpers
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
482 **************************************************************************/
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
483 static void
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
484 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
485 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
486
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
487 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
488
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
489 g_free(priv->id);
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
490 priv->id = g_strdup(id);
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
491
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
492 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
493 }
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
494
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
495 static void
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
496 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
497 PurpleAccount *account)
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
498 {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
499 PurpleConnectionPrivate *priv = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
500
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
501 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
502
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
503 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
504 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
505 properties[PROP_ACCOUNT]);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
506 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
507 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
508
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
509 /**************************************************************************
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
510 * GObject Implementation
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
511 **************************************************************************/
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
512 static void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
513 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
514 const GValue *value, GParamSpec *pspec)
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
515 {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
516 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
517 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
518
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
519 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
520
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
521 switch (param_id) {
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
522 case PROP_ID:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
523 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
524 break;
36366
202c60d1300f Refactored connection, conversation, conversationtypes to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents: 36362
diff changeset
525 case PROP_PROTOCOL:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
526 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
527 break;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
528 case PROP_FLAGS:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
529 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
530 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
531 case PROP_STATE:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
532 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
533 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
534 case PROP_ACCOUNT:
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
535 purple_connection_set_account(connection,
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
536 g_value_get_object(value));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
537 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
538 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
539 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
540 g_value_get_string(value));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
541 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
542 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
543 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
544 g_value_get_string(value));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
545 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
546 default:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
547 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
548 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
549 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
550 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
551
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
552 static void
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
553 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
554 GParamSpec *pspec)
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
555 {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
556 PurpleConnection *connection = PURPLE_CONNECTION(obj);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
557
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
558 switch (param_id) {
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
559 case PROP_ID:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
560 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
561 break;
42542
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
562 case PROP_CANCELLABLE:
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
563 g_value_set_object(value,
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
564 purple_connection_get_cancellable(connection));
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
565 break;
36366
202c60d1300f Refactored connection, conversation, conversationtypes to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents: 36362
diff changeset
566 case PROP_PROTOCOL:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
567 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
568 purple_connection_get_protocol(connection));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
569 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
570 case PROP_FLAGS:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
571 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
572 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
573 case PROP_STATE:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
574 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
575 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
576 case PROP_ACCOUNT:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
577 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
578 purple_connection_get_account(connection));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
579 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
580 case PROP_PASSWORD:
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
581 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
582 purple_connection_get_password(connection));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
583 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
584 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
585 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
586 purple_connection_get_display_name(connection));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
587 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
588 default:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
589 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
590 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
591 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
592 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
593
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
594 static void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
595 purple_connection_init(PurpleConnection *connection) {
42542
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
596 PurpleConnectionPrivate *priv = NULL;
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
597
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
598 priv = purple_connection_get_instance_private(connection);
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
599
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
600 priv->cancellable = g_cancellable_new();
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
601
41812
c3cd920261b6 Fix the namespace of the PurpleConnectionState enum constants
Gary Kramlich <grim@reaperworld.com>
parents: 41799
diff changeset
602 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
603 connections = g_list_append(connections, connection);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
604 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
605
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
606 static void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
607 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
608 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
609 PurpleConnectionPrivate *priv = NULL;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
610
39433
f033955d125a Use G_DEFINE_TYPE_WITH_PRIVATE for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39352
diff changeset
611 G_OBJECT_CLASS(purple_connection_parent_class)->constructed(object);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
612
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
613 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
614
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
615 if(priv->id == NULL) {
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
616 gchar *uuid = g_uuid_string_random();
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
617
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
618 purple_connection_set_id(connection, uuid);
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
619
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
620 g_free(uuid);
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
621 }
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
622
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
623 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
624 connection);
32679
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
625 }
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
626
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
627 static void
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
628 purple_connection_dispose(GObject *obj) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
629 PurpleConnection *connection = PURPLE_CONNECTION(obj);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
630 PurpleConnectionPrivate *priv = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
631
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
632 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
633
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
634 g_clear_object(&priv->account);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
635
42175
4185b4043214 Use g_clear_handle_id everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41976
diff changeset
636 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
637
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
638 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
639 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
640
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
641 static void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
642 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
643 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
644 PurpleConnectionPrivate *priv = NULL;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
645
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
646 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
647
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
648 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
649
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
650 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
651 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
652 g_free(priv->id);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
653
42542
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
654 g_clear_object(&priv->cancellable);
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
655
39433
f033955d125a Use G_DEFINE_TYPE_WITH_PRIVATE for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39352
diff changeset
656 G_OBJECT_CLASS(purple_connection_parent_class)->finalize(object);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
657 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
658
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
659 static void
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
660 purple_connection_class_init(PurpleConnectionClass *klass) {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
661 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
662
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
663 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
664 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
665 obj_class->dispose = purple_connection_dispose;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
666 obj_class->finalize = purple_connection_finalize;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
667 obj_class->constructed = purple_connection_constructed;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
668
42656
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
669 /**
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
670 * PurpleConnection:id:
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
671 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
672 * The unique identifier for the connection.
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
673 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
674 * Since: 3.0
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
675 */
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
676 properties[PROP_ID] = g_param_spec_string(
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
677 "id", "id",
42656
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
678 "The identifier of the connection",
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
679 NULL,
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
680 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
681
42542
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
682 /**
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
683 * PurpleConnection:cancellable:
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
684 *
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
685 * A [class@Gio.Cancellable] to be used with the connection.
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
686 *
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
687 * This can be passed function that require a cancellable for the
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
688 * connection.
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
689 *
42612
d905313bc732 Remove the micro version from since tags for libpurple part 1
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
690 * Since: 3.0
42542
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
691 */
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
692 properties[PROP_CANCELLABLE] = g_param_spec_object(
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
693 "cancellable", "cancellable",
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
694 "A cancellable for the connection.",
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
695 G_TYPE_CANCELLABLE,
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
696 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
697
42656
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
698 /**
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
699 * PurpleConnection:protocol:
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
700 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
701 * The protocol that this connection is for.
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
702 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
703 * Since: 3.0
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
704 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
705 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
706 "protocol", "Protocol",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
707 "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
708 PURPLE_TYPE_PROTOCOL,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
709 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
710
42656
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
711 /**
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
712 * PurpleConnection:flags:
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
713 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
714 * The flags for this connection.
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
715 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
716 * Since: 3.0
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
717 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
718 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
719 "flags", "Connection flags",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
720 "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
721 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
722 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
723
42656
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
724 /**
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
725 * PurpleConnection:state:
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
726 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
727 * The state of the connection.
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
728 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
729 * Since: 3.0
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
730 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
731 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
732 "state", "Connection state",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
733 "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
734 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
735 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
736
42656
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
737 /**
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
738 * PurpleConnection:account:
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
739 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
740 * The account this connection belongs to.
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
741 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
742 * Since: 3.0
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
743 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
744 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
745 "account", "Account",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
746 "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
747 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
748
42656
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
749 /**
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
750 * PurpleConnection:password:
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
751 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
752 * The password for this connection.
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
753 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
754 * This is only stored for reconnections and may go away in the future.
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
755 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
756 * Since: 3.0
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
757 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
758 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
759 "password", "Password",
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
760 "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
761 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
762
42656
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
763 /**
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
764 * PurpleConnection:display-name:
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
765 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
766 * The display name for the account.
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
767 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
768 * Since: 3.0
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42612
diff changeset
769 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
770 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
771 "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
772 "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
773 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
774
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42542
diff changeset
775 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
776 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
777
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
778 gboolean
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
779 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
780 PurpleConnectionClass *klass = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
781 PurpleConnectionPrivate *priv = NULL;
41976
49969fa9a664 Update libpurple for the deprecations in the account api
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
782 PurpleContactInfo *info = NULL;
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
783
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
784 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
785
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
786 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
787
41976
49969fa9a664 Update libpurple for the deprecations in the account api
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
788 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
789
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
790 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
791 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
792 "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
793 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
794
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
795 return TRUE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
796 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
797
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
798 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
799 !(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
800 !(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
801 {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
802 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
803 "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
804 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
805
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
806 return FALSE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
807 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
808
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
809 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
810 connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
811
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
812 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
813 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
814 return klass->connect(connection, error);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
815 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
816
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
817 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
818 "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
819 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
820
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
821 return FALSE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
822 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
823
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
824 gboolean
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
825 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
826 PurpleConnectionClass *klass = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
827 PurpleConnectionPrivate *priv = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
828 GSList *buddies = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
829 gboolean remove = FALSE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
830 gboolean ret = TRUE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
831 gpointer handle = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
832
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
833 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
834
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
835 /* 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
836 * 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
837 */
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
838
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
839 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
840
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
841 /* 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
842 * from the buddy list.
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 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
845 remove = TRUE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
846 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
847
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
848 handle = purple_connections_get_handle();
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
849
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
850 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
851 purple_connection_set_state(connection,
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
852 PURPLE_CONNECTION_STATE_DISCONNECTING);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
853 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
854
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
855 /* 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
856 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
857 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
858 ret = klass->disconnect(connection, error);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
859 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
860
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
861 /* 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
862 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
863 while (buddies != NULL) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
864 PurpleBuddy *buddy = buddies->data;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
865 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
866 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
867 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
868
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
869 /* 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
870 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
871
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
872 purple_connection_set_state(connection,
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
873 PURPLE_CONNECTION_STATE_DISCONNECTED);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
874
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
875 if(remove) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
876 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
877 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
878
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
879 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
880
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
881 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
882 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
883 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
884
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
885 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
886 if(connections_connected == NULL) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
887 purple_signal_emit(handle, "offline");
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
888 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
889
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
890 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
891
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
892 return ret;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
893 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
894
42542
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
895 GCancellable *
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
896 purple_connection_get_cancellable(PurpleConnection *connection) {
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
897 PurpleConnectionPrivate *priv = NULL;
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
898
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
899 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), NULL);
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
900
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
901 priv = purple_connection_get_instance_private(connection);
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
902
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
903 return priv->cancellable;
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
904 }
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
905
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
906 /**************************************************************************
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
907 * Connections API
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
908 **************************************************************************/
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
909
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36067
diff changeset
910 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
911 purple_connections_disconnect_all(void) {
18122
9bf9970c1b6a disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents: 18121
diff changeset
912 GList *l;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
913
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
914 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
915 PurpleConnection *connection = l->data;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
916 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
917
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
918 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
919
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
920 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
921
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
922 purple_account_disconnect(priv->account);
6113
5bc7394e69ea [gaim-migrate @ 6575]
Mark Doliner <markdoliner@pidgin.im>
parents: 6111
diff changeset
923 }
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
924 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
925
18122
9bf9970c1b6a disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents: 18121
diff changeset
926 GList *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
927 purple_connections_get_all(void) {
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
928 return connections;
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
929 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
930
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
931 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
932 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
933 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
934 }
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
935
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
936 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
937 purple_connections_init(void) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
938 void *handle = purple_connections_get_handle();
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
939
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
940 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
941 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
942
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
943 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
944 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
945
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
946 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
947 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
948 PURPLE_TYPE_CONNECTION);
6564
a7a2c1927544 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6533
diff changeset
949
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
950 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
951 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
952 PURPLE_TYPE_CONNECTION);
6564
a7a2c1927544 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6533
diff changeset
953
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
954 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
955 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
956 PURPLE_TYPE_CONNECTION);
6564
a7a2c1927544 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6533
diff changeset
957
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
958 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
959 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
960 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
961
ca8cb8706802 I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents: 21279
diff changeset
962 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
963 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
964 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
965 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
966
30039
9cd7672bae4f Add an autojoin connection signal
Richard Laager <rlaager@pidgin.im>
parents: 28577
diff changeset
967 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
968 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
969 PURPLE_TYPE_CONNECTION);
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
970 }
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
971
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
972 void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
973 purple_connections_uninit(void) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
974 purple_signals_unregister_by_instance(purple_connections_get_handle());
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
975 }
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
976
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
977 void *
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
978 purple_connections_get_handle(void) {
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
979 return &connections_handle;
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
980 }

mercurial