libpurple/connection.c

Thu, 13 Feb 2014 20:11:13 +0100

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Thu, 13 Feb 2014 20:11:13 +0100
changeset 35559
061c2ae3679c
parent 35499
c4c5e0a670b1
child 35572
5c4846317f2f
child 37101
8ba9a23354ff
permissions
-rw-r--r--

Fix the build again

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 #define _PURPLE_CONNECTION_C_
5dbd0617a27d Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents: 22336
diff changeset
22
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
23 #include "internal.h"
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
24 #include "glibcompat.h"
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
25
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
26 #include "account.h"
34706
02cb08146888 Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents: 34645
diff changeset
27 #include "buddylist.h"
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 #include "connection.h"
11146
c56333373e3c [gaim-migrate @ 13217]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents: 11033
diff changeset
29 #include "dbus-maybe.h"
5717
2f3a377de638 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents: 5676
diff changeset
30 #include "debug.h"
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
31 #include "enums.h"
33427
dd0c0860e293 Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32679
diff changeset
32 #include "http.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
33 #include "log.h"
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
34 #include "notify.h"
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
35 #include "prefs.h"
14900
4af8b81519b6 [gaim-migrate @ 17607]
Mark Doliner <markdoliner@pidgin.im>
parents: 14814
diff changeset
36 #include "proxy.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
37 #include "request.h"
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
38 #include "server.h"
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
39 #include "signals.h"
6106
1dc08be40f0a [gaim-migrate @ 6567]
Mark Doliner <markdoliner@pidgin.im>
parents: 6076
diff changeset
40 #include "util.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
41
21865
59b1c56633d1 De-magic number the prpl_info->keepalive interval, and document it.
Will Thompson <resiak@pidgin.im>
parents: 21831
diff changeset
42 #define KEEPALIVE_INTERVAL 30
59b1c56633d1 De-magic number the prpl_info->keepalive interval, and document it.
Will Thompson <resiak@pidgin.im>
parents: 21831
diff changeset
43
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
44 #define PURPLE_CONNECTION_GET_PRIVATE(obj) \
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
45 (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_CONNECTION, PurpleConnectionPrivate))
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
46
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
47 typedef struct _PurpleConnectionPrivate PurpleConnectionPrivate;
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
48
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
49 /* Private data for a connection */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
50 struct _PurpleConnectionPrivate
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
51 {
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
52 PurplePlugin *prpl; /* The protocol plugin. */
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
53 PurpleConnectionFlags flags; /* Connection flags. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
54
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
55 PurpleConnectionState state; /* The connection state. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
56
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
57 PurpleAccount *account; /* The account being connected to. */
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
58 char *password; /* The password used. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
59
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
60 GSList *active_chats; /* A list of active chats
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
61 (#PurpleChatConversation structs). */
35097
0d6a2ff4f776 Minor comment fiddling.
Mark Doliner <mark@kingant.net>
parents: 35085
diff changeset
62
0d6a2ff4f776 Minor comment fiddling.
Mark Doliner <mark@kingant.net>
parents: 35085
diff changeset
63 /* TODO Remove this and use protocol-specific subclasses. */
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
64 void *proto_data; /* Protocol-specific data. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
65
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
66 char *display_name; /* How you appear to other people. */
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
67 guint keepalive; /* Keep-alive. */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
68
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
69 /* Wants to Die state. This is set when the user chooses to log out, or
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
70 * when the protocol is disconnected and should not be automatically
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
71 * reconnected (incorrect password, etc.). prpls should rely on
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
72 * purple_connection_error() to set this for them rather than
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
73 * setting it themselves.
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
74 * See purple_connection_error_is_fatal()
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
75 */
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
76 gboolean wants_to_die;
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
77
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
78 gboolean is_finalizing; /* The object is being destroyed. */
35130
2033f0755d68 Fix a glib warning, by not calling g_object_notify while the connection object is being destroyed. There may be a better fix possible, though
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35097
diff changeset
79
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
80 /* The connection error and its description if an error occured */
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
81 PurpleConnectionErrorInfo *error_info;
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
82
35458
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
83 guint disconnect_timeout; /* Timer used for nasty stack tricks */
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
84 time_t last_received; /* When we last received a packet. Set by the
385156e1b493 Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
85 prpl to avoid sending unneeded keepalives */
34748
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
86 };
02efb47ea4f4 Added GObject boilerplate code for PurpleConnection
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
87
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
88 /* GObject property enums */
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
89 enum
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
90 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
91 PROP_0,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
92 PROP_PRPL,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
93 PROP_FLAGS,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
94 PROP_STATE,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
95 PROP_ACCOUNT,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
96 PROP_PASSWORD,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
97 PROP_DISPLAY_NAME,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
98 PROP_LAST
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
99 };
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
100
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
101 static GObjectClass *parent_class;
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
102 static GParamSpec *properties[PROP_LAST];
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
103
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 static GList *connections = NULL;
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
105 static GList *connections_connecting = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
106 static PurpleConnectionUiOps *connection_ui_ops = NULL;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
108 static int connections_handle;
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
109
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
110 static PurpleConnectionErrorInfo *
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
111 purple_connection_error_info_new(PurpleConnectionError type,
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
112 const gchar *description);
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
113
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
114 /**************************************************************************
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
115 * Connection API
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
116 **************************************************************************/
10745
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
117 static gboolean
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
118 send_keepalive(gpointer data)
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
119 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
120 PurpleConnection *gc = data;
28577
513297aa5f42 Minor cleanup. gc->prpl is guarranteed to be a PurplePlugin with
Mark Doliner <markdoliner@pidgin.im>
parents: 28091
diff changeset
121 PurplePluginProtocolInfo *prpl_info;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
122 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
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
123
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
124 /* Only send keep-alives if we haven't heard from the
22324
ca786d5fa291 send_keepalive needs to return TRUE to ensure it'll get called again, and
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22277
diff changeset
125 * server in a while.
ca786d5fa291 send_keepalive needs to return TRUE to ensure it'll get called again, and
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22277
diff changeset
126 */
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
127 if ((time(NULL) - priv->last_received) < KEEPALIVE_INTERVAL)
22324
ca786d5fa291 send_keepalive needs to return TRUE to ensure it'll get called again, and
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22277
diff changeset
128 return TRUE;
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
129
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
130 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(priv->prpl);
28577
513297aa5f42 Minor cleanup. gc->prpl is guarranteed to be a PurplePlugin with
Mark Doliner <markdoliner@pidgin.im>
parents: 28091
diff changeset
131 if (prpl_info->keepalive)
10745
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
132 prpl_info->keepalive(gc);
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
133
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
134 return TRUE;
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
135 }
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
136
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
137 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
138 update_keepalive(PurpleConnection *gc, gboolean on)
10745
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
139 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
140 PurplePluginProtocolInfo *prpl_info = NULL;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
141 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
14545
f8b45a0ddac5 [gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
142
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
143 if (priv != NULL && priv->prpl != NULL)
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
144 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(priv->prpl);
14545
f8b45a0ddac5 [gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
145
f8b45a0ddac5 [gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
146 if (!prpl_info || !prpl_info->keepalive)
f8b45a0ddac5 [gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
147 return;
f8b45a0ddac5 [gaim-migrate @ 17202]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
148
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
149 if (on && !priv->keepalive)
10745
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
150 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
151 purple_debug_info("connection", "Activating keepalive.\n");
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
152 priv->keepalive = purple_timeout_add_seconds(KEEPALIVE_INTERVAL, send_keepalive, gc);
10745
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
153 }
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
154 else if (!on && priv->keepalive > 0)
10745
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
155 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
156 purple_debug_info("connection", "Deactivating keepalive.\n");
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
157 purple_timeout_remove(priv->keepalive);
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
158 priv->keepalive = 0;
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
159 }
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 }
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 /*
8130
58e4e51f514b [gaim-migrate @ 8835]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
163 * d:)->-<
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 *
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 * d:O-\-<
8130
58e4e51f514b [gaim-migrate @ 8835]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
166 *
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 * d:D-/-<
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168 *
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 * d8D->-< DANCE!
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 */
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
173 purple_connection_set_state(PurpleConnection *gc, PurpleConnectionState state)
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
175 PurpleConnectionUiOps *ops;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
176 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
5885
223ac977eed2 [gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents: 5883
diff changeset
177
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
178 g_return_if_fail(priv != NULL);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
180 if (priv->state == state)
5784
4c9046760b5b [gaim-migrate @ 6209]
Christian Hammond <chipx86@chipx86.com>
parents: 5741
diff changeset
181 return;
4c9046760b5b [gaim-migrate @ 6209]
Christian Hammond <chipx86@chipx86.com>
parents: 5741
diff changeset
182
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
183 priv->state = state;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
185 ops = purple_connections_get_ui_ops();
5885
223ac977eed2 [gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents: 5883
diff changeset
186
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
187 if (priv->state == PURPLE_CONNECTION_CONNECTING) {
5905
62a6bdbc09b7 [gaim-migrate @ 6337]
Robert McQueen <robot101@debian.org>
parents: 5885
diff changeset
188 connections_connecting = g_list_append(connections_connecting, gc);
62a6bdbc09b7 [gaim-migrate @ 6337]
Robert McQueen <robot101@debian.org>
parents: 5885
diff changeset
189 }
62a6bdbc09b7 [gaim-migrate @ 6337]
Robert McQueen <robot101@debian.org>
parents: 5885
diff changeset
190 else {
5885
223ac977eed2 [gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents: 5883
diff changeset
191 connections_connecting = g_list_remove(connections_connecting, gc);
5905
62a6bdbc09b7 [gaim-migrate @ 6337]
Robert McQueen <robot101@debian.org>
parents: 5885
diff changeset
192 }
5885
223ac977eed2 [gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents: 5883
diff changeset
193
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
194 if (priv->state == PURPLE_CONNECTION_CONNECTED) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
195 PurpleAccount *account;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
196 PurplePresence *presence;
10052
329dad7e2da3 [gaim-migrate @ 11013]
Dave West <kat@users.sourceforge.net>
parents: 9944
diff changeset
197
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
198 account = purple_connection_get_account(gc);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
199 presence = purple_account_get_presence(account);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 /* Set the time the account came online */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
202 purple_presence_set_login_time(presence, time(NULL));
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203
16478
19107605c565 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents: 15890
diff changeset
204 if (purple_prefs_get_bool("/purple/logging/log_system"))
11698
afbf0d8bdacf [gaim-migrate @ 13989]
Mark Doliner <markdoliner@pidgin.im>
parents: 11562
diff changeset
205 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
206 PurpleLog *log = purple_account_get_log(account, TRUE);
13508
3c66c5a0ca7c [gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents: 12412
diff changeset
207
3c66c5a0ca7c [gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents: 12412
diff changeset
208 if (log != NULL)
3c66c5a0ca7c [gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents: 12412
diff changeset
209 {
3c66c5a0ca7c [gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents: 12412
diff changeset
210 char *msg = g_strdup_printf(_("+++ %s signed on"),
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
211 purple_account_get_username(account));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
212 purple_log_write(log, PURPLE_MESSAGE_SYSTEM,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
213 purple_account_get_username(account),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
214 purple_presence_get_login_time(presence),
13508
3c66c5a0ca7c [gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents: 12412
diff changeset
215 msg);
3c66c5a0ca7c [gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents: 12412
diff changeset
216 g_free(msg);
3c66c5a0ca7c [gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents: 12412
diff changeset
217 }
10301
fd24ab69574a [gaim-migrate @ 11486]
Mark Doliner <markdoliner@pidgin.im>
parents: 10193
diff changeset
218 }
fd24ab69574a [gaim-migrate @ 11486]
Mark Doliner <markdoliner@pidgin.im>
parents: 10193
diff changeset
219
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 if (ops != NULL && ops->connected != NULL)
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 ops->connected(gc);
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
223 purple_blist_add_account(account);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
225 purple_signal_emit(purple_connections_get_handle(), "signed-on", gc);
30039
9cd7672bae4f Add an autojoin connection signal
Richard Laager <rlaager@pidgin.im>
parents: 28577
diff changeset
226 purple_signal_emit_return_1(purple_connections_get_handle(), "autojoin", gc);
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
227
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35458
diff changeset
228 purple_serv_set_permit_deny(gc);
10745
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
229
04039e970a30 [gaim-migrate @ 12347]
Mark Doliner <markdoliner@pidgin.im>
parents: 10742
diff changeset
230 update_keepalive(gc, TRUE);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 }
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
232 else if (priv->state == PURPLE_CONNECTION_DISCONNECTED) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
233 PurpleAccount *account = purple_connection_get_account(gc);
8573
3f37bd7005c8 [gaim-migrate @ 9321]
Ka-Hing Cheung <khc@pidgin.im>
parents: 8287
diff changeset
234
16478
19107605c565 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents: 15890
diff changeset
235 if (purple_prefs_get_bool("/purple/logging/log_system"))
11698
afbf0d8bdacf [gaim-migrate @ 13989]
Mark Doliner <markdoliner@pidgin.im>
parents: 11562
diff changeset
236 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
237 PurpleLog *log = purple_account_get_log(account, FALSE);
13508
3c66c5a0ca7c [gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents: 12412
diff changeset
238
3c66c5a0ca7c [gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents: 12412
diff changeset
239 if (log != NULL)
3c66c5a0ca7c [gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents: 12412
diff changeset
240 {
3c66c5a0ca7c [gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents: 12412
diff changeset
241 char *msg = g_strdup_printf(_("+++ %s signed off"),
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
242 purple_account_get_username(account));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
243 purple_log_write(log, PURPLE_MESSAGE_SYSTEM,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
244 purple_account_get_username(account), time(NULL),
13508
3c66c5a0ca7c [gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents: 12412
diff changeset
245 msg);
3c66c5a0ca7c [gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents: 12412
diff changeset
246 g_free(msg);
3c66c5a0ca7c [gaim-migrate @ 15883]
Richard Laager <rlaager@pidgin.im>
parents: 12412
diff changeset
247 }
8573
3f37bd7005c8 [gaim-migrate @ 9321]
Ka-Hing Cheung <khc@pidgin.im>
parents: 8287
diff changeset
248 }
3f37bd7005c8 [gaim-migrate @ 9321]
Ka-Hing Cheung <khc@pidgin.im>
parents: 8287
diff changeset
249
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
250 purple_account_destroy_log(account);
8573
3f37bd7005c8 [gaim-migrate @ 9321]
Ka-Hing Cheung <khc@pidgin.im>
parents: 8287
diff changeset
251
5885
223ac977eed2 [gaim-migrate @ 6317]
Christian Hammond <chipx86@chipx86.com>
parents: 5883
diff changeset
252 if (ops != NULL && ops->disconnected != NULL)
9190
251729887ad8 [gaim-migrate @ 9985]
Evan Schoenberg <evands@pidgin.im>
parents: 9019
diff changeset
253 ops->disconnected(gc);
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
254 }
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
255
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
256 if (!priv->is_finalizing)
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
257 g_object_notify_by_pspec(G_OBJECT(gc), properties[PROP_STATE]);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 void
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
261 purple_connection_set_flags(PurpleConnection *gc, PurpleConnectionFlags flags)
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
262 {
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
263 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
264
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
265 g_return_if_fail(priv != NULL);
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
266
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
267 priv->flags = flags;
35012
e07a9b9c6bda Cleaned up properties and added g_object_notify calls for PurpleConnection and PurpleConversation's
Ankit Vani <a@nevitus.org>
parents: 35000
diff changeset
268
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
269 g_object_notify_by_pspec(G_OBJECT(gc), properties[PROP_FLAGS]);
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
270 }
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
271
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
272 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
273 purple_connection_set_display_name(PurpleConnection *gc, const char *name)
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 {
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
275 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
277 g_return_if_fail(priv != NULL);
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
278
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
279 g_free(priv->display_name);
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
280 priv->display_name = g_strdup(name);
35012
e07a9b9c6bda Cleaned up properties and added g_object_notify calls for PurpleConnection and PurpleConversation's
Ankit Vani <a@nevitus.org>
parents: 35000
diff changeset
281
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
282 g_object_notify_by_pspec(G_OBJECT(gc), properties[PROP_DISPLAY_NAME]);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
283 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284
24937
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
285 void
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
286 purple_connection_set_protocol_data(PurpleConnection *gc, void *proto_data)
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
287 {
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
288 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
24937
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
289
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
290 g_return_if_fail(priv != NULL);
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
291
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
292 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
293 }
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
294
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
295 PurpleConnectionState
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
296 purple_connection_get_state(const PurpleConnection *gc)
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297 {
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
298 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
300 g_return_val_if_fail(priv != NULL, PURPLE_CONNECTION_DISCONNECTED);
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
301
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
302 return priv->state;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
305 PurpleConnectionFlags
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
306 purple_connection_get_flags(const PurpleConnection *gc)
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
307 {
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
308 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
309
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
310 g_return_val_if_fail(priv != NULL, 0);
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
311
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
312 return priv->flags;
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
313 }
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
314
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
315 PurpleAccount *
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
316 purple_connection_get_account(const PurpleConnection *gc)
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317 {
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
318 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
320 g_return_val_if_fail(priv != NULL, NULL);
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
321
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
322 return priv->account;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324
22336
ac905bb0a8ec Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22324
diff changeset
325 PurplePlugin *
ac905bb0a8ec Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22324
diff changeset
326 purple_connection_get_prpl(const PurpleConnection *gc)
ac905bb0a8ec Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22324
diff changeset
327 {
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
328 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
22336
ac905bb0a8ec Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22324
diff changeset
329
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
330 g_return_val_if_fail(priv != NULL, NULL);
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
331
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
332 return priv->prpl;
22336
ac905bb0a8ec Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22324
diff changeset
333 }
ac905bb0a8ec Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22324
diff changeset
334
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335 const char *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
336 purple_connection_get_password(const PurpleConnection *gc)
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
337 {
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
338 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
339
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
340 g_return_val_if_fail(priv != NULL, NULL);
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
341
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
342 return priv->password;
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
343 }
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
344
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
345 GSList *
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
346 purple_connection_get_active_chats(const PurpleConnection *gc)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
347 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
348 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
349
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
350 g_return_val_if_fail(priv != NULL, NULL);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
351
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
352 return priv->active_chats;
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
353 }
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
354
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10738
diff changeset
355 const char *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
356 purple_connection_get_display_name(const PurpleConnection *gc)
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357 {
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
358 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
359
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
360 g_return_val_if_fail(priv != NULL, NULL);
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
361
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
362 return priv->display_name;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
363 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364
24937
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
365 void *
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
366 purple_connection_get_protocol_data(const PurpleConnection *gc)
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
367 {
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
368 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
24937
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
369
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
370 g_return_val_if_fail(priv != NULL, NULL);
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
371
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
372 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
373 }
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
374
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375 void
34755
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
376 _purple_connection_add_active_chat(PurpleConnection *gc, PurpleChatConversation *chat)
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
377 {
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
378 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
379
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
380 g_return_if_fail(priv != NULL);
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
381
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
382 priv->active_chats = g_slist_append(priv->active_chats, chat);
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
383 }
24937
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
384
34755
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
385 void
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
386 _purple_connection_remove_active_chat(PurpleConnection *gc, PurpleChatConversation *chat)
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
387 {
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
388 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
389
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
390 g_return_if_fail(priv != NULL);
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
391
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
392 priv->active_chats = g_slist_remove(priv->active_chats, chat);
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
393 }
9336815f86b6 Refactored the remaining libpurple to use the initial GObject connection API
Ankit Vani <a@nevitus.org>
parents: 34753
diff changeset
394
34877
5b3c720b9077 Added missing internal function, used by account.c
Ankit Vani <a@nevitus.org>
parents: 34866
diff changeset
395 gboolean
5b3c720b9077 Added missing internal function, used by account.c
Ankit Vani <a@nevitus.org>
parents: 34866
diff changeset
396 _purple_connection_wants_to_die(const PurpleConnection *gc)
5b3c720b9077 Added missing internal function, used by account.c
Ankit Vani <a@nevitus.org>
parents: 34866
diff changeset
397 {
5b3c720b9077 Added missing internal function, used by account.c
Ankit Vani <a@nevitus.org>
parents: 34866
diff changeset
398 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
5b3c720b9077 Added missing internal function, used by account.c
Ankit Vani <a@nevitus.org>
parents: 34866
diff changeset
399
34879
9dc3f5a25202 Return FALSE if assertion fails
Ankit Vani <a@nevitus.org>
parents: 34877
diff changeset
400 g_return_val_if_fail(priv != NULL, FALSE);
34877
5b3c720b9077 Added missing internal function, used by account.c
Ankit Vani <a@nevitus.org>
parents: 34866
diff changeset
401
5b3c720b9077 Added missing internal function, used by account.c
Ankit Vani <a@nevitus.org>
parents: 34866
diff changeset
402 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
403 }
3664132c36c8 Added purple_connection_set_protocol_data and purple_connection_get_protocol_data
Gary Kramlich <grim@reaperworld.com>
parents: 22336
diff changeset
404
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
405 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
406 purple_connection_update_progress(PurpleConnection *gc, const char *text,
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407 size_t step, size_t count)
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
409 PurpleConnectionUiOps *ops;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34967
diff changeset
411 g_return_if_fail(PURPLE_IS_CONNECTION(gc));
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
412 g_return_if_fail(text != NULL);
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
413 g_return_if_fail(step < count);
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414 g_return_if_fail(count > 1);
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
416 ops = purple_connections_get_ui_ops();
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
417
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
418 if (ops != NULL && ops->connect_progress != NULL)
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419 ops->connect_progress(gc, text, step, count);
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
420 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
421
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
422 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
423 purple_connection_notice(PurpleConnection *gc, const char *text)
5571
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
424 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
425 PurpleConnectionUiOps *ops;
5571
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
426
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34967
diff changeset
427 g_return_if_fail(PURPLE_IS_CONNECTION(gc));
5571
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
428 g_return_if_fail(text != NULL);
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
429
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
430 ops = purple_connections_get_ui_ops();
5571
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
431
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
432 if (ops != NULL && ops->notice != NULL)
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
433 ops->notice(gc, text);
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
434 }
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
435
12412
8abe3226695e [gaim-migrate @ 14719]
Richard Laager <rlaager@pidgin.im>
parents: 12272
diff changeset
436 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
437 purple_connection_disconnect_cb(gpointer data)
10742
2783135f0ecf [gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents: 10740
diff changeset
438 {
27336
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
439 PurpleAccount *account;
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
440 PurpleConnection *gc;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
441 PurpleConnectionPrivate *priv;
27336
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
442
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
443 account = data;
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
444 gc = purple_account_get_connection(account);
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
445 priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
27336
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
446
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
447 if (priv != NULL)
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
448 priv->disconnect_timeout = 0;
27336
7b4e3682e5a1 Cleanup the code surrounding gc->disconnect_timeout and set it to 0
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
449
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
450 purple_account_disconnect(account);
10742
2783135f0ecf [gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents: 10740
diff changeset
451 return FALSE;
2783135f0ecf [gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents: 10740
diff changeset
452 }
2783135f0ecf [gaim-migrate @ 12344]
Mark Doliner <markdoliner@pidgin.im>
parents: 10740
diff changeset
453
5571
b709464f507e [gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
454 void
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32156
diff changeset
455 purple_connection_error (PurpleConnection *gc,
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
456 PurpleConnectionError reason,
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
457 const char *description)
20430
bb30dff3da21 Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents: 19897
diff changeset
458 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
459 PurpleConnectionUiOps *ops;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
460 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
461
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
462 g_return_if_fail(priv != NULL);
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
463 /* This sanity check relies on PURPLE_CONNECTION_ERROR_OTHER_ERROR
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
464 * being the last member of the PurpleConnectionError enum in
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
465 * connection.h; if other reasons are added after it, this check should
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
466 * be updated.
21278
19f6ce8ee4ad rlaager suggested using the last element of the PurpleDisconnectReason enum
Will Thompson <resiak@pidgin.im>
parents: 21154
diff changeset
467 */
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
468 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
469 purple_debug_error("connection",
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32156
diff changeset
470 "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
471 "valid reason\n", reason);
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
472 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
473 }
15848
44463a06e833 Change connection.c:gaim_connection_error() to still work even if the
Mark Doliner <markdoliner@pidgin.im>
parents: 15537
diff changeset
474
20430
bb30dff3da21 Create PurpleConnectionUiOps.report_disconnect_reason and
Will Thompson <resiak@pidgin.im>
parents: 19897
diff changeset
475 if (description == NULL) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32156
diff changeset
476 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
477 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
478 }
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
479
6393
b845f8d02597 [gaim-migrate @ 6898]
Nathan Walp <nwalp@pidgin.im>
parents: 6297
diff changeset
480 /* If we've already got one error, we don't need any more */
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
481 if (purple_connection_get_error_info(gc))
6393
b845f8d02597 [gaim-migrate @ 6898]
Nathan Walp <nwalp@pidgin.im>
parents: 6297
diff changeset
482 return;
b845f8d02597 [gaim-migrate @ 6898]
Nathan Walp <nwalp@pidgin.im>
parents: 6297
diff changeset
483
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
484 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
485
28091
03d2cecdb234 Log the reason for disconnection to the debug log, so that we might
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 27336
diff changeset
486 purple_debug_info("connection", "Connection error on %p (reason: %u description: %s)\n",
03d2cecdb234 Log the reason for disconnection to the debug log, so that we might
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 27336
diff changeset
487 gc, reason, description);
03d2cecdb234 Log the reason for disconnection to the debug log, so that we might
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 27336
diff changeset
488
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
489 ops = purple_connections_get_ui_ops();
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
490
32153
121f15699f88 Rename the report_disconnect_reason cb function to report_disconnect
Mark Doliner <markdoliner@pidgin.im>
parents: 32152
diff changeset
491 if (ops && ops->report_disconnect)
121f15699f88 Rename the report_disconnect_reason cb function to report_disconnect
Mark Doliner <markdoliner@pidgin.im>
parents: 32152
diff changeset
492 ops->report_disconnect(gc, reason, description);
5727
883d5bc2eb0d [gaim-migrate @ 6150]
Nathan Walp <nwalp@pidgin.im>
parents: 5725
diff changeset
493
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
494 priv->error_info = purple_connection_error_info_new(reason, description);
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
495
21285
ca8cb8706802 I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents: 21279
diff changeset
496 purple_signal_emit(purple_connections_get_handle(), "connection-error",
ca8cb8706802 I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents: 21279
diff changeset
497 gc, reason, description);
5727
883d5bc2eb0d [gaim-migrate @ 6150]
Nathan Walp <nwalp@pidgin.im>
parents: 5725
diff changeset
498
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
499 priv->disconnect_timeout = purple_timeout_add(0, purple_connection_disconnect_cb,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
500 purple_connection_get_account(gc));
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
501 }
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
502
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
503 PurpleConnectionErrorInfo *
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
504 purple_connection_get_error_info(const PurpleConnection *gc)
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
505 {
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
506 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
507
35048
d374b5aef355 Fixed an incorrect return value in purple_connection_get_error_info
Ankit Vani <a@nevitus.org>
parents: 35042
diff changeset
508 g_return_val_if_fail(priv != NULL, NULL);
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
509
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
510 return priv->error_info;
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
511 }
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
512
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
513 void
20443
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
514 purple_connection_ssl_error (PurpleConnection *gc,
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
515 PurpleSslErrorType ssl_error)
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
516 {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
517 PurpleConnectionError reason;
20443
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
518
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
519 switch (ssl_error) {
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
520 case PURPLE_SSL_HANDSHAKE_FAILED:
22162
1e0f1dbe89da Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21865
diff changeset
521 reason = PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR;
1e0f1dbe89da Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21865
diff changeset
522 break;
20443
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
523 case PURPLE_SSL_CONNECT_FAILED:
22162
1e0f1dbe89da Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21865
diff changeset
524 reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
20443
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
525 break;
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
526 case PURPLE_SSL_CERTIFICATE_INVALID:
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
527 /* TODO: maybe PURPLE_SSL_* should be more specific? */
22163
186613d5bc34 Huh, you want to be able to compile? I clearly (or not so clearly) need new
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22162
diff changeset
528 reason = PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR;
20443
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
529 break;
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
530 default:
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
531 g_assert_not_reached ();
22163
186613d5bc34 Huh, you want to be able to compile? I clearly (or not so clearly) need new
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22162
diff changeset
532 reason = PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR;
20443
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
533 }
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
534
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32156
diff changeset
535 purple_connection_error (gc, reason,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
536 purple_ssl_strerror(ssl_error));
20443
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
537 }
7487bb69ae76 Create purple_connection_ssl_error(), which converts a PurpleSslErrorType
Will Thompson <resiak@pidgin.im>
parents: 20442
diff changeset
538
20431
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
539 gboolean
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
540 purple_connection_error_is_fatal (PurpleConnectionError reason)
20431
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
541 {
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
542 switch (reason)
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
543 {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
544 case PURPLE_CONNECTION_ERROR_NETWORK_ERROR:
22162
1e0f1dbe89da Adjust some network error fatalities and things
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21865
diff changeset
545 case PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR:
21508
0ae51085309d Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents: 21507
diff changeset
546 return FALSE;
0ae51085309d Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents: 21507
diff changeset
547 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
548 case PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED:
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
549 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
550 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
551 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
552 case PURPLE_CONNECTION_ERROR_INVALID_SETTINGS:
0ae51085309d Consensus on #pidgin is that certificate errors and AUTHENTICATION_IMPOSSIBLE
Will Thompson <resiak@pidgin.im>
parents: 21507
diff changeset
553 case PURPLE_CONNECTION_ERROR_OTHER_ERROR:
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
554 case PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
555 case PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
556 case PURPLE_CONNECTION_ERROR_CERT_EXPIRED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
557 case PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
558 case PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
559 case PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
560 case PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED:
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21278
diff changeset
561 case PURPLE_CONNECTION_ERROR_CERT_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
562 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
563 default:
610a45545a40 datallah pointed out that using g_return_if_fail() is preferable to
Will Thompson <resiak@pidgin.im>
parents: 21149
diff changeset
564 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
565 }
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
566 }
49979e453876 Create purple_connection_reason_is_fatal, which is basically a replacement for
Will Thompson <resiak@pidgin.im>
parents: 20430
diff changeset
567
32679
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
568 void purple_connection_update_last_received(PurpleConnection *gc)
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
569 {
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
570 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
32679
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
571
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
572 g_return_if_fail(priv != NULL);
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
573
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
574 priv->last_received = time(NULL);
32679
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
575 }
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
576
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
577 static PurpleConnectionErrorInfo *
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
578 purple_connection_error_info_new(PurpleConnectionError type,
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
579 const gchar *description)
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
580 {
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
581 PurpleConnectionErrorInfo *err;
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
582
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
583 g_return_val_if_fail(description != NULL, NULL);
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
584
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
585 err = g_new(PurpleConnectionErrorInfo, 1);
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
586
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
587 err->type = type;
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
588 err->description = g_strdup(description);
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
589
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
590 return err;
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
591 }
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
592
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
593 /**************************************************************************
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
594 * GBoxed code
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
595 **************************************************************************/
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
596 static PurpleConnectionErrorInfo *
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
597 purple_connection_error_info_copy(PurpleConnectionErrorInfo *err)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
598 {
34787
d736bcb6c5a1 Check for NULL value in GBoxed functions
Ankit Vani <a@nevitus.org>
parents: 34786
diff changeset
599 g_return_val_if_fail(err != NULL, NULL);
d736bcb6c5a1 Check for NULL value in GBoxed functions
Ankit Vani <a@nevitus.org>
parents: 34786
diff changeset
600
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
601 return purple_connection_error_info_new(err->type, err->description);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
602 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
603
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
604 static void
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
605 purple_connection_error_info_free(PurpleConnectionErrorInfo *err)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
606 {
34787
d736bcb6c5a1 Check for NULL value in GBoxed functions
Ankit Vani <a@nevitus.org>
parents: 34786
diff changeset
607 g_return_if_fail(err != NULL);
d736bcb6c5a1 Check for NULL value in GBoxed functions
Ankit Vani <a@nevitus.org>
parents: 34786
diff changeset
608
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
609 g_free(err->description);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
610 g_free(err);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
611 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
612
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
613 GType
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
614 purple_connection_error_info_get_type(void)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
615 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
616 static GType type = 0;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
617
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
618 if (type == 0) {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
619 type = g_boxed_type_register_static("PurpleConnectionErrorInfo",
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
620 (GBoxedCopyFunc)purple_connection_error_info_copy,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
621 (GBoxedFreeFunc)purple_connection_error_info_free);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
622 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
623
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
624 return type;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
625 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
626
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
627 /**************************************************************************
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
628 * GObject code
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
629 **************************************************************************/
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
630
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
631 /* Set method for GObject properties */
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
632 static void
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
633 purple_connection_set_property(GObject *obj, guint param_id, const GValue *value,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
634 GParamSpec *pspec)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
635 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
636 PurpleConnection *gc = PURPLE_CONNECTION(obj);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
637 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
32679
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 switch (param_id) {
34756
7a11ecbb92d3 Added setting of property "prpl" in PurpleConnection -- only settable during construction
Ankit Vani <a@nevitus.org>
parents: 34755
diff changeset
640 case PROP_PRPL:
34786
24216dad8696 Use spec_pointer instead of spec_boxed for properties
Ankit Vani <a@nevitus.org>
parents: 34783
diff changeset
641 priv->prpl = g_value_get_pointer(value);
34756
7a11ecbb92d3 Added setting of property "prpl" in PurpleConnection -- only settable during construction
Ankit Vani <a@nevitus.org>
parents: 34755
diff changeset
642 break;
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
643 case PROP_FLAGS:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
644 purple_connection_set_flags(gc, g_value_get_flags(value));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
645 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
646 case PROP_STATE:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
647 purple_connection_set_state(gc, g_value_get_enum(value));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
648 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
649 case PROP_ACCOUNT:
34985
f7ff90f6c9c6 Removed purple_connection_set_account()
Ankit Vani <a@nevitus.org>
parents: 34983
diff changeset
650 priv->account = g_value_get_object(value);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
651 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
652 case PROP_PASSWORD:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
653 g_free(priv->password);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
654 priv->password = g_strdup(g_value_get_string(value));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
655 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
656 case PROP_DISPLAY_NAME:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
657 purple_connection_set_display_name(gc, g_value_get_string(value));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
658 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
659 default:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
660 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
661 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
662 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
663 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
664
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
665 /* Get method for GObject properties */
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
666 static void
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
667 purple_connection_get_property(GObject *obj, guint param_id, GValue *value,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
668 GParamSpec *pspec)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
669 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
670 PurpleConnection *gc = PURPLE_CONNECTION(obj);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
671
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
672 switch (param_id) {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
673 case PROP_PRPL:
34786
24216dad8696 Use spec_pointer instead of spec_boxed for properties
Ankit Vani <a@nevitus.org>
parents: 34783
diff changeset
674 g_value_set_pointer(value, purple_connection_get_prpl(gc));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
675 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
676 case PROP_FLAGS:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
677 g_value_set_flags(value, purple_connection_get_flags(gc));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
678 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
679 case PROP_STATE:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
680 g_value_set_enum(value, purple_connection_get_state(gc));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
681 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
682 case PROP_ACCOUNT:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
683 g_value_set_object(value, purple_connection_get_account(gc));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
684 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
685 case PROP_PASSWORD:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
686 g_value_set_string(value, purple_connection_get_password(gc));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
687 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
688 case PROP_DISPLAY_NAME:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
689 g_value_set_string(value, purple_connection_get_display_name(gc));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
690 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
691 default:
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
692 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
693 break;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
694 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
695 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
696
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
697 /* GObject initialization function */
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
698 static void
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
699 purple_connection_init(GTypeInstance *instance, gpointer klass)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
700 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
701 PurpleConnection *gc = PURPLE_CONNECTION(instance);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
702
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
703 purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTING);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
704 connections = g_list_append(connections, gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
705
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
706 PURPLE_DBUS_REGISTER_POINTER(gc, PurpleConnection);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
707 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
708
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
709 /* Called when done constructing */
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
710 static void
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
711 purple_connection_constructed(GObject *object)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
712 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
713 PurpleConnection *gc = PURPLE_CONNECTION(object);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
714 PurpleAccount *account;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
715
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
716 G_OBJECT_CLASS(parent_class)->constructed(object);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
717
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
718 g_object_get(gc, "account", &account, NULL);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
719 purple_account_set_connection(account, gc);
34923
416a7736a401 Unref and free everything recieved from g_object_get
Ankit Vani <a@nevitus.org>
parents: 34904
diff changeset
720 g_object_unref(account);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
721
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
722 purple_signal_emit(purple_connections_get_handle(), "signing-on", gc);
32679
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
723 }
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
724
34986
894c29e33300 Move all object destruction code to finalize() methods and keep unrefs in dispose()
Ankit Vani <a@nevitus.org>
parents: 34985
diff changeset
725 /* GObject finalize function */
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
726 static void
34986
894c29e33300 Move all object destruction code to finalize() methods and keep unrefs in dispose()
Ankit Vani <a@nevitus.org>
parents: 34985
diff changeset
727 purple_connection_finalize(GObject *object)
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
728 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
729 PurpleConnection *gc = PURPLE_CONNECTION(object);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
730 PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
731 PurpleAccount *account;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
732 GSList *buddies;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
733 PurplePluginProtocolInfo *prpl_info = NULL;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
734 gboolean remove = FALSE;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
735
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
736 priv->is_finalizing = TRUE;
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
737
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
738 account = purple_connection_get_account(gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
739
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
740 purple_debug_info("connection", "Disconnecting connection %p\n", gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
741
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
742 if (purple_connection_get_state(gc) != PURPLE_CONNECTION_CONNECTING)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
743 remove = TRUE;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
744
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
745 purple_signal_emit(purple_connections_get_handle(), "signing-off", gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
746
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
747 while (priv->active_chats)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
748 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
749 PurpleChatConversation *b = priv->active_chats->data;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
750
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
751 priv->active_chats = g_slist_remove(priv->active_chats, b);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
752 purple_chat_conversation_leave(b);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
753 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
754
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
755 update_keepalive(gc, FALSE);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
756
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
757 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(priv->prpl);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
758 if (prpl_info->close)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
759 (prpl_info->close)(gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
760
35000
f1830e23ab81 A bit of logical rearranging
Ankit Vani <a@nevitus.org>
parents: 34997
diff changeset
761 /* Clear out the proto data that was freed in the prpl close method */
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
762 buddies = purple_blist_find_buddies(account, NULL);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
763 while (buddies != NULL) {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
764 PurpleBuddy *buddy = buddies->data;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
765 purple_buddy_set_protocol_data(buddy, NULL);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
766 buddies = g_slist_delete_link(buddies, buddies);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
767 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
768
35000
f1830e23ab81 A bit of logical rearranging
Ankit Vani <a@nevitus.org>
parents: 34997
diff changeset
769 purple_http_conn_cancel_all(gc);
f1830e23ab81 A bit of logical rearranging
Ankit Vani <a@nevitus.org>
parents: 34997
diff changeset
770 purple_proxy_connect_cancel_with_handle(gc);
f1830e23ab81 A bit of logical rearranging
Ankit Vani <a@nevitus.org>
parents: 34997
diff changeset
771
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
772 connections = g_list_remove(connections, gc);
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 purple_connection_set_state(gc, PURPLE_CONNECTION_DISCONNECTED);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
775
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
776 if (remove)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
777 purple_blist_remove_account(account);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
778
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
779 purple_signal_emit(purple_connections_get_handle(), "signed-off", gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
780
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
781 purple_account_request_close_with_account(account);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
782 purple_request_close_with_handle(gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
783 purple_notify_close_with_handle(gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
784
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
785 purple_debug_info("connection", "Destroying connection %p\n", gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
786
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
787 purple_account_set_connection(account, NULL);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
788
35042
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
789 if (priv->error_info)
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
790 purple_connection_error_info_free(priv->error_info);
c284eef5cd26 Added purple_connection_get_error_info()
Ankit Vani <a@nevitus.org>
parents: 35012
diff changeset
791
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
792 if (priv->disconnect_timeout > 0)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
793 purple_timeout_remove(priv->disconnect_timeout);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
794
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
795 purple_str_wipe(priv->password);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
796 g_free(priv->display_name);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
797
34986
894c29e33300 Move all object destruction code to finalize() methods and keep unrefs in dispose()
Ankit Vani <a@nevitus.org>
parents: 34985
diff changeset
798 PURPLE_DBUS_UNREGISTER_POINTER(gc);
894c29e33300 Move all object destruction code to finalize() methods and keep unrefs in dispose()
Ankit Vani <a@nevitus.org>
parents: 34985
diff changeset
799
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
800 G_OBJECT_CLASS(parent_class)->finalize(object);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
801 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
802
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
803 /* Class initializer function */
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
804 static void purple_connection_class_init(PurpleConnectionClass *klass)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
805 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
806 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
807
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
808 parent_class = g_type_class_peek_parent(klass);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
809
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
810 obj_class->finalize = purple_connection_finalize;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
811 obj_class->constructed = purple_connection_constructed;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
812
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
813 /* Setup properties */
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
814 obj_class->get_property = purple_connection_get_property;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
815 obj_class->set_property = purple_connection_set_property;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
816
35085
abab0adfa0ec libpurple: use g_object_class_install_properties instead of repeated g_object_class_install_property
Ankit Vani <a@nevitus.org>
parents: 35080
diff changeset
817 g_type_class_add_private(klass, sizeof(PurpleConnectionPrivate));
abab0adfa0ec libpurple: use g_object_class_install_properties instead of repeated g_object_class_install_property
Ankit Vani <a@nevitus.org>
parents: 35080
diff changeset
818
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
819 properties[PROP_PRPL] = g_param_spec_pointer("prpl", "Protocol plugin",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35048
diff changeset
820 "The prpl that is using the connection.",
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
821 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
822 G_PARAM_STATIC_STRINGS);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
823
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
824 properties[PROP_FLAGS] = g_param_spec_flags("flags", "Connection flags",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35048
diff changeset
825 "The flags of the connection.",
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
826 PURPLE_TYPE_CONNECTION_FLAGS, 0,
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
827 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
828
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
829 properties[PROP_STATE] = g_param_spec_enum("state", "Connection state",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35048
diff changeset
830 "The current state of the connection.",
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
831 PURPLE_TYPE_CONNECTION_STATE, PURPLE_CONNECTION_DISCONNECTED,
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
832 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
833
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
834 properties[PROP_ACCOUNT] = g_param_spec_object("account", "Account",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35048
diff changeset
835 "The account using the connection.", PURPLE_TYPE_ACCOUNT,
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
836 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
837 G_PARAM_STATIC_STRINGS);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
838
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
839 properties[PROP_PASSWORD] = g_param_spec_string("password", "Password",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35048
diff changeset
840 "The password used for connection.", NULL,
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
841 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
842 G_PARAM_STATIC_STRINGS);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
843
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
844 properties[PROP_DISPLAY_NAME] = g_param_spec_string("display-name",
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
845 "Display name",
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
846 "Your name that appears to other people.", NULL,
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
847 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
848
35085
abab0adfa0ec libpurple: use g_object_class_install_properties instead of repeated g_object_class_install_property
Ankit Vani <a@nevitus.org>
parents: 35080
diff changeset
849 g_object_class_install_properties(obj_class, PROP_LAST, properties);
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
850 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
851
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
852 GType
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
853 purple_connection_get_type(void)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
854 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
855 static GType type = 0;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
856
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
857 if(type == 0) {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
858 static const GTypeInfo info = {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
859 sizeof(PurpleConnectionClass),
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
860 NULL,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
861 NULL,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
862 (GClassInitFunc)purple_connection_class_init,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
863 NULL,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
864 NULL,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
865 sizeof(PurpleConnection),
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
866 0,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
867 (GInstanceInitFunc)purple_connection_init,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
868 NULL,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
869 };
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
870
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
871 type = g_type_register_static(G_TYPE_OBJECT, "PurpleConnection",
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
872 &info, 0);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
873 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
874
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
875 return type;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
876 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
877
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
878 void
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
879 _purple_connection_new(PurpleAccount *account, gboolean regist, const char *password)
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 PurpleConnection *gc;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
882 PurplePlugin *prpl;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
883 PurplePluginProtocolInfo *prpl_info;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
884
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34967
diff changeset
885 g_return_if_fail(PURPLE_IS_ACCOUNT(account));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
886
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
887 if (!purple_account_is_disconnected(account))
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
888 return;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
889
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
890 prpl = purple_find_prpl(purple_account_get_protocol_id(account));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
891
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
892 if (prpl != NULL)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
893 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
894 else {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
895 gchar *message;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
896
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
897 message = g_strdup_printf(_("Missing protocol plugin for %s"),
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
898 purple_account_get_username(account));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
899 purple_notify_error(NULL, regist ? _("Registration Error") :
34955
854143116575 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34923 34449
diff changeset
900 _("Connection Error"), message, NULL,
854143116575 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34923 34449
diff changeset
901 purple_request_cpar_from_account(account));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
902 g_free(message);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
903 return;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
904 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
905
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
906 if (regist)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
907 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
908 if (prpl_info->register_user == NULL)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
909 return;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
910 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
911 else
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
912 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
913 if (((password == NULL) || (*password == '\0')) &&
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
914 !(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
915 !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL))
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
916 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
917 purple_debug_error("connection", "Cannot connect to account %s without "
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
918 "a password.\n", purple_account_get_username(account));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
919 return;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
920 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
921 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
922
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
923 gc = g_object_new(PURPLE_TYPE_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
924 "prpl", prpl,
e07a9b9c6bda Cleaned up properties and added g_object_notify calls for PurpleConnection and PurpleConversation's
Ankit Vani <a@nevitus.org>
parents: 35000
diff changeset
925 "password", password,
e07a9b9c6bda Cleaned up properties and added g_object_notify calls for PurpleConnection and PurpleConversation's
Ankit Vani <a@nevitus.org>
parents: 35000
diff changeset
926 "account", account,
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
927 NULL);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
928
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
929 if (regist)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
930 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
931 purple_debug_info("connection", "Registering. gc = %p\n", gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
932
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
933 /* set this so we don't auto-reconnect after registering */
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
934 PURPLE_CONNECTION_GET_PRIVATE(gc)->wants_to_die = TRUE;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
935
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
936 prpl_info->register_user(account);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
937 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
938 else
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
939 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
940 purple_debug_info("connection", "Connecting. gc = %p\n", gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
941
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
942 purple_signal_emit(purple_accounts_get_handle(), "account-connecting", account);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
943 prpl_info->login(account);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
944 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
945 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
946
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
947 void
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
948 _purple_connection_new_unregister(PurpleAccount *account, const char *password,
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
949 PurpleAccountUnregistrationCb cb, void *user_data)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
950 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
951 /* Lots of copy/pasted code to avoid API changes. You might want to integrate that into the previous function when posssible. */
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
952 PurpleConnection *gc;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
953 PurplePlugin *prpl;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
954 PurplePluginProtocolInfo *prpl_info;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
955
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34967
diff changeset
956 g_return_if_fail(PURPLE_IS_ACCOUNT(account));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
957
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
958 prpl = purple_find_prpl(purple_account_get_protocol_id(account));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
959
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
960 if (prpl != NULL)
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
961 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
962 else {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
963 gchar *message;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
964
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
965 message = g_strdup_printf(_("Missing protocol plugin for %s"),
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
966 purple_account_get_username(account));
34955
854143116575 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34923 34449
diff changeset
967 purple_notify_error(NULL, _("Unregistration Error"), message,
854143116575 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34923 34449
diff changeset
968 NULL, purple_request_cpar_from_account(account));
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
969 g_free(message);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
970 return;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
971 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
972
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
973 if (!purple_account_is_disconnected(account)) {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
974 prpl_info->unregister_user(account, cb, user_data);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
975 return;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
976 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
977
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
978 if (((password == NULL) || (*password == '\0')) &&
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
979 !(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
980 !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL))
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
981 {
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
982 purple_debug_error("connection", "Cannot connect to account %s without "
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
983 "a password.\n", purple_account_get_username(account));
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
984 return;
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
985 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
986
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
987 gc = g_object_new(PURPLE_TYPE_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
988 "prpl", prpl,
e07a9b9c6bda Cleaned up properties and added g_object_notify calls for PurpleConnection and PurpleConversation's
Ankit Vani <a@nevitus.org>
parents: 35000
diff changeset
989 "password", password,
e07a9b9c6bda Cleaned up properties and added g_object_notify calls for PurpleConnection and PurpleConversation's
Ankit Vani <a@nevitus.org>
parents: 35000
diff changeset
990 "account", account,
34753
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
991 NULL);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
992
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
993 purple_debug_info("connection", "Unregistering. gc = %p\n", gc);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
994
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
995 prpl_info->unregister_user(account, cb, user_data);
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
996 }
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
997
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
998 /**************************************************************************
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
999 * Connections API
b2c73469c1be GObjectified the PurpleConnection source
Ankit Vani <a@nevitus.org>
parents: 34752
diff changeset
1000 **************************************************************************/
5564
1779a1bfbdb8 [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1001 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1002 purple_connections_disconnect_all(void)
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1003 {
18122
9bf9970c1b6a disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents: 18121
diff changeset
1004 GList *l;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1005 PurpleConnection *gc;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
1006 PurpleConnectionPrivate *priv;
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1007
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1008 while ((l = purple_connections_get_all()) != NULL) {
6113
5bc7394e69ea [gaim-migrate @ 6575]
Mark Doliner <markdoliner@pidgin.im>
parents: 6111
diff changeset
1009 gc = l->data;
34752
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
1010 priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
1011 priv->wants_to_die = TRUE;
c43a22ac7452 Used PurpleConnectionPrivate
Ankit Vani <a@nevitus.org>
parents: 34751
diff changeset
1012 purple_account_disconnect(priv->account);
6113
5bc7394e69ea [gaim-migrate @ 6575]
Mark Doliner <markdoliner@pidgin.im>
parents: 6111
diff changeset
1013 }
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1014 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1015
18122
9bf9970c1b6a disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents: 18121
diff changeset
1016 GList *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1017 purple_connections_get_all(void)
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1018 {
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1019 return connections;
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1020 }
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1021
18122
9bf9970c1b6a disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents: 18121
diff changeset
1022 GList *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1023 purple_connections_get_connecting(void)
5788
dd6e33a59151 [gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents: 5784
diff changeset
1024 {
dd6e33a59151 [gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents: 5784
diff changeset
1025 return connections_connecting;
dd6e33a59151 [gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents: 5784
diff changeset
1026 }
dd6e33a59151 [gaim-migrate @ 6213]
Christian Hammond <chipx86@chipx86.com>
parents: 5784
diff changeset
1027
5563
d5a7852aa0cb [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1028 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1029 purple_connections_set_ui_ops(PurpleConnectionUiOps *ops)
7035
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1030 {
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1031 connection_ui_ops = ops;
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1032 }
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1033
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1034 PurpleConnectionUiOps *
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1035 purple_connections_get_ui_ops(void)
7035
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1036 {
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1037 return connection_ui_ops;
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1038 }
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1039
76bca80cd91d [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1040 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1041 purple_connections_init(void)
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1042 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1043 void *handle = purple_connections_get_handle();
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1044
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1045 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
1046 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
1047 PURPLE_TYPE_CONNECTION);
6564
a7a2c1927544 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6533
diff changeset
1048
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1049 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
1050 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
1051 PURPLE_TYPE_CONNECTION);
6564
a7a2c1927544 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6533
diff changeset
1052
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1053 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
1054 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
1055 PURPLE_TYPE_CONNECTION);
6564
a7a2c1927544 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6533
diff changeset
1056
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1057 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
1058 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
1059 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
1060
ca8cb8706802 I figured a signal firing on a connection error would be useful.
Will Thompson <resiak@pidgin.im>
parents: 21279
diff changeset
1061 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
1062 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
1063 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
1064 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
1065
30039
9cd7672bae4f Add an autojoin connection signal
Richard Laager <rlaager@pidgin.im>
parents: 28577
diff changeset
1066 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
1067 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
1068 PURPLE_TYPE_CONNECTION);
30039
9cd7672bae4f Add an autojoin connection signal
Richard Laager <rlaager@pidgin.im>
parents: 28577
diff changeset
1069
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1070 }
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1071
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1072 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1073 purple_connections_uninit(void)
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1074 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1075 purple_signals_unregister_by_instance(purple_connections_get_handle());
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1076 }
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1077
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1078 void *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15871
diff changeset
1079 purple_connections_get_handle(void)
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1080 {
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1081 return &connections_handle;
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6468
diff changeset
1082 }

mercurial