smiley.h File Reference

Smiley API. More...

#include <glib-object.h>
#include "imgstore.h"
#include "util.h"

Go to the source code of this file.

Defines

#define PURPLE_TYPE_SMILEY   (purple_smiley_get_type ())
#define PURPLE_SMILEY(smiley)   (G_TYPE_CHECK_INSTANCE_CAST ((smiley), PURPLE_TYPE_SMILEY, PurpleSmiley))
#define PURPLE_SMILEY_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), PURPLE_TYPE_SMILEY, PurpleSmileyClass))
#define PURPLE_IS_SMILEY(smiley)   (G_TYPE_CHECK_INSTANCE_TYPE ((smiley), PURPLE_TYPE_SMILEY))
#define PURPLE_IS_SMILEY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PURPLE_TYPE_SMILEY))
#define PURPLE_SMILEY_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), PURPLE_TYPE_SMILEY, PurpleSmileyClass))

Typedefs

typedef struct _PurpleSmiley PurpleSmiley
 A custom smiley.
typedef struct _PurpleSmileyClass PurpleSmileyClass

Functions

Custom Smiley API
GType purple_smiley_get_type (void)
 GObject foo.
PurpleSmileypurple_smiley_new (PurpleStoredImage *img, const char *shortcut)
 Creates a new custom smiley structure and populates it.
PurpleSmileypurple_smiley_new_from_file (const char *shortcut, const char *filepath)
 Creates a new custom smiley structure and populates it.
void purple_smiley_delete (PurpleSmiley *smiley)
 Destroy the custom smiley and release the associated resources.
gboolean purple_smiley_set_shortcut (PurpleSmiley *smiley, const char *shortcut)
 Changes the custom smiley's shortcut.
void purple_smiley_set_data (PurpleSmiley *smiley, guchar *smiley_data, size_t smiley_data_len)
 Changes the custom smiley's data.
const char * purple_smiley_get_shortcut (const PurpleSmiley *smiley)
 Returns the custom smiley's associated shortcut.
const char * purple_smiley_get_checksum (const PurpleSmiley *smiley)
 Returns the custom smiley data's checksum.
PurpleStoredImagepurple_smiley_get_stored_image (const PurpleSmiley *smiley)
 Returns the PurpleStoredImage with the reference counter incremented.
gconstpointer purple_smiley_get_data (const PurpleSmiley *smiley, size_t *len)
 Returns the custom smiley's data.
const char * purple_smiley_get_extension (const PurpleSmiley *smiley)
 Returns an extension corresponding to the custom smiley's file type.
char * purple_smiley_get_full_path (PurpleSmiley *smiley)
 Returns a full path to an custom smiley.
Custom Smiley Subsystem API
GList * purple_smileys_get_all (void)
 Returns a list of all custom smileys.
PurpleSmileypurple_smileys_find_by_shortcut (const char *shortcut)
 Returns the custom smiley given it's shortcut.
PurpleSmileypurple_smileys_find_by_checksum (const char *checksum)
 Returns the custom smiley given it's checksum.
const char * purple_smileys_get_storing_dir (void)
 Returns the directory used to store custom smiley cached files.
void purple_smileys_init (void)
 Initializes the custom smiley subsystem.
void purple_smileys_uninit (void)
 Uninitializes the custom smiley subsystem.


Detailed Description

Smiley API.

Since:
2.5.0

Definition in file smiley.h.


Typedef Documentation

typedef struct _PurpleSmiley PurpleSmiley

A custom smiley.

This contains everything Purple will ever need to know about a custom smiley. Everything.

PurpleSmiley is a GObject.

Definition at line 44 of file smiley.h.


Function Documentation

void purple_smiley_delete ( PurpleSmiley smiley  ) 

Destroy the custom smiley and release the associated resources.

Parameters:
smiley The custom smiley.

const char* purple_smiley_get_checksum ( const PurpleSmiley smiley  ) 

Returns the custom smiley data's checksum.

Parameters:
smiley The custom smiley.
Returns:
The checksum.

gconstpointer purple_smiley_get_data ( const PurpleSmiley smiley,
size_t *  len 
)

Returns the custom smiley's data.

Parameters:
smiley The custom smiley.
len If not NULL, the length of the icon data returned will be set in the location pointed to by this.
Returns:
A pointer to the custom smiley data.

const char* purple_smiley_get_extension ( const PurpleSmiley smiley  ) 

Returns an extension corresponding to the custom smiley's file type.

Parameters:
smiley The custom smiley.
Returns:
The custom smiley's extension, "icon" if unknown, or NULL if the image data has disappeared.

char* purple_smiley_get_full_path ( PurpleSmiley smiley  ) 

Returns a full path to an custom smiley.

If the custom smiley has data and the file exists in the cache, this will return a full path to the cached file.

In general, it is not appropriate to be poking in the file cached directly. If you find yourself wanting to use this function, think very long and hard about it, and then don't.

Parameters:
smiley The custom smiley.
Returns:
A full path to the file, or NULL under various conditions. The caller should use g_free to free the returned string.

const char* purple_smiley_get_shortcut ( const PurpleSmiley smiley  ) 

Returns the custom smiley's associated shortcut.

Parameters:
smiley The custom smiley.
Returns:
The shortcut.

PurpleStoredImage* purple_smiley_get_stored_image ( const PurpleSmiley smiley  ) 

Returns the PurpleStoredImage with the reference counter incremented.

The returned PurpleStoredImage reference counter must be decremented after use.

Parameters:
smiley The custom smiley.
Returns:
A PurpleStoredImage reference.

PurpleSmiley* purple_smiley_new ( PurpleStoredImage img,
const char *  shortcut 
)

Creates a new custom smiley structure and populates it.

If a custom smiley with the informed shortcut already exist, it will be automaticaly returned.

Parameters:
img The image associated with the smiley.
shortcut The custom smiley associated shortcut.
Returns:
The custom smiley structure filled up.

PurpleSmiley* purple_smiley_new_from_file ( const char *  shortcut,
const char *  filepath 
)

Creates a new custom smiley structure and populates it.

The data is retrieved from an already existent file.

If a custom smiley with the informed shortcut already exist, it will be automaticaly returned.

Parameters:
shortcut The custom smiley associated shortcut.
filepath The image file to be imported to a new custom smiley.
Returns:
The custom smiley structure filled up.

void purple_smiley_set_data ( PurpleSmiley smiley,
guchar *  smiley_data,
size_t  smiley_data_len 
)

Changes the custom smiley's data.

When the filename controling is made outside this API, the param keepfilename must be TRUE. Otherwise, the file and filename will be regenerated, and the old one will be removed.

Parameters:
smiley The custom smiley.
smiley_data The custom smiley data.
smiley_data_len The custom smiley data length.

gboolean purple_smiley_set_shortcut ( PurpleSmiley smiley,
const char *  shortcut 
)

Changes the custom smiley's shortcut.

Parameters:
smiley The custom smiley.
shortcut The custom smiley associated shortcut.
Returns:
TRUE whether the shortcut is not associated with another custom smiley and the parameters are valid. FALSE otherwise.

PurpleSmiley* purple_smileys_find_by_checksum ( const char *  checksum  ) 

Returns the custom smiley given it's checksum.

Parameters:
checksum The custom smiley's checksum.
Returns:
The custom smiley (with a reference for the caller) if found, or NULL if not found.

PurpleSmiley* purple_smileys_find_by_shortcut ( const char *  shortcut  ) 

Returns the custom smiley given it's shortcut.

Parameters:
shortcut The custom smiley's shortcut.
Returns:
The custom smiley (with a reference for the caller) if found, or NULL if not found.

GList* purple_smileys_get_all ( void   ) 

Returns a list of all custom smileys.

The caller should free the list.

Returns:
A list of all custom smileys.

const char* purple_smileys_get_storing_dir ( void   ) 

Returns the directory used to store custom smiley cached files.

The default directory is PURPLEDIR/smileys, unless otherwise specified by purple_buddy_icons_set_cache_dir().

Returns:
The directory to store custom smyles cached files to.