Tue, 01 Oct 2013 03:34:56 +0530
Check for valid PurpleProtocols
| 8113 | 1 | /** |
| 2 | * @file roomlist.c Room List API | |
| 3 | * @ingroup core | |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
4 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
5 | /* purple |
| 8113 | 6 | * |
| 15884 | 7 | * Purple is the legal property of its developers, whose names are too numerous |
|
8146
4961c9c5fd61
[gaim-migrate @ 8854]
John Silvestri <john.silvestri@gmail.com>
parents:
8113
diff
changeset
|
8 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
4961c9c5fd61
[gaim-migrate @ 8854]
John Silvestri <john.silvestri@gmail.com>
parents:
8113
diff
changeset
|
9 | * source distribution. |
| 8113 | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify | |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * 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:
18265
diff
changeset
|
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 8113 | 24 | */ |
| 25 | ||
|
18265
9f26190d7f46
Move the define in internal.h instead.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15884
diff
changeset
|
26 | #include "internal.h" |
|
9f26190d7f46
Move the define in internal.h instead.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15884
diff
changeset
|
27 | |
| 8113 | 28 | #include "account.h" |
| 29 | #include "connection.h" | |
| 30 | #include "debug.h" | |
| 31 | #include "roomlist.h" | |
| 8199 | 32 | #include "server.h" |
| 8113 | 33 | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
34 | #define PURPLE_ROOMLIST_GET_PRIVATE(obj) \ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
35 | (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_ROOMLIST, PurpleRoomlistPrivate)) |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
36 | |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
37 | /** @copydoc _PurpleRoomlistPrivate */ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
38 | typedef struct _PurpleRoomlistPrivate PurpleRoomlistPrivate; |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
39 | |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
40 | /** |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
41 | * Private data for a room list. |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
42 | */ |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
43 | struct _PurpleRoomlistPrivate { |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
44 | PurpleAccount *account; /**< The account this list belongs to. */ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
45 | GList *fields; /**< The fields. */ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
46 | GList *rooms; /**< The list of rooms. */ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
47 | gboolean in_progress; /**< The listing is in progress. */ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
48 | gpointer proto_data; /** Protocol private data. |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
49 | TODO Remove this, and use |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
50 | protocol-specific subclasses */ |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
51 | }; |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
52 | |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
53 | /** |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
54 | * Represents a room. |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
55 | */ |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
56 | struct _PurpleRoomlistRoom { |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
57 | PurpleRoomlistRoomType type; /**< The type of room. */ |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
58 | gchar *name; /**< The name of the room. */ |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
59 | GList *fields; /**< Other fields. */ |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
60 | PurpleRoomlistRoom *parent; /**< The parent room, or NULL. */ |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36630
diff
changeset
|
61 | gboolean expanded_once; /**< A flag the UI uses to avoid multiple expand protocol cbs. */ |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
62 | }; |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
63 | |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
64 | /** |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
65 | * A field a room might have. |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
66 | */ |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
67 | struct _PurpleRoomlistField { |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
68 | PurpleRoomlistFieldType type; /**< The type of field. */ |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
69 | gchar *label; /**< The i18n user displayed name of the field. */ |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
70 | gchar *name; /**< The internal name of the field. */ |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
71 | gboolean hidden; /**< Hidden? */ |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
72 | }; |
| 8113 | 73 | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
74 | /* Room list property enums */ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
75 | enum |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
76 | { |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
77 | PROP_0, |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
78 | PROP_ACCOUNT, |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
79 | PROP_FIELDS, |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
80 | PROP_IN_PROGRESS, |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
81 | PROP_LAST |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
82 | }; |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
83 | |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
84 | static GObjectClass *parent_class; |
| 15884 | 85 | static PurpleRoomlistUiOps *ops = NULL; |
| 8113 | 86 | |
|
34934
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
87 | static void purple_roomlist_field_free(PurpleRoomlistField *f); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
88 | static void purple_roomlist_room_destroy(PurpleRoomlist *list, PurpleRoomlistRoom *r); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
89 | |
| 8113 | 90 | /**************************************************************************/ |
| 91 | /** @name Room List API */ | |
| 92 | /**************************************************************************/ | |
| 93 | /*@{*/ | |
| 94 | ||
| 15884 | 95 | void purple_roomlist_show_with_account(PurpleAccount *account) |
| 8352 | 96 | { |
| 97 | if (ops && ops->show_with_account) | |
| 98 | ops->show_with_account(account); | |
| 99 | } | |
| 100 | ||
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
101 | PurpleAccount *purple_roomlist_get_account(PurpleRoomlist *list) |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
102 | { |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
103 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
104 | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
105 | g_return_val_if_fail(priv != NULL, NULL); |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
106 | |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
107 | return priv->account; |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
108 | } |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
109 | |
| 15884 | 110 | void purple_roomlist_set_fields(PurpleRoomlist *list, GList *fields) |
| 8113 | 111 | { |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
112 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
| 8113 | 113 | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
114 | g_return_if_fail(priv != NULL); |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
115 | |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
116 | priv->fields = fields; |
| 8113 | 117 | |
| 118 | if (ops && ops->set_fields) | |
| 119 | ops->set_fields(list, fields); | |
| 120 | } | |
| 121 | ||
| 15884 | 122 | void purple_roomlist_set_in_progress(PurpleRoomlist *list, gboolean in_progress) |
| 8113 | 123 | { |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
124 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
| 8113 | 125 | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
126 | g_return_if_fail(priv != NULL); |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
127 | |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
128 | priv->in_progress = in_progress; |
| 8199 | 129 | |
| 8113 | 130 | if (ops && ops->in_progress) |
| 131 | ops->in_progress(list, in_progress); | |
| 132 | } | |
| 133 | ||
| 15884 | 134 | gboolean purple_roomlist_get_in_progress(PurpleRoomlist *list) |
| 8199 | 135 | { |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
136 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
| 8199 | 137 | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
138 | g_return_val_if_fail(priv != NULL, FALSE); |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
139 | |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
140 | return priv->in_progress; |
| 8199 | 141 | } |
| 142 | ||
| 15884 | 143 | void purple_roomlist_room_add(PurpleRoomlist *list, PurpleRoomlistRoom *room) |
| 8113 | 144 | { |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
145 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
146 | |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
147 | g_return_if_fail(priv != NULL); |
| 8113 | 148 | g_return_if_fail(room != NULL); |
| 149 | ||
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
150 | priv->rooms = g_list_append(priv->rooms, room); |
| 8113 | 151 | |
| 152 | if (ops && ops->add_room) | |
| 153 | ops->add_room(list, room); | |
| 154 | } | |
| 155 | ||
| 15884 | 156 | PurpleRoomlist *purple_roomlist_get_list(PurpleConnection *gc) |
| 8113 | 157 | { |
|
36544
1bf8b6ef5aea
Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents:
36376
diff
changeset
|
158 | PurpleProtocol *protocol = NULL; |
| 8113 | 159 | |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34942
diff
changeset
|
160 | g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), NULL); |
|
24863
68c109ca0089
Fix a crash that happens when accessing the roomlist for an account that's
Paul Aurich <darkrain42@pidgin.im>
parents:
24814
diff
changeset
|
161 | g_return_val_if_fail(PURPLE_CONNECTION_IS_CONNECTED(gc), NULL); |
| 8113 | 162 | |
|
36623
caaadef03507
Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents:
36606
diff
changeset
|
163 | protocol = purple_connection_get_protocol(gc); |
| 8113 | 164 | |
|
36630
ff356949df25
Refactored the rest of libpurple to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
165 | if(protocol) |
| 36719 | 166 | return purple_protocol_roomlist_iface_get_list(protocol, gc); |
|
22390
d22357d5c7ba
Kill off gc->prpl in the core everywhere but connection.c (when the struct
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22134
diff
changeset
|
167 | |
| 8113 | 168 | return NULL; |
| 169 | } | |
| 170 | ||
| 15884 | 171 | void purple_roomlist_cancel_get_list(PurpleRoomlist *list) |
| 8113 | 172 | { |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
173 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
|
36544
1bf8b6ef5aea
Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents:
36376
diff
changeset
|
174 | PurpleProtocol *protocol = NULL; |
| 15884 | 175 | PurpleConnection *gc; |
| 8113 | 176 | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
177 | g_return_if_fail(priv != NULL); |
| 8113 | 178 | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
179 | gc = purple_account_get_connection(priv->account); |
| 8113 | 180 | |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34942
diff
changeset
|
181 | g_return_if_fail(PURPLE_IS_CONNECTION(gc)); |
| 8113 | 182 | |
|
22390
d22357d5c7ba
Kill off gc->prpl in the core everywhere but connection.c (when the struct
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22134
diff
changeset
|
183 | if(gc) |
|
36623
caaadef03507
Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents:
36606
diff
changeset
|
184 | protocol = purple_connection_get_protocol(gc); |
| 8113 | 185 | |
|
36630
ff356949df25
Refactored the rest of libpurple to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
186 | if(protocol) |
| 36719 | 187 | purple_protocol_roomlist_iface_cancel(protocol, list); |
| 8113 | 188 | } |
| 189 | ||
| 15884 | 190 | void purple_roomlist_expand_category(PurpleRoomlist *list, PurpleRoomlistRoom *category) |
| 8113 | 191 | { |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
192 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
|
36544
1bf8b6ef5aea
Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents:
36376
diff
changeset
|
193 | PurpleProtocol *protocol = NULL; |
| 15884 | 194 | PurpleConnection *gc; |
| 8113 | 195 | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
196 | g_return_if_fail(priv != NULL); |
| 8584 | 197 | g_return_if_fail(category != NULL); |
| 15884 | 198 | g_return_if_fail(category->type & PURPLE_ROOMLIST_ROOMTYPE_CATEGORY); |
| 8113 | 199 | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
200 | gc = purple_account_get_connection(priv->account); |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34942
diff
changeset
|
201 | g_return_if_fail(PURPLE_IS_CONNECTION(gc)); |
| 8113 | 202 | |
|
22390
d22357d5c7ba
Kill off gc->prpl in the core everywhere but connection.c (when the struct
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22134
diff
changeset
|
203 | if(gc) |
|
36623
caaadef03507
Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents:
36606
diff
changeset
|
204 | protocol = purple_connection_get_protocol(gc); |
| 8113 | 205 | |
|
36630
ff356949df25
Refactored the rest of libpurple to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
206 | if(protocol) |
| 36719 | 207 | purple_protocol_roomlist_iface_expand_category(protocol, list, category); |
| 8113 | 208 | } |
| 209 | ||
|
22134
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
210 | GList * purple_roomlist_get_fields(PurpleRoomlist *list) |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
211 | { |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
212 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
213 | |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
214 | g_return_val_if_fail(priv != NULL, NULL); |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
215 | |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
216 | return priv->fields; |
|
22134
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
217 | } |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
218 | |
|
34942
e1783e620a85
Renamed purple_roomlist_[gs]et_proto_data to purple_roomlist_[gs]et_protocol_data
Ankit Vani <a@nevitus.org>
parents:
34934
diff
changeset
|
219 | gpointer purple_roomlist_get_protocol_data(PurpleRoomlist *list) |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
220 | { |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
221 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
222 | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
223 | g_return_val_if_fail(priv != NULL, NULL); |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
224 | |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
225 | return priv->proto_data; |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
226 | } |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
227 | |
|
34942
e1783e620a85
Renamed purple_roomlist_[gs]et_proto_data to purple_roomlist_[gs]et_protocol_data
Ankit Vani <a@nevitus.org>
parents:
34934
diff
changeset
|
228 | void purple_roomlist_set_protocol_data(PurpleRoomlist *list, gpointer proto_data) |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
229 | { |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
230 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
231 | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
232 | g_return_if_fail(priv != NULL); |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
233 | |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
234 | priv->proto_data = proto_data; |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
235 | } |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
236 | |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
237 | gpointer purple_roomlist_get_ui_data(PurpleRoomlist *list) |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
238 | { |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34942
diff
changeset
|
239 | g_return_val_if_fail(PURPLE_IS_ROOMLIST(list), NULL); |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
240 | |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
241 | return list->ui_data; |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
242 | } |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
243 | |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
244 | void purple_roomlist_set_ui_data(PurpleRoomlist *list, gpointer ui_data) |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
245 | { |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34942
diff
changeset
|
246 | g_return_if_fail(PURPLE_IS_ROOMLIST(list)); |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
247 | |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
248 | list->ui_data = ui_data; |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
249 | } |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
250 | |
| 8113 | 251 | /*@}*/ |
| 252 | ||
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
253 | /**************************************************************************/ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
254 | /** @name Room List GObject code */ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
255 | /**************************************************************************/ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
256 | /*@{*/ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
257 | |
|
34933
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
258 | /* GObject Property names */ |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
259 | #define PROP_ACCOUNT_S "account" |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
260 | #define PROP_FIELDS_S "fields" |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
261 | #define PROP_IN_PROGRESS_S "in-progress" |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
262 | |
|
34933
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
263 | /* Set method for GObject properties */ |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
264 | static void |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
265 | purple_roomlist_set_property(GObject *obj, guint param_id, const GValue *value, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
266 | GParamSpec *pspec) |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
267 | { |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
268 | PurpleRoomlist *list = PURPLE_ROOMLIST(obj); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
269 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
270 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
271 | switch (param_id) { |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
272 | case PROP_ACCOUNT: |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
273 | priv->account = g_value_get_object(value); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
274 | break; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
275 | case PROP_FIELDS: |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
276 | purple_roomlist_set_fields(list, g_value_get_pointer(value)); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
277 | break; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
278 | case PROP_IN_PROGRESS: |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
279 | purple_roomlist_set_in_progress(list, g_value_get_boolean(value)); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
280 | break; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
281 | default: |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
282 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
283 | break; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
284 | } |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
285 | } |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
286 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
287 | /* Get method for GObject properties */ |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
288 | static void |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
289 | purple_roomlist_get_property(GObject *obj, guint param_id, GValue *value, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
290 | GParamSpec *pspec) |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
291 | { |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
292 | PurpleRoomlist *list = PURPLE_ROOMLIST(obj); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
293 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
294 | switch (param_id) { |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
295 | case PROP_ACCOUNT: |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
296 | g_value_set_object(value, purple_roomlist_get_account(list)); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
297 | break; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
298 | case PROP_FIELDS: |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
299 | g_value_set_pointer(value, purple_roomlist_get_fields(list)); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
300 | break; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
301 | case PROP_IN_PROGRESS: |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
302 | g_value_set_boolean(value, purple_roomlist_get_in_progress(list)); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
303 | break; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
304 | default: |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
305 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
306 | break; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
307 | } |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
308 | } |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
309 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
310 | /* Called when done constructing */ |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
311 | static void |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
312 | purple_roomlist_constructed(GObject *object) |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
313 | { |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
314 | PurpleRoomlist *list = PURPLE_ROOMLIST(object); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
315 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
316 | parent_class->constructed(object); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
317 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
318 | if (ops && ops->create) |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
319 | ops->create(list); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
320 | } |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
321 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
322 | /* GObject dispose function */ |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
323 | static void |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
324 | purple_roomlist_dispose(GObject *object) |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
325 | { |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
326 | PurpleRoomlist *list = PURPLE_ROOMLIST(object); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
327 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
328 | purple_debug_misc("roomlist", "destroying list %p\n", list); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
329 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
330 | if (ops && ops->destroy) |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
331 | ops->destroy(list); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
332 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
333 | parent_class->dispose(object); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
334 | } |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
335 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
336 | /* GObject finalize function */ |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
337 | static void |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
338 | purple_roomlist_finalize(GObject *object) |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
339 | { |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
340 | PurpleRoomlist *list = PURPLE_ROOMLIST(object); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
341 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
342 | GList *l; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
343 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
344 | for (l = priv->rooms; l; l = l->next) { |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
345 | PurpleRoomlistRoom *r = l->data; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
346 | purple_roomlist_room_destroy(list, r); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
347 | } |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
348 | g_list_free(priv->rooms); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
349 | |
|
34934
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
350 | g_list_foreach(priv->fields, (GFunc)purple_roomlist_field_free, NULL); |
|
34933
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
351 | g_list_free(priv->fields); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
352 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
353 | parent_class->finalize(object); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
354 | } |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
355 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
356 | /* Class initializer function */ |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
357 | static void |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
358 | purple_roomlist_class_init(PurpleRoomlistClass *klass) |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
359 | { |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
360 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
361 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
362 | parent_class = g_type_class_peek_parent(klass); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
363 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
364 | obj_class->dispose = purple_roomlist_dispose; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
365 | obj_class->finalize = purple_roomlist_finalize; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
366 | obj_class->constructed = purple_roomlist_constructed; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
367 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
368 | /* Setup properties */ |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
369 | obj_class->get_property = purple_roomlist_get_property; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
370 | obj_class->set_property = purple_roomlist_set_property; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
371 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
372 | g_object_class_install_property(obj_class, PROP_ACCOUNT, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
373 | g_param_spec_object(PROP_ACCOUNT_S, _("Account"), |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
374 | _("The account for the room list."), |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
375 | PURPLE_TYPE_ACCOUNT, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
376 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY) |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
377 | ); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
378 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
379 | g_object_class_install_property(obj_class, PROP_FIELDS, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
380 | g_param_spec_pointer(PROP_FIELDS_S, _("Fields"), |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
381 | _("The list of fields for a roomlist."), |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
382 | G_PARAM_READWRITE) |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
383 | ); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
384 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
385 | g_object_class_install_property(obj_class, PROP_IN_PROGRESS, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
386 | g_param_spec_boolean(PROP_IN_PROGRESS_S, _("In progress"), |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
387 | _("Whether the room list is being fetched."), FALSE, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
388 | G_PARAM_READWRITE) |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
389 | ); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
390 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
391 | g_type_class_add_private(klass, sizeof(PurpleRoomlistPrivate)); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
392 | } |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
393 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
394 | GType |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
395 | purple_roomlist_get_type(void) |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
396 | { |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
397 | static GType type = 0; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
398 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
399 | if(type == 0) { |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
400 | static const GTypeInfo info = { |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
401 | sizeof(PurpleRoomlistClass), |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
402 | NULL, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
403 | NULL, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
404 | (GClassInitFunc)purple_roomlist_class_init, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
405 | NULL, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
406 | NULL, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
407 | sizeof(PurpleRoomlist), |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
408 | 0, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
409 | NULL, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
410 | NULL, |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
411 | }; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
412 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
413 | type = g_type_register_static(G_TYPE_OBJECT, "PurpleRoomlist", |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
414 | &info, 0); |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
415 | } |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
416 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
417 | return type; |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
418 | } |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
419 | |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
420 | PurpleRoomlist *purple_roomlist_new(PurpleAccount *account) |
|
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
421 | { |
|
36728
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
422 | PurpleRoomlist *list; |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
423 | PurpleProtocol *protocol; |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
424 | |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34942
diff
changeset
|
425 | g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL); |
|
34933
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
426 | |
|
36728
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
427 | protocol = purple_protocols_find(purple_account_get_protocol_id(account)); |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
428 | |
|
36844
b62140058cd3
Check for valid PurpleProtocols
Ankit Vani <a@nevitus.org>
parents:
36843
diff
changeset
|
429 | g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol), NULL); |
|
36728
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
430 | |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
431 | if (PURPLE_PROTOCOL_IMPLEMENTS(protocol, FACTORY_IFACE, roomlist_new)) |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
432 | list = purple_protocol_factory_iface_roomlist_new(protocol, account); |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
433 | else |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
434 | list = g_object_new(PURPLE_TYPE_ROOMLIST, |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
435 | PROP_ACCOUNT_S, account, |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
436 | NULL |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
437 | ); |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
438 | |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
439 | g_return_val_if_fail(list != NULL, NULL); |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
440 | |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36719
diff
changeset
|
441 | return list; |
|
34933
94df3aa56d12
Added GObject code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34931
diff
changeset
|
442 | } |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
443 | |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
444 | /*@}*/ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
445 | |
| 8113 | 446 | /**************************************************************************/ |
| 447 | /** @name Room API */ | |
| 448 | /**************************************************************************/ | |
| 449 | /*@{*/ | |
| 450 | ||
| 15884 | 451 | PurpleRoomlistRoom *purple_roomlist_room_new(PurpleRoomlistRoomType type, const gchar *name, |
| 452 | PurpleRoomlistRoom *parent) | |
| 8113 | 453 | { |
| 15884 | 454 | PurpleRoomlistRoom *room; |
| 8113 | 455 | |
| 456 | g_return_val_if_fail(name != NULL, NULL); | |
| 457 | ||
| 15884 | 458 | room = g_new0(PurpleRoomlistRoom, 1); |
| 8113 | 459 | room->type = type; |
| 460 | room->name = g_strdup(name); | |
| 461 | room->parent = parent; | |
| 462 | ||
| 463 | return room; | |
| 464 | } | |
| 465 | ||
| 15884 | 466 | void purple_roomlist_room_add_field(PurpleRoomlist *list, PurpleRoomlistRoom *room, gconstpointer field) |
| 8113 | 467 | { |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
468 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
| 15884 | 469 | PurpleRoomlistField *f; |
| 8113 | 470 | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
471 | g_return_if_fail(priv != NULL); |
| 8113 | 472 | g_return_if_fail(room != NULL); |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
473 | g_return_if_fail(priv->fields != NULL); |
| 8113 | 474 | |
|
24814
9e3c1c3b4123
Add a comment to clarify code I initially thought was broken.
Richard Laager <rlaager@pidgin.im>
parents:
22390
diff
changeset
|
475 | /* If this is the first call for this room, grab the first field in |
|
9e3c1c3b4123
Add a comment to clarify code I initially thought was broken.
Richard Laager <rlaager@pidgin.im>
parents:
22390
diff
changeset
|
476 | * the Roomlist's fields. Otherwise, grab the field that is one |
|
9e3c1c3b4123
Add a comment to clarify code I initially thought was broken.
Richard Laager <rlaager@pidgin.im>
parents:
22390
diff
changeset
|
477 | * more than the number of fields already present for the room. |
|
9e3c1c3b4123
Add a comment to clarify code I initially thought was broken.
Richard Laager <rlaager@pidgin.im>
parents:
22390
diff
changeset
|
478 | * (This works because g_list_nth_data() is zero-indexed and |
|
9e3c1c3b4123
Add a comment to clarify code I initially thought was broken.
Richard Laager <rlaager@pidgin.im>
parents:
22390
diff
changeset
|
479 | * g_list_length() is one-indexed.) */ |
| 8113 | 480 | if (!room->fields) |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
481 | f = priv->fields->data; |
| 8113 | 482 | else |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
483 | f = g_list_nth_data(priv->fields, g_list_length(room->fields)); |
| 8113 | 484 | |
| 485 | g_return_if_fail(f != NULL); | |
| 486 | ||
| 487 | switch(f->type) { | |
| 15884 | 488 | case PURPLE_ROOMLIST_FIELD_STRING: |
| 8113 | 489 | room->fields = g_list_append(room->fields, g_strdup(field)); |
| 490 | break; | |
| 15884 | 491 | case PURPLE_ROOMLIST_FIELD_BOOL: |
| 492 | case PURPLE_ROOMLIST_FIELD_INT: | |
| 8113 | 493 | room->fields = g_list_append(room->fields, GINT_TO_POINTER(field)); |
| 494 | break; | |
| 495 | } | |
| 496 | } | |
| 497 | ||
| 15884 | 498 | void purple_roomlist_room_join(PurpleRoomlist *list, PurpleRoomlistRoom *room) |
| 8199 | 499 | { |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
500 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
| 8199 | 501 | GHashTable *components; |
| 502 | GList *l, *j; | |
| 15884 | 503 | PurpleConnection *gc; |
| 8199 | 504 | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
505 | g_return_if_fail(priv != NULL); |
| 8199 | 506 | g_return_if_fail(room != NULL); |
| 507 | ||
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
508 | gc = purple_account_get_connection(priv->account); |
| 8199 | 509 | if (!gc) |
| 510 | return; | |
| 511 | ||
| 512 | components = g_hash_table_new(g_str_hash, g_str_equal); | |
| 513 | ||
| 514 | g_hash_table_replace(components, "name", room->name); | |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
515 | for (l = priv->fields, j = room->fields; l && j; l = l->next, j = j->next) { |
| 15884 | 516 | PurpleRoomlistField *f = l->data; |
| 8199 | 517 | |
| 518 | g_hash_table_replace(components, f->name, j->data); | |
| 519 | } | |
| 520 | ||
| 521 | serv_join_chat(gc, components); | |
| 522 | ||
| 523 | g_hash_table_destroy(components); | |
| 524 | } | |
| 525 | ||
|
22134
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
526 | PurpleRoomlistRoomType purple_roomlist_room_get_type(PurpleRoomlistRoom *room) |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
527 | { |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
528 | return room->type; |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
529 | } |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
530 | |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
531 | const char * purple_roomlist_room_get_name(PurpleRoomlistRoom *room) |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
532 | { |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
533 | return room->name; |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
534 | } |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
535 | |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
536 | PurpleRoomlistRoom * purple_roomlist_room_get_parent(PurpleRoomlistRoom *room) |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
537 | { |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
538 | return room->parent; |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
539 | } |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
540 | |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
541 | gboolean purple_roomlist_room_get_expanded_once(PurpleRoomlistRoom *room) |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
542 | { |
|
32237
d5398bd73913
Fix two compile warnings. Did I do that? I totally didn't notice. My bad.
Mark Doliner <markdoliner@pidgin.im>
parents:
32218
diff
changeset
|
543 | g_return_val_if_fail(room != NULL, FALSE); |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
544 | |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
545 | return room->expanded_once; |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
546 | } |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
547 | |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
548 | void purple_roomlist_room_set_expanded_once(PurpleRoomlistRoom *room, gboolean expanded_once) |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
549 | { |
|
32237
d5398bd73913
Fix two compile warnings. Did I do that? I totally didn't notice. My bad.
Mark Doliner <markdoliner@pidgin.im>
parents:
32218
diff
changeset
|
550 | g_return_if_fail(room != NULL); |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
551 | |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
552 | room->expanded_once = expanded_once; |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
553 | } |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
554 | |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
28981
diff
changeset
|
555 | GList *purple_roomlist_room_get_fields(PurpleRoomlistRoom *room) |
|
22134
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
556 | { |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
557 | return room->fields; |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
558 | } |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
559 | |
|
34934
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
560 | static void purple_roomlist_room_destroy(PurpleRoomlist *list, PurpleRoomlistRoom *r) |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
561 | { |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
562 | PurpleRoomlistPrivate *priv = PURPLE_ROOMLIST_GET_PRIVATE(list); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
563 | GList *l, *j; |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
564 | |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
565 | for (l = priv->fields, j = r->fields; l && j; l = l->next, j = j->next) { |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
566 | PurpleRoomlistField *f = l->data; |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
567 | if (f->type == PURPLE_ROOMLIST_FIELD_STRING) |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
568 | g_free(j->data); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
569 | } |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
570 | |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
571 | g_list_free(r->fields); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
572 | g_free(r->name); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
573 | g_free(r); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
574 | } |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
575 | |
| 8113 | 576 | /*@}*/ |
| 577 | ||
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
578 | /**************************************************************************/ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
579 | /** @name Room GBoxed code */ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
580 | /**************************************************************************/ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
581 | /*@{*/ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
582 | |
|
34934
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
583 | static PurpleRoomlistRoom *purple_roomlist_room_copy(PurpleRoomlistRoom *r) |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
584 | { |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
585 | g_return_val_if_fail(r != NULL, NULL); |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
586 | |
|
34934
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
587 | return purple_roomlist_room_new(r->type, r->name, r->parent); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
588 | } |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
589 | |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
590 | static void purple_roomlist_room_free(PurpleRoomlistRoom *r) |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
591 | { |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
592 | g_return_if_fail(r != NULL); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
593 | |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
594 | g_list_free(r->fields); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
595 | g_free(r->name); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
596 | g_free(r); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
597 | } |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
598 | |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
599 | GType purple_roomlist_room_get_gtype(void) |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
600 | { |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
601 | static GType type = 0; |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
602 | |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
603 | if (type == 0) { |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
604 | type = g_boxed_type_register_static("PurpleRoomlistRoom", |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
605 | (GBoxedCopyFunc)purple_roomlist_room_copy, |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
606 | (GBoxedFreeFunc)purple_roomlist_room_free); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
607 | } |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
608 | |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
609 | return type; |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
610 | } |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
611 | |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
612 | /*@}*/ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
613 | |
| 8113 | 614 | /**************************************************************************/ |
| 615 | /** @name Room Field API */ | |
| 616 | /**************************************************************************/ | |
| 617 | /*@{*/ | |
| 618 | ||
| 15884 | 619 | PurpleRoomlistField *purple_roomlist_field_new(PurpleRoomlistFieldType type, |
| 8113 | 620 | const gchar *label, const gchar *name, |
| 621 | gboolean hidden) | |
| 622 | { | |
| 15884 | 623 | PurpleRoomlistField *f; |
| 8113 | 624 | |
| 625 | g_return_val_if_fail(label != NULL, NULL); | |
| 626 | g_return_val_if_fail(name != NULL, NULL); | |
| 627 | ||
| 15884 | 628 | f = g_new0(PurpleRoomlistField, 1); |
| 8113 | 629 | |
| 630 | f->type = type; | |
| 631 | f->label = g_strdup(label); | |
| 632 | f->name = g_strdup(name); | |
| 633 | f->hidden = hidden; | |
| 634 | ||
| 635 | return f; | |
| 636 | } | |
| 637 | ||
|
22134
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
638 | PurpleRoomlistFieldType purple_roomlist_field_get_type(PurpleRoomlistField *field) |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
639 | { |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
640 | return field->type; |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
641 | } |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
642 | |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
643 | const char * purple_roomlist_field_get_label(PurpleRoomlistField *field) |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
644 | { |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
645 | return field->label; |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
646 | } |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
647 | |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
648 | gboolean purple_roomlist_field_get_hidden(PurpleRoomlistField *field) |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
649 | { |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
650 | return field->hidden; |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
651 | } |
|
692ceed9d307
A list of accessor functions to the roomlist API.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20147
diff
changeset
|
652 | |
| 8113 | 653 | /*@}*/ |
| 654 | ||
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
655 | /**************************************************************************/ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
656 | /** @name Room Field GBoxed code */ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
657 | /**************************************************************************/ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
658 | /*@{*/ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
659 | |
|
34934
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
660 | static PurpleRoomlistField *purple_roomlist_field_copy(PurpleRoomlistField *f) |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
661 | { |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
662 | g_return_val_if_fail(f != NULL, NULL); |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
663 | |
|
34934
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
664 | return purple_roomlist_field_new(f->type, f->label, f->name, f->hidden); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
665 | } |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
666 | |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
667 | static void purple_roomlist_field_free(PurpleRoomlistField *f) |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
668 | { |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
669 | g_return_if_fail(f != NULL); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
670 | |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
671 | g_free(f->label); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
672 | g_free(f->name); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
673 | g_free(f); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
674 | } |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
675 | |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
676 | GType purple_roomlist_field_get_gtype(void) |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
677 | { |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
678 | static GType type = 0; |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
679 | |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
680 | if (type == 0) { |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
681 | type = g_boxed_type_register_static("PurpleRoomlistField", |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
682 | (GBoxedCopyFunc)purple_roomlist_field_copy, |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
683 | (GBoxedFreeFunc)purple_roomlist_field_free); |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
684 | } |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
685 | |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
686 | return type; |
|
d50c4b767a5e
Added room and field GBoxed code to roomlist.c
Ankit Vani <a@nevitus.org>
parents:
34933
diff
changeset
|
687 | } |
|
34931
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
688 | |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
689 | /*@}*/ |
|
6ea8ce77ec34
Started GObjectification of PurpleRoomlist
Ankit Vani <a@nevitus.org>
parents:
32237
diff
changeset
|
690 | |
| 8113 | 691 | /**************************************************************************/ |
| 692 | /** @name UI Registration Functions */ | |
| 693 | /**************************************************************************/ | |
| 694 | /*@{*/ | |
| 695 | ||
| 696 | ||
| 15884 | 697 | void purple_roomlist_set_ui_ops(PurpleRoomlistUiOps *ui_ops) |
| 8113 | 698 | { |
| 699 | ops = ui_ops; | |
| 700 | } | |
| 701 | ||
| 15884 | 702 | PurpleRoomlistUiOps *purple_roomlist_get_ui_ops(void) |
| 8113 | 703 | { |
| 704 | return ops; | |
| 705 | } | |
| 706 | ||
| 707 | /*@}*/ |