src/gaim_buffer.h

Tue, 14 Mar 2006 06:15:31 +0000

author
Richard Laager <rlaager@pidgin.im>
date
Tue, 14 Mar 2006 06:15:31 +0000
changeset 13506
056604f3537f
parent 13233
1a55c46f0a24
permissions
-rw-r--r--

[gaim-migrate @ 15881]
On Mon, 2006-03-13 at 15:10 -0500, Adil wrote:
> Would it be `better' to not print an error message for the event
> (because it is possible to have a chat-window for a disconnected
> account), and popup a menu with disabled entries instead?

This commit implements that. I've also removed some code duplication by having create_chat_menu() look up the prpl_info from the gc.

Also, I think we should grey out the Send File menu item when a particular user doesn't have the ability to receive files, rather than not show it. It's more consistent with what we do elsewhere. I've made that change as well.

13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
1 /*
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
2 * @file gaim_buffer.h Buffer Utility Functions
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
3 * @ingroup core
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
4 *
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
5 * Gaim is the legal property of its developers, whose names are too numerous
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
7 * source distribution.
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
8 *
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
12 * (at your option) any later version.
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
13 *
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
17 * GNU General Public License for more details.
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
18 *
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
22 */
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
23 #ifndef _GAIM_BUFFER_H
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
24 #define _GAIM_BUFFER_H
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
25
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
26 #ifdef __cplusplus
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
27 extern "C" {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
28 #endif
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
29
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
30 typedef struct _GaimCircBuffer {
13230
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
31
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
32 /** A pointer to the starting address of our chunk of memory. */
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
33 gchar *buffer;
13230
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
34
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
35 /** The incremental amount to increase this buffer by when
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
36 * the buffer is not big enough to hold incoming data, in bytes. */
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
37 gsize growsize;
13230
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
38
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
39 /** The length of this buffer, in bytes. */
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
40 gsize buflen;
13230
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
41
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
42 /** The number of bytes of this buffer that contain unread data. */
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
43 gsize bufused;
13230
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
44
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
45 /** A pointer to the next byte where new incoming data is
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
46 * buffered to. */
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
47 gchar *inptr;
13230
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
48
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
49 /** A pointer to the next byte of buffered data that should be
13233
1a55c46f0a24 [gaim-migrate @ 15597]
Mark Doliner <markdoliner@pidgin.im>
parents: 13230
diff changeset
50 * read by the consumer. */
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
51 gchar *outptr;
13230
44b216532ea2 [gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents: 13213
diff changeset
52
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
53 } GaimCircBuffer;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
54
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
55 /**
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
56 * Creates a new circular buffer. This will not allocate any memory for the
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
57 * actual buffer until data is appended to it.
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
58 *
13213
8dcf2385a862 [gaim-migrate @ 15576]
Mark Doliner <markdoliner@pidgin.im>
parents: 13201
diff changeset
59 * @param growsize The amount that the buffer should grow the first time data
8dcf2385a862 [gaim-migrate @ 15576]
Mark Doliner <markdoliner@pidgin.im>
parents: 13201
diff changeset
60 * is appended and every time more space is needed. Pass in
8dcf2385a862 [gaim-migrate @ 15576]
Mark Doliner <markdoliner@pidgin.im>
parents: 13201
diff changeset
61 * "0" to use the default of 256 bytes.
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
62 *
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
63 * @return The new GaimCircBuffer. This should be freed with
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
64 * gaim_circ_buffer_destroy when you are done with it
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
65 */
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
66 GaimCircBuffer *gaim_circ_buffer_new(gsize growsize);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
67
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
68 /**
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
69 * Dispose of the GaimCircBuffer and free any memory used by it (including any
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
70 * memory used by the internal buffer).
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
71 *
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
72 * @param buf The GaimCircBuffer to free
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
73 */
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
74 void gaim_circ_buffer_destroy(GaimCircBuffer *buf);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
75
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
76 /**
13213
8dcf2385a862 [gaim-migrate @ 15576]
Mark Doliner <markdoliner@pidgin.im>
parents: 13201
diff changeset
77 * Append data to the GaimCircBuffer. This will grow the internal
8dcf2385a862 [gaim-migrate @ 15576]
Mark Doliner <markdoliner@pidgin.im>
parents: 13201
diff changeset
78 * buffer to fit the added data, if needed.
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
79 *
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
80 * @param buf The GaimCircBuffer to which to append the data
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
81 * @param src pointer to the data to copy into the buffer
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
82 * @param len number of bytes to copy into the buffer
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
83 */
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
84 void gaim_circ_buffer_append(GaimCircBuffer *buf, gconstpointer src, gsize len);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
85
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
86 /**
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
87 * Determine the maximum number of contiguous bytes that can be read from the
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
88 * GaimCircBuffer.
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
89 * Note: This may not be the total number of bytes that are buffered - a
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
90 * subsequent call after calling gaim_circ_buffer_mark_read() may indicate more
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
91 * data is available to read.
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
92 *
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
93 * @param buf the GaimCircBuffer for which to determine the maximum contiguous
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
94 * bytes that can be read.
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
95 *
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
96 * @return the number of bytes that can be read from the GaimCircBuffer
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
97 */
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
98 gsize gaim_circ_buffer_get_max_read(GaimCircBuffer *buf);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
99
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
100 /**
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
101 * Mark the number of bytes that have been read from the buffer.
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
102 *
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
103 * @param buf The GaimCircBuffer to mark bytes read from
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
104 * @param len The number of bytes to mark as read
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
105 *
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
106 * @return TRUE if we successfully marked the bytes as having been read, FALSE
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
107 * otherwise.
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
108 */
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
109 gboolean gaim_circ_buffer_mark_read(GaimCircBuffer *buf, gsize len);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
110
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
111 #ifdef __cplusplus
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
112 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
113 #endif
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
114
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
115 #endif /* _GAIM_BUFFER_H */

mercurial