libpurple/purpleconnection.c

Mon, 30 Jun 2025 14:22:13 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 30 Jun 2025 14:22:13 -0500
changeset 43269
1523eab3b5a0
parent 43237
c641f6bea7dd
permissions
-rw-r--r--

Update the flatpak to gnome 48 and to the matching birb version

The birb version was missed here when it was updated.

Testing Done:
Built the flatpak with the instructions in the readme.

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

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
43016
158d07e5cd54 Rename connection.[ch] to purpleconnection.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 42999
diff changeset
25 #include "purpleconnection.h"
42997
368deff13c21 Split purpleprivate.h up into individual files
Gary Kramlich <grim@reaperworld.com>
parents: 42994
diff changeset
26
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 "prefs.h"
14900
4af8b81519b6 [gaim-migrate @ 17607]
Mark Doliner <markdoliner@pidgin.im>
parents: 14814
diff changeset
29 #include "proxy.h"
42344
c51d37734155 Rename account.[ch] to purpleaccount.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 42175
diff changeset
30 #include "purpleaccount.h"
41007
90d2dee9b3dc Fix the includes for the purpleenums rename
Gary Kramlich <grim@reaperworld.com>
parents: 40813
diff changeset
31 #include "purpleenums.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
32 #include "request.h"
6106
1dc08be40f0a [gaim-migrate @ 6567]
Mark Doliner <markdoliner@pidgin.im>
parents: 6076
diff changeset
33 #include "util.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
34
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
35 typedef struct {
39549
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
36 GObject gparent;
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
37
42989
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
38 char *id;
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
39
42542
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
40 GCancellable *cancellable;
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
41
37069
22bf5ea00006 Merge gtkdoc-conversion
Ankit Vani <a@nevitus.org>
parents: 37066 35458
diff changeset
42 PurpleProtocol *protocol; /* The protocol. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
43
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
44 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
45 char *password; /* The password used. */
39549
ee61762c3ebe Use G_DECLARE* for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39520
diff changeset
46 } PurpleConnectionPrivate;
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
47
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
48 enum {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
49 PROP_0,
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
50 PROP_ID,
42542
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
51 PROP_CANCELLABLE,
36366
202c60d1300f Refactored connection, conversation, conversationtypes to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents: 36362
diff changeset
52 PROP_PROTOCOL,
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
53 PROP_ACCOUNT,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
54 PROP_PASSWORD,
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42542
diff changeset
55 N_PROPERTIES,
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
56 };
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
57
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42542
diff changeset
58 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
59
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
60 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
61
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
62 /**************************************************************************
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
63 * Connection API
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
64 **************************************************************************/
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 /*
8130
58e4e51f514b [gaim-migrate @ 8835]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
67 * d:)->-<
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 *
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 * d:O-\-<
8130
58e4e51f514b [gaim-migrate @ 8835]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
70 *
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 * d:D-/-<
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 *
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 * d8D->-< DANCE!
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 */
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
76 PurpleAccount *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
77 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
78 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
79
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
80 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
81
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
82 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
83
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
84 return priv->account;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86
42989
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
87 const char *
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
88 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
89 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
90
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
91 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
92
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
93 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
94
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
95 return priv->id;
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
96 }
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
97
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36477
diff changeset
98 PurpleProtocol *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
99 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
100 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
101
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
102 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
103
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
104 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
105
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
106 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
107 }
ac905bb0a8ec Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22324
diff changeset
108
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 const char *
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
110 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
111 PurpleConnectionPrivate *priv = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
112
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
113 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
114
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
115 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
116
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
117 return priv->password;
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
118 }
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
119
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
120 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
121 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
122 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
123 {
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
124 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
125
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
126 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
127
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
128 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
129
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
130 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
131 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
132
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
133 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
134 }
7d551859bd94 Fix an issue where XMPP accounts weren't reading passwords from the credential manager
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
135
34877
5b3c720b9077 Added missing internal function, used by account.c
Ankit Vani <a@nevitus.org>
parents: 34866
diff changeset
136 gboolean
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
137 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
138 switch (reason) {
42989
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
139 case PURPLE_CONNECTION_ERROR_NETWORK_ERROR:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
140 case PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
141 case PURPLE_CONNECTION_ERROR_CUSTOM_TEMPORARY:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
142 return FALSE;
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
143 case PURPLE_CONNECTION_ERROR_INVALID_USERNAME:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
144 case PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
145 case PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
146 case PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
147 case PURPLE_CONNECTION_ERROR_NAME_IN_USE:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
148 case PURPLE_CONNECTION_ERROR_INVALID_SETTINGS:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
149 case PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
150 case PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
151 case PURPLE_CONNECTION_ERROR_CERT_EXPIRED:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
152 case PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
153 case PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
154 case PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
155 case PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
156 case PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
157 case PURPLE_CONNECTION_ERROR_CUSTOM_FATAL:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
158 case PURPLE_CONNECTION_ERROR_OTHER_ERROR:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
159 return TRUE;
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
160 default:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
161 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
162 }
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
163 }
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
164
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
165 /**************************************************************************
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
166 * Helpers
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
167 **************************************************************************/
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
168 static void
42989
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
169 purple_connection_set_id(PurpleConnection *connection, const char *id) {
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 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
173
42767
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42727
diff changeset
174 if(g_set_str(&priv->id, id)) {
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42727
diff changeset
175 g_object_notify_by_pspec(G_OBJECT(connection), properties[PROP_ID]);
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42727
diff changeset
176 }
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
177 }
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
178
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
179 static void
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
180 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
181 PurpleAccount *account)
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
182 {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
183 PurpleConnectionPrivate *priv = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
184
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
185 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
186
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
187 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
188 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
189 properties[PROP_ACCOUNT]);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
190 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
191 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
192
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
193 /**************************************************************************
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
194 * GObject Implementation
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
195 **************************************************************************/
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
196 static void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
197 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
198 const GValue *value, GParamSpec *pspec)
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
199 {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
200 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
201 PurpleConnectionPrivate *priv = NULL;
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
202
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
203 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
204
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
205 switch (param_id) {
42989
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
206 case PROP_ID:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
207 purple_connection_set_id(connection, g_value_get_string(value));
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
208 break;
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
209 case PROP_PROTOCOL:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
210 priv->protocol = g_value_get_object(value);
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
211 break;
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
212 case PROP_ACCOUNT:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
213 purple_connection_set_account(connection, g_value_get_object(value));
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
214 break;
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
215 case PROP_PASSWORD:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
216 purple_connection_set_password(connection, g_value_get_string(value));
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
217 break;
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
218 default:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
219 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
220 break;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
221 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
222 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
223
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
224 static void
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
225 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
226 GParamSpec *pspec)
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
227 {
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
228 PurpleConnection *connection = PURPLE_CONNECTION(obj);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
229
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
230 switch (param_id) {
42989
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
231 case PROP_ID:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
232 g_value_set_string(value, purple_connection_get_id(connection));
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
233 break;
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
234 case PROP_CANCELLABLE:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
235 g_value_set_object(value,
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
236 purple_connection_get_cancellable(connection));
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
237 break;
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
238 case PROP_PROTOCOL:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
239 g_value_set_object(value, purple_connection_get_protocol(connection));
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
240 break;
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
241 case PROP_ACCOUNT:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
242 g_value_set_object(value, purple_connection_get_account(connection));
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
243 break;
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
244 case PROP_PASSWORD:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
245 g_value_set_string(value, purple_connection_get_password(connection));
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
246 break;
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
247 default:
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
248 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
249 break;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
250 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
251 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
252
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
253 static void
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
254 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
255 PurpleConnectionPrivate *priv = NULL;
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
256
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
257 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
258
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
259 priv->cancellable = g_cancellable_new();
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
260 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
261
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
262 static void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
263 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
264 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
265 PurpleConnectionPrivate *priv = NULL;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
266
39433
f033955d125a Use G_DEFINE_TYPE_WITH_PRIVATE for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39352
diff changeset
267 G_OBJECT_CLASS(purple_connection_parent_class)->constructed(object);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
268
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
269 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
270
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
271 if(priv->id == NULL) {
42989
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
272 char *uuid = g_uuid_string_random();
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
273
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
274 purple_connection_set_id(connection, uuid);
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
275
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
276 g_free(uuid);
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
277 }
32679
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
278 }
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
279
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
280 static void
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
281 purple_connection_dispose(GObject *obj) {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
282 PurpleConnection *connection = PURPLE_CONNECTION(obj);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
283 PurpleConnectionPrivate *priv = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
284
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
285 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
286
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
287 g_clear_object(&priv->account);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
288
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
289 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
290 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
291
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
292 static void
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
293 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
294 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
295 PurpleConnectionPrivate *priv = NULL;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
296
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
297 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
298
41792
715d38814f5d Make PurpleConnection derivable, which also means adding a private structure.
Gary Kramlich <grim@reaperworld.com>
parents: 41769
diff changeset
299 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
300 g_free(priv->id);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
301
42542
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
302 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
303
39433
f033955d125a Use G_DEFINE_TYPE_WITH_PRIVATE for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39352
diff changeset
304 G_OBJECT_CLASS(purple_connection_parent_class)->finalize(object);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
305 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
306
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
307 static void
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
308 purple_connection_class_init(PurpleConnectionClass *klass) {
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
309 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
310
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
311 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
312 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
313 obj_class->dispose = purple_connection_dispose;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
314 obj_class->finalize = purple_connection_finalize;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
315 obj_class->constructed = purple_connection_constructed;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
316
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
317 /**
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
318 * 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
319 *
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
320 * 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
321 *
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
322 * 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
323 */
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
324 properties[PROP_ID] = g_param_spec_string(
42989
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
325 "id", NULL, NULL,
41300
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
326 NULL,
fa932768f319 Add an ID property to PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41156
diff changeset
327 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
328
42542
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
329 /**
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
330 * PurpleConnection:cancellable:
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
331 *
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
332 * 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
333 *
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
334 * 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
335 * connection.
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
336 *
42612
d905313bc732 Remove the micro version from since tags for libpurple part 1
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
337 * 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
338 */
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
339 properties[PROP_CANCELLABLE] = g_param_spec_object(
42989
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
340 "cancellable", NULL, NULL,
42542
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
341 G_TYPE_CANCELLABLE,
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
342 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
343
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
344 /**
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
345 * 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
346 *
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
347 * 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
348 *
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
349 * 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
350 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
351 properties[PROP_PROTOCOL] = g_param_spec_object(
42989
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
352 "protocol", NULL, NULL,
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
353 PURPLE_TYPE_PROTOCOL,
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
354 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
355
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
356 /**
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
357 * 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
358 *
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
359 * 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
360 *
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
361 * 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
362 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
363 properties[PROP_ACCOUNT] = g_param_spec_object(
42989
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
364 "account", NULL, NULL,
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
365 PURPLE_TYPE_ACCOUNT,
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
366 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
367
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
368 /**
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
369 * 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
370 *
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
371 * 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
372 *
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
373 * 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
374 *
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
375 * 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
376 */
41156
268e57363246 Remove private data from PurpleConnection and fix up PURPLE_CONNECTION_ERROR
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
377 properties[PROP_PASSWORD] = g_param_spec_string(
42989
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
378 "password", NULL, NULL,
0c386608e7a7 Modernization and random cleanup of Purple.Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42949
diff changeset
379 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
380 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
381
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42542
diff changeset
382 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
383 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
384
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
385 gboolean
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
386 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
387 PurpleConnectionClass *klass = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
388 PurpleConnectionPrivate *priv = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
389
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
390 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
391
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
392 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
393
43237
c641f6bea7dd Move the connection-state implementation to Purple.Account
Gary Kramlich <grim@reaperworld.com>
parents: 43037
diff changeset
394 if(!purple_account_is_connecting(priv->account)) {
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
395 g_set_error(error, PURPLE_CONNECTION_ERROR, 0,
43237
c641f6bea7dd Move the connection-state implementation to Purple.Account
Gary Kramlich <grim@reaperworld.com>
parents: 43037
diff changeset
396 "account %s is not in a connecting state",
42805
3e77e81168a5 Update libpurple to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
397 purple_account_get_username(priv->account));
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
398
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
399 return TRUE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
400 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
401
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
402 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
403 !(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
404 !(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
405 {
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
406 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
407 "Cannot connect to account %s without a password.",
42805
3e77e81168a5 Update libpurple to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
408 purple_account_get_username(priv->account));
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
409
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
410 return FALSE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
411 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
412
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
413 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
414 connection);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
415
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
416 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
417 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
418 return klass->connect(connection, error);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
419 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
420
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
421 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
422 "The connection for %s did not implement the connect method",
42805
3e77e81168a5 Update libpurple to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
423 purple_account_get_username(priv->account));
41869
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
424
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
425 return FALSE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
426 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
427
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
428 gboolean
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
429 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
430 PurpleConnectionClass *klass = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
431 PurpleConnectionPrivate *priv = NULL;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
432 gboolean ret = TRUE;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
433
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
434 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
435
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
436 /* 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
437 * 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
438 */
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
439
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
440 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
441
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
442 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
443
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
444 /* 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
445 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
446 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
447 ret = klass->disconnect(connection, error);
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
448 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
449
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
450 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
451 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
452
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
453 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
454
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
455 return ret;
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
456 }
7bd5bff547b4 Change the way accounts connect while keeping backwards compatibility
Gary Kramlich <grim@reaperworld.com>
parents: 41850
diff changeset
457
42542
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
458 GCancellable *
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
459 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
460 PurpleConnectionPrivate *priv = NULL;
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
461
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
462 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
463
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
464 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
465
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
466 return priv->cancellable;
1407a0aac0bf Add a cancellable property to PurpleConnection and port IRCv3 to it
Gary Kramlich <grim@reaperworld.com>
parents: 42344
diff changeset
467 }

mercurial