3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef PURPLE_SAVEDSTATUSES_H
23 #define PURPLE_SAVEDSTATUSES_H
25 * SECTION:savedstatuses
26 * @section_id: libpurple-savedstatuses
27 * @short_description: <filename>savedstatuses.h</filename>
28 * @title: Saved Status API
29 * @see_also: <link linkend="chapter-signals-savedstatus">Saved Status signals</link>
32 #define PURPLE_TYPE_SAVEDSTATUS (purple_savedstatus_get_type())
37 * Saved statuses don't really interact much with the rest of Purple. It
38 * could really be a plugin. It's just a list of away states. When
39 * a user chooses one of the saved states, their Purple accounts are set
40 * to the settings of that state.
42 * In the savedstatus API, there is the concept of a 'transient'
43 * saved status. A transient saved status is one that is not
44 * permanent. Purple will removed it automatically if it isn't
45 * used for a period of time. Transient saved statuses don't
46 * have titles and they don't show up in the list of saved
47 * statuses. In fact, if a saved status does not have a title
48 * then it is transient. If it does have a title, then it is not
51 * What good is a transient status, you ask? They can be used to
52 * keep track of the user's 5 most recently used statuses, for
53 * example. Basically if they just set a message on the fly,
54 * we'll cache it for them in case they want to use it again. If
55 * they don't use it again, we'll just delete it.
58 * TODO: Hmm. We should probably just be saving PurplePresences. That's
59 * something we should look into once the status box gets fleshed
62 typedef struct _PurpleSavedStatus PurpleSavedStatus
;
64 typedef struct _PurpleSavedStatusSub PurpleSavedStatusSub
;
70 /**************************************************************************/
71 /* Saved status subsystem */
72 /**************************************************************************/
75 * purple_savedstatus_get_type:
77 * Returns: The #GType for the #PurpleSavedStatus boxed structure.
79 /* TODO Boxing of PurpleSavedStatus is a temporary solution to having a GType
80 * for saved statuses. This should rather be a GObject instead of a GBoxed.
82 GType
purple_savedstatus_get_type(void);
85 * purple_savedstatus_new:
86 * @title: The title of the saved status. This must be
87 * unique. Or, if you want to create a transient
88 * saved status, then pass in NULL.
89 * @type: The type of saved status.
91 * Create a new saved status. This will add the saved status to the
92 * list of saved statuses and writes the revised list to status.xml.
94 * Returns: The newly created saved status, or NULL if the title you
95 * used was already taken.
97 PurpleSavedStatus
*purple_savedstatus_new(const char *title
,
98 PurpleStatusPrimitive type
);
101 * purple_savedstatus_set_title:
102 * @status: The saved status.
103 * @title: The title of the saved status.
105 * Set the title for the given saved status.
107 void purple_savedstatus_set_title(PurpleSavedStatus
*status
,
111 * purple_savedstatus_set_primitive_type:
112 * @status: The saved status.
113 * @type: The type of saved status.
115 * Set the type for the given saved status.
117 void purple_savedstatus_set_primitive_type(PurpleSavedStatus
*status
,
118 PurpleStatusPrimitive type
);
121 * purple_savedstatus_set_message:
122 * @status: The saved status.
123 * @message: The message, or NULL if you want to unset the
124 * message for this status.
126 * Set the message for the given saved status.
128 void purple_savedstatus_set_message(PurpleSavedStatus
*status
,
129 const char *message
);
132 * purple_savedstatus_set_substatus:
133 * @status: The saved status.
134 * @account: The account.
135 * @type: The status type for the account in the saved
137 * @message: The message for the account in the substatus.
139 * Set a substatus for an account in a saved status.
141 void purple_savedstatus_set_substatus(PurpleSavedStatus
*status
,
142 const PurpleAccount
*account
,
143 const PurpleStatusType
*type
,
144 const char *message
);
147 * purple_savedstatus_unset_substatus:
148 * @saved_status: The saved status.
149 * @account: The account.
151 * Unset a substatus for an account in a saved status. This clears
152 * the previosly set substatus for the PurpleSavedStatus. If this
153 * saved status is activated then this account will use the default
154 * status type and message.
156 void purple_savedstatus_unset_substatus(PurpleSavedStatus
*saved_status
,
157 const PurpleAccount
*account
);
160 * purple_savedstatus_delete:
161 * @title: The title of the saved status.
163 * Delete a saved status. This removes the saved status from the list
164 * of saved statuses, and writes the revised list to status.xml.
166 * Returns: TRUE if the status was successfully deleted. FALSE if the
167 * status could not be deleted because no saved status exists
168 * with the given title.
170 gboolean
purple_savedstatus_delete(const char *title
);
173 * purple_savedstatus_delete_by_status:
174 * @saved_status: the status to delete, the pointer is invalid after
177 * Delete a saved status. This removes the saved status from the list
178 * of saved statuses, and writes the revised list to status.xml.
180 void purple_savedstatus_delete_by_status(PurpleSavedStatus
*saved_status
);
183 * purple_savedstatuses_get_all:
185 * Returns all saved statuses.
187 * Returns: (element-type PurpleSavedStatus) (transfer none): A list of saved statuses.
189 GList
*purple_savedstatuses_get_all(void);
192 * purple_savedstatuses_get_popular:
193 * @how_many: The maximum number of saved statuses
194 * to return, or '0' to get all saved
195 * statuses sorted by popularity.
197 * Returns the n most popular saved statuses. "Popularity" is
198 * determined by when the last time a saved_status was used and
199 * how many times it has been used. Transient statuses without
200 * messages are not included in the list.
202 * Returns: (element-type PurpleSavedStatus) (transfer container): A list containing
203 * at most how_many saved statuses.
205 GList
*purple_savedstatuses_get_popular(unsigned int how_many
);
208 * purple_savedstatus_get_current:
210 * Returns the currently selected saved status. If we are idle
211 * then this returns purple_savedstatus_get_idleaway(). Otherwise
212 * it returns purple_savedstatus_get_default().
214 * Returns: A pointer to the in-use PurpleSavedStatus.
215 * This function never returns NULL.
217 PurpleSavedStatus
*purple_savedstatus_get_current(void);
220 * purple_savedstatus_get_default:
222 * Returns the default saved status that is used when our
223 * accounts are not idle-away.
225 * Returns: A pointer to the in-use PurpleSavedStatus.
226 * This function never returns NULL.
228 PurpleSavedStatus
*purple_savedstatus_get_default(void);
231 * purple_savedstatus_get_idleaway:
233 * Returns the saved status that is used when your
234 * accounts become idle-away.
236 * Returns: A pointer to the idle-away PurpleSavedStatus.
237 * This function never returns NULL.
239 PurpleSavedStatus
*purple_savedstatus_get_idleaway(void);
242 * purple_savedstatus_is_idleaway:
244 * Return TRUE if we are currently idle-away. Otherwise
247 * Returns: TRUE if our accounts have been set to idle-away.
249 gboolean
purple_savedstatus_is_idleaway(void);
252 * purple_savedstatus_set_idleaway:
253 * @idleaway: TRUE if accounts should be switched to use the
254 * idle-away saved status. FALSE if they should
255 * be switched to use the default status.
257 * Set whether accounts in Purple are idle-away or not.
259 void purple_savedstatus_set_idleaway(gboolean idleaway
);
262 * purple_savedstatus_get_startup:
264 * Returns the status to be used when purple is starting up
266 * Returns: A pointer to the startup PurpleSavedStatus.
267 * This function never returns NULL.
269 PurpleSavedStatus
*purple_savedstatus_get_startup(void);
272 * purple_savedstatus_find:
273 * @title: The name of the saved status.
275 * Finds a saved status with the specified title.
277 * Returns: The saved status if found, or NULL.
279 PurpleSavedStatus
*purple_savedstatus_find(const char *title
);
282 * purple_savedstatus_find_by_creation_time:
283 * @creation_time: The timestamp when the saved
284 * status was created.
286 * Finds a saved status with the specified creation time.
288 * Returns: The saved status if found, or NULL.
290 PurpleSavedStatus
*purple_savedstatus_find_by_creation_time(time_t creation_time
);
293 * purple_savedstatus_find_transient_by_type_and_message:
294 * @type: The PurpleStatusPrimitive for the status you're trying
296 * @message: The message for the status you're trying
299 * Finds a saved status with the specified primitive and message.
301 * Returns: The saved status if found, or NULL.
303 PurpleSavedStatus
*purple_savedstatus_find_transient_by_type_and_message(PurpleStatusPrimitive type
, const char *message
);
306 * purple_savedstatus_is_transient:
307 * @saved_status: The saved status.
309 * Determines if a given saved status is "transient."
310 * A transient saved status is one that was not
311 * explicitly added by the user. Transient statuses
312 * are automatically removed if they are not used
313 * for a period of time.
315 * A transient saved statuses is automatically
316 * created by the status box when the user sets himself
317 * to one of the generic primitive statuses. The reason
318 * we need to save this status information is so we can
319 * restore it when Purple restarts.
321 * Returns: TRUE if the saved status is transient.
323 gboolean
purple_savedstatus_is_transient(const PurpleSavedStatus
*saved_status
);
326 * purple_savedstatus_get_title:
327 * @saved_status: The saved status.
329 * Return the name of a given saved status.
331 * Returns: The title. This value may be a static buffer which may
332 * be overwritten on subsequent calls to this function. If
333 * you need a reference to the title for prolonged use then
334 * you should make a copy of it.
336 const char *purple_savedstatus_get_title(const PurpleSavedStatus
*saved_status
);
339 * purple_savedstatus_get_primitive_type:
340 * @saved_status: The saved status.
342 * Return the type of a given saved status.
344 * Returns: The primitive type.
346 PurpleStatusPrimitive
purple_savedstatus_get_primitive_type(const PurpleSavedStatus
*saved_status
);
349 * purple_savedstatus_get_message:
350 * @saved_status: The saved status.
352 * Return the default message of a given saved status.
354 * Returns: The message. This will return NULL if the saved
355 * status does not have a message. This will
356 * contain the normal markup that is created by
357 * Purple's IMHTML (basically HTML markup).
359 const char *purple_savedstatus_get_message(const PurpleSavedStatus
*saved_status
);
362 * purple_savedstatus_get_creation_time:
363 * @saved_status: The saved status.
365 * Return the time in seconds-since-the-epoch when this
366 * saved status was created. Note: For any status created
367 * by Purple 1.5.0 or older this value will be invalid and
368 * very small (close to 0). This is because Purple 1.5.0
369 * and older did not record the timestamp when the status
372 * However, this value is guaranteed to be a unique
373 * identifier for the given saved status.
375 * Returns: The timestamp when this saved status was created.
377 time_t purple_savedstatus_get_creation_time(const PurpleSavedStatus
*saved_status
);
380 * purple_savedstatus_has_substatuses:
381 * @saved_status: The saved status.
383 * Determine if a given saved status has "substatuses,"
384 * or if it is a simple status (the same for all
387 * Returns: TRUE if the saved_status has substatuses.
390 gboolean
purple_savedstatus_has_substatuses(const PurpleSavedStatus
*saved_status
);
393 * purple_savedstatus_get_substatus:
394 * @saved_status: The saved status.
395 * @account: The account.
397 * Get the substatus for an account in a saved status.
399 * Returns: The PurpleSavedStatusSub for the account, or NULL if
400 * the given account does not have a substatus that
401 * differs from the default status of this PurpleSavedStatus.
403 PurpleSavedStatusSub
*purple_savedstatus_get_substatus(
404 const PurpleSavedStatus
*saved_status
,
405 const PurpleAccount
*account
);
408 * purple_savedstatus_substatus_get_status_type:
409 * @substatus: The substatus.
411 * Get the status type of a given substatus.
413 * Returns: The status type.
415 const PurpleStatusType
*purple_savedstatus_substatus_get_status_type(
416 const PurpleSavedStatusSub
*substatus
);
419 * purple_savedstatus_substatus_get_message:
420 * @substatus: The substatus.
422 * Get the message of a given substatus.
424 * Returns: The message of the substatus, or NULL if this substatus does
425 * not have a message.
427 const char *purple_savedstatus_substatus_get_message(const PurpleSavedStatusSub
*substatus
);
430 * purple_savedstatus_activate:
431 * @saved_status: The status you want to set your accounts to.
433 * Sets the statuses for all your accounts to those specified
434 * by the given saved_status. This function calls
435 * purple_savedstatus_activate_for_account() for all your accounts.
437 void purple_savedstatus_activate(PurpleSavedStatus
*saved_status
);
440 * purple_savedstatus_activate_for_account:
441 * @saved_status: The status you want to set your accounts to.
442 * @account: The account whose statuses you want to change.
444 * Sets the statuses for a given account to those specified
445 * by the given saved_status.
447 void purple_savedstatus_activate_for_account(const PurpleSavedStatus
*saved_status
, PurpleAccount
*account
);
450 * purple_savedstatuses_get_handle:
452 * Get the handle for the status subsystem.
454 * Returns: the handle to the status subsystem
456 void *purple_savedstatuses_get_handle(void);
459 * purple_savedstatuses_init:
461 * Initializes the status subsystem.
463 void purple_savedstatuses_init(void);
466 * purple_savedstatuses_uninit:
468 * Uninitializes the status subsystem.
470 void purple_savedstatuses_uninit(void);
474 #endif /* PURPLE_SAVEDSTATUSES_H */