| |
1 /* |
| |
2 * nmuserrecord.h |
| |
3 * |
| |
4 * Copyright (c) 2004 Novell, Inc. All Rights Reserved. |
| |
5 * |
| |
6 * This program is free software; you can redistribute it and/or modify |
| |
7 * it under the terms of the GNU General Public License as published by |
| |
8 * the Free Software Foundation; version 2 of the License. |
| |
9 * |
| |
10 * This program is distributed in the hope that it will be useful, |
| |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| |
13 * GNU General Public License for more details. |
| |
14 * |
| |
15 * You should have received a copy of the GNU General Public License |
| |
16 * along with this program; if not, write to the Free Software |
| |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| |
18 * |
| |
19 */ |
| |
20 |
| |
21 #ifndef __NM_USER_RECORD_H__ |
| |
22 #define __NM_USER_RECORD_H__ |
| |
23 |
| |
24 #include <glib.h> |
| |
25 |
| |
26 typedef struct _NMUserRecord NMUserRecord; |
| |
27 typedef struct _NMProperty NMProperty; |
| |
28 |
| |
29 #include "nmfield.h" |
| |
30 #include "nmuser.h" |
| |
31 |
| |
32 /** |
| |
33 * Creates an NMUserRecord |
| |
34 * |
| |
35 * The NMUserRecord should be released by calling |
| |
36 * nm_release_user_record |
| |
37 * |
| |
38 * @return The new user record |
| |
39 * |
| |
40 */ |
| |
41 NMUserRecord *nm_create_user_record(void); |
| |
42 |
| |
43 /** |
| |
44 * Creates an NMUserRecord |
| |
45 * |
| |
46 * The NMUserRecord should be released by calling |
| |
47 * nm_release_user_record |
| |
48 * |
| |
49 * @param details Should be a NM_A_FA_USER_DETAILS |
| |
50 * |
| |
51 * |
| |
52 * @return The new user record |
| |
53 * |
| |
54 */ |
| |
55 NMUserRecord *nm_create_user_record_from_fields(NMField * details); |
| |
56 |
| |
57 /** |
| |
58 * Add a reference to an existing user_record |
| |
59 * |
| |
60 * The reference should be released by calling |
| |
61 * nm_release_user_record |
| |
62 * |
| |
63 * @param user_record The contact to addref |
| |
64 * |
| |
65 */ |
| |
66 void nm_user_record_add_ref(NMUserRecord * user_record); |
| |
67 |
| |
68 /** |
| |
69 * Release a reference to the user record |
| |
70 * |
| |
71 * @param user_record The user record |
| |
72 * |
| |
73 */ |
| |
74 void nm_release_user_record(NMUserRecord * user_record); |
| |
75 |
| |
76 /** |
| |
77 * Set the status for the user record |
| |
78 * |
| |
79 * @param user_record The user record |
| |
80 * @param status The status for the user |
| |
81 * @param text The status text for the user |
| |
82 * |
| |
83 */ |
| |
84 void nm_user_record_set_status(NMUserRecord * user_record, NMSTATUS_T status, |
| |
85 const char *text); |
| |
86 |
| |
87 /** |
| |
88 * Get the status for the user record |
| |
89 * |
| |
90 * @param user_record The user record |
| |
91 * |
| |
92 * @return The status for the user record |
| |
93 */ |
| |
94 NMSTATUS_T nm_user_record_get_status(NMUserRecord * user_record); |
| |
95 |
| |
96 /** |
| |
97 * Get the status text for the user record |
| |
98 * |
| |
99 * @param user_record The user record |
| |
100 * |
| |
101 * @return The status text if there is any, NULL otherwise |
| |
102 * |
| |
103 */ |
| |
104 const char *nm_user_record_get_status_text(NMUserRecord * user_record); |
| |
105 |
| |
106 /** |
| |
107 * Set the DN for the user record |
| |
108 * |
| |
109 * @param user_record The user record |
| |
110 * @param dn The new DN for the user record |
| |
111 * |
| |
112 */ |
| |
113 void nm_user_record_set_dn(NMUserRecord * user_record, const char *dn); |
| |
114 |
| |
115 /** |
| |
116 * Get the DN for the user record |
| |
117 * |
| |
118 * @param user_record The user record |
| |
119 * |
| |
120 * @return The DN for the user record |
| |
121 */ |
| |
122 const char *nm_user_record_get_dn(NMUserRecord * user_record); |
| |
123 |
| |
124 /** |
| |
125 * Set the user id for the |
| |
126 * |
| |
127 * @param user_record The user record |
| |
128 * @param userid The userid (CN) for the user record |
| |
129 * |
| |
130 */ |
| |
131 void nm_user_record_set_userid(NMUserRecord * user_record, const char *userid); |
| |
132 |
| |
133 /** |
| |
134 * Get the user id for the user record |
| |
135 * |
| |
136 * @param user_record The user record |
| |
137 * |
| |
138 * @return The user id for the user record |
| |
139 */ |
| |
140 const char *nm_user_record_get_userid(NMUserRecord * user_record); |
| |
141 |
| |
142 /** |
| |
143 * Set the display id for the user record |
| |
144 * |
| |
145 * @param user_record The user record |
| |
146 * @param display_id The new display id for the user |
| |
147 * |
| |
148 */ |
| |
149 void nm_user_record_set_display_id(NMUserRecord * user_record, |
| |
150 const char *display_id); |
| |
151 |
| |
152 /** |
| |
153 * Get the display id for the user record |
| |
154 * |
| |
155 * @param user_record The user record |
| |
156 * |
| |
157 * @return The display id for the user record |
| |
158 */ |
| |
159 const char *nm_user_record_get_display_id(NMUserRecord * user_record); |
| |
160 |
| |
161 /** |
| |
162 * Return whether or not the display id is an auth attribute or not. |
| |
163 * |
| |
164 * @param user_record The user record |
| |
165 * |
| |
166 * @return TRUE if display_id is an auth attribute, FALSE otherwise. |
| |
167 */ |
| |
168 gboolean |
| |
169 nm_user_record_get_auth_attr(NMUserRecord *user_record); |
| |
170 |
| |
171 /** |
| |
172 * Get the full name for the user record |
| |
173 * |
| |
174 * @param user_record The user record |
| |
175 * |
| |
176 * @return The full name for the user |
| |
177 */ |
| |
178 const char *nm_user_record_get_full_name(NMUserRecord * user_record); |
| |
179 |
| |
180 /** |
| |
181 * Get the first name for the user record |
| |
182 * |
| |
183 * @param user_record The user record |
| |
184 * |
| |
185 * @return The first name for the user |
| |
186 */ |
| |
187 const char *nm_user_record_get_first_name(NMUserRecord * user_record); |
| |
188 |
| |
189 /** |
| |
190 * Get the last name for the user record |
| |
191 * |
| |
192 * @param user_record The user record |
| |
193 * |
| |
194 * @return The last name for the user |
| |
195 */ |
| |
196 const char *nm_user_record_get_last_name(NMUserRecord * user_record); |
| |
197 |
| |
198 /** |
| |
199 * Set the user defined data for the user record |
| |
200 * |
| |
201 * @param user_record The user record |
| |
202 * @param data The user defined data for the user record |
| |
203 * |
| |
204 */ |
| |
205 void nm_user_record_set_data(NMUserRecord * user_record, gpointer data); |
| |
206 |
| |
207 /** |
| |
208 * Get the user defined data for the user record |
| |
209 * |
| |
210 * @param user_record The user record |
| |
211 * |
| |
212 * @return The user defined data for the user record |
| |
213 */ |
| |
214 gpointer nm_user_record_get_data(NMUserRecord * user_record); |
| |
215 |
| |
216 /** |
| |
217 * Get the property count for the user record |
| |
218 * |
| |
219 * @param user_record The user record |
| |
220 * |
| |
221 * @return The number of information properties for the user record |
| |
222 * |
| |
223 */ |
| |
224 int nm_user_record_get_property_count(NMUserRecord * user_record); |
| |
225 |
| |
226 /** |
| |
227 * Get an info property for the user record. The property must be released |
| |
228 * by calling nm_release_property() |
| |
229 * |
| |
230 * @param user_record The user record |
| |
231 * @param index The index of the property to get (zero based) |
| |
232 * |
| |
233 * @return The property |
| |
234 */ |
| |
235 NMProperty *nm_user_record_get_property(NMUserRecord * user_record, int index); |
| |
236 |
| |
237 /** |
| |
238 * Release a property object |
| |
239 * |
| |
240 * @param property The property |
| |
241 * |
| |
242 */ |
| |
243 void nm_release_property(NMProperty * property); |
| |
244 |
| |
245 /** |
| |
246 * Get the tag for the property |
| |
247 * |
| |
248 * @param property The property |
| |
249 * |
| |
250 * @return The tag of the property (i.e. "Email Address") |
| |
251 */ |
| |
252 const char *nm_property_get_tag(NMProperty * property); |
| |
253 |
| |
254 /** |
| |
255 * Get the value for the property |
| |
256 * |
| |
257 * @param property The property |
| |
258 * |
| |
259 * @return The value of the property (i.e. "nobody@nowhere.com") |
| |
260 */ |
| |
261 const char *nm_property_get_value(NMProperty * property); |
| |
262 |
| |
263 /** |
| |
264 * Copy a user record (deep copy). The dest user record must have already been |
| |
265 * created (nm_create_user_record) |
| |
266 * |
| |
267 * @param dest The destination of the copy |
| |
268 * @param src The source of the copy |
| |
269 * |
| |
270 */ |
| |
271 void nm_user_record_copy(NMUserRecord * dest, NMUserRecord * src); |
| |
272 |
| |
273 #endif |