3 * oFono - Open Source Telephony
5 * Copyright (C) 2011-2012 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <ofono/log.h>
27 #include <ofono/modem.h>
28 #include <ofono/ussd.h>
35 struct qmi_service *voice;
40 static void create_voice_cb(struct qmi_service *service, void *user_data)
42 struct ofono_ussd *ussd = user_data;
43 struct ussd_data *data = ofono_ussd_get_data(ussd);
48 ofono_error("Failed to request Voice service");
49 ofono_ussd_remove(ussd);
53 if (!qmi_service_get_version(service, &data->major, &data->minor)) {
54 ofono_error("Failed to get Voice service version");
55 ofono_ussd_remove(ussd);
59 data->voice = qmi_service_ref(service);
61 ofono_ussd_register(ussd);
64 static int qmi_ussd_probe(struct ofono_ussd *ussd,
65 unsigned int vendor, void *user_data)
67 struct qmi_device *device = user_data;
68 struct ussd_data *data;
72 data = g_new0(struct ussd_data, 1);
74 ofono_ussd_set_data(ussd, data);
76 qmi_service_create_shared(device, QMI_SERVICE_VOICE,
77 create_voice_cb, ussd, NULL);
83 static void qmi_ussd_remove(struct ofono_ussd *ussd)
85 struct ussd_data *data = ofono_ussd_get_data(ussd);
89 ofono_ussd_set_data(ussd, NULL);
91 qmi_service_unref(data->voice);
96 static struct ofono_ussd_driver driver = {
98 .probe = qmi_ussd_probe,
99 .remove = qmi_ussd_remove,
102 void qmi_ussd_init(void)
104 ofono_ussd_driver_register(&driver);
107 void qmi_ussd_exit(void)
109 ofono_ussd_driver_unregister(&driver);