libpurple/connection.c

Fri, 26 Jan 2024 02:33:19 -0600

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Fri, 26 Jan 2024 02:33:19 -0600
changeset 42584
687260353985
parent 42542
1407a0aac0bf
child 42594
eddde70cedd8
permissions
-rw-r--r--

Make signal and property enums and initializers consistent

Using empty braces `{}` as initializer breaks on MSVC, and some places didn't
even have an initializer.

Testing Done:
Compiled only.

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

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

mercurial