annotate src/imgstore.h @ 7152:cada5ddc21f5

[gaim-migrate @ 7719] Thanks to Sean for committing my patch and attempting to fix it. It gave me the motivation to figure out what was wrong, which turned out to be a g_free() in the wrong place in the GAIM_DEBUG_FATAL handling code. Now it works how it was supposed to. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 05 Oct 2003 00:46:28 +0000
parents bf630f7dfdcd
children fa6395637e2c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1 /**
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
2 * @file imgstore.h IM Image Store API
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
3 * @ingroup core
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
4 *
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
5 * gaim
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
6 *
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
7 * Copyright (C) 2003 Robert McQueen <robot101@debian.org>
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
8 *
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
12 * (at your option) any later version.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
13 *
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
17 * GNU General Public License for more details.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
18 *
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
22 *
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
23 */
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
24 #ifndef _GAIM_CONV_IMGSTORE_H_
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
25 #define _GAIM_CONV_IMGSTORE_H_
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
26
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
27 /**
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
28 * Stored image
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
29 *
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
30 * Represents a single IM image awaiting display and/or transmission.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
31 */
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
32 typedef struct
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
33 {
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
34 char *data; /**< The image data. */
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
35 size_t size; /**< The image data's size. */
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
36 char *filename; /**< The filename (for the UI) */
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
37 } GaimStoredImage;
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
38
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
39 #ifdef __cplusplus
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
40 extern "C" {
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
41 #endif
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
42
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
43 /**
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
44 * Add an image to the store. The caller owns a reference
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
45 * to the image in the store, and must dereference the image
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
46 * with gaim_imgstore_unref for it to be freed.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
47 *
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
48 * @param data Pointer to the image data.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
49 * @param size Image data's size.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
50 * @param filename Filename associated with image.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
51
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
52 * @return ID for the image.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
53 */
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
54 int gaim_imgstore_add(const void *data, size_t size, const char *filename);
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
55
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
56 /**
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
57 * Retrieve an image from the store. The caller does not own a
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
58 * reference to the image.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
59 *
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
60 * @param id The ID for the image.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
61 *
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
62 * @return A pointer to the requested image, or NULL if it was not found.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
63 */
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
64 GaimStoredImage *gaim_imgstore_get(int id);
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
65
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
66 /**
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
67 * Increment the reference count for an image in the store. The
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
68 * image will be removed from the store when the reference count
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
69 * is zero.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
70 *
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
71 * @param id The ID for the image.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
72 */
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
73 void gaim_imgstore_ref(int id);
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
74
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
75 /**
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
76 * Decrement the reference count for an image in the store. The
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
77 * image will be removed from the store when the reference count
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
78 * is zero.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
79 *
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
80 * @param id The ID for the image.
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
81 */
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
82 void gaim_imgstore_unref(int id);
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
83
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
84 #ifdef __cplusplus
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
85 }
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
86 #endif
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
87
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
88 #endif /* _GAIM_CONV_IMGSTORE_H_ */