Frameworks/libpurple.framework/Versions/0.6.2/Headers/smiley.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 2069 Frameworks/libpurple.framework/Versions/0.6.0/Headers/smiley.h@1346acdb9a2b
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
Evan@653
     1
/**
Evan@653
     2
 * @file smiley.h Smiley API
Evan@653
     3
 * @ingroup core
Evan@653
     4
 * @since 2.5.0
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
 */
Evan@653
    28
Evan@653
    29
#ifndef _PURPLE_SMILEY_H_
Evan@653
    30
#define _PURPLE_SMILEY_H_
Evan@653
    31
Evan@653
    32
#include <glib-object.h>
Evan@653
    33
Evan@653
    34
#include "imgstore.h"
Evan@653
    35
#include "util.h"
Evan@653
    36
Evan@653
    37
/**
Evan@653
    38
 * A custom smiley.
Evan@653
    39
 * This contains everything Purple will ever need to know about a custom smiley.
Evan@653
    40
 * Everything.
Evan@653
    41
 *
Evan@653
    42
 * PurpleSmiley is a GObject.
Evan@653
    43
 */
Evan@653
    44
typedef struct _PurpleSmiley        PurpleSmiley;
Evan@653
    45
typedef struct _PurpleSmileyClass   PurpleSmileyClass;
Evan@653
    46
Evan@653
    47
#define PURPLE_TYPE_SMILEY             (purple_smiley_get_type ())
Evan@653
    48
#define PURPLE_SMILEY(smiley)          (G_TYPE_CHECK_INSTANCE_CAST ((smiley), PURPLE_TYPE_SMILEY, PurpleSmiley))
Evan@653
    49
#define PURPLE_SMILEY_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), PURPLE_TYPE_SMILEY, PurpleSmileyClass))
Evan@653
    50
#define PURPLE_IS_SMILEY(smiley)       (G_TYPE_CHECK_INSTANCE_TYPE ((smiley), PURPLE_TYPE_SMILEY))
Evan@653
    51
#define PURPLE_IS_SMILEY_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), PURPLE_TYPE_SMILEY))
Evan@653
    52
#define PURPLE_SMILEY_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), PURPLE_TYPE_SMILEY, PurpleSmileyClass))
Evan@653
    53
Evan@653
    54
#ifdef __cplusplus
Evan@653
    55
extern "C" {
Evan@653
    56
#endif
Evan@653
    57
Evan@653
    58
/**************************************************************************/
Evan@653
    59
/** @name Custom Smiley API                                               */
Evan@653
    60
/**************************************************************************/
Evan@653
    61
/*@{*/
Evan@653
    62
Evan@653
    63
/**
zacw@2069
    64
 * GObject-fu.
Evan@653
    65
 * @internal.
Evan@653
    66
 */
Evan@653
    67
GType purple_smiley_get_type(void);
Evan@653
    68
Evan@653
    69
/**
zacw@2069
    70
 * Creates a new custom smiley from a PurpleStoredImage.
Evan@653
    71
 *
zacw@2069
    72
 * If a custom smiley with the given shortcut already exists, it
Evan@653
    73
 * will be automaticaly returned.
Evan@653
    74
 *
Evan@653
    75
 * @param img         The image associated with the smiley.
zacw@2069
    76
 * @param shortcut    The associated shortcut (e.g. "(homer)").
Evan@653
    77
 *
zacw@2069
    78
 * @return The custom smiley.
Evan@653
    79
 */
Evan@653
    80
PurpleSmiley *
Evan@653
    81
purple_smiley_new(PurpleStoredImage *img, const char *shortcut);
Evan@653
    82
Evan@653
    83
/**
zacw@2069
    84
 * Creates a new custom smiley, reading the image data from a file.
Evan@653
    85
 *
zacw@2069
    86
 * If a custom smiley with the given shortcut already exists, it
Evan@653
    87
 * will be automaticaly returned.
Evan@653
    88
 *
zacw@2069
    89
 * @param shortcut           The associated shortcut (e.g. "(homer)").
zacw@2069
    90
 * @param filepath           The image file.
Evan@653
    91
 *
zacw@2069
    92
 * @return The custom smiley.
Evan@653
    93
 */
Evan@653
    94
PurpleSmiley *
Evan@653
    95
purple_smiley_new_from_file(const char *shortcut, const char *filepath);
Evan@653
    96
Evan@653
    97
/**
zacw@2069
    98
 * Destroys the custom smiley and release the associated resources.
Evan@653
    99
 *
Evan@653
   100
 * @param smiley    The custom smiley.
Evan@653
   101
 */
Evan@653
   102
void
Evan@653
   103
purple_smiley_delete(PurpleSmiley *smiley);
Evan@653
   104
Evan@653
   105
/**
Evan@653
   106
 * Changes the custom smiley's shortcut.
Evan@653
   107
 *
Evan@653
   108
 * @param smiley    The custom smiley.
zacw@2069
   109
 * @param shortcut  The new shortcut. A custom smiley with this shortcut
zacw@2069
   110
 *                  cannot already be in use.
Evan@653
   111
 *
zacw@2069
   112
 * @return TRUE if the shortcut was changed. FALSE otherwise.
Evan@653
   113
 */
Evan@653
   114
gboolean
Evan@653
   115
purple_smiley_set_shortcut(PurpleSmiley *smiley, const char *shortcut);
Evan@653
   116
Evan@653
   117
/**
zacw@2069
   118
 * Changes the custom smiley's image data.
Evan@653
   119
 *
Evan@653
   120
 * @param smiley             The custom smiley.
zacw@2069
   121
 * @param smiley_data        The custom smiley data, which the smiley code
zacw@2069
   122
 *                           takes ownership of and will free.
zacw@2069
   123
 * @param smiley_data_len    The length of the data in @a smiley_data.
Evan@653
   124
 */
Evan@653
   125
void
Evan@653
   126
purple_smiley_set_data(PurpleSmiley *smiley, guchar *smiley_data,
Evan@653
   127
                                           size_t smiley_data_len);
Evan@653
   128
Evan@653
   129
/**
zacw@2069
   130
 * Returns the custom smiley's associated shortcut (e.g. "(homer)").
Evan@653
   131
 *
Evan@653
   132
 * @param smiley   The custom smiley.
Evan@653
   133
 *
Evan@653
   134
 * @return The shortcut.
Evan@653
   135
 */
Evan@653
   136
const char *purple_smiley_get_shortcut(const PurpleSmiley *smiley);
Evan@653
   137
Evan@653
   138
/**
Evan@653
   139
 * Returns the custom smiley data's checksum.
Evan@653
   140
 *
Evan@653
   141
 * @param smiley   The custom smiley.
Evan@653
   142
 *
Evan@653
   143
 * @return The checksum.
Evan@653
   144
 */
Evan@653
   145
const char *purple_smiley_get_checksum(const PurpleSmiley *smiley);
Evan@653
   146
Evan@653
   147
/**
Evan@653
   148
 * Returns the PurpleStoredImage with the reference counter incremented.
Evan@653
   149
 *
Evan@653
   150
 * The returned PurpleStoredImage reference counter must be decremented
zacw@2069
   151
 * when the caller is done using it.
Evan@653
   152
 *
Evan@653
   153
 * @param smiley   The custom smiley.
Evan@653
   154
 *
zacw@2069
   155
 * @return A PurpleStoredImage.
Evan@653
   156
 */
Evan@653
   157
PurpleStoredImage *purple_smiley_get_stored_image(const PurpleSmiley *smiley);
Evan@653
   158
Evan@653
   159
/**
Evan@653
   160
 * Returns the custom smiley's data.
Evan@653
   161
 *
Evan@653
   162
 * @param smiley  The custom smiley.
zacw@2069
   163
 * @param len     If not @c NULL, the length of the image data returned
Evan@653
   164
 *                will be set in the location pointed to by this.
Evan@653
   165
 *
Evan@653
   166
 * @return A pointer to the custom smiley data.
Evan@653
   167
 */
Evan@653
   168
gconstpointer purple_smiley_get_data(const PurpleSmiley *smiley, size_t *len);
Evan@653
   169
Evan@653
   170
/**
Evan@653
   171
 * Returns an extension corresponding to the custom smiley's file type.
Evan@653
   172
 *
Evan@653
   173
 * @param smiley  The custom smiley.
Evan@653
   174
 *
Evan@653
   175
 * @return The custom smiley's extension, "icon" if unknown, or @c NULL if
Evan@653
   176
 *         the image data has disappeared.
Evan@653
   177
 */
Evan@653
   178
const char *purple_smiley_get_extension(const PurpleSmiley *smiley);
Evan@653
   179
Evan@653
   180
/**
Evan@653
   181
 * Returns a full path to an custom smiley.
Evan@653
   182
 *
Evan@653
   183
 * If the custom smiley has data and the file exists in the cache, this
Evan@653
   184
 * will return a full path to the cached file.
Evan@653
   185
 *
Evan@653
   186
 * In general, it is not appropriate to be poking in the file cached
Evan@653
   187
 * directly.  If you find yourself wanting to use this function, think
Evan@653
   188
 * very long and hard about it, and then don't.
Evan@653
   189
 *
zacw@2069
   190
 * Think some more.
zacw@2069
   191
 *
Evan@653
   192
 * @param smiley  The custom smiley.
Evan@653
   193
 *
Evan@653
   194
 * @return A full path to the file, or @c NULL under various conditions.
Evan@653
   195
 *         The caller should use #g_free to free the returned string.
Evan@653
   196
 */
Evan@653
   197
char *purple_smiley_get_full_path(PurpleSmiley *smiley);
Evan@653
   198
Evan@653
   199
/*@}*/
Evan@653
   200
Evan@653
   201
Evan@653
   202
/**************************************************************************/
Evan@653
   203
/** @name Custom Smiley Subsystem API                                     */
Evan@653
   204
/**************************************************************************/
Evan@653
   205
/*@{*/
Evan@653
   206
Evan@653
   207
/**
zacw@2069
   208
 * Returns a list of all custom smileys. The caller is responsible for freeing
zacw@2069
   209
 * the list.
Evan@653
   210
 *
Evan@653
   211
 * @return A list of all custom smileys.
Evan@653
   212
 */
Evan@653
   213
GList *
Evan@653
   214
purple_smileys_get_all(void);
Evan@653
   215
Evan@653
   216
/**
zacw@2069
   217
 * Returns a custom smiley given its shortcut.
Evan@653
   218
 *
Evan@653
   219
 * @param shortcut The custom smiley's shortcut.
Evan@653
   220
 *
zacw@2069
   221
 * @return The custom smiley if found, or @c NULL if not found.
Evan@653
   222
 */
Evan@653
   223
PurpleSmiley *
Evan@653
   224
purple_smileys_find_by_shortcut(const char *shortcut);
Evan@653
   225
Evan@653
   226
/**
zacw@2069
   227
 * Returns a custom smiley given its checksum.
Evan@653
   228
 *
Evan@653
   229
 * @param checksum The custom smiley's checksum.
Evan@653
   230
 *
zacw@2069
   231
 * @return The custom smiley if found, or @c NULL if not found.
Evan@653
   232
 */
Evan@653
   233
PurpleSmiley *
Evan@653
   234
purple_smileys_find_by_checksum(const char *checksum);
Evan@653
   235
Evan@653
   236
/**
Evan@653
   237
 * Returns the directory used to store custom smiley cached files.
Evan@653
   238
 *
zacw@2069
   239
 * The default directory is PURPLEDIR/custom_smiley.
Evan@653
   240
 *
zacw@2069
   241
 * @return The directory in which to store custom smileys cached files.
Evan@653
   242
 */
Evan@653
   243
const char *purple_smileys_get_storing_dir(void);
Evan@653
   244
Evan@653
   245
/**
Evan@653
   246
 * Initializes the custom smiley subsystem.
Evan@653
   247
 */
Evan@653
   248
void purple_smileys_init(void);
Evan@653
   249
Evan@653
   250
/**
Evan@653
   251
 * Uninitializes the custom smiley subsystem.
Evan@653
   252
 */
Evan@653
   253
void purple_smileys_uninit(void);
Evan@653
   254
Evan@653
   255
/*@}*/
Evan@653
   256
Evan@653
   257
#ifdef __cplusplus
Evan@653
   258
}
Evan@653
   259
#endif
Evan@653
   260
Evan@653
   261
#endif /* _PURPLE_SMILEY_H_ */
Evan@653
   262