Frameworks/libpurple.framework/Versions/0.6.2/Headers/savedstatuses.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 1739 Frameworks/libpurple.framework/Versions/0.6.0/Headers/savedstatuses.h@8b0daad9656c
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
Evan@653
     1
/**
Evan@653
     2
 * @file savedstatuses.h Saved Status API
Evan@653
     3
 * @ingroup core
Evan@653
     4
 * @see @ref savedstatus-signals
Evan@653
     5
 */
Evan@653
     6
Evan@653
     7
/* purple
Evan@653
     8
 *
Evan@653
     9
 * Purple is the legal property of its developers, whose names are too numerous
Evan@653
    10
 * to list here.  Please refer to the COPYRIGHT file distributed with this
Evan@653
    11
 * source distribution.
Evan@653
    12
 *
Evan@653
    13
 * This program is free software; you can redistribute it and/or modify
Evan@653
    14
 * it under the terms of the GNU General Public License as published by
Evan@653
    15
 * the Free Software Foundation; either version 2 of the License, or
Evan@653
    16
 * (at your option) any later version.
Evan@653
    17
 *
Evan@653
    18
 * This program is distributed in the hope that it will be useful,
Evan@653
    19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Evan@653
    20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Evan@653
    21
 * GNU General Public License for more details.
Evan@653
    22
 *
Evan@653
    23
 * You should have received a copy of the GNU General Public License
Evan@653
    24
 * along with this program; if not, write to the Free Software
Evan@653
    25
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
Evan@653
    26
 */
Evan@653
    27
#ifndef _PURPLE_SAVEDSTATUSES_H_
Evan@653
    28
#define _PURPLE_SAVEDSTATUSES_H_
Evan@653
    29
Evan@653
    30
/**
Evan@653
    31
 * Saved statuses don't really interact much with the rest of Purple.  It
Evan@653
    32
 * could really be a plugin.  It's just a list of away states.  When
Evan@653
    33
 * a user chooses one of the saved states, their Purple accounts are set
Evan@653
    34
 * to the settings of that state.
Evan@653
    35
 *
Evan@653
    36
 * In the savedstatus API, there is the concept of a 'transient'
Evan@653
    37
 * saved status.  A transient saved status is one that is not
Evan@653
    38
 * permanent.  Purple will removed it automatically if it isn't
Evan@653
    39
 * used for a period of time.  Transient saved statuses don't
Evan@653
    40
 * have titles and they don't show up in the list of saved
Evan@653
    41
 * statuses.  In fact, if a saved status does not have a title
Evan@653
    42
 * then it is transient.  If it does have a title, then it is not
Evan@653
    43
 * transient.
Evan@653
    44
 *
Evan@653
    45
 * What good is a transient status, you ask?  They can be used to
Evan@653
    46
 * keep track of the user's 5 most recently used statuses, for
Evan@653
    47
 * example.  Basically if they just set a message on the fly,
Evan@653
    48
 * we'll cache it for them in case they want to use it again.  If
Evan@653
    49
 * they don't use it again, we'll just delete it.
Evan@653
    50
 */
Evan@653
    51
Evan@653
    52
/*
Evan@653
    53
 * TODO: Hmm.  We should probably just be saving PurplePresences.  That's
Evan@653
    54
 *       something we should look into once the status box gets fleshed
Evan@653
    55
 *       out more.
Evan@653
    56
 */
Evan@653
    57
Evan@653
    58
typedef struct _PurpleSavedStatus     PurpleSavedStatus;
Evan@653
    59
typedef struct _PurpleSavedStatusSub  PurpleSavedStatusSub;
Evan@653
    60
Evan@653
    61
#include "status.h"
Evan@653
    62
Evan@653
    63
#ifdef __cplusplus
Evan@653
    64
extern "C" {
Evan@653
    65
#endif
Evan@653
    66
Evan@653
    67
/**************************************************************************/
Evan@653
    68
/** @name Saved status subsystem                                          */
Evan@653
    69
/**************************************************************************/
Evan@653
    70
/*@{*/
Evan@653
    71
Evan@653
    72
/**
Evan@653
    73
 * Create a new saved status.  This will add the saved status to the
Evan@653
    74
 * list of saved statuses and writes the revised list to status.xml.
Evan@653
    75
 *
Evan@653
    76
 * @param title     The title of the saved status.  This must be
Evan@653
    77
 *                  unique.  Or, if you want to create a transient
Evan@653
    78
 *                  saved status, then pass in NULL.
Evan@653
    79
 * @param type      The type of saved status.
Evan@653
    80
 *
Evan@653
    81
 * @return The newly created saved status, or NULL if the title you
Evan@653
    82
 *         used was already taken.
Evan@653
    83
 */
Evan@653
    84
PurpleSavedStatus *purple_savedstatus_new(const char *title,
Evan@653
    85
									  PurpleStatusPrimitive type);
Evan@653
    86
Evan@653
    87
/**
Evan@653
    88
 * Set the title for the given saved status.
Evan@653
    89
 *
Evan@653
    90
 * @param status  The saved status.
Evan@653
    91
 * @param title   The title of the saved status.
Evan@653
    92
 */
Evan@653
    93
void purple_savedstatus_set_title(PurpleSavedStatus *status,
Evan@653
    94
								const char *title);
Evan@653
    95
Evan@653
    96
/**
Evan@653
    97
 * Set the type for the given saved status.
Evan@653
    98
 *
Evan@653
    99
 * @param status  The saved status.
Evan@653
   100
 * @param type    The type of saved status.
Evan@653
   101
 */
Evan@653
   102
void purple_savedstatus_set_type(PurpleSavedStatus *status,
Evan@653
   103
							   PurpleStatusPrimitive type);
Evan@653
   104
Evan@653
   105
/**
Evan@653
   106
 * Set the message for the given saved status.
Evan@653
   107
 *
Evan@653
   108
 * @param status  The saved status.
Evan@653
   109
 * @param message The message, or NULL if you want to unset the
Evan@653
   110
 *                message for this status.
Evan@653
   111
 */
Evan@653
   112
void purple_savedstatus_set_message(PurpleSavedStatus *status,
Evan@653
   113
								  const char *message);
Evan@653
   114
Evan@653
   115
/**
Evan@653
   116
 * Set a substatus for an account in a saved status.
Evan@653
   117
 *
Evan@653
   118
 * @param status	The saved status.
Evan@653
   119
 * @param account	The account.
Evan@653
   120
 * @param type		The status type for the account in the staved
Evan@653
   121
 *                  status.
Evan@653
   122
 * @param message	The message for the account in the substatus.
Evan@653
   123
 */
Evan@653
   124
void purple_savedstatus_set_substatus(PurpleSavedStatus *status,
Evan@653
   125
									const PurpleAccount *account,
Evan@653
   126
									const PurpleStatusType *type,
Evan@653
   127
									const char *message);
Evan@653
   128
Evan@653
   129
/**
Evan@653
   130
 * Unset a substatus for an account in a saved status.  This clears
Evan@653
   131
 * the previosly set substatus for the PurpleSavedStatus.  If this
Evan@653
   132
 * saved status is activated then this account will use the default
Evan@653
   133
 * status type and message.
Evan@653
   134
 *
Evan@653
   135
 * @param saved_status The saved status.
Evan@653
   136
 * @param account      The account.
Evan@653
   137
*/
Evan@653
   138
void purple_savedstatus_unset_substatus(PurpleSavedStatus *saved_status,
Evan@653
   139
												  const PurpleAccount *account);
Evan@653
   140
Evan@653
   141
/**
Evan@653
   142
 * Delete a saved status.  This removes the saved status from the list
Evan@653
   143
 * of saved statuses, and writes the revised list to status.xml.
Evan@653
   144
 *
Evan@653
   145
 * @param title The title of the saved status.
Evan@653
   146
 *
Evan@653
   147
 * @return TRUE if the status was successfully deleted.  FALSE if the
Evan@653
   148
 *         status could not be deleted because no saved status exists
Evan@653
   149
 *         with the given title.
Evan@653
   150
 */
Evan@653
   151
gboolean purple_savedstatus_delete(const char *title);
Evan@653
   152
Evan@653
   153
/**
Evan@653
   154
 * Delete a saved status.  This removes the saved status from the list
Evan@653
   155
 * of saved statuses, and writes the revised list to status.xml.
Evan@653
   156
 *
Evan@653
   157
 * @param saved_status the status to delete, the pointer is invalid after
Evan@653
   158
 *        the call
Evan@653
   159
 *
Evan@653
   160
 */
Evan@653
   161
void purple_savedstatus_delete_by_status(PurpleSavedStatus *saved_status);
Evan@653
   162
Evan@653
   163
/**
Evan@653
   164
 * Returns all saved statuses.
Evan@653
   165
 *
Evan@653
   166
 * @constreturn A list of saved statuses.
Evan@653
   167
 */
Evan@653
   168
GList *purple_savedstatuses_get_all(void);
Evan@653
   169
Evan@653
   170
/**
Evan@653
   171
 * Returns the n most popular saved statuses.  "Popularity" is
Evan@653
   172
 * determined by when the last time a saved_status was used and
Evan@653
   173
 * how many times it has been used. Transient statuses without
Evan@653
   174
 * messages are not included in the list.
Evan@653
   175
 *
Evan@653
   176
 * @param how_many The maximum number of saved statuses
Evan@653
   177
 *                 to return, or '0' to get all saved
Evan@653
   178
 *                 statuses sorted by popularity.
Evan@653
   179
 * @return A linked list containing at most how_many
Evan@653
   180
 *         PurpleSavedStatuses.  This list should be
Evan@653
   181
 *         g_list_free'd by the caller (but the
Evan@653
   182
 *         PurpleSavedStatuses must not be free'd).
Evan@653
   183
 */
Evan@653
   184
GList *purple_savedstatuses_get_popular(unsigned int how_many);
Evan@653
   185
Evan@653
   186
/**
Evan@653
   187
 * Returns the currently selected saved status.  If we are idle
Evan@653
   188
 * then this returns purple_savedstatus_get_idleaway().  Otherwise
Evan@653
   189
 * it returns purple_savedstatus_get_default().
Evan@653
   190
 *
Evan@653
   191
 * @return A pointer to the in-use PurpleSavedStatus.
Evan@653
   192
 *         This function never returns NULL.
Evan@653
   193
 */
Evan@653
   194
PurpleSavedStatus *purple_savedstatus_get_current(void);
Evan@653
   195
Evan@653
   196
/**
Evan@653
   197
 * Returns the default saved status that is used when our
Evan@653
   198
 * accounts are not idle-away.
Evan@653
   199
 *
Evan@653
   200
 * @return A pointer to the in-use PurpleSavedStatus.
Evan@653
   201
 *         This function never returns NULL.
Evan@653
   202
 */
Evan@653
   203
PurpleSavedStatus *purple_savedstatus_get_default(void);
Evan@653
   204
Evan@653
   205
/**
Evan@653
   206
 * Returns the saved status that is used when your
Evan@653
   207
 * accounts become idle-away.
Evan@653
   208
 *
Evan@653
   209
 * @return A pointer to the idle-away PurpleSavedStatus.
Evan@653
   210
 *         This function never returns NULL.
Evan@653
   211
 */
Evan@653
   212
PurpleSavedStatus *purple_savedstatus_get_idleaway(void);
Evan@653
   213
Evan@653
   214
/**
Evan@653
   215
 * Return TRUE if we are currently idle-away.  Otherwise
Evan@653
   216
 * returns FALSE.
Evan@653
   217
 *
Evan@653
   218
 * @return TRUE if our accounts have been set to idle-away.
Evan@653
   219
 */
Evan@653
   220
gboolean purple_savedstatus_is_idleaway(void);
Evan@653
   221
Evan@653
   222
/**
Evan@653
   223
 * Set whether accounts in Purple are idle-away or not.
Evan@653
   224
 *
Evan@653
   225
 * @param idleaway TRUE if accounts should be switched to use the
Evan@653
   226
 *                 idle-away saved status.  FALSE if they should
Evan@653
   227
 *                 be switched to use the default status.
Evan@653
   228
 */
Evan@653
   229
void purple_savedstatus_set_idleaway(gboolean idleaway);
Evan@653
   230
Evan@653
   231
/**
Evan@653
   232
 * Returns the status to be used when purple is starting up
Evan@653
   233
 *
Evan@653
   234
 * @return A pointer to the startup PurpleSavedStatus.
Evan@653
   235
 *         This function never returns NULL.
Evan@653
   236
 */
Evan@653
   237
PurpleSavedStatus *purple_savedstatus_get_startup(void);
Evan@653
   238
Evan@653
   239
/**
Evan@653
   240
 * Finds a saved status with the specified title.
Evan@653
   241
 *
Evan@653
   242
 * @param title The name of the saved status.
Evan@653
   243
 *
Evan@653
   244
 * @return The saved status if found, or NULL.
Evan@653
   245
 */
Evan@653
   246
PurpleSavedStatus *purple_savedstatus_find(const char *title);
Evan@653
   247
Evan@653
   248
/**
Evan@653
   249
 * Finds a saved status with the specified creation time.
Evan@653
   250
 *
Evan@653
   251
 * @param creation_time The timestamp when the saved
Evan@653
   252
 *        status was created.
Evan@653
   253
 *
Evan@653
   254
 * @return The saved status if found, or NULL.
Evan@653
   255
 */
Evan@653
   256
PurpleSavedStatus *purple_savedstatus_find_by_creation_time(time_t creation_time);
Evan@653
   257
Evan@653
   258
/**
Evan@653
   259
 * Finds a saved status with the specified primitive and message.
Evan@653
   260
 *
Evan@653
   261
 * @param type The PurpleStatusPrimitive for the status you're trying
Evan@653
   262
 *        to find.
Evan@653
   263
 * @param message The message for the status you're trying
Evan@653
   264
 *        to find.
Evan@653
   265
 *
Evan@653
   266
 * @return The saved status if found, or NULL.
Evan@653
   267
 */
Evan@653
   268
PurpleSavedStatus *purple_savedstatus_find_transient_by_type_and_message(PurpleStatusPrimitive type, const char *message);
Evan@653
   269
Evan@653
   270
/**
Evan@653
   271
 * Determines if a given saved status is "transient."
Evan@653
   272
 * A transient saved status is one that was not
Evan@653
   273
 * explicitly added by the user.  Transient statuses
Evan@653
   274
 * are automatically removed if they are not used
Evan@653
   275
 * for a period of time.
Evan@653
   276
 *
Evan@653
   277
 * A transient saved statuses is automatically
Evan@653
   278
 * created by the status box when the user sets himself
Evan@653
   279
 * to one of the generic primitive statuses.  The reason
Evan@653
   280
 * we need to save this status information is so we can
Evan@653
   281
 * restore it when Purple restarts.
Evan@653
   282
 *
Evan@653
   283
 * @param saved_status The saved status.
Evan@653
   284
 *
Evan@653
   285
 * @return TRUE if the saved status is transient.
Evan@653
   286
 */
Evan@653
   287
gboolean purple_savedstatus_is_transient(const PurpleSavedStatus *saved_status);
Evan@653
   288
Evan@653
   289
/**
Evan@653
   290
 * Return the name of a given saved status.
Evan@653
   291
 *
Evan@653
   292
 * @param saved_status The saved status.
Evan@653
   293
 *
Evan@653
   294
 * @return The title.  This value may be a static buffer which may
Evan@653
   295
 *         be overwritten on subsequent calls to this function.  If
Evan@653
   296
 *         you need a reference to the title for prolonged use then
Evan@653
   297
 *         you should make a copy of it.
Evan@653
   298
 */
Evan@653
   299
const char *purple_savedstatus_get_title(const PurpleSavedStatus *saved_status);
Evan@653
   300
Evan@653
   301
/**
Evan@653
   302
 * Return the type of a given saved status.
Evan@653
   303
 *
Evan@653
   304
 * @param saved_status The saved status.
Evan@653
   305
 *
Evan@653
   306
 * @return The name.
Evan@653
   307
 */
Evan@653
   308
PurpleStatusPrimitive purple_savedstatus_get_type(const PurpleSavedStatus *saved_status);
Evan@653
   309
Evan@653
   310
/**
Evan@653
   311
 * Return the default message of a given saved status.
Evan@653
   312
 *
Evan@653
   313
 * @param saved_status The saved status.
Evan@653
   314
 *
Evan@653
   315
 * @return The message.  This will return NULL if the saved
Evan@653
   316
 *         status does not have a message.  This will
Evan@653
   317
 *         contain the normal markup that is created by
Evan@653
   318
 *         Purple's IMHTML (basically HTML markup).
Evan@653
   319
 */
Evan@653
   320
const char *purple_savedstatus_get_message(const PurpleSavedStatus *saved_status);
Evan@653
   321
Evan@653
   322
/**
Evan@653
   323
 * Return the time in seconds-since-the-epoch when this
Evan@653
   324
 * saved status was created.  Note: For any status created
Evan@653
   325
 * by Purple 1.5.0 or older this value will be invalid and
Evan@653
   326
 * very small (close to 0).  This is because Purple 1.5.0
Evan@653
   327
 * and older did not record the timestamp when the status
Evan@653
   328
 * was created.
Evan@653
   329
 *
Evan@653
   330
 * However, this value is guaranteed to be a unique
Evan@653
   331
 * identifier for the given saved status.
Evan@653
   332
 *
Evan@653
   333
 * @param saved_status The saved status.
Evan@653
   334
 *
Evan@653
   335
 * @return The timestamp when this saved status was created.
Evan@653
   336
 */
Evan@653
   337
time_t purple_savedstatus_get_creation_time(const PurpleSavedStatus *saved_status);
Evan@653
   338
Evan@653
   339
/**
Evan@653
   340
 * Determine if a given saved status has "substatuses,"
Evan@653
   341
 * or if it is a simple status (the same for all
Evan@653
   342
 * accounts).
Evan@653
   343
 *
Evan@653
   344
 * @param saved_status The saved status.
Evan@653
   345
 *
Evan@653
   346
 * @return TRUE if the saved_status has substatuses.
Evan@653
   347
 *         FALSE otherwise.
Evan@653
   348
 */
Evan@653
   349
gboolean purple_savedstatus_has_substatuses(const PurpleSavedStatus *saved_status);
Evan@653
   350
Evan@653
   351
/**
Evan@653
   352
 * Get the substatus for an account in a saved status.
Evan@653
   353
 *
Evan@653
   354
 * @param saved_status The saved status.
Evan@653
   355
 * @param account      The account.
Evan@653
   356
 *
Evan@653
   357
 * @return The PurpleSavedStatusSub for the account, or NULL if
Evan@653
   358
 *         the given account does not have a substatus that
Evan@653
   359
 *         differs from the default status of this PurpleSavedStatus.
Evan@653
   360
 */
Evan@653
   361
PurpleSavedStatusSub *purple_savedstatus_get_substatus(
Evan@653
   362
									const PurpleSavedStatus *saved_status,
Evan@653
   363
									const PurpleAccount *account);
Evan@653
   364
Evan@653
   365
/**
Evan@653
   366
 * Get the status type of a given substatus.
Evan@653
   367
 *
Evan@653
   368
 * @param substatus The substatus.
Evan@653
   369
 *
Evan@653
   370
 * @return The status type.
Evan@653
   371
 */
Evan@653
   372
const PurpleStatusType *purple_savedstatus_substatus_get_type(const PurpleSavedStatusSub *substatus);
Evan@653
   373
Evan@653
   374
/**
Evan@653
   375
 * Get the message of a given substatus.
Evan@653
   376
 *
Evan@653
   377
 * @param substatus The substatus.
Evan@653
   378
 *
Evan@653
   379
 * @return The message of the substatus, or NULL if this substatus does
Evan@653
   380
 *         not have a message.
Evan@653
   381
 */
Evan@653
   382
const char *purple_savedstatus_substatus_get_message(const PurpleSavedStatusSub *substatus);
Evan@653
   383
Evan@653
   384
/**
Evan@653
   385
 * Sets the statuses for all your accounts to those specified
Evan@653
   386
 * by the given saved_status.  This function calls
Evan@653
   387
 * purple_savedstatus_activate_for_account() for all your accounts.
Evan@653
   388
 *
Evan@653
   389
 * @param saved_status The status you want to set your accounts to.
Evan@653
   390
 */
Evan@653
   391
void purple_savedstatus_activate(PurpleSavedStatus *saved_status);
Evan@653
   392
Evan@653
   393
/**
Evan@653
   394
 * Sets the statuses for a given account to those specified
Evan@653
   395
 * by the given saved_status.
Evan@653
   396
 *
Evan@653
   397
 * @param saved_status The status you want to set your accounts to.
Evan@653
   398
 * @param account      The account whose statuses you want to change.
Evan@653
   399
 */
Evan@653
   400
void purple_savedstatus_activate_for_account(const PurpleSavedStatus *saved_status, PurpleAccount *account);
Evan@653
   401
Evan@653
   402
/**
Evan@653
   403
 * Get the handle for the status subsystem.
Evan@653
   404
 *
Evan@653
   405
 * @return the handle to the status subsystem
Evan@653
   406
 */
Evan@653
   407
void *purple_savedstatuses_get_handle(void);
Evan@653
   408
Evan@653
   409
/**
Evan@653
   410
 * Initializes the status subsystem.
Evan@653
   411
 */
Evan@653
   412
void purple_savedstatuses_init(void);
Evan@653
   413
Evan@653
   414
/**
Evan@653
   415
 * Uninitializes the status subsystem.
Evan@653
   416
 */
Evan@653
   417
void purple_savedstatuses_uninit(void);
Evan@653
   418
Evan@653
   419
/*@}*/
Evan@653
   420
Evan@653
   421
#ifdef __cplusplus
Evan@653
   422
}
Evan@653
   423
#endif
Evan@653
   424
Evan@653
   425
#endif /* _PURPLE_SAVEDSTATUSES_H_ */