# HG changeset patch # User Sadrul Habib Chowdhury # Date 1204931663 0 # Node ID 0ae4d67bd6b1472f1c03f1240de60ffcd7fdc93e # Parent e04a69cf1d8e097844e042d528227a465d1f9586 Make it simple to create a stored-image from a filename. diff -r e04a69cf1d8e -r 0ae4d67bd6b1 libpurple/imgstore.c --- a/libpurple/imgstore.c Fri Mar 07 21:32:09 2008 +0000 +++ b/libpurple/imgstore.c Fri Mar 07 23:14:23 2008 +0000 @@ -70,6 +70,22 @@ return img; } +PurpleStoredImage * +purple_imgstore_new_from_file(const char *path) +{ + gchar *data = NULL; + size_t len; + GError *err = NULL; + + if (!g_file_get_contents(path, &data, &len, &err)) { + purple_debug_error("imgstore", "Error reading %s: %s\n", + path, err->message); + g_error_free(err); + return NULL; + } + return purple_imgstore_add(data, len, path); +} + int purple_imgstore_add_with_id(gpointer data, size_t size, const char *filename) { diff -r e04a69cf1d8e -r 0ae4d67bd6b1 libpurple/imgstore.h --- a/libpurple/imgstore.h Fri Mar 07 21:32:09 2008 +0000 +++ b/libpurple/imgstore.h Fri Mar 07 23:14:23 2008 +0000 @@ -56,6 +56,17 @@ purple_imgstore_add(gpointer data, size_t size, const char *filename); /** + * Create an image and add it to the store. + * + * @param path The path to the image. + * + * @return The stored image. + * @since 2.X.X + */ +PurpleStoredImage * +purple_imgstore_new_from_file(const char *path); + +/** * Add an image to the store, allocating an ID. * * The caller owns a reference to the image in the store, and must dereference