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