chenqiyang
2022-09-02 6a99d9bf65aa5878cb409945ed2bdbdcb916d047
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/*
 * Copyright (c) 2010-2019 Belledonne Communications SARL.
 *
 * This file is part of Liblinphone.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
 
#ifndef _L_C_CONTENT_H_
#define _L_C_CONTENT_H_
 
#include "linphone/api/c-types.h"
 
// =============================================================================
 
#ifdef __cplusplus
    extern "C" {
#endif // ifdef __cplusplus
 
/**
 * @addtogroup misc
 * @{
 */
 
/**
 * Acquire a reference to the content.
 * @param content #LinphoneContent object. @notnil
 * @return The same #LinphoneContent object. @notnil
**/
LINPHONE_PUBLIC LinphoneContent *linphone_content_ref (LinphoneContent *content);
 
/**
 * Release reference to the content.
 * @param content #LinphoneContent object. @notnil
**/
LINPHONE_PUBLIC void linphone_content_unref (LinphoneContent *content);
 
/**
 * Retrieve the user pointer associated with the content.
 * @param content #LinphoneContent object. @notnil
 * @return The user pointer associated with the content. @maybenil
**/
LINPHONE_PUBLIC void *linphone_content_get_user_data (const LinphoneContent *content);
 
/**
 * Assign a user pointer to the content.
 * @param content #LinphoneContent object. @notnil
 * @param user_data The user pointer to associate with the content. @maybenil
**/
LINPHONE_PUBLIC void linphone_content_set_user_data (LinphoneContent *content, void *user_data);
 
/**
 * Get the mime type of the content data.
 * @param content #LinphoneContent object. @notnil
 * @return The mime type of the content data, for example "application". @notnil
 */
LINPHONE_PUBLIC const char *linphone_content_get_type (const LinphoneContent *content);
 
/**
 * Set the mime type of the content data.
 * @param content #LinphoneContent object. @notnil
 * @param type The mime type of the content data, for example "application". @notnil
 */
LINPHONE_PUBLIC void linphone_content_set_type (LinphoneContent *content, const char *type);
 
/**
 * Get the mime subtype of the content data.
 * @param content #LinphoneContent object. @notnil
 * @return The mime subtype of the content data, for example "html". @notnil
 */
LINPHONE_PUBLIC const char *linphone_content_get_subtype (const LinphoneContent *content);
 
/**
 * Set the mime subtype of the content data.
 * @param content #LinphoneContent object. @notnil
 * @param subtype The mime subtype of the content data, for example "html". @notnil
 */
LINPHONE_PUBLIC void linphone_content_set_subtype (LinphoneContent *content, const char *subtype);
 
/**
 * Adds a parameter to the ContentType header.
 * @param content #LinphoneContent object. @notnil
 * @param name the name of the parameter to add. @notnil
 * @param value the value of the parameter to add. @maybenil
 */
LINPHONE_PUBLIC void linphone_content_add_content_type_parameter (
    LinphoneContent *content,
    const char *name,
    const char *value
);
 
/**
 * Get the content data buffer, usually a string.
 * @param content #LinphoneContent object. @notnil
 * @return The content data buffer. @notnil
 */
LINPHONE_PUBLIC const uint8_t *linphone_content_get_buffer (const LinphoneContent *content);
 
/**
 * Set the content data buffer, usually a string.
 * @param content #LinphoneContent object. @notnil
 * @param buffer The content data buffer. @notnil
 * @param size The size of the content data buffer.
 */
LINPHONE_PUBLIC void linphone_content_set_buffer (LinphoneContent *content, const uint8_t *buffer, size_t size);
 
/**
 * Get the string content data buffer. Introduced in 01/07/2020
 * @param content #LinphoneContent object. @notnil
 * @return The string content data buffer in UTF8. @maybenil
 */
LINPHONE_PUBLIC const char *linphone_content_get_utf8_text(const LinphoneContent *content);
 
/**
 * Get the string content data buffer. Introduced in 01/07/2020
 * @param content #LinphoneContent object. @notnil
 * @param buffer The string content data buffer in UTF8. @maybenil
 */
LINPHONE_PUBLIC void linphone_content_set_utf8_text (LinphoneContent *content, const char *buffer);
 
/**
 * Get the content data buffer size, excluding null character despite null character is always set for convenience.
 * @param content #LinphoneContent object. @notnil
 * @return The content data buffer size.
 */
LINPHONE_PUBLIC size_t linphone_content_get_size (const LinphoneContent *content);
 
/**
 * Get the file size if content is either a FileContent or a FileTransferContent.
 * @param content #LinphoneContent object. @notnil
 * @return The represented file size.
 */
LINPHONE_PUBLIC size_t linphone_content_get_file_size(const LinphoneContent *content);
 
/**
 * Set the content data size, excluding null character despite null character is always set for convenience.
 * @param content #LinphoneContent object @notnil
 * @param size The content data buffer size.
 */
LINPHONE_PUBLIC void linphone_content_set_size (LinphoneContent *content, size_t size);
 
/**
 * Get the encoding of the data buffer, for example "gzip".
 * @param content #LinphoneContent object. @notnil
 * @return The encoding of the data buffer. @maybenil
 */
LINPHONE_PUBLIC const char *linphone_content_get_encoding (const LinphoneContent *content);
 
/**
 * Set the encoding of the data buffer, for example "gzip".
 * @param content #LinphoneContent object. @notnil
 * @param encoding The encoding of the data buffer. @maybenil
 */
LINPHONE_PUBLIC void linphone_content_set_encoding (LinphoneContent *content, const char *encoding);
 
/**
 * Get the name associated with a RCS file transfer message. It is used to store the original filename of the file to be downloaded from server.
 * @param content #LinphoneContent object. @notnil
 * @return The name of the content. @maybenil
 */
LINPHONE_PUBLIC const char *linphone_content_get_name (const LinphoneContent *content);
 
/**
 * Set the name associated with a RCS file transfer message. It is used to store the original filename of the file to be downloaded from server.
 * @param content #LinphoneContent object. @notnil
 * @param name The name of the content. @maybenil
 */
LINPHONE_PUBLIC void linphone_content_set_name (LinphoneContent *content, const char *name);
 
/**
 * Tell whether a content is a multipart content.
 * @param content #LinphoneContent object. @notnil
 * @return A boolean value telling whether the content is multipart or not.
 */
LINPHONE_PUBLIC bool_t linphone_content_is_multipart (const LinphoneContent *content);
 
/**
 * Get all the parts from a multipart content.
 * @param content #LinphoneContent object. @notnil
 * @return A \bctbx_list{LinphoneContent} object holding the part if found, NULL otherwise. @tobefreed @maybenil
 */
LINPHONE_PUBLIC bctbx_list_t *linphone_content_get_parts (const LinphoneContent *content);
 
/**
 * Get a part from a multipart content according to its index.
 * @param content #LinphoneContent object. @notnil
 * @param index The index of the part to get.
 * @return A #LinphoneContent object holding the part if found, NULL otherwise. @maybenil
 */
LINPHONE_PUBLIC LinphoneContent *linphone_content_get_part (const LinphoneContent *content, int index);
 
/**
 * Find a part from a multipart content looking for a part header with a specified value.
 * @param content #LinphoneContent object. @notnil
 * @param header_name The name of the header to look for. @notnil
 * @param header_value The value of the header to look for. @notnil
 * @return A #LinphoneContent object object the part if found, NULL otherwise. @maybenil
 */
LINPHONE_PUBLIC LinphoneContent *linphone_content_find_part_by_header (
    const LinphoneContent *content,
    const char *header_name,
    const char *header_value
);
 
/**
 * Get a custom header value of a content.
 * @param content #LinphoneContent object. @notnil
 * @param header_name The name of the header to get the value from. @notnil
 * @return The value of the header if found, NULL otherwise. @maybenil
 */
LINPHONE_PUBLIC const char *linphone_content_get_custom_header (const LinphoneContent *content, const char *header_name);
 
/**
 * Get the key associated with a RCS file transfer message if encrypted
 * @param content #LinphoneContent object. @notnil
 * @return The key to encrypt/decrypt the file associated to this content. @maybenil
 */
LINPHONE_PUBLIC const char *linphone_content_get_key (const LinphoneContent *content);
 
/**
 * Get the size of key associated with a RCS file transfer message if encrypted
 * @param content #LinphoneContent object. @notnil
 * @return The key size in bytes
 */
LINPHONE_PUBLIC size_t linphone_content_get_key_size (const LinphoneContent *content);
 
/**
 * Set the key associated with a RCS file transfer message if encrypted
 * @param content #LinphoneContent object. @notnil
 * @param key The key to be used to encrypt/decrypt file associated to this content. @notnil
 * @param key_length The lengh of the key.
 */
LINPHONE_PUBLIC void linphone_content_set_key (LinphoneContent *content, const char *key, const size_t key_length);
 
/**
 * Get the file transfer filepath set for this content (replace linphone_chat_message_get_file_transfer_filepath).
 * @param content #LinphoneContent object. @notnil
 * @return The file path set for this content if it has been set, NULL otherwise. @maybenil
 */
LINPHONE_PUBLIC const char *linphone_content_get_file_path (const LinphoneContent *content);
 
/**
 * If the content is an encrypted file, generate a temporary plain copy of the file and returns its paths
 * The caller is responsible to then delete this temporary copy and the returned string
 * @param[in] content #LinphoneContent object.
 * @return The file path set for this content if it has been set, NULL otherwise.
 */
LINPHONE_PUBLIC char *linphone_content_get_plain_file_path (const LinphoneContent *content);
 
/**
 * Set the file transfer filepath for this content (replace linphone_chat_message_set_file_transfer_filepath).
 * @param content #LinphoneContent object. @notnil
 * @param file_path the file transfer filepath. @maybenil
 */
LINPHONE_PUBLIC void linphone_content_set_file_path (LinphoneContent *content, const char *file_path);
 
/**
 * Tells whether or not this content contains text.
 * @param content #LinphoneContent object. @notnil
 * @return TRUE if this content contains plain text, FALSE otherwise.
 */
LINPHONE_PUBLIC bool_t linphone_content_is_text (const LinphoneContent *content);
 
/**
 * Tells whether or not this content contains a file.
 * @param content #LinphoneContent object. @notnil
 * @return TRUE if this content contains a file, FALSE otherwise.
 */
LINPHONE_PUBLIC bool_t linphone_content_is_file (const LinphoneContent *content);
 
/**
 * Tells whether or not this content is a file transfer.
 * @param content #LinphoneContent object. @notnil
 * @return TRUE if this content is a file transfer, FALSE otherwise.
 */
LINPHONE_PUBLIC bool_t linphone_content_is_file_transfer (const LinphoneContent *content);
 
/************ */
/* DEPRECATED */
/* ********** */
 
/**
 * Get the string content data buffer.
 * @param content #LinphoneContent object @notnil
 * @return The string content data buffer. @notnil
 * @deprecated 2020-07-01. Use linphone_content_get_utf8_text() instead.
 */
LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_content_get_string_buffer (const LinphoneContent *content);
 
/**
 * Set the string content data buffer.
 * @param content #LinphoneContent object. @notnil
 * @param buffer The string content data buffer in UTF8. @notnil
 * @deprecated 2020-07-01. Use linphone_content_set_utf8_text() instead.
 */
LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_content_set_string_buffer (LinphoneContent *content, const char *buffer);
 
/**
 * Tells whether or not this content contains an encrypted file
 * @return True is this content contains a file and this file is encrypted, false otherwise.
 */
LINPHONE_PUBLIC bool_t linphone_content_is_file_encrypted (const LinphoneContent *content);
 
/**
 * @}
 */
 
#ifdef __cplusplus
    }
#endif // ifdef __cplusplus
 
#endif // ifndef _L_C_CONTENT_H_