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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
/*
 * 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_ADDRESS_H_
#define _L_C_ADDRESS_H_
 
#include "linphone/api/c-types.h"
 
// =============================================================================
 
#ifdef __cplusplus
    extern "C" {
#endif // ifdef __cplusplus
 
/**
 * @addtogroup linphone_address
 * @{
 */
 
/**
 * Constructs a #LinphoneAddress object by parsing the user supplied address,
 * given as a string.
 * @param address an address to parse. @notnil
 * @return a LinphoneAddress if parsing is successful, NULL otherwise. @maybenil
 **/
LINPHONE_PUBLIC LinphoneAddress *linphone_address_new (const char *address);
 
/**
 * Clones a #LinphoneAddress object.
 * @param address a #LinphoneAddress object to clone. @notnil
 * @return a new #LinphoneAddress object. @notnil
 **/
LINPHONE_PUBLIC LinphoneAddress *linphone_address_clone (const LinphoneAddress *address);
 
/**
 * Increment reference count of #LinphoneAddress object.
 * @param address a #LinphoneAddress object. @notnil
 * @return the same #LinphoneAddress object. @notnil
 **/
LINPHONE_PUBLIC LinphoneAddress *linphone_address_ref (LinphoneAddress *address);
 
/**
 * Decrement reference count of #LinphoneAddress object. When dropped to zero, memory is freed.
 * @param address a #LinphoneAddress object. @notnil
 **/
LINPHONE_PUBLIC void linphone_address_unref (LinphoneAddress *address);
 
/**
 * Returns the address scheme, normally "sip".
 * @param address a #LinphoneAddress object. @notnil
 * @return the scheme if any, NULL otherwise. @maybenil
 **/
LINPHONE_PUBLIC const char *linphone_address_get_scheme (const LinphoneAddress *address);
 
/**
 * Returns the display name.
 * @param address a #LinphoneAddress object. @notnil
 * @return the display name if any, NULL otherwise. @maybenil
 **/
LINPHONE_PUBLIC const char *linphone_address_get_display_name (const LinphoneAddress *address);
 
/**
 * Sets the display name.
 * @param address a #LinphoneAddress object. @notnil
 * @param display_name the display name to set. @maybenil
 **/
LINPHONE_PUBLIC LinphoneStatus linphone_address_set_display_name (LinphoneAddress *address, const char *display_name);
 
/**
 * Returns the username.
 * @param address a #LinphoneAddress object. @notnil
 * @return the username name if any, NULL otherwise. @maybenil
 **/
LINPHONE_PUBLIC const char *linphone_address_get_username (const LinphoneAddress *address);
 
/**
 * Sets the username.
 * @param address a #LinphoneAddress object. @notnil
 * @param username the username to set. @maybenil
 **/
LINPHONE_PUBLIC LinphoneStatus linphone_address_set_username (LinphoneAddress *address, const char *username);
 
/**
 * Returns the domain name.
 * @param address a #LinphoneAddress object. @notnil
 * @return the domain name if any, NULL otherwise. @maybenil
 **/
LINPHONE_PUBLIC const char *linphone_address_get_domain (const LinphoneAddress *address);
 
/**
 * Sets the domain.
 * @param address a #LinphoneAddress object. @notnil
 * @param domain the domain to set. @maybenil
 **/
LINPHONE_PUBLIC LinphoneStatus linphone_address_set_domain (LinphoneAddress *address, const char *domain);
 
/**
 * Get port number as an integer value, 0 if not present.
 * @param address a #LinphoneAddress object. @notnil
 * @return the port set in the address or 0 if not present.
 */
LINPHONE_PUBLIC int linphone_address_get_port (const LinphoneAddress *address);
 
/**
 * Sets the port number.
 * @param address a #LinphoneAddress object. @notnil
 * @param port the port to set in the address
 **/
LINPHONE_PUBLIC LinphoneStatus linphone_address_set_port (LinphoneAddress *address, int port);
 
/**
 * Get the transport.
 * @param address a #LinphoneAddress object. @notnil
 * @return a #LinphoneTransportType, default value if not set is UDP.
 **/
LINPHONE_PUBLIC LinphoneTransportType linphone_address_get_transport (const LinphoneAddress *address);
 
/**
 * Set a transport.
 * @param address a #LinphoneAddress object. @notnil
 * @param transport a #LinphoneTransportType
 **/
LINPHONE_PUBLIC LinphoneStatus linphone_address_set_transport (LinphoneAddress *address, LinphoneTransportType transport);
 
/**
 * Returns whether the address refers to a secure location (sips) or not
 * @param address a #LinphoneAddress object. @notnil
 * @return TRUE if address refers to a secure location, FALSE otherwise
 **/
LINPHONE_PUBLIC bool_t linphone_address_get_secure (const LinphoneAddress *address);
 
/**
 * Make the address refer to a secure location (sips scheme)
 * @param address A #LinphoneAddress object. @notnil
 * @param enabled TRUE if address is requested to be secure.
 **/
LINPHONE_PUBLIC void linphone_address_set_secure (LinphoneAddress *address, bool_t enabled);
 
/**
 * returns whether the address is a routable SIP address or not
 * @param address a #LinphoneAddress object. @notnil
 * @return TRUE if it is a routable SIP address, FALSE otherwise
 */
LINPHONE_PUBLIC bool_t linphone_address_is_sip (const LinphoneAddress *address);
 
/**
 * Get the value of the method parameter
 * @param address a #LinphoneAddress object. @notnil
 * @return the value of the parameter or NULL. @maybenil
 **/
LINPHONE_PUBLIC const char *linphone_address_get_method_param (const LinphoneAddress *address);
 
/**
 * Set the value of the method parameter
 * @param address a #LinphoneAddress object. @notnil
 * @param method_param the value to set to the method parameter. @maybenil
 **/
LINPHONE_PUBLIC void linphone_address_set_method_param (LinphoneAddress *address, const char *method_param);
 
/**
 * Get the password encoded in the address.
 * It is used for basic authentication (not recommended).
 * @param address a #LinphoneAddress object. @notnil
 * @return the password if any, NULL otherwise. @maybenil
 **/
LINPHONE_PUBLIC const char *linphone_address_get_password (const LinphoneAddress *address);
 
/**
 * Set the password encoded in the address.
 * It is used for basic authentication (not recommended).
 * @param address a #LinphoneAddress object. @notnil
 * @param password the password to set. @maybenil
 **/
LINPHONE_PUBLIC void linphone_address_set_password (LinphoneAddress *address, const char *password);
 
/**
 * Removes address's tags and uri headers so that it is displayable to the user.
 * @param address a #LinphoneAddress object. @notnil
 **/
LINPHONE_PUBLIC void linphone_address_clean (LinphoneAddress *address);
 
/**
 * Returns the address as a string.
 * The returned char * must be freed by the application. Use ms_free().
 * @param address a #LinphoneAddress object. @notnil
 * @return a string representation of the address. @notnil
 **/
LINPHONE_PUBLIC char *linphone_address_as_string (const LinphoneAddress *address);
 
/**
 * Returns the SIP uri only as a string, that is display name is removed.
 * The returned char * must be freed by the application. Use ms_free().
 * @param address a #LinphoneAddress object. @notnil
 * @return a string representation of the address. @notnil
 **/
LINPHONE_PUBLIC char *linphone_address_as_string_uri_only (const LinphoneAddress *address);
 
/**
 * Compare two #LinphoneAddress ignoring tags and headers, basically just domain, username, and port.
 * @param address1 #LinphoneAddress object. @notnil
 * @param address2 #LinphoneAddress object. @notnil
 * @return Boolean value telling if the #LinphoneAddress objects are equal.
 * @see linphone_address_equal()
 **/
LINPHONE_PUBLIC bool_t linphone_address_weak_equal (const LinphoneAddress *address1, const LinphoneAddress *address2);
 
/**
 * Compare two #LinphoneAddress taking the tags and headers into account.
 * @param address1 #LinphoneAddress object. @notnil
 * @param address2 #LinphoneAddress object. @notnil
 * @return Boolean value telling if the #LinphoneAddress objects are equal.
 * @see linphone_address_weak_equal()
 */
LINPHONE_PUBLIC bool_t linphone_address_equal (const LinphoneAddress *address1, const LinphoneAddress *address2);
 
/**
 * Get the header encoded in the address.
 * @param address a #LinphoneAddress object. @notnil
 * @param header_name the header name. @notnil
 * @return the header value or NULL if it doesn't exists. @maybenil
**/
LINPHONE_PUBLIC const char *linphone_address_get_header (const LinphoneAddress *address, const char *header_name);
 
/**
 * Set a header into the address.
 * Headers appear in the URI with '?', such as \<sip:test@linphone.org?SomeHeader=SomeValue\>.
 * @param address a #LinphoneAddress object. @notnil
 * @param header_name the header name. @notnil
 * @param header_value the header value. @maybenil
 **/
LINPHONE_PUBLIC void linphone_address_set_header (LinphoneAddress *address, const char *header_name, const char *header_value);
 
/**
 * Tell whether a parameter is present in the address
 * @param address a #LinphoneAddress object. @notnil
 * @param param_name The name of the parameter. @notnil
 * @return A boolean value telling whether the parameter is present in the address
 */
LINPHONE_PUBLIC bool_t linphone_address_has_param (const LinphoneAddress *address, const char *param_name);
 
/**
 * Get the value of a parameter of the address
 * @param address a #LinphoneAddress object. @notnil
 * @param param_name The name of the parameter. @notnil
 * @return The value of the parameter or NULL if it doesn't exists. @maybenil
 */
LINPHONE_PUBLIC const char *linphone_address_get_param (const LinphoneAddress *address, const char *param_name);
 
/**
 * Set the value of a parameter of the address
 * @param address a #LinphoneAddress object. @notnil
 * @param param_name The name of the parameter. @notnil
 * @param param_value The new value of the parameter. @maybenil
 */
LINPHONE_PUBLIC void linphone_address_set_param (LinphoneAddress *address, const char *param_name, const char *param_value);
 
LINPHONE_PUBLIC void linphone_address_set_params (LinphoneAddress *address, const char *params);
 
/**
 * Tell whether a parameter is present in the URI of the address
 * @param address a #LinphoneAddress object. @notnil
 * @param uri_param_name The name of the parameter. @notnil
 * @return A boolean value telling whether the parameter is present in the URI of the address
 */
LINPHONE_PUBLIC bool_t linphone_address_has_uri_param (const LinphoneAddress *address, const char *uri_param_name);
 
/**
 * Get the value of a parameter of the URI of the address
 * @param address a #LinphoneAddress object. @notnil
 * @param uri_param_name The name of the parameter. @notnil
 * @return The value of the parameter or NULL if it doesn't exists. @maybenil
 */
LINPHONE_PUBLIC const char *linphone_address_get_uri_param (const LinphoneAddress *address, const char *uri_param_name);
 
/**
 * Set the value of a parameter of the URI of the address
 * @param address a #LinphoneAddress object. @notnil
 * @param uri_param_name The name of the parameter. @notnil
 * @param uri_param_value The new value of the parameter. @maybenil
 */
LINPHONE_PUBLIC void linphone_address_set_uri_param (LinphoneAddress *address, const char *uri_param_name, const char *uri_param_value);
 
/**
 * Set the value of the parameters of the URI of the address
 * @param[in] address #LinphoneAddress object
 * @param[in] params The parameters string
 */
LINPHONE_PUBLIC void linphone_address_set_uri_params (LinphoneAddress *address, const char *params);
 
/**
 * Removes the value of a parameter of the URI of the address
 * @param address a #LinphoneAddress object. @notnil
 * @param uri_param_name The name of the parameter. @notnil
 */
LINPHONE_PUBLIC void linphone_address_remove_uri_param (LinphoneAddress *address, const char *uri_param_name);
 
/************ */
/* DEPRECATED */
/* ********** */
 
/**
 * Destroys a #LinphoneAddress object (actually calls linphone_address_unref()).
 * @deprecated 04/09/17 Use linphone_address_unref() instead
 * @donotwrap
 **/
LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_address_destroy (LinphoneAddress *address);
 
/**
 * Returns true if address refers to a secure location (sips)
 * @deprecated 04/09/17 use linphone_address_get_secure()
 * @donotwrap
 **/
LINPHONE_DEPRECATED LINPHONE_PUBLIC bool_t linphone_address_is_secure (const LinphoneAddress *address);
 
/**
 * @}
 */
 
#ifdef __cplusplus
    }
#endif // ifdef __cplusplus
 
#endif // ifndef _L_C_ADDRESS_H_