Merged pidgin/main into default
[pidgin-git.git] / libpurple / image-store.h
blobd00d271b6fcdd45d9919dcb020e371cd809dc235
1 /* purple
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
5 * source distribution.
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_IMAGE_STORE_H_
23 #define _PURPLE_IMAGE_STORE_H_
24 /**
25 * SECTION:image-store
26 * @include:image-store.h
27 * @section_id: libpurple-image-store
28 * @short_description: a global, temporary storage for images
29 * @title: Image store
31 * Image store references #PurpleImage's by a simple integer value.
32 * It's a convenient way to embed images in HTML-like strings.
34 * Integer ID's are tracked for being valid - when a image is destroyed, it's
35 * also removed from the store. If the application runs for a very long time and
36 * all possible id numbers from integer range are utilized, it will use
37 * previously released numbers.
40 #include "image.h"
42 /**
43 * PURPLE_IMAGE_STORE_PROTOCOL:
45 * A global URI prefix for images stored in this subsystem.
47 #define PURPLE_IMAGE_STORE_PROTOCOL "purple-image:"
49 /**
50 * PURPLE_IMAGE_STORE_STOCK_PROTOCOL:
52 * A global URI prefix for stock images, with names defined by libpurple and
53 * contents defined by the UI.
55 #define PURPLE_IMAGE_STORE_STOCK_PROTOCOL "purple-stock-image:"
57 G_BEGIN_DECLS
59 /**
60 * purple_image_store_add:
61 * @image: the image.
63 * Permanently adds an image to the store. If the @image is already in the
64 * store, it will return its current id.
66 * This function increases @image's reference count, so it won't be destroyed
67 * until image store subsystem is shut down. Don't decrease @image's reference
68 * count by yourself - if you don't want the store to hold the reference,
69 * use #purple_image_store_add_weak.
71 * Returns: the unique identifier for the @image.
73 guint
74 purple_image_store_add(PurpleImage *image);
76 /**
77 * purple_image_store_add_weak:
78 * @image: the image.
80 * Adds an image to the store without increasing reference count. It will be
81 * removed from the store when @image gets destroyed.
83 * If the @image is already in the store, it will return its current id.
85 * Returns: the unique identifier for the @image.
87 guint
88 purple_image_store_add_weak(PurpleImage *image);
90 /**
91 * purple_image_store_add_temporary:
92 * @image: the image.
94 * Adds an image to the store to be used in a short period of time.
95 * If the @image is already in the store, it will just return its current id.
97 * Increases reference count for the @image for a time long enough to display
98 * the @image by the UI. In current implementation it's five seconds, but may be
99 * changed in the future, so if you need more sophisticated reference
100 * management, implement it on your own.
102 * Returns: the unique identifier for the @image.
104 guint
105 purple_image_store_add_temporary(PurpleImage *image);
108 * purple_image_store_get:
109 * @id: the unique identifier of an image.
111 * Finds the image with a certain identifier within a store.
113 * Returns: (transfer none): the image referenced by @id, or %NULL if it
114 * doesn't exists.
116 PurpleImage *
117 purple_image_store_get(guint id);
120 * purple_image_store_get_from_uri:
121 * @uri: the URI of a potential #PurpleImage. Should not be %NULL.
123 * Checks, if the @uri is pointing to any #PurpleImage by referring
124 * to #PURPLE_IMAGE_STORE_PROTOCOL and returns the image, if it's valid.
126 * The function doesn't throw any warning, if the @uri is for any
127 * other protocol.
129 * Returns: (transfer none): the image referenced by @uri, or %NULL if it
130 * doesn't point to any valid image.
132 PurpleImage *
133 purple_image_store_get_from_uri(const gchar *uri);
136 * purple_image_store_get_uri:
137 * @image: the image.
139 * Generates an URI for the @image, to be retrieved using
140 * #purple_image_store_get_from_uri.
142 * Returns: (transfer full): the URI for the @image. Should be #g_free'd when
143 * you done using it.
145 gchar *
146 purple_image_store_get_uri(PurpleImage *image);
149 * _purple_image_store_init: (skip)
151 * Initializes the image store subsystem.
153 void
154 _purple_image_store_init(void);
157 * _purple_image_store_uninit: (skip)
159 * Uninitializes the image store subsystem.
161 void
162 _purple_image_store_uninit(void);
164 G_END_DECLS
166 #endif /* _PURPLE_IMAGE_STORE_H_ */