aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/qmimodem/voice_generated.c
blob: 3d26ab239720172f797ad8393aad65ea4deb19fe (plain)
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

#include <stdint.h>
#include <string.h>
#include <glib.h>

#include "voice_generated.h"

int qmi_voice_dial_call(
		struct qmi_voice_dial_call_arg *arg,
		struct qmi_service *service,
		qmi_result_func_t func,
		void *user_data,
		qmi_destroy_func_t destroy)
{
	struct qmi_param *param = NULL;

	param = qmi_param_new();
	if (!param)
		goto error;

	if (arg->calling_number_set) {
		if (!qmi_param_append(param,
				 0x1,
				 strlen(arg->calling_number),
				 arg->calling_number))
			goto error;
	}

	if (arg->call_type_set)
		qmi_param_append_uint8(param, 0x10, arg->call_type);

	if (qmi_service_send(service,
			     0x20,
			     param,
			     func,
			     user_data,
			     destroy) > 0)
		return 0;
error:
	g_free(param);
	return 1;
}

enum parse_error qmi_voice_dial_call_parse(
		struct qmi_result *qmi_result,
		struct qmi_voice_dial_call_result *result)
{
	int err = NONE;

	/* mandatory */
	if (qmi_result_get_uint8(qmi_result, 0x10, &result->call_id))
		result->call_id_set = 1;
	else
		err = MISSING_MANDATORY;

	return err;
}

int qmi_voice_manage_call(
		struct qmi_voice_manage_call_arg *arg,
		struct qmi_service *service,
		qmi_result_func_t func,
		void *user_data,
		qmi_destroy_func_t destroy)
{
	struct qmi_param *param = NULL;

	param = qmi_param_new();
	if (!param)
		goto error;

	if (!qmi_param_append_uint8(
			param,
			0x1,
			arg->ss_call_type))
		goto error;

	if (arg->call_id_set) {
		if (!qmi_param_append_uint8(
					param,
					0x10,
					arg->call_id))
			goto error;
	}

	if (qmi_service_send(service,
			     0x31,
			     param,
			     func,
			     user_data,
			     destroy) > 0)
		return 0;
error:
	g_free(param);
	return 1;
}

enum parse_error qmi_voice_manage_call_parse(
		struct qmi_result *qmi_result,
		struct qmi_voice_manage_call_result *result)
{
	/* optional */
	if (qmi_result_get_uint16(qmi_result, 0x10, &result->failcause))
		result->failcause_set = 1;

	return NONE;
}


int qmi_voice_answer_call(
		struct qmi_voice_answer_call_arg *arg,
		struct qmi_service *service,
		qmi_result_func_t func,
		void *user_data,
		qmi_destroy_func_t destroy)
{
	struct qmi_param *param = NULL;

	param = qmi_param_new();
	if (!param)
		goto error;

	if (arg->call_id_set) {
		if (!qmi_param_append_uint8(
					param,
					0x1,
					arg->call_id))
			goto error;
	}

	if (qmi_service_send(service,
			     0x22,
			     param,
			     func,
			     user_data,
			     destroy) > 0)
		return 0;
error:
	g_free(param);
	return 1;
}


enum parse_error qmi_voice_answer_call_parse(
		struct qmi_result *qmi_result,
		struct qmi_voice_answer_call_result *result)
{
	int err = NONE;

	/* optional */
	if (qmi_result_get_uint8(qmi_result, 0x10, &result->call_id))
		result->call_id_set = 1;

	return err;
}

enum parse_error qmi_voice_ind_call_status(
		struct qmi_result *qmi_result,
		struct qmi_voice_all_call_status_ind *result)
{
	int err = NONE;
	int offset;
	uint16_t len;
	const struct qmi_voice_remote_party_number *remote_party_number;
	const struct qmi_voice_call_information *call_information;

	/* mandatory */
	call_information = qmi_result_get(qmi_result, 0x01, &len);
	if (call_information)
	{
		int instance_size = sizeof(struct qmi_voice_call_information_instance);
		/* verify the length */
		if (len < sizeof(call_information->size))
			return INVALID_LENGTH;

		if (len != call_information->size * sizeof(struct qmi_voice_call_information_instance)
			    + sizeof(call_information->size))
			return INVALID_LENGTH;
		result->call_information_set = 1;
		result->call_information = call_information;
	} else
		return MISSING_MANDATORY;

	/* mandatory */
	remote_party_number = qmi_result_get(qmi_result, 0x10, &len);
	if (remote_party_number) {
		const struct qmi_voice_remote_party_number_instance *instance;
		int instance_size = sizeof(struct qmi_voice_remote_party_number_instance);
		int i;

		/* verify the length */
		if (len < sizeof(remote_party_number->size))
			return INVALID_LENGTH;

		for (i = 0, offset = sizeof(remote_party_number->size);
		     offset <= len && i < 16 && i < remote_party_number->size; i++)
		{
			if (offset == len) {
				break;
			} else if (offset + instance_size > len) {
				return INVALID_LENGTH;
			}

			instance = (void *)remote_party_number + offset;
			result->remote_party_number[i] = instance;
			offset += sizeof(struct qmi_voice_remote_party_number_instance) + instance->number_size;
		}
		result->remote_party_number_set = 1;
		result->remote_party_number_size = remote_party_number->size;
	} else
		return MISSING_MANDATORY;

	return err;
}