1 /* 2 content.h 3 Copyright (C) 2010-2014 Belledonne Communications SARL 4 5 This program is free software; you can redistribute it and/or 6 modify it under the terms of the GNU General Public License 7 as published by the Free Software Foundation; either version 2 8 of the License, or (at your option) any later version. 9 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. 14 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 02110-1301, USA. 18 */ 19 20 #ifndef LINPHONE_CONTENT_H_ 21 #define LINPHONE_CONTENT_H_ 22 23 24 #include "linphone/types.h" 25 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 32 /** 33 * @addtogroup misc 34 * @{ 35 */ 36 37 /** 38 * Acquire a reference to the content. 39 * @param[in] content LinphoneContent object. 40 * @return The same LinphoneContent object. 41 **/ 42 LINPHONE_PUBLIC LinphoneContent * linphone_content_ref(LinphoneContent *content); 43 44 /** 45 * Release reference to the content. 46 * @param[in] content LinphoneContent object. 47 **/ 48 LINPHONE_PUBLIC void linphone_content_unref(LinphoneContent *content); 49 50 /** 51 * Retrieve the user pointer associated with the content. 52 * @param[in] content LinphoneContent object. 53 * @return The user pointer associated with the content. 54 **/ 55 LINPHONE_PUBLIC void *linphone_content_get_user_data(const LinphoneContent *content); 56 57 /** 58 * Assign a user pointer to the content. 59 * @param[in] content LinphoneContent object. 60 * @param[in] ud The user pointer to associate with the content. 61 **/ 62 LINPHONE_PUBLIC void linphone_content_set_user_data(LinphoneContent *content, void *ud); 63 64 /** 65 * Get the mime type of the content data. 66 * @param[in] content LinphoneContent object. 67 * @return The mime type of the content data, for example "application". 68 */ 69 LINPHONE_PUBLIC const char * linphone_content_get_type(const LinphoneContent *content); 70 71 /** 72 * Set the mime type of the content data. 73 * @param[in] content LinphoneContent object. 74 * @param[in] type The mime type of the content data, for example "application". 75 */ 76 LINPHONE_PUBLIC void linphone_content_set_type(LinphoneContent *content, const char *type); 77 78 /** 79 * Get the mime subtype of the content data. 80 * @param[in] content LinphoneContent object. 81 * @return The mime subtype of the content data, for example "html". 82 */ 83 LINPHONE_PUBLIC const char * linphone_content_get_subtype(const LinphoneContent *content); 84 85 /** 86 * Set the mime subtype of the content data. 87 * @param[in] content LinphoneContent object. 88 * @param[in] subtype The mime subtype of the content data, for example "html". 89 */ 90 LINPHONE_PUBLIC void linphone_content_set_subtype(LinphoneContent *content, const char *subtype); 91 92 /** 93 * Get the content data buffer, usually a string. 94 * @param[in] content LinphoneContent object. 95 * @return The content data buffer. 96 */ 97 LINPHONE_PUBLIC void * linphone_content_get_buffer(const LinphoneContent *content); 98 99 /** 100 * Set the content data buffer, usually a string. 101 * @param[in] content LinphoneContent object. 102 * @param[in] buffer The content data buffer. 103 * @param[in] size The size of the content data buffer. 104 */ 105 LINPHONE_PUBLIC void linphone_content_set_buffer(LinphoneContent *content, const void *buffer, size_t size); 106 107 /** 108 * Get the string content data buffer. 109 * @param[in] content LinphoneContent object 110 * @return The string content data buffer. 111 */ 112 LINPHONE_PUBLIC const char * linphone_content_get_string_buffer(const LinphoneContent *content); 113 114 /** 115 * Set the string content data buffer. 116 * @param[in] content LinphoneContent object. 117 * @param[in] buffer The string content data buffer. 118 */ 119 LINPHONE_PUBLIC void linphone_content_set_string_buffer(LinphoneContent *content, const char *buffer); 120 121 /** 122 * Get the content data buffer size, excluding null character despite null character is always set for convenience. 123 * @param[in] content LinphoneContent object. 124 * @return The content data buffer size. 125 */ 126 LINPHONE_PUBLIC size_t linphone_content_get_size(const LinphoneContent *content); 127 128 /** 129 * Set the content data size, excluding null character despite null character is always set for convenience. 130 * @param[in] content LinphoneContent object 131 * @param[in] size The content data buffer size. 132 */ 133 LINPHONE_PUBLIC void linphone_content_set_size(LinphoneContent *content, size_t size); 134 135 /** 136 * Get the encoding of the data buffer, for example "gzip". 137 * @param[in] content LinphoneContent object. 138 * @return The encoding of the data buffer. 139 */ 140 LINPHONE_PUBLIC const char * linphone_content_get_encoding(const LinphoneContent *content); 141 142 /** 143 * Set the encoding of the data buffer, for example "gzip". 144 * @param[in] content LinphoneContent object. 145 * @param[in] encoding The encoding of the data buffer. 146 */ 147 LINPHONE_PUBLIC void linphone_content_set_encoding(LinphoneContent *content, const char *encoding); 148 149 /** 150 * 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. 151 * @param[in] content LinphoneContent object. 152 * @return The name of the content. 153 */ 154 LINPHONE_PUBLIC const char * linphone_content_get_name(const LinphoneContent *content); 155 156 /** 157 * 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. 158 * @param[in] content LinphoneContent object. 159 * @param[in] name The name of the content. 160 */ 161 LINPHONE_PUBLIC void linphone_content_set_name(LinphoneContent *content, const char *name); 162 163 /** 164 * Tell whether a content is a multipart content. 165 * @param[in] content LinphoneContent object. 166 * @return A boolean value telling whether the content is multipart or not. 167 */ 168 LINPHONE_PUBLIC bool_t linphone_content_is_multipart(const LinphoneContent *content); 169 170 /** 171 * Get a part from a multipart content according to its index. 172 * @param[in] content LinphoneContent object. 173 * @param[in] idx The index of the part to get. 174 * @return A LinphoneContent object holding the part if found, NULL otherwise. 175 */ 176 LINPHONE_PUBLIC LinphoneContent * linphone_content_get_part(const LinphoneContent *content, int idx); 177 178 /** 179 * Find a part from a multipart content looking for a part header with a specified value. 180 * @param[in] content LinphoneContent object. 181 * @param[in] header_name The name of the header to look for. 182 * @param[in] header_value The value of the header to look for. 183 * @return A LinphoneContent object object the part if found, NULL otherwise. 184 */ 185 LINPHONE_PUBLIC LinphoneContent * linphone_content_find_part_by_header(const LinphoneContent *content, const char *header_name, const char *header_value); 186 187 /** 188 * Get a custom header value of a content. 189 * @param[in] content LinphoneContent object. 190 * @param[in] header_name The name of the header to get the value from. 191 * @return The value of the header if found, NULL otherwise. 192 */ 193 LINPHONE_PUBLIC const char * linphone_content_get_custom_header(const LinphoneContent *content, const char *header_name); 194 195 /** 196 * @} 197 */ 198 199 200 #ifdef __cplusplus 201 } 202 #endif 203 204 #endif /* LINPHONE_CONTENT_H_ */ 205