mark PurpleImageClass as private
[pidgin-git.git] / libpurple / protocols / novell / nmfield.h
blobbc550b8595b47bdb5fbcc935a965f56be9524f0d
1 /*
2 * nmfield.h
4 * Copyright (c) 2004 Novell, Inc. All Rights Reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
21 #ifndef PURPLE_NOVELL_NMFIELD_H
22 #define PURPLE_NOVELL_NMFIELD_H
24 #include <glib.h>
26 typedef struct {
27 char *tag; /* Field tag */
28 guint8 method; /* Method of the field */
29 guint8 flags; /* Flags */
30 guint8 type; /* Type of value */
31 guint32 size; /* Size of value if binary */
32 guint32 value; /* Value of a numeric field */
33 gpointer ptr_value; /* Value of a string or sub array field */
34 guint32 len; /* Length of the array */
35 } NMField;
37 /* Field types */
38 #define NMFIELD_TYPE_INVALID 0
39 #define NMFIELD_TYPE_NUMBER 1
40 #define NMFIELD_TYPE_BINARY 2
41 #define NMFIELD_TYPE_BYTE 3
42 #define NMFIELD_TYPE_UBYTE 4
43 #define NMFIELD_TYPE_WORD 5
44 #define NMFIELD_TYPE_UWORD 6
45 #define NMFIELD_TYPE_DWORD 7
46 #define NMFIELD_TYPE_UDWORD 8
47 #define NMFIELD_TYPE_ARRAY 9
48 #define NMFIELD_TYPE_UTF8 10
49 #define NMFIELD_TYPE_BOOL 11
50 #define NMFIELD_TYPE_MV 12
51 #define NMFIELD_TYPE_DN 13
53 /* Field methods */
54 #define NMFIELD_METHOD_VALID 0
55 #define NMFIELD_METHOD_IGNORE 1
56 #define NMFIELD_METHOD_DELETE 2
57 #define NMFIELD_METHOD_DELETE_ALL 3
58 #define NMFIELD_METHOD_EQUAL 4
59 #define NMFIELD_METHOD_ADD 5
60 #define NMFIELD_METHOD_UPDATE 6
61 #define NMFIELD_METHOD_GTE 10
62 #define NMFIELD_METHOD_LTE 12
63 #define NMFIELD_METHOD_NE 14
64 #define NMFIELD_METHOD_EXIST 15
65 #define NMFIELD_METHOD_NOTEXIST 16
66 #define NMFIELD_METHOD_SEARCH 17
67 #define NMFIELD_METHOD_MATCHBEGIN 19
68 #define NMFIELD_METHOD_MATCHEND 20
69 #define NMFIELD_METHOD_NOT_ARRAY 40
70 #define NMFIELD_METHOD_OR_ARRAY 41
71 #define NMFIELD_METHOD_AND_ARRAY 42
73 /* Attribute Names (field tags) */
74 #define NM_A_IP_ADDRESS "nnmIPAddress"
75 #define NM_A_PORT "nnmPort"
76 #define NM_A_FA_FOLDER "NM_A_FA_FOLDER"
77 #define NM_A_FA_CONTACT "NM_A_FA_CONTACT"
78 #define NM_A_FA_CONVERSATION "NM_A_FA_CONVERSATION"
79 #define NM_A_FA_MESSAGE "NM_A_FA_MESSAGE"
80 #define NM_A_FA_CONTACT_LIST "NM_A_FA_CONTACT_LIST"
81 #define NM_A_FA_RESULTS "NM_A_FA_RESULTS"
82 #define NM_A_FA_INFO_DISPLAY_ARRAY "NM_A_FA_INFO_DISPLAY_ARRAY"
83 #define NM_A_FA_USER_DETAILS "NM_A_FA_USER_DETAILS"
84 #define NM_A_SZ_OBJECT_ID "NM_A_SZ_OBJECT_ID"
85 #define NM_A_SZ_PARENT_ID "NM_A_SZ_PARENT_ID"
86 #define NM_A_SZ_SEQUENCE_NUMBER "NM_A_SZ_SEQUENCE_NUMBER"
87 #define NM_A_SZ_TYPE "NM_A_SZ_TYPE"
88 #define NM_A_SZ_STATUS "NM_A_SZ_STATUS"
89 #define NM_A_SZ_STATUS_TEXT "NM_A_SZ_STATUS_TEXT"
90 #define NM_A_SZ_DN "NM_A_SZ_DN"
91 #define NM_A_SZ_DISPLAY_NAME "NM_A_SZ_DISPLAY_NAME"
92 #define NM_A_SZ_USERID "NM_A_SZ_USERID"
93 #define NM_A_SZ_CREDENTIALS "NM_A_SZ_CREDENTIALS"
94 #define NM_A_SZ_MESSAGE_BODY "NM_A_SZ_MESSAGE_BODY"
95 #define NM_A_SZ_MESSAGE_TEXT "NM_A_SZ_MESSAGE_TEXT"
96 #define NM_A_UD_MESSAGE_TYPE "NM_A_UD_MESSAGE_TYPE"
97 #define NM_A_FA_PARTICIPANTS "NM_A_FA_PARTICIPANTS"
98 #define NM_A_FA_INVITES "NM_A_FA_INVITES"
99 #define NM_A_FA_EVENT "NM_A_FA_EVENT"
100 #define NM_A_UD_COUNT "NM_A_UD_COUNT"
101 #define NM_A_UD_DATE "NM_A_UD_DATE"
102 #define NM_A_UD_EVENT "NM_A_UD_EVENT"
103 #define NM_A_B_NO_CONTACTS "NM_A_B_NO_CONTACTS"
104 #define NM_A_B_NO_CUSTOMS "NM_A_B_NO_CUSTOMS"
105 #define NM_A_B_NO_PRIVACY "NM_A_B_NO_PRIVACY"
106 #define NM_A_UW_STATUS "NM_A_UW_STATUS"
107 #define NM_A_UD_OBJECT_ID "NM_A_UD_OBJECT_ID"
108 #define NM_A_SZ_TRANSACTION_ID "NM_A_SZ_TRANSACTION_ID"
109 #define NM_A_SZ_RESULT_CODE "NM_A_SZ_RESULT_CODE"
110 #define NM_A_UD_BUILD "NM_A_UD_BUILD"
111 #define NM_A_SZ_AUTH_ATTRIBUTE "NM_A_SZ_AUTH_ATTRIBUTE"
112 #define NM_A_UD_KEEPALIVE "NM_A_UD_KEEPALIVE"
113 #define NM_A_SZ_USER_AGENT "NM_A_SZ_USER_AGENT"
114 #define NM_A_BLOCKING "nnmBlocking"
115 #define NM_A_BLOCKING_DENY_LIST "nnmBlockingDenyList"
116 #define NM_A_BLOCKING_ALLOW_LIST "nnmBlockingAllowList"
117 #define NM_A_SZ_BLOCKING_ALLOW_ITEM "NM_A_SZ_BLOCKING_ALLOW_ITEM"
118 #define NM_A_SZ_BLOCKING_DENY_ITEM "NM_A_SZ_BLOCKING_DENY_ITEM"
119 #define NM_A_LOCKED_ATTR_LIST "nnmLockedAttrList"
121 #define NM_PROTOCOL_VERSION 2
123 #define NM_FIELD_TRUE "1"
124 #define NM_FIELD_FALSE "0"
126 #define NMFIELD_MAX_STR_LENGTH 32768
129 * Count the number of fields
131 * @param fields Field array
133 * @return The number of fields in the array.
136 guint32 nm_count_fields(NMField * fields);
139 * Add a field to the field array. The field should be of type NMFIELD_TYPE_UTF8,
140 * NMFIELD_TYPE_DN, NMFIELD_TYPE_ARRAY, or NMFIELD_TYPE_MV
142 * NOTE: field array that is passed in may be realloc'd so you should use
143 * the returned field array pointer not the passed in pointer after calling
144 * this function.
146 * @param fields Field array
147 * @param tag Tag for the new field
148 * @param size Size of the field value (if type = binary)
149 * @param method Field method (see method defines above)
150 * @param flags Flags for new field
151 * @param value The value of the field
152 * @param type The type of the field value
154 * @return Pointer to the updated field array
157 NMField *nm_field_add_pointer(NMField *fields, const char *tag, guint32 size, guint8 method,
158 guint8 flags, gpointer value, guint8 type);
161 * Add a numeric field to the field array.
163 * NOTE: field array that is passed in may be realloc'd so you should use
164 * the returned field array pointer not the passed in pointer after calling
165 * this function.
167 * @param fields Field array
168 * @param tag Tag for the new field
169 * @param size Size of the field value (if type = binary)
170 * @param method Field method (see method defines above)
171 * @param flags Flags for new field
172 * @param value The value of the field
173 * @param type The type of the field value
175 * @return Pointer to the updated field array
178 NMField *nm_field_add_number(NMField *fields, const char *tag, guint32 size, guint8 method,
179 guint8 flags, guint32 value, guint8 type);
182 * Recursively free an array of fields and set pointer to NULL.
184 * @param fields Pointer to a field array
187 void nm_free_fields(NMField ** fields);
190 * Find first field with given tag in field array.
192 * Note: this will only work for 7-bit ascii tags (which is all that
193 * we use currently).
195 * @param tag Tag to search for
196 * @param fields Field array
198 * @return The first matching field, or NULL if no fields match.
201 NMField *nm_locate_field(char *tag, NMField * fields);
204 * Make a deep copy of a field array
206 * @param src The array to copy
208 * @return The new (copied) array, which must be freed.
211 NMField *nm_copy_field_array(NMField * src);
214 * Remove a field and move other fields up to fill the gap
216 * @param field The field to remove
219 void nm_remove_field(NMField * field);
221 /* Print a field array (for debugging purposes) */
222 void nm_print_fields(NMField * fields);
224 #endif /* PURPLE_NOVELL_NMFIELD_H */