Mercurial > pidgin.yaz
annotate src/status.h @ 10738:55af3fa46329
[gaim-migrate @ 12340]
Lots of changes here. A lot of it stems from chaning
gaim_account_connect() so that it DOES NOT have the GaimStatus
parameter. It will attempt to use the GaimStatus of your
account from the last time it was connected (which doesn't
work quite right yet).
My goal here was to save and load each account's GaimStatuses
to accounts.xml, so if you were "away" when you signed off then
you'll be "away" when you sign back on. Not quite there yet.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 26 Mar 2005 20:08:43 +0000 |
parents | b7f0bc436179 |
children | 94cc67130789 |
rev | line source |
---|---|
9944 | 1 /** |
2 * @file status.h Status API | |
3 * @ingroup core | |
4 * | |
6065 | 5 * gaim |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
9944 | 10 * |
6065 | 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 | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
9944 | 25 #ifndef _GAIM_STATUS_H_ |
26 #define _GAIM_STATUS_H_ | |
6065 | 27 |
10737 | 28 /** |
29 * TODO: Someone figure out if we need to do something to get | |
30 * this in the Doxygen generated docs. | |
31 * | |
32 * A brief explanation of the status API: | |
33 * | |
34 * GaimStatusType's are created by each PRPL. They outline the | |
35 * available statuses of the protocol. AIM, for example, supports | |
36 * and available state with an optional available message, an away | |
37 * state with a mandatory message, and an invisible state (which is | |
38 * technically "independant" of the other two, but we'll get into | |
39 * that later). GaimStatusTypes are very permanent. They are | |
40 * hardcoded in each PRPL and will not change often. And because | |
41 * they are hardcoded, they do not need to be saved to any XML file. | |
42 * | |
43 * A GaimStatus can be thought of as an "instance" of a GaimStatusType. | |
44 * If you've familiar with object-oriented programming languages | |
45 * then this should be immediately clear. Say, for example, that | |
46 * one of your AIM buddies has set himself as "away." You have a | |
47 * GaimBuddy node for this person in your buddy list. Gaim wants | |
48 * to mark this buddy as "away," so it creates a new GaimStatus. | |
49 * The GaimStatus has its GaimStatusType set to the "away" state | |
50 * for the oscar PRPL. The GaimStatus also contains the buddy's | |
51 * away message. GaimStatuses are sometimes saved, depending on | |
52 * the context. The current GaimStatuses associated with each of | |
53 * your accounts is saved so that the next time you start Gaim, | |
54 * your accounts will be set to their last know statuses. There | |
55 * is also a list of saved statuses that are written to the | |
56 * status.xml file. | |
57 * | |
58 * A GaimPresence is like a collection of GaimStatuses (plus some | |
59 * other random info). For any buddy, or for any one of your accounts, | |
60 * or for any person you're chatting with, you may know various | |
61 * amounts of information. This information is all contained in | |
62 * one GaimPresence. If one of your buddies is away and idle, | |
63 * then the presence contains the GaimStatus for their awayness, | |
64 * and it contains their current idle time. GaimPresences are | |
65 * never saved to disk. The information they contain is only relevent | |
66 * for the current GaimSession. | |
67 * | |
68 * TODO: Talk about independant statuses. | |
69 */ | |
70 | |
10337 | 71 typedef struct _GaimStatusType GaimStatusType; |
72 typedef struct _GaimStatusAttr GaimStatusAttr; | |
73 typedef struct _GaimPresence GaimPresence; | |
74 typedef struct _GaimStatus GaimStatus; | |
9944 | 75 |
76 /** | |
77 * A context for a presence. | |
78 * | |
79 * The context indicates what the presence applies to. | |
80 */ | |
81 typedef enum | |
82 { | |
83 GAIM_PRESENCE_CONTEXT_UNSET = 0, | |
84 GAIM_PRESENCE_CONTEXT_ACCOUNT, | |
85 GAIM_PRESENCE_CONTEXT_CONV, | |
86 GAIM_PRESENCE_CONTEXT_BUDDY | |
87 | |
88 } GaimPresenceContext; | |
89 | |
90 /** | |
91 * A primitive defining the basic structure of a status type. | |
92 */ | |
93 typedef enum | |
94 { | |
10151
d83e6f2125b1
[gaim-migrate @ 11228]
Christian Hammond <chipx86@chipx86.com>
parents:
10087
diff
changeset
|
95 GAIM_STATUS_UNSET = 0, |
d83e6f2125b1
[gaim-migrate @ 11228]
Christian Hammond <chipx86@chipx86.com>
parents:
10087
diff
changeset
|
96 GAIM_STATUS_OFFLINE, |
9944 | 97 GAIM_STATUS_ONLINE, |
98 GAIM_STATUS_AVAILABLE, | |
99 GAIM_STATUS_UNAVAILABLE, | |
100 GAIM_STATUS_HIDDEN, | |
101 GAIM_STATUS_AWAY, | |
10348 | 102 GAIM_STATUS_EXTENDED_AWAY, |
103 GAIM_STATUS_NUM_PRIMITIVES | |
9944 | 104 |
105 } GaimStatusPrimitive; | |
106 | |
107 #include "account.h" | |
108 #include "blist.h" | |
109 #include "conversation.h" | |
110 #include "value.h" | |
111 | |
112 /**************************************************************************/ | |
10419 | 113 /** @name GaimStatusPrimtive API */ |
114 /**************************************************************************/ | |
115 /*@{*/ | |
116 | |
117 /** | |
118 * Lookup the id of a primitive status type based on the type. This | |
119 * ID is a unique plain-text name of the status, without spaces. | |
120 * | |
121 * @param type A primitive status type. | |
122 * | |
123 * @return The unique ID for this type. | |
124 */ | |
125 const char *gaim_primitive_get_id_from_type(GaimStatusPrimitive type); | |
126 | |
127 /** | |
128 * Lookup the name of a primitive status type based on the type. This | |
129 * name is the plain-English name of the status type. It is usually one | |
130 * or two works. | |
131 * | |
132 * @param type A primitive status type. | |
133 * | |
134 * @return The name of this type, suitable for users to see. | |
135 */ | |
136 const char *gaim_primitive_get_name_from_type(GaimStatusPrimitive type); | |
137 | |
138 /** | |
139 * Lookup the value of a primitive status type based on the id. The | |
140 * ID is a unique plain-text name of the status, without spaces. | |
141 * | |
10469 | 142 * @param id The unique ID of a primitive status type. |
10419 | 143 * |
144 * @return The GaimStatusPrimitive value. | |
145 */ | |
146 GaimStatusPrimitive gaim_primitive_get_type_from_id(const char *id); | |
147 | |
148 /*@}*/ | |
149 | |
150 /**************************************************************************/ | |
9944 | 151 /** @name GaimStatusType API */ |
152 /**************************************************************************/ | |
153 /*@{*/ | |
154 | |
155 /** | |
156 * Creates a new status type. | |
157 * | |
158 * @param primitive The primitive status type. | |
159 * @param id The ID of the status type. | |
160 * @param name The name presented to the user. | |
161 * @param saveable TRUE if the information set for this status by the | |
162 * user can be saved for future sessions. | |
163 * @param user_settable TRUE if this is a status the user can manually set. | |
164 * @param independent TRUE if this is an independent (non-exclusive) | |
165 * status type. | |
166 * | |
167 * @return A new status type. | |
168 */ | |
169 GaimStatusType *gaim_status_type_new_full(GaimStatusPrimitive primitive, | |
170 const char *id, const char *name, | |
171 gboolean saveable, | |
172 gboolean user_settable, | |
173 gboolean independent); | |
174 | |
175 /** | |
176 * Creates a new status type with some default values. | |
177 * | |
178 * @param primitive The primitive status type. | |
179 * @param id The ID of the status type. | |
180 * @param name The name presented to the user. | |
181 * @param user_settable TRUE if this is a status the user can manually set. | |
182 * | |
183 * @return A new status type. | |
184 */ | |
185 GaimStatusType *gaim_status_type_new(GaimStatusPrimitive primitive, | |
186 const char *id, const char *name, | |
187 gboolean user_settable); | |
188 | |
189 /** | |
190 * Creates a new status type with attributes. | |
191 * | |
192 * @param primitive The primitive status type. | |
193 * @param id The ID of the status type. | |
194 * @param name The name presented to the user. | |
195 * @param saveable TRUE if the information set for this status by the | |
196 * user can be saved for future sessions. | |
197 * @param user_settable TRUE if this is a status the user can manually set. | |
198 * @param independent TRUE if this is an independent (non-exclusive) | |
199 * status type. | |
200 * @param attr_id The ID of the first attribute. | |
201 * @param attr_name The name of the first attribute. | |
202 * @param attr_value The value type of the first attribute attribute. | |
203 * @param ... Additional attribute information. | |
204 * | |
205 * @return A new status type. | |
206 */ | |
207 GaimStatusType *gaim_status_type_new_with_attrs(GaimStatusPrimitive primitive, | |
208 const char *id, | |
209 const char *name, | |
210 gboolean saveable, | |
211 gboolean user_settable, | |
212 gboolean independent, | |
213 const char *attr_id, | |
214 const char *attr_name, | |
215 GaimValue *attr_value, ...); | |
216 | |
217 /** | |
218 * Destroys a status type. | |
219 * | |
220 * @param status_type The status type to destroy. | |
221 */ | |
222 void gaim_status_type_destroy(GaimStatusType *status_type); | |
223 | |
224 /** | |
225 * Sets a status type's primary attribute. | |
226 * | |
227 * The value for the primary attribute is used as the description for | |
228 * the particular status type. An example is an away message. The message | |
229 * would be the primary attribute. | |
230 * | |
231 * @param status_type The status type. | |
232 * @param attr_id The ID of the primary attribute. | |
233 */ | |
234 void gaim_status_type_set_primary_attr(GaimStatusType *status_type, | |
235 const char *attr_id); | |
236 | |
237 /** | |
238 * Adds an attribute to a status type. | |
239 * | |
240 * @param status_type The status type to add the attribute to. | |
241 * @param id The ID of the attribute. | |
242 * @param name The name presented to the user. | |
243 * @param value The value type of this attribute. | |
244 */ | |
245 void gaim_status_type_add_attr(GaimStatusType *status_type, const char *id, | |
246 const char *name, GaimValue *value); | |
247 | |
248 /** | |
249 * Adds multiple attributes to a status type. | |
250 * | |
251 * @param status_type The status type to add the attribute to. | |
252 * @param id The ID of the first attribute. | |
253 * @param name The description of the first attribute. | |
254 * @param value The value type of the first attribute attribute. | |
255 * @param ... Additional attribute information. | |
256 */ | |
257 void gaim_status_type_add_attrs(GaimStatusType *status_type, const char *id, | |
258 const char *name, GaimValue *value, ...); | |
259 | |
260 /** | |
261 * Adds multiple attributes to a status type using a va_list. | |
262 * | |
263 * @param status_type The status type to add the attribute to. | |
264 * @param args The va_list of attributes. | |
265 */ | |
266 void gaim_status_type_add_attrs_vargs(GaimStatusType *status_type, | |
267 va_list args); | |
268 | |
269 /** | |
270 * Returns the primitive type of a status type. | |
271 * | |
272 * @param status_type The status type. | |
273 * | |
274 * @return The primitive type of the status type. | |
275 */ | |
276 GaimStatusPrimitive gaim_status_type_get_primitive( | |
277 const GaimStatusType *status_type); | |
278 | |
279 /** | |
280 * Returns the ID of a status type. | |
281 * | |
282 * @param status_type The status type. | |
283 * | |
284 * @return The ID of the status type. | |
285 */ | |
286 const char *gaim_status_type_get_id(const GaimStatusType *status_type); | |
287 | |
288 /** | |
289 * Returns the name of a status type. | |
290 * | |
291 * @param status_type The status type. | |
292 * | |
293 * @return The name of the status type. | |
294 */ | |
295 const char *gaim_status_type_get_name(const GaimStatusType *status_type); | |
296 | |
297 /** | |
298 * Returns whether or not the status type is saveable. | |
299 * | |
300 * @param status_type The status type. | |
301 * | |
302 * @return TRUE if user-defined statuses based off this type are saveable. | |
303 * FALSE otherwise. | |
304 */ | |
305 gboolean gaim_status_type_is_saveable(const GaimStatusType *status_type); | |
306 | |
307 /** | |
308 * Returns whether or not the status type can be set or modified by the | |
309 * user. | |
310 * | |
311 * @param status_type The status type. | |
312 * | |
313 * @return TRUE if the status type can be set or modified by the user. | |
314 * FALSE if it's a protocol-set setting. | |
315 */ | |
316 gboolean gaim_status_type_is_user_settable(const GaimStatusType *status_type); | |
317 | |
318 /** | |
319 * Returns whether or not the status type is independent. | |
320 * | |
321 * Independent status types are non-exclusive. If other status types on | |
322 * the same hierarchy level are set, this one will not be affected. | |
323 * | |
324 * @param status_type The status type. | |
325 * | |
326 * @return TRUE if the status type is independent, or FALSE otherwise. | |
327 */ | |
328 gboolean gaim_status_type_is_independent(const GaimStatusType *status_type); | |
329 | |
330 /** | |
10071 | 331 * Returns whether the status type is exclusive. |
10067 | 332 * |
333 * @param status_type The status type. | |
334 * | |
335 * @return TRUE if the status type is exclusive, FALSE otherwise. | |
336 */ | |
337 gboolean gaim_status_type_is_exclusive(const GaimStatusType *status_type); | |
338 | |
339 /** | |
9944 | 340 * Returns whether or not a status type is available. |
341 * | |
342 * Available status types are online and possibly hidden, but not away. | |
343 * | |
344 * @param status_type The status type. | |
345 * | |
346 * @return TRUE if the status is available, or FALSE otherwise. | |
347 */ | |
348 gboolean gaim_status_type_is_available(const GaimStatusType *status_type); | |
349 | |
350 /** | |
351 * Returns a status type's primary attribute ID. | |
352 * | |
353 * @param type The status type. | |
354 * | |
355 * @return The primary attribute's ID. | |
356 */ | |
357 const char *gaim_status_type_get_primary_attr(const GaimStatusType *type); | |
358 | |
359 /** | |
360 * Returns the attribute with the specified ID. | |
361 * | |
362 * @param status_type The status type containing the attribute. | |
363 * @param id The ID of the desired attribute. | |
364 * | |
365 * @return The attribute, if found. NULL otherwise. | |
366 */ | |
367 GaimStatusAttr *gaim_status_type_get_attr(const GaimStatusType *status_type, | |
368 const char *id); | |
369 | |
370 /** | |
371 * Returns a list of all attributes in a status type. | |
372 * | |
373 * @param status_type The status type. | |
374 * | |
375 * @return The list of attributes. | |
376 */ | |
377 const GList *gaim_status_type_get_attrs(const GaimStatusType *status_type); | |
378 | |
10348 | 379 /** |
380 * Find the GaimStatusType with the given id. | |
381 * | |
382 * @param status_types A list of status types. Often account->status_types. | |
383 * @param id The unique ID of the status type you wish to find. | |
384 * | |
385 * @return The status type with the given ID, or NULL if one could | |
386 * not be found. | |
387 */ | |
388 const GaimStatusType *gaim_status_type_find_with_id(GList *status_types, | |
389 const char *id); | |
390 | |
9944 | 391 /*@}*/ |
392 | |
393 /**************************************************************************/ | |
394 /** @name GaimStatusAttr API */ | |
395 /**************************************************************************/ | |
396 /*@{*/ | |
397 | |
398 /** | |
399 * Creates a new status attribute. | |
400 * | |
401 * @param id The ID of the attribute. | |
402 * @param name The name presented to the user. | |
403 * @param value_type The type of data contained in the attribute. | |
404 * | |
405 * @return A new status attribute. | |
406 */ | |
407 GaimStatusAttr *gaim_status_attr_new(const char *id, const char *name, | |
408 GaimValue *value_type); | |
409 | |
410 /** | |
411 * Destroys a status attribute. | |
412 * | |
413 * @param attr The status attribute to destroy. | |
414 */ | |
415 void gaim_status_attr_destroy(GaimStatusAttr *attr); | |
416 | |
417 /** | |
418 * Returns the ID of a status attribute. | |
419 * | |
420 * @param attr The status attribute. | |
421 * | |
422 * @return The status attribute's ID. | |
423 */ | |
424 const char *gaim_status_attr_get_id(const GaimStatusAttr *attr); | |
425 | |
426 /** | |
427 * Returns the name of a status attribute. | |
428 * | |
429 * @param attr The status attribute. | |
430 * | |
431 * @return The status attribute's name. | |
432 */ | |
433 const char *gaim_status_attr_get_name(const GaimStatusAttr *attr); | |
434 | |
435 /** | |
436 * Returns the value type of a status attribute. | |
437 * | |
438 * @param attr The status attribute. | |
439 * | |
440 * @return The status attribute's value type. | |
441 */ | |
442 GaimValue *gaim_status_attr_get_value_type(const GaimStatusAttr *attr); | |
443 | |
444 /*@}*/ | |
445 | |
446 /**************************************************************************/ | |
447 /** @name GaimStatus API */ | |
448 /**************************************************************************/ | |
449 /*@{*/ | |
450 | |
451 /** | |
452 * Creates a new status. | |
453 * | |
454 * @param status_type The type of status. | |
455 * @param presence The parent presence. | |
456 * | |
457 * @return The new status. | |
458 */ | |
459 GaimStatus *gaim_status_new(GaimStatusType *status_type, | |
460 GaimPresence *presence); | |
461 | |
462 /** | |
463 * Destroys a status. | |
464 * | |
465 * @param status The status to destroy. | |
466 */ | |
467 void gaim_status_destroy(GaimStatus *status); | |
468 | |
469 /** | |
470 * Sets whether or not a status is active. | |
471 * | |
472 * This should only be called by the account, conversation, and buddy APIs. | |
473 * | |
10204 | 474 * @param status The status. |
9944 | 475 * @param active The active state. |
476 */ | |
477 void gaim_status_set_active(GaimStatus *status, gboolean active); | |
478 | |
479 /** | |
10204 | 480 * Sets whether or not a status is active. |
481 * | |
482 * This should only be called by the account, conversation, and buddy APIs. | |
483 * | |
484 * @param status The status. | |
485 * @param active The active state. | |
486 * @param args A list of attributes to set on the status. This list is | |
487 * composed of key/value pairs, where each key is a valid | |
488 * attribute name for this GaimStatusType. The list should | |
489 * be NULL terminated. | |
490 */ | |
491 void gaim_status_set_active_with_attrs(GaimStatus *status, gboolean active, | |
492 va_list args); | |
493 | |
494 /** | |
9944 | 495 * Sets the boolean value of an attribute in a status with the specified ID. |
496 * | |
497 * @param status The status. | |
498 * @param id The attribute ID. | |
499 * @param value The boolean value. | |
500 */ | |
501 void gaim_status_set_attr_boolean(GaimStatus *status, const char *id, | |
502 gboolean value); | |
503 | |
504 /** | |
505 * Sets the integer value of an attribute in a status with the specified ID. | |
506 * | |
507 * @param status The status. | |
508 * @param id The attribute ID. | |
509 * @param value The integer value. | |
510 */ | |
511 void gaim_status_set_attr_int(GaimStatus *status, const char *id, | |
512 int value); | |
513 | |
514 /** | |
515 * Sets the string value of an attribute in a status with the specified ID. | |
516 * | |
517 * @param status The status. | |
518 * @param id The attribute ID. | |
519 * @param value The string value. | |
520 */ | |
521 void gaim_status_set_attr_string(GaimStatus *status, const char *id, | |
522 const char *value); | |
523 | |
524 /** | |
525 * Returns the status's type. | |
526 * | |
527 * @param status The status. | |
528 * | |
529 * @return The status's type. | |
530 */ | |
531 GaimStatusType *gaim_status_get_type(const GaimStatus *status); | |
532 | |
533 /** | |
534 * Returns the status's presence. | |
535 * | |
536 * @param status The status. | |
537 * | |
538 * @return The status's presence. | |
539 */ | |
540 GaimPresence *gaim_status_get_presence(const GaimStatus *status); | |
541 | |
542 /** | |
543 * Returns the status's type ID. | |
544 * | |
545 * This is a convenience method for | |
546 * gaim_status_type_get_id(gaim_status_get_type(status)). | |
547 * | |
548 * @param status The status. | |
549 * | |
550 * @return The status's ID. | |
551 */ | |
552 const char *gaim_status_get_id(const GaimStatus *status); | |
553 | |
554 /** | |
555 * Returns the status's name. | |
556 * | |
557 * This is a convenience method for | |
558 * gaim_status_type_get_name(gaim_status_get_type(status)). | |
559 * | |
560 * @param status The status. | |
561 * | |
562 * @return The status's name. | |
563 */ | |
564 const char *gaim_status_get_name(const GaimStatus *status); | |
565 | |
566 /** | |
567 * Returns whether or not a status is independent. | |
568 * | |
569 * This is a convenience method for | |
570 * gaim_status_type_is_independent(gaim_status_get_type(status)). | |
571 * | |
572 * @param status The status. | |
573 * | |
574 * @return TRUE if the status is independent, or FALSE otherwise. | |
575 */ | |
576 gboolean gaim_status_is_independent(const GaimStatus *status); | |
577 | |
578 /** | |
10067 | 579 * Returns whether or not a status is exclusive. |
580 * | |
581 * This is a convenience method for | |
582 * gaim_status_type_is_exclusive(gaim_status_get_type(status)). | |
583 * | |
584 * @param status The status. | |
585 * | |
586 * @return TRUE if the status is exclusive, FALSE otherwise. | |
587 */ | |
588 gboolean gaim_status_is_exclusive(const GaimStatus *status); | |
589 | |
590 /** | |
9944 | 591 * Returns whether or not a status is available. |
592 * | |
593 * Available statuses are online and possibly hidden, but not away or idle. | |
594 * | |
595 * This is a convenience method for | |
596 * gaim_status_type_is_available(gaim_status_get_type(status)). | |
597 * | |
598 * @param status The status. | |
599 * | |
600 * @return TRUE if the status is available, or FALSE otherwise. | |
601 */ | |
602 gboolean gaim_status_is_available(const GaimStatus *status); | |
603 | |
604 /** | |
605 * Returns the active state of a status. | |
606 * | |
607 * @param status The status. | |
608 * | |
609 * @return The active state of the status. | |
610 */ | |
611 gboolean gaim_status_is_active(const GaimStatus *status); | |
612 | |
613 /** | |
10040
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
614 * Returns whether or not a status is considered 'online' |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
615 * |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
616 * @param status The status. |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
617 * |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
618 * @return TRUE if the status is considered online, FALSE otherwise |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
619 */ |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
620 gboolean gaim_status_is_online(const GaimStatus *status); |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
621 |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
622 /** |
9944 | 623 * Returns the value of an attribute in a status with the specified ID. |
624 * | |
625 * @param status The status. | |
626 * @param id The attribute ID. | |
627 * | |
628 * @return The value of the attribute. | |
629 */ | |
630 GaimValue *gaim_status_get_attr_value(const GaimStatus *status, | |
631 const char *id); | |
632 | |
633 /** | |
634 * Returns the boolean value of an attribute in a status with the specified ID. | |
635 * | |
636 * @param status The status. | |
637 * @param id The attribute ID. | |
638 * | |
639 * @return The boolean value of the attribute. | |
640 */ | |
641 gboolean gaim_status_get_attr_boolean(const GaimStatus *status, | |
642 const char *id); | |
643 | |
644 /** | |
645 * Returns the integer value of an attribute in a status with the specified ID. | |
646 * | |
647 * @param status The status. | |
648 * @param id The attribute ID. | |
649 * | |
650 * @return The integer value of the attribute. | |
651 */ | |
652 int gaim_status_get_attr_int(const GaimStatus *status, const char *id); | |
653 | |
654 /** | |
655 * Returns the string value of an attribute in a status with the specified ID. | |
656 * | |
657 * @param status The status. | |
658 * @param id The attribute ID. | |
659 * | |
660 * @return The string value of the attribute. | |
661 */ | |
662 const char *gaim_status_get_attr_string(const GaimStatus *status, | |
663 const char *id); | |
664 | |
665 /** | |
666 * Compares two statuses for availability. | |
667 * | |
668 * @param status1 The first status. | |
669 * @param status2 The second status. | |
670 * | |
671 * @return -1 if @a status1 is more available than @a status2. | |
672 * 0 if @a status1 is equal to @a status2. | |
673 * 1 if @a status2 is more available than @a status1. | |
674 */ | |
675 gint gaim_status_compare(const GaimStatus *status1, const GaimStatus *status2); | |
676 | |
677 /*@}*/ | |
678 | |
679 /**************************************************************************/ | |
680 /** @name GaimPresence API */ | |
681 /**************************************************************************/ | |
682 /*@{*/ | |
683 | |
684 /** | |
685 * Creates a new presence. | |
686 * | |
687 * @param context The presence context. | |
688 * | |
689 * @return A new presence. | |
690 */ | |
691 GaimPresence *gaim_presence_new(GaimPresenceContext context); | |
692 | |
693 /** | |
694 * Creates a presence for an account. | |
695 * | |
696 * @param account The account. | |
697 * | |
698 * @return The new presence. | |
699 */ | |
700 GaimPresence *gaim_presence_new_for_account(GaimAccount *account); | |
701 | |
702 /** | |
703 * Creates a presence for a conversation. | |
704 * | |
705 * @param conv The conversation. | |
706 * | |
707 * @return The new presence. | |
708 */ | |
709 GaimPresence *gaim_presence_new_for_conv(GaimConversation *conv); | |
710 | |
711 /** | |
712 * Creates a presence for a buddy. | |
713 * | |
714 * @param buddy The buddy. | |
715 * | |
716 * @return The new presence. | |
717 */ | |
718 GaimPresence *gaim_presence_new_for_buddy(GaimBuddy *buddy); | |
719 | |
720 /** | |
721 * Destroys a presence. | |
722 * | |
723 * All statuses added to this list will be destroyed along with | |
724 * the presence. | |
725 * | |
726 * If this presence belongs to a buddy, you must call | |
727 * gaim_presence_remove_buddy() first. | |
728 * | |
729 * @param presence The presence to destroy. | |
730 */ | |
731 void gaim_presence_destroy(GaimPresence *presence); | |
732 | |
733 /** | |
734 * Removes a buddy from a presence. | |
735 * | |
736 * This must be done before destroying a buddy in a presence. | |
737 * | |
738 * @param presence The presence. | |
739 * @param buddy The buddy. | |
740 */ | |
741 void gaim_presence_remove_buddy(GaimPresence *presence, GaimBuddy *buddy); | |
742 | |
743 /** | |
744 * Adds a status to a presence. | |
745 * | |
746 * @param presence The presence. | |
747 * @param status The status to add. | |
748 */ | |
749 void gaim_presence_add_status(GaimPresence *presence, GaimStatus *status); | |
750 | |
751 /** | |
752 * Adds a list of statuses to the presence. | |
753 * | |
754 * @param presence The presence. | |
755 * @param source_list The source list of statuses to add. | |
756 */ | |
757 void gaim_presence_add_list(GaimPresence *presence, const GList *source_list); | |
758 | |
759 /** | |
760 * Sets the active state of a status in a presence. | |
761 * | |
762 * Only independent statuses can be set unactive. Normal statuses can only | |
763 * be set active, so if you wish to disable a status, set another | |
764 * non-independent status to active, or use gaim_presence_switch_status(). | |
765 * | |
766 * @param presence The presence. | |
767 * @param status_id The ID of the status. | |
768 * @param active The active state. | |
769 */ | |
770 void gaim_presence_set_status_active(GaimPresence *presence, | |
771 const char *status_id, gboolean active); | |
772 | |
773 /** | |
774 * Switches the active status in a presence. | |
775 * | |
776 * This is similar to gaim_presence_set_status_active(), except it won't | |
777 * activate independent statuses. | |
778 * | |
779 * @param presence The presence. | |
780 * @param status_id The status ID to switch to. | |
781 */ | |
782 void gaim_presence_switch_status(GaimPresence *presence, | |
783 const char *status_id); | |
784 | |
785 /** | |
786 * Sets the idle state and time on a presence. | |
787 * | |
788 * @param presence The presence. | |
789 * @param idle The idle state. | |
790 * @param idle_time The idle time, if @a idle is TRUE. | |
791 */ | |
792 void gaim_presence_set_idle(GaimPresence *presence, gboolean idle, | |
793 time_t idle_time); | |
794 | |
795 /** | |
10006 | 796 * Sets the login time on a presence. |
797 * | |
10071 | 798 * @param presence The presence. |
799 * @param login_time The login time. | |
10006 | 800 */ |
801 void gaim_presence_set_login_time(GaimPresence *presence, time_t login_time); | |
802 | |
803 /** | |
9944 | 804 * Sets the warning level on a presence. |
805 * | |
806 * @param presence The presence. | |
9978 | 807 * @param level The warning level. An integer between 0 and 100 |
808 * (inclusive) representing the percentage warned. | |
9944 | 809 */ |
810 void gaim_presence_set_warning_level(GaimPresence *presence, | |
811 unsigned int level); | |
812 | |
813 /** | |
814 * Returns the presence's context. | |
815 * | |
816 * @param presence The presence. | |
817 * | |
818 * @return The presence's context. | |
819 */ | |
820 GaimPresenceContext gaim_presence_get_context(const GaimPresence *presence); | |
821 | |
822 /** | |
823 * Returns a presence's account. | |
824 * | |
825 * @param presence The presence. | |
826 * | |
827 * @return The presence's account. | |
828 */ | |
829 GaimAccount *gaim_presence_get_account(const GaimPresence *presence); | |
830 | |
831 /** | |
832 * Returns a presence's conversation. | |
833 * | |
834 * @param presence The presence. | |
835 * | |
836 * @return The presence's conversation. | |
837 */ | |
838 GaimConversation *gaim_presence_get_conversation(const GaimPresence *presence); | |
839 | |
840 /** | |
841 * Returns a presence's chat user. | |
842 * | |
843 * @param presence The presence. | |
844 * | |
845 * @return The chat's user. | |
846 */ | |
847 const char *gaim_presence_get_chat_user(const GaimPresence *presence); | |
848 | |
849 /** | |
850 * Returns a presence's list of buddies. | |
851 * | |
852 * @param presence The presence. | |
853 * | |
854 * @return The presence's list of buddies. | |
855 */ | |
856 const GList *gaim_presence_get_buddies(const GaimPresence *presence); | |
857 | |
858 /** | |
859 * Returns all the statuses in a presence. | |
860 * | |
861 * @param presence The presence. | |
862 * | |
863 * @return The statuses. | |
864 */ | |
865 const GList *gaim_presence_get_statuses(const GaimPresence *presence); | |
866 | |
867 /** | |
868 * Returns the status with the specified ID from a presence. | |
869 * | |
870 * @param presence The presence. | |
871 * @param status_id The ID of the status. | |
872 * | |
873 * @return The status if found, or NULL. | |
874 */ | |
875 GaimStatus *gaim_presence_get_status(const GaimPresence *presence, | |
876 const char *status_id); | |
877 | |
878 /** | |
879 * Returns the active exclusive status from a presence. | |
880 * | |
881 * @param presence The presence. | |
882 * | |
883 * @return The active exclusive status. | |
884 */ | |
885 GaimStatus *gaim_presence_get_active_status(const GaimPresence *presence); | |
886 | |
887 /** | |
888 * Returns whether or not a presence is available. | |
889 * | |
890 * Available presences are online and possibly hidden, but not away or idle. | |
891 * | |
892 * @param presence The presence. | |
893 * | |
894 * @return TRUE if the presence is available, or FALSE otherwise. | |
895 */ | |
896 gboolean gaim_presence_is_available(const GaimPresence *presence); | |
897 | |
898 /** | |
899 * Returns whether or not a presence is online. | |
900 * | |
901 * @param presence The presence. | |
902 * | |
903 * @return TRUE if the presence is online, or FALSE otherwise. | |
904 */ | |
905 gboolean gaim_presence_is_online(const GaimPresence *presence); | |
906 | |
907 /** | |
908 * Returns whether or not a status in a presence is active. | |
909 * | |
910 * A status is active if itself or any of its sub-statuses are active. | |
911 * | |
912 * @param presence The presence. | |
913 * @param status_id The ID of the status. | |
914 * | |
915 * @return TRUE if the status is active, or FALSE. | |
916 */ | |
917 gboolean gaim_presence_is_status_active(const GaimPresence *presence, | |
918 const char *status_id); | |
919 | |
920 /** | |
921 * Returns whether or not a status with the specified primitive type | |
922 * in a presence is active. | |
923 * | |
924 * A status is active if itself or any of its sub-statuses are active. | |
925 * | |
926 * @param presence The presence. | |
927 * @param primitive The status primitive. | |
928 * | |
929 * @return TRUE if the status is active, or FALSE. | |
930 */ | |
931 gboolean gaim_presence_is_status_primitive_active( | |
932 const GaimPresence *presence, GaimStatusPrimitive primitive); | |
933 | |
934 /** | |
935 * Returns whether or not a presence is idle. | |
936 * | |
937 * @param presence The presence. | |
938 * | |
939 * @return TRUE if the presence is idle, or FALSE otherwise. | |
940 */ | |
941 gboolean gaim_presence_is_idle(const GaimPresence *presence); | |
942 | |
943 /** | |
944 * Returns the presence's idle time. | |
945 * | |
946 * @param presence The presence. | |
947 * | |
948 * @return The presence's idle time. | |
949 */ | |
950 time_t gaim_presence_get_idle_time(const GaimPresence *presence); | |
951 | |
952 /** | |
953 * Returns the presence's warning level. | |
954 * | |
955 * @param presence The presence. | |
956 * | |
957 * @return The presence's warning level. | |
958 */ | |
959 unsigned int gaim_presence_get_warning_level(const GaimPresence *presence); | |
960 | |
961 /** | |
10567 | 962 * Returns the presence's login time. |
963 * | |
964 * @param presence The presence. | |
965 * | |
966 * @return The presence's login time. | |
967 */ | |
968 time_t gaim_presence_get_login_time(const GaimPresence *presence); | |
969 | |
970 /** | |
9944 | 971 * Compares two presences for availability. |
972 * | |
973 * @param presence1 The first presence. | |
974 * @param presence2 The second presence. | |
975 * | |
976 * @return -1 if @a presence1 is less available than @a presence2. | |
977 * 0 if @a presence1 is equal to @a presence2. | |
978 * 1 if @a presence2 is more available than @a presence1. | |
979 */ | |
980 gint gaim_presence_compare(const GaimPresence *presence1, | |
981 const GaimPresence *presence2); | |
982 | |
983 /*@}*/ | |
984 | |
985 /**************************************************************************/ | |
986 /** @name Status subsystem */ | |
987 /**************************************************************************/ | |
988 /*@{*/ | |
989 | |
990 /** | |
10087 | 991 * Get the handle for the status subsystem. |
992 * | |
993 * @return the handle to the status subsystem | |
994 */ | |
10418 | 995 void *gaim_status_get_handle(); |
10087 | 996 |
997 /** | |
9944 | 998 * Initializes the status subsystem. |
999 */ | |
10418 | 1000 void gaim_status_init(void); |
9944 | 1001 |
1002 /** | |
1003 * Uninitializes the status subsystem. | |
1004 */ | |
10418 | 1005 void gaim_status_uninit(void); |
9944 | 1006 |
1007 /*@}*/ | |
1008 | |
1009 #endif /* _GAIM_STATUS_H_ */ |