File: info.c

package info (click to toggle)
linphone 5.3.105-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 57,048 kB
  • sloc: cpp: 166,867; ansic: 102,939; python: 8,280; java: 4,406; sh: 1,040; xml: 1,023; makefile: 777; perl: 377; objc: 190; php: 88; javascript: 38; cs: 38
file content (120 lines) | stat: -rw-r--r-- 4,612 bytes parent folder | download | duplicates (2)
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
/*
 * Copyright (c) 2010-2022 Belledonne Communications SARL.
 *
 * This file is part of Liblinphone
 * (see https://gitlab.linphone.org/BC/public/liblinphone).
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

/*
 *  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 2 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, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include <bctoolbox/defs.h>

#include "linphone/api/c-content.h"
#include "linphone/core.h"
#include "linphone/lpconfig.h"

#include "c-wrapper/c-wrapper.h"

struct _LinphoneInfoMessage {
	belle_sip_object_t base;
	LinphoneContent *content;
	SalCustomHeader *headers;
};

static void _linphone_info_message_uninit(LinphoneInfoMessage *im);
static void _linphone_info_message_copy(LinphoneInfoMessage *im, const LinphoneInfoMessage *orig);

BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneInfoMessage);
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneInfoMessage);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneInfoMessage,
                           belle_sip_object_t,
                           _linphone_info_message_uninit, // uninit
                           _linphone_info_message_copy,   // clone
                           NULL,                          // marshal
                           FALSE);

static void _linphone_info_message_uninit(LinphoneInfoMessage *im) {
	if (im->content) linphone_content_unref(im->content);
	if (im->headers) sal_custom_header_free(im->headers);
}

LinphoneInfoMessage *linphone_info_message_ref(LinphoneInfoMessage *im) {
	return (LinphoneInfoMessage *)belle_sip_object_ref(im);
}

void linphone_info_message_unref(LinphoneInfoMessage *im) {
	belle_sip_object_unref(im);
}

void linphone_info_message_destroy(LinphoneInfoMessage *im) {
	linphone_info_message_unref(im);
}

static void _linphone_info_message_copy(LinphoneInfoMessage *im, const LinphoneInfoMessage *orig) {
	if (orig->content) im->content = linphone_content_copy(orig->content);
	if (orig->headers) im->headers = sal_custom_header_clone(orig->headers);
}

LinphoneInfoMessage *linphone_info_message_copy(const LinphoneInfoMessage *orig) {
	return (LinphoneInfoMessage *)belle_sip_object_clone((const belle_sip_object_t *)orig);
}

LinphoneInfoMessage *linphone_core_create_info_message(BCTBX_UNUSED(LinphoneCore *lc)) {
	return belle_sip_object_new(LinphoneInfoMessage);
}

void linphone_info_message_add_header(LinphoneInfoMessage *im, const char *name, const char *value) {
	im->headers = sal_custom_header_append(im->headers, name, value);
}

const char *linphone_info_message_get_header(const LinphoneInfoMessage *im, const char *name) {
	return sal_custom_header_find(im->headers, name);
}

void linphone_info_message_set_content(LinphoneInfoMessage *im, const LinphoneContent *content) {
	if (im->content) linphone_content_unref(im->content);
	if (content) im->content = linphone_content_copy(content);
}

const LinphoneContent *linphone_info_message_get_content(const LinphoneInfoMessage *im) {
	return (im->content && linphone_content_get_type(im->content)) ? im->content : NULL;
}

SalCustomHeader *linphone_info_message_get_headers(const LinphoneInfoMessage *im) {
	return im->headers;
}

void linphone_info_message_set_headers(LinphoneInfoMessage *im, const SalCustomHeader *headers) {
	if (im->headers) {
		sal_custom_header_free(im->headers);
		im->headers = nullptr;
	}
	if (headers) im->headers = sal_custom_header_clone(headers);
}