3
* oFono - Open Source Telephony
5
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
6
* Copyright (C) 2012 Canonical Ltd.
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License version 2 as
10
* published by the Free Software Foundation.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34
#include <ofono/log.h>
35
#include <ofono/modem.h>
36
#include <ofono/call-volume.h>
51
static void volume_mute_cb(struct ril_msg *message, gpointer user_data)
53
struct cb_data *cbd = user_data;
54
ofono_call_volume_cb_t cb = cbd->cb;
55
struct ofono_error error;
59
if (message->error == RIL_E_SUCCESS) {
60
decode_ril_error(&error, "OK");
62
ofono_error("Could not set the ril mute state");
63
decode_ril_error(&error, "FAIL");
66
cb(&error, cbd->data);
69
static void ril_call_volume_mute(struct ofono_call_volume *cv, int muted,
70
ofono_call_volume_cb_t cb, void *data)
72
struct cv_data *cvd = ofono_call_volume_get_data(cv);
73
struct cb_data *cbd = cb_data_new(cb, data);
79
parcel_w_int32(&rilp, 1);
80
parcel_w_int32(&rilp, muted);
81
g_ril_send(cvd->ril, RIL_REQUEST_SET_MUTE, rilp.data,
82
rilp.size, volume_mute_cb, cbd, g_free);
88
static void probe_mute_cb(struct ril_msg *message, gpointer user_data)
90
struct ofono_call_volume *cv = user_data;
96
if (message->error != RIL_E_SUCCESS) {
97
ofono_error("Could not retrive the ril mute state");
101
/* Set up Parcel struct for proper parsing */
102
rilp.data = message->buf;
103
rilp.size = message->buf_len;
104
rilp.capacity = message->buf_len;
107
muted = parcel_r_int32(&rilp);
108
DBG("Initial ril muted state: %d", muted);
110
ofono_call_volume_set_muted(cv, muted);
113
static void call_probe_mute(gpointer user_data)
115
struct ofono_call_volume *cv = user_data;
116
struct cv_data *cvd = ofono_call_volume_get_data(cv);
118
DBG("Requesting mute from RIL");
120
g_ril_send(cvd->ril, RIL_REQUEST_GET_MUTE, NULL, 0,
121
probe_mute_cb, cv, NULL);
126
static gboolean ril_delayed_register(gpointer user_data)
128
struct ofono_call_volume *cv = user_data;
130
ofono_call_volume_register(cv);
132
/* Probe the mute state */
133
call_probe_mute(user_data);
135
/* This makes the timeout a single-shot */
139
static int ril_call_volume_probe(struct ofono_call_volume *cv,
140
unsigned int vendor, void *data)
147
cvd = g_new0(struct cv_data, 1);
151
cvd->ril = g_ril_clone(ril);
152
cvd->vendor = vendor;
154
ofono_call_volume_set_data(cv, cvd);
156
g_timeout_add_seconds(2, ril_delayed_register, cv);
161
static void ril_call_volume_remove(struct ofono_call_volume *cv)
163
struct cv_data *cvd = ofono_call_volume_get_data(cv);
165
ofono_call_volume_set_data(cv, NULL);
167
g_ril_unref(cvd->ril);
171
static struct ofono_call_volume_driver driver = {
173
.probe = ril_call_volume_probe,
174
.remove = ril_call_volume_remove,
175
.mute = ril_call_volume_mute,
178
void ril_call_volume_init(void)
180
ofono_call_volume_driver_register(&driver);
183
void ril_call_volume_exit(void)
185
ofono_call_volume_driver_unregister(&driver);