2009-05-06 04:13:14 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* oFono - Open Source Telephony
|
|
|
|
*
|
2011-10-10 20:39:42 +00:00
|
|
|
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
2009-05-06 04:13:14 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2009-05-28 18:50:25 +00:00
|
|
|
#include <stdlib.h>
|
2009-08-13 20:00:36 +00:00
|
|
|
#include <errno.h>
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <gdbus.h>
|
|
|
|
|
|
|
|
#include "ofono.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
#define CALL_SETTINGS_FLAG_CACHED 0x1
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static GSList *g_drivers = NULL;
|
|
|
|
|
2009-08-17 20:29:01 +00:00
|
|
|
/* 27.007 Section 7.7 */
|
|
|
|
enum clir_status {
|
2011-01-12 11:27:47 +00:00
|
|
|
CLIR_STATUS_NOT_PROVISIONED = 0,
|
|
|
|
CLIR_STATUS_PROVISIONED_PERMANENT = 1,
|
|
|
|
CLIR_STATUS_UNKNOWN = 2,
|
|
|
|
CLIR_STATUS_TEMPORARY_RESTRICTED = 3,
|
|
|
|
CLIR_STATUS_TEMPORARY_ALLOWED = 4
|
2009-08-17 20:29:01 +00:00
|
|
|
};
|
|
|
|
|
2009-08-17 20:30:34 +00:00
|
|
|
/* 27.007 Section 7.6 */
|
|
|
|
enum clip_status {
|
2011-01-12 11:27:47 +00:00
|
|
|
CLIP_STATUS_NOT_PROVISIONED = 0,
|
|
|
|
CLIP_STATUS_PROVISIONED = 1,
|
|
|
|
CLIP_STATUS_UNKNOWN = 2
|
2009-08-17 20:30:34 +00:00
|
|
|
};
|
|
|
|
|
2010-12-06 20:12:39 +00:00
|
|
|
/* 27.007 Section 7.30 */
|
|
|
|
enum cnap_status {
|
2011-01-12 11:27:47 +00:00
|
|
|
CNAP_STATUS_NOT_PROVISIONED = 0,
|
|
|
|
CNAP_STATUS_PROVISIONED = 1,
|
|
|
|
CNAP_STATUS_UNKNOWN = 2
|
2010-12-06 20:12:39 +00:00
|
|
|
};
|
|
|
|
|
2009-08-17 20:31:17 +00:00
|
|
|
/* 27.007 Section 7.8 */
|
|
|
|
enum colp_status {
|
2011-01-12 11:27:47 +00:00
|
|
|
COLP_STATUS_NOT_PROVISIONED = 0,
|
|
|
|
COLP_STATUS_PROVISIONED = 1,
|
|
|
|
COLP_STATUS_UNKNOWN = 2
|
2009-08-17 20:31:17 +00:00
|
|
|
};
|
|
|
|
|
2011-01-12 11:27:44 +00:00
|
|
|
/* 27.007 Section 7.9 */
|
|
|
|
enum cdip_status {
|
|
|
|
CDIP_STATUS_NOT_PROVISIONED = 0,
|
|
|
|
CDIP_STATUS_PROVISIONED = 1,
|
|
|
|
CDIP_STATUS_UNKNOWN = 2
|
|
|
|
};
|
|
|
|
|
2009-08-17 20:31:46 +00:00
|
|
|
/* This is not defined in 27.007, but presumably the same as CLIP/COLP */
|
|
|
|
enum colr_status {
|
2011-01-12 11:27:47 +00:00
|
|
|
COLR_STATUS_NOT_PROVISIONED = 0,
|
|
|
|
COLR_STATUS_PROVISIONED = 1,
|
|
|
|
COLR_STATUS_UNKNOWN = 2
|
2009-08-17 20:31:46 +00:00
|
|
|
};
|
|
|
|
|
2009-05-28 18:50:25 +00:00
|
|
|
enum call_setting_type {
|
|
|
|
CALL_SETTING_TYPE_CLIP = 0,
|
2010-12-06 20:12:39 +00:00
|
|
|
CALL_SETTING_TYPE_CNAP,
|
2011-01-12 11:27:44 +00:00
|
|
|
CALL_SETTING_TYPE_CDIP,
|
2009-05-28 18:50:25 +00:00
|
|
|
CALL_SETTING_TYPE_COLP,
|
|
|
|
CALL_SETTING_TYPE_COLR,
|
|
|
|
CALL_SETTING_TYPE_CLIR,
|
|
|
|
CALL_SETTING_TYPE_CW
|
|
|
|
};
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings {
|
2009-05-06 04:13:14 +00:00
|
|
|
int clir;
|
|
|
|
int colr;
|
|
|
|
int clip;
|
2010-12-06 20:12:39 +00:00
|
|
|
int cnap;
|
2011-01-12 11:27:44 +00:00
|
|
|
int cdip;
|
2009-05-06 04:13:14 +00:00
|
|
|
int colp;
|
|
|
|
int clir_setting;
|
2009-05-28 18:50:25 +00:00
|
|
|
int cw;
|
2009-05-06 04:13:14 +00:00
|
|
|
int flags;
|
|
|
|
DBusMessage *pending;
|
|
|
|
int ss_req_type;
|
2009-05-28 18:50:25 +00:00
|
|
|
int ss_req_cls;
|
|
|
|
enum call_setting_type ss_setting;
|
2009-08-17 19:49:43 +00:00
|
|
|
struct ofono_ussd *ussd;
|
2009-08-17 20:14:05 +00:00
|
|
|
unsigned int ussd_watch;
|
2009-08-13 20:00:36 +00:00
|
|
|
const struct ofono_call_settings_driver *driver;
|
|
|
|
void *driver_data;
|
|
|
|
struct ofono_atom *atom;
|
2009-05-06 04:13:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char *clip_status_to_string(int status)
|
|
|
|
{
|
|
|
|
switch (status) {
|
|
|
|
case CLIP_STATUS_NOT_PROVISIONED:
|
|
|
|
return "disabled";
|
|
|
|
case CLIP_STATUS_PROVISIONED:
|
|
|
|
return "enabled";
|
|
|
|
}
|
2010-12-06 20:12:37 +00:00
|
|
|
|
|
|
|
return "unknown";
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2011-01-12 11:27:44 +00:00
|
|
|
static const char *cdip_status_to_string(int status)
|
|
|
|
{
|
|
|
|
switch (status) {
|
|
|
|
case CDIP_STATUS_NOT_PROVISIONED:
|
|
|
|
return "disabled";
|
|
|
|
case CDIP_STATUS_PROVISIONED:
|
|
|
|
return "enabled";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
2010-12-06 20:12:39 +00:00
|
|
|
static const char *cnap_status_to_string(int status)
|
|
|
|
{
|
|
|
|
switch (status) {
|
|
|
|
case CNAP_STATUS_NOT_PROVISIONED:
|
|
|
|
return "disabled";
|
|
|
|
case CNAP_STATUS_PROVISIONED:
|
|
|
|
return "enabled";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
2009-05-06 04:13:14 +00:00
|
|
|
static const char *colp_status_to_string(int status)
|
|
|
|
{
|
|
|
|
switch (status) {
|
|
|
|
case COLP_STATUS_NOT_PROVISIONED:
|
|
|
|
return "disabled";
|
|
|
|
case COLP_STATUS_PROVISIONED:
|
|
|
|
return "enabled";
|
|
|
|
}
|
2010-12-06 20:12:37 +00:00
|
|
|
|
|
|
|
return "unknown";
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char *colr_status_to_string(int status)
|
|
|
|
{
|
|
|
|
switch (status) {
|
|
|
|
case COLR_STATUS_NOT_PROVISIONED:
|
|
|
|
return "disabled";
|
|
|
|
case COLR_STATUS_PROVISIONED:
|
|
|
|
return "enabled";
|
|
|
|
}
|
2010-12-06 20:12:37 +00:00
|
|
|
|
|
|
|
return "unknown";
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char *hide_callerid_to_string(int status)
|
|
|
|
{
|
|
|
|
switch (status) {
|
|
|
|
case OFONO_CLIR_OPTION_DEFAULT:
|
|
|
|
return "default";
|
|
|
|
case OFONO_CLIR_OPTION_INVOCATION:
|
|
|
|
return "enabled";
|
|
|
|
case OFONO_CLIR_OPTION_SUPPRESSION:
|
|
|
|
return "disabled";
|
|
|
|
}
|
2010-12-06 20:12:37 +00:00
|
|
|
|
|
|
|
return "default";
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char *clir_status_to_string(int status)
|
|
|
|
{
|
|
|
|
switch (status) {
|
|
|
|
case CLIR_STATUS_NOT_PROVISIONED:
|
|
|
|
return "disabled";
|
|
|
|
case CLIR_STATUS_PROVISIONED_PERMANENT:
|
|
|
|
return "permanent";
|
|
|
|
case CLIR_STATUS_TEMPORARY_RESTRICTED:
|
|
|
|
return "on";
|
|
|
|
case CLIR_STATUS_TEMPORARY_ALLOWED:
|
|
|
|
return "off";
|
|
|
|
}
|
2010-12-06 20:12:37 +00:00
|
|
|
|
|
|
|
return "unknown";
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void set_clir_network(struct ofono_call_settings *cs, int clir)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
DBusConnection *conn;
|
|
|
|
const char *path;
|
|
|
|
const char *str;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
if (cs->clir == clir)
|
|
|
|
return;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->clir = clir;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
conn = ofono_dbus_get_connection();
|
2009-08-14 20:54:52 +00:00
|
|
|
path = __ofono_atom_get_path(cs->atom);
|
2009-08-13 20:00:36 +00:00
|
|
|
|
|
|
|
str = clir_status_to_string(clir);
|
|
|
|
|
2009-08-14 21:15:09 +00:00
|
|
|
ofono_dbus_signal_property_changed(conn, path,
|
|
|
|
OFONO_CALL_SETTINGS_INTERFACE,
|
2009-08-13 20:00:36 +00:00
|
|
|
"CallingLineRestriction",
|
|
|
|
DBUS_TYPE_STRING, &str);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void set_clir_override(struct ofono_call_settings *cs, int override)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
DBusConnection *conn;
|
|
|
|
const char *path;
|
|
|
|
const char *str;
|
|
|
|
|
|
|
|
if (cs->clir_setting == override)
|
|
|
|
return;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->clir_setting = override;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
conn = ofono_dbus_get_connection();
|
2009-08-14 20:54:52 +00:00
|
|
|
path = __ofono_atom_get_path(cs->atom);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
str = hide_callerid_to_string(override);
|
|
|
|
|
2009-08-14 21:15:09 +00:00
|
|
|
ofono_dbus_signal_property_changed(conn, path,
|
|
|
|
OFONO_CALL_SETTINGS_INTERFACE,
|
2009-08-13 20:00:36 +00:00
|
|
|
"HideCallerId",
|
|
|
|
DBUS_TYPE_STRING, &str);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2011-01-12 11:27:44 +00:00
|
|
|
static void set_cdip(struct ofono_call_settings *cs, int cdip)
|
|
|
|
{
|
|
|
|
DBusConnection *conn;
|
|
|
|
const char *path;
|
|
|
|
const char *str;
|
|
|
|
|
|
|
|
if (cs->cdip == cdip)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cs->cdip = cdip;
|
|
|
|
|
|
|
|
conn = ofono_dbus_get_connection();
|
|
|
|
path = __ofono_atom_get_path(cs->atom);
|
|
|
|
|
|
|
|
str = cdip_status_to_string(cdip);
|
|
|
|
|
|
|
|
ofono_dbus_signal_property_changed(conn, path,
|
|
|
|
OFONO_CALL_SETTINGS_INTERFACE,
|
|
|
|
"CalledLinePresentation",
|
|
|
|
DBUS_TYPE_STRING, &str);
|
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void set_clip(struct ofono_call_settings *cs, int clip)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
DBusConnection *conn;
|
|
|
|
const char *path;
|
|
|
|
const char *str;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
if (cs->clip == clip)
|
|
|
|
return;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->clip = clip;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
conn = ofono_dbus_get_connection();
|
2009-08-14 20:54:52 +00:00
|
|
|
path = __ofono_atom_get_path(cs->atom);
|
2009-08-13 20:00:36 +00:00
|
|
|
|
|
|
|
str = clip_status_to_string(clip);
|
|
|
|
|
2009-08-14 21:15:09 +00:00
|
|
|
ofono_dbus_signal_property_changed(conn, path,
|
|
|
|
OFONO_CALL_SETTINGS_INTERFACE,
|
2009-08-13 20:00:36 +00:00
|
|
|
"CallingLinePresentation",
|
|
|
|
DBUS_TYPE_STRING, &str);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2010-12-06 20:12:39 +00:00
|
|
|
static void set_cnap(struct ofono_call_settings *cs, int cnap)
|
|
|
|
{
|
|
|
|
DBusConnection *conn;
|
|
|
|
const char *path;
|
|
|
|
const char *str;
|
|
|
|
|
|
|
|
if (cs->cnap == cnap)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cs->cnap = cnap;
|
|
|
|
|
|
|
|
conn = ofono_dbus_get_connection();
|
|
|
|
path = __ofono_atom_get_path(cs->atom);
|
|
|
|
|
|
|
|
str = cnap_status_to_string(cnap);
|
|
|
|
|
|
|
|
ofono_dbus_signal_property_changed(conn, path,
|
|
|
|
OFONO_CALL_SETTINGS_INTERFACE,
|
|
|
|
"CallingNamePresentation",
|
|
|
|
DBUS_TYPE_STRING, &str);
|
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void set_colp(struct ofono_call_settings *cs, int colp)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
DBusConnection *conn;
|
|
|
|
const char *path;
|
|
|
|
const char *str;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
if (cs->colp == colp)
|
|
|
|
return;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->colp = colp;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
conn = ofono_dbus_get_connection();
|
2009-08-14 20:54:52 +00:00
|
|
|
path = __ofono_atom_get_path(cs->atom);
|
2009-08-13 20:00:36 +00:00
|
|
|
|
|
|
|
str = colp_status_to_string(colp);
|
|
|
|
|
2009-08-14 21:15:09 +00:00
|
|
|
ofono_dbus_signal_property_changed(conn, path,
|
|
|
|
OFONO_CALL_SETTINGS_INTERFACE,
|
2010-12-29 02:41:00 +00:00
|
|
|
"ConnectedLinePresentation",
|
2009-08-13 20:00:36 +00:00
|
|
|
DBUS_TYPE_STRING, &str);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void set_colr(struct ofono_call_settings *cs, int colr)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
DBusConnection *conn;
|
|
|
|
const char *path;
|
|
|
|
const char *str;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
if (cs->colr == colr)
|
|
|
|
return;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->colr = colr;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
conn = ofono_dbus_get_connection();
|
2009-08-14 20:54:52 +00:00
|
|
|
path = __ofono_atom_get_path(cs->atom);
|
2009-08-13 20:00:36 +00:00
|
|
|
|
|
|
|
str = colr_status_to_string(colr);
|
|
|
|
|
2009-08-14 21:15:09 +00:00
|
|
|
ofono_dbus_signal_property_changed(conn, path,
|
|
|
|
OFONO_CALL_SETTINGS_INTERFACE,
|
2010-12-29 02:41:00 +00:00
|
|
|
"ConnectedLineRestriction",
|
2009-08-13 20:00:36 +00:00
|
|
|
DBUS_TYPE_STRING, &str);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void set_cw(struct ofono_call_settings *cs, int new_cw, int mask)
|
2009-05-28 18:50:25 +00:00
|
|
|
{
|
2009-07-28 20:56:11 +00:00
|
|
|
DBusConnection *conn = ofono_dbus_get_connection();
|
2009-08-14 20:54:52 +00:00
|
|
|
const char *path = __ofono_atom_get_path(cs->atom);
|
2009-05-28 18:50:25 +00:00
|
|
|
char buf[64];
|
|
|
|
int j;
|
|
|
|
const char *value;
|
|
|
|
|
|
|
|
for (j = 1; j <= BEARER_CLASS_PAD; j = j << 1) {
|
|
|
|
if ((j & mask) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((cs->cw & j) == (new_cw & j))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (new_cw & j)
|
|
|
|
value = "enabled";
|
|
|
|
else
|
|
|
|
value = "disabled";
|
|
|
|
|
2010-02-05 16:33:58 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%sCallWaiting",
|
|
|
|
bearer_class_to_string(j));
|
2009-08-13 20:00:36 +00:00
|
|
|
ofono_dbus_signal_property_changed(conn, path,
|
2009-08-14 21:15:09 +00:00
|
|
|
OFONO_CALL_SETTINGS_INTERFACE,
|
|
|
|
buf, DBUS_TYPE_STRING,
|
|
|
|
&value);
|
2009-05-28 18:50:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cs->cw = new_cw;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void property_append_cw_conditions(DBusMessageIter *dict,
|
|
|
|
int conditions, int mask)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char prop[128];
|
|
|
|
const char *value;
|
|
|
|
|
|
|
|
for (i = 1; i <= BEARER_CLASS_PAD; i = i << 1) {
|
|
|
|
if (!(mask & i))
|
|
|
|
continue;
|
|
|
|
|
2010-02-05 16:33:58 +00:00
|
|
|
snprintf(prop, sizeof(prop), "%sCallWaiting",
|
|
|
|
bearer_class_to_string(i));
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
if (conditions & i)
|
|
|
|
value = "enabled";
|
|
|
|
else
|
|
|
|
value = "disabled";
|
|
|
|
|
2009-07-29 15:26:55 +00:00
|
|
|
ofono_dbus_dict_append(dict, prop, DBUS_TYPE_STRING, &value);
|
2009-05-28 18:50:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void generate_cw_ss_query_reply(struct ofono_call_settings *cs)
|
2009-05-28 18:50:25 +00:00
|
|
|
{
|
|
|
|
const char *sig = "(sa{sv})";
|
|
|
|
const char *ss_type = ss_control_type_to_string(cs->ss_req_type);
|
|
|
|
const char *context = "CallWaiting";
|
|
|
|
DBusMessageIter iter;
|
|
|
|
DBusMessageIter var;
|
|
|
|
DBusMessageIter vstruct;
|
|
|
|
DBusMessageIter dict;
|
|
|
|
DBusMessage *reply;
|
|
|
|
|
|
|
|
reply = dbus_message_new_method_return(cs->pending);
|
|
|
|
|
|
|
|
dbus_message_iter_init_append(reply, &iter);
|
|
|
|
|
|
|
|
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &context);
|
|
|
|
|
|
|
|
dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, sig, &var);
|
|
|
|
|
|
|
|
dbus_message_iter_open_container(&var, DBUS_TYPE_STRUCT, NULL,
|
|
|
|
&vstruct);
|
|
|
|
|
|
|
|
dbus_message_iter_append_basic(&vstruct, DBUS_TYPE_STRING,
|
|
|
|
&ss_type);
|
|
|
|
|
|
|
|
dbus_message_iter_open_container(&vstruct, DBUS_TYPE_ARRAY,
|
2009-07-29 15:26:38 +00:00
|
|
|
OFONO_PROPERTIES_ARRAY_SIGNATURE,
|
|
|
|
&dict);
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
property_append_cw_conditions(&dict, cs->cw, cs->ss_req_cls);
|
|
|
|
|
|
|
|
dbus_message_iter_close_container(&vstruct, &dict);
|
|
|
|
|
|
|
|
dbus_message_iter_close_container(&var, &vstruct);
|
|
|
|
|
|
|
|
dbus_message_iter_close_container(&iter, &var);
|
|
|
|
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending, reply);
|
2009-05-28 18:50:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cw_ss_query_callback(const struct ofono_error *error, int status,
|
|
|
|
void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
|
2010-02-08 17:54:03 +00:00
|
|
|
DBG("setting CW via SS failed");
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
cs->flags &= ~CALL_SETTINGS_FLAG_CACHED;
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending,
|
2009-07-29 00:11:32 +00:00
|
|
|
__ofono_error_failed(cs->pending));
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
set_cw(cs, status, BEARER_CLASS_VOICE);
|
2009-05-28 18:50:25 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
generate_cw_ss_query_reply(cs);
|
2009-05-28 18:50:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cw_ss_set_callback(const struct ofono_error *error, void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
|
2012-05-30 13:53:10 +00:00
|
|
|
DBG("setting CW via SS failed with error: %s",
|
|
|
|
telephony_error_to_str(error));
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending,
|
2012-05-30 13:53:10 +00:00
|
|
|
__ofono_error_from_error(error, cs->pending));
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->cw_query(cs, BEARER_CLASS_DEFAULT,
|
|
|
|
cw_ss_query_callback, cs);
|
2009-05-28 18:50:25 +00:00
|
|
|
}
|
|
|
|
|
2009-08-17 19:49:43 +00:00
|
|
|
static gboolean cw_ss_control(int type,
|
2009-05-28 18:50:25 +00:00
|
|
|
const char *sc, const char *sia,
|
|
|
|
const char *sib, const char *sic,
|
2009-08-17 19:49:43 +00:00
|
|
|
const char *dn, DBusMessage *msg, void *data)
|
2009-05-28 18:50:25 +00:00
|
|
|
{
|
2009-08-17 19:49:43 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-07-28 20:56:11 +00:00
|
|
|
DBusConnection *conn = ofono_dbus_get_connection();
|
2009-05-28 18:50:25 +00:00
|
|
|
int cls = BEARER_CLASS_SS_DEFAULT;
|
|
|
|
DBusMessage *reply;
|
|
|
|
|
2010-11-27 19:39:03 +00:00
|
|
|
if (cs == NULL)
|
2009-05-28 18:50:25 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (strcmp(sc, "43"))
|
|
|
|
return FALSE;
|
|
|
|
|
2010-09-21 10:21:17 +00:00
|
|
|
if (__ofono_call_settings_is_busy(cs)) {
|
2009-07-29 00:11:32 +00:00
|
|
|
reply = __ofono_error_busy(msg);
|
2009-05-28 18:50:25 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(sib) || strlen(sib) || strlen(dn))
|
|
|
|
goto bad_format;
|
|
|
|
|
2010-11-27 19:39:03 +00:00
|
|
|
if ((type == SS_CONTROL_TYPE_QUERY && cs->driver->cw_query == NULL) ||
|
|
|
|
(type != SS_CONTROL_TYPE_QUERY && cs->driver->cw_set == NULL)) {
|
2009-07-29 00:11:32 +00:00
|
|
|
reply = __ofono_error_not_implemented(msg);
|
2009-05-28 18:50:25 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(sia) > 0) {
|
|
|
|
long service_code;
|
|
|
|
char *end;
|
|
|
|
|
|
|
|
service_code = strtoul(sia, &end, 10);
|
|
|
|
|
|
|
|
if (end == sia || *end != '\0')
|
|
|
|
goto bad_format;
|
|
|
|
|
|
|
|
cls = mmi_service_code_to_bearer_class(service_code);
|
|
|
|
if (cls == 0)
|
|
|
|
goto bad_format;
|
|
|
|
}
|
|
|
|
|
|
|
|
cs->ss_req_cls = cls;
|
|
|
|
cs->pending = dbus_message_ref(msg);
|
|
|
|
|
|
|
|
/* For the default case use the more readily accepted value */
|
|
|
|
if (cls == BEARER_CLASS_SS_DEFAULT)
|
|
|
|
cls = BEARER_CLASS_DEFAULT;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case SS_CONTROL_TYPE_REGISTRATION:
|
|
|
|
case SS_CONTROL_TYPE_ACTIVATION:
|
|
|
|
cs->ss_req_type = SS_CONTROL_TYPE_ACTIVATION;
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->cw_set(cs, 1, cls, cw_ss_set_callback, cs);
|
2009-05-28 18:50:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SS_CONTROL_TYPE_QUERY:
|
|
|
|
cs->ss_req_type = SS_CONTROL_TYPE_QUERY;
|
2010-09-21 19:18:15 +00:00
|
|
|
/*
|
|
|
|
* Always query the entire set, SMS not applicable
|
2009-05-28 18:50:25 +00:00
|
|
|
* according to 22.004 Appendix A, so CLASS_DEFAULT
|
|
|
|
* is safe to use here
|
|
|
|
*/
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->cw_query(cs, BEARER_CLASS_DEFAULT,
|
|
|
|
cw_ss_query_callback, cs);
|
2009-05-28 18:50:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SS_CONTROL_TYPE_DEACTIVATION:
|
|
|
|
case SS_CONTROL_TYPE_ERASURE:
|
|
|
|
cs->ss_req_type = SS_CONTROL_TYPE_DEACTIVATION;
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->cw_set(cs, 0, cls, cw_ss_set_callback, cs);
|
2009-05-28 18:50:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
bad_format:
|
2009-07-29 00:11:32 +00:00
|
|
|
reply = __ofono_error_invalid_format(msg);
|
2009-05-28 18:50:25 +00:00
|
|
|
error:
|
|
|
|
g_dbus_send_message(conn, reply);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void generate_ss_query_reply(struct ofono_call_settings *cs,
|
2009-05-06 04:13:14 +00:00
|
|
|
const char *context, const char *value)
|
|
|
|
{
|
|
|
|
const char *sig = "(ss)";
|
|
|
|
const char *ss_type = ss_control_type_to_string(cs->ss_req_type);
|
|
|
|
DBusMessageIter iter;
|
|
|
|
DBusMessageIter var;
|
|
|
|
DBusMessageIter vstruct;
|
|
|
|
DBusMessage *reply;
|
|
|
|
|
|
|
|
reply = dbus_message_new_method_return(cs->pending);
|
|
|
|
|
|
|
|
dbus_message_iter_init_append(reply, &iter);
|
|
|
|
|
|
|
|
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &context);
|
|
|
|
|
|
|
|
dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, sig, &var);
|
|
|
|
|
|
|
|
dbus_message_iter_open_container(&var, DBUS_TYPE_STRUCT, NULL,
|
|
|
|
&vstruct);
|
|
|
|
|
|
|
|
dbus_message_iter_append_basic(&vstruct, DBUS_TYPE_STRING,
|
|
|
|
&ss_type);
|
|
|
|
|
|
|
|
dbus_message_iter_append_basic(&vstruct, DBUS_TYPE_STRING, &value);
|
|
|
|
|
|
|
|
dbus_message_iter_close_container(&var, &vstruct);
|
|
|
|
|
|
|
|
dbus_message_iter_close_container(&iter, &var);
|
|
|
|
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending, reply);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2010-12-06 20:12:39 +00:00
|
|
|
static void clip_cnap_colp_colr_ss_query_cb(const struct ofono_error *error,
|
2009-05-06 04:13:14 +00:00
|
|
|
int status, void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-06 04:13:14 +00:00
|
|
|
const char *context;
|
|
|
|
const char *value;
|
|
|
|
|
|
|
|
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
|
2012-05-30 13:53:10 +00:00
|
|
|
DBG("SS control query failed with error: %s",
|
|
|
|
telephony_error_to_str(error));
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending,
|
2012-05-30 13:53:10 +00:00
|
|
|
__ofono_error_from_error(error, cs->pending));
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-05-28 18:50:25 +00:00
|
|
|
switch (cs->ss_setting) {
|
2009-05-06 04:13:14 +00:00
|
|
|
case CALL_SETTING_TYPE_CLIP:
|
2009-08-13 20:00:36 +00:00
|
|
|
set_clip(cs, status);
|
2009-05-06 04:13:14 +00:00
|
|
|
value = clip_status_to_string(status);
|
|
|
|
context = "CallingLinePresentation";
|
|
|
|
break;
|
|
|
|
|
2010-12-06 20:12:39 +00:00
|
|
|
case CALL_SETTING_TYPE_CNAP:
|
|
|
|
set_cnap(cs, status);
|
|
|
|
value = cnap_status_to_string(status);
|
|
|
|
context = "CallingNamePresentation";
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2009-05-06 04:13:14 +00:00
|
|
|
case CALL_SETTING_TYPE_COLP:
|
2009-08-13 20:00:36 +00:00
|
|
|
set_colp(cs, status);
|
2009-05-06 04:13:14 +00:00
|
|
|
value = colp_status_to_string(status);
|
2010-12-29 02:41:00 +00:00
|
|
|
context = "ConnectedLinePresentation";
|
2009-05-06 04:13:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CALL_SETTING_TYPE_COLR:
|
2009-08-13 20:00:36 +00:00
|
|
|
set_colr(cs, status);
|
2009-05-06 04:13:14 +00:00
|
|
|
value = colr_status_to_string(status);
|
2010-12-29 02:41:00 +00:00
|
|
|
context = "ConnectedLineRestriction";
|
2009-05-06 04:13:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending,
|
2009-07-29 00:11:32 +00:00
|
|
|
__ofono_error_failed(cs->pending));
|
2010-12-06 20:12:39 +00:00
|
|
|
ofono_error("Unknown type during COLR/COLP/CLIP/CNAP ss");
|
2009-05-06 04:13:14 +00:00
|
|
|
return;
|
|
|
|
};
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
generate_ss_query_reply(cs, context, value);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2010-12-06 20:12:39 +00:00
|
|
|
static gboolean clip_cnap_colp_colr_ss(int type,
|
2009-05-06 04:13:14 +00:00
|
|
|
const char *sc, const char *sia,
|
|
|
|
const char *sib, const char *sic,
|
2009-08-17 19:49:43 +00:00
|
|
|
const char *dn, DBusMessage *msg, void *data)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2009-08-17 19:49:43 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-07-28 20:56:11 +00:00
|
|
|
DBusConnection *conn = ofono_dbus_get_connection();
|
2009-08-13 20:00:36 +00:00
|
|
|
void (*query_op)(struct ofono_call_settings *cs,
|
|
|
|
ofono_call_settings_status_cb_t cb, void *data);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2010-11-27 19:39:03 +00:00
|
|
|
if (cs == NULL)
|
2009-05-06 04:13:14 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2010-09-21 10:21:17 +00:00
|
|
|
if (__ofono_call_settings_is_busy(cs)) {
|
2009-07-29 00:11:32 +00:00
|
|
|
DBusMessage *reply = __ofono_error_busy(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
g_dbus_send_message(conn, reply);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(sc, "30")) {
|
2009-05-28 18:50:25 +00:00
|
|
|
cs->ss_setting = CALL_SETTING_TYPE_CLIP;
|
2009-08-13 20:00:36 +00:00
|
|
|
query_op = cs->driver->clip_query;
|
2010-12-06 20:12:39 +00:00
|
|
|
} else if (!strcmp(sc, "300")) {
|
|
|
|
cs->ss_setting = CALL_SETTING_TYPE_CNAP;
|
|
|
|
query_op = cs->driver->cnap_query;
|
2009-05-06 04:13:14 +00:00
|
|
|
} else if (!strcmp(sc, "76")) {
|
2009-05-28 18:50:25 +00:00
|
|
|
cs->ss_setting = CALL_SETTING_TYPE_COLP;
|
2009-08-13 20:00:36 +00:00
|
|
|
query_op = cs->driver->colp_query;
|
2009-05-06 04:13:14 +00:00
|
|
|
} else if (!strcmp(sc, "77")) {
|
2009-05-28 18:50:25 +00:00
|
|
|
cs->ss_setting = CALL_SETTING_TYPE_COLR;
|
2009-08-13 20:00:36 +00:00
|
|
|
query_op = cs->driver->colr_query;
|
2009-12-18 03:31:35 +00:00
|
|
|
} else {
|
2009-05-06 04:13:14 +00:00
|
|
|
return FALSE;
|
2009-12-18 03:31:35 +00:00
|
|
|
}
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
if (type != SS_CONTROL_TYPE_QUERY || strlen(sia) || strlen(sib) ||
|
|
|
|
strlen(sic) || strlen(dn)) {
|
2009-07-29 00:11:32 +00:00
|
|
|
DBusMessage *reply = __ofono_error_invalid_format(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
g_dbus_send_message(conn, reply);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-11-27 19:39:03 +00:00
|
|
|
if (query_op == NULL) {
|
2009-07-29 00:11:32 +00:00
|
|
|
DBusMessage *reply = __ofono_error_not_implemented(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
g_dbus_send_message(conn, reply);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-12-06 20:12:39 +00:00
|
|
|
DBG("Received CLIP/CNAP/COLR/COLP query ss control");
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
cs->pending = dbus_message_ref(msg);
|
|
|
|
|
2010-12-06 20:12:39 +00:00
|
|
|
query_op(cs, clip_cnap_colp_colr_ss_query_cb, cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void clir_ss_query_callback(const struct ofono_error *error,
|
|
|
|
int override, int network, void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-06 04:13:14 +00:00
|
|
|
const char *value;
|
|
|
|
|
|
|
|
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
|
2012-08-22 16:18:22 +00:00
|
|
|
DBG("clir query via SS failed with error: %s",
|
|
|
|
telephony_error_to_str(error));
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending,
|
2012-08-22 16:18:22 +00:00
|
|
|
__ofono_error_from_error(error, cs->pending));
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (network) {
|
|
|
|
case CLIR_STATUS_UNKNOWN:
|
2011-06-17 13:09:12 +00:00
|
|
|
value = "unknown";
|
2009-05-06 04:13:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CLIR_STATUS_PROVISIONED_PERMANENT:
|
|
|
|
value = "enabled";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLIR_STATUS_NOT_PROVISIONED:
|
|
|
|
value = "disabled";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLIR_STATUS_TEMPORARY_RESTRICTED:
|
|
|
|
if (override == OFONO_CLIR_OPTION_SUPPRESSION)
|
|
|
|
value = "enabled";
|
|
|
|
else
|
|
|
|
value = "disabled";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLIR_STATUS_TEMPORARY_ALLOWED:
|
|
|
|
if (override == OFONO_CLIR_OPTION_INVOCATION)
|
|
|
|
value = "enabled";
|
|
|
|
else
|
|
|
|
value = "disabled";
|
|
|
|
break;
|
2009-06-01 17:51:49 +00:00
|
|
|
default:
|
|
|
|
value = "unknown";
|
2009-05-06 04:13:14 +00:00
|
|
|
};
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
generate_ss_query_reply(cs, "CallingLineRestriction", value);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
set_clir_network(cs, network);
|
|
|
|
set_clir_override(cs, override);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void clir_ss_set_callback(const struct ofono_error *error, void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
|
2012-05-30 13:53:10 +00:00
|
|
|
DBG("setting clir via SS failed with error: %s",
|
|
|
|
telephony_error_to_str(error));
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending,
|
2012-05-30 13:53:10 +00:00
|
|
|
__ofono_error_from_error(error, cs->pending));
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->clir_query(cs, clir_ss_query_callback, cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-17 19:49:43 +00:00
|
|
|
static gboolean clir_ss_control(int type,
|
2009-05-06 04:13:14 +00:00
|
|
|
const char *sc, const char *sia,
|
|
|
|
const char *sib, const char *sic,
|
2009-08-17 19:49:43 +00:00
|
|
|
const char *dn, DBusMessage *msg, void *data)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2009-08-17 19:49:43 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-07-28 20:56:11 +00:00
|
|
|
DBusConnection *conn = ofono_dbus_get_connection();
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2010-11-27 19:39:03 +00:00
|
|
|
if (cs == NULL)
|
2009-05-06 04:13:14 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (strcmp(sc, "31"))
|
|
|
|
return FALSE;
|
|
|
|
|
2010-09-21 10:21:17 +00:00
|
|
|
if (__ofono_call_settings_is_busy(cs)) {
|
2009-07-29 00:11:32 +00:00
|
|
|
DBusMessage *reply = __ofono_error_busy(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
g_dbus_send_message(conn, reply);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the temporary form of CLIR, handled in voicecalls */
|
|
|
|
if (!strlen(sia) && !strlen(sib) & !strlen(sic) &&
|
2010-11-22 22:32:27 +00:00
|
|
|
strlen(dn) && type != SS_CONTROL_TYPE_QUERY)
|
2009-05-06 04:13:14 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (strlen(sia) || strlen(sib) || strlen(sic) || strlen(dn)) {
|
2009-07-29 00:11:32 +00:00
|
|
|
DBusMessage *reply = __ofono_error_invalid_format(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
g_dbus_send_message(conn, reply);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-11-22 22:32:27 +00:00
|
|
|
if (type == SS_CONTROL_TYPE_QUERY && cs->driver->clir_query == NULL) {
|
|
|
|
DBusMessage *reply = __ofono_error_not_implemented(msg);
|
|
|
|
g_dbus_send_message(conn, reply);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-11-27 19:39:03 +00:00
|
|
|
if (type != SS_CONTROL_TYPE_QUERY && cs->driver->clir_set == NULL) {
|
2009-07-29 00:11:32 +00:00
|
|
|
DBusMessage *reply = __ofono_error_not_implemented(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
g_dbus_send_message(conn, reply);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-05-28 18:50:25 +00:00
|
|
|
cs->ss_setting = CALL_SETTING_TYPE_CLIR;
|
2009-05-06 04:13:14 +00:00
|
|
|
cs->pending = dbus_message_ref(msg);
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case SS_CONTROL_TYPE_REGISTRATION:
|
|
|
|
case SS_CONTROL_TYPE_ACTIVATION:
|
|
|
|
cs->ss_req_type = SS_CONTROL_TYPE_ACTIVATION;
|
2010-11-22 22:29:46 +00:00
|
|
|
cs->driver->clir_set(cs, OFONO_CLIR_OPTION_SUPPRESSION,
|
2009-08-13 20:00:36 +00:00
|
|
|
clir_ss_set_callback, cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SS_CONTROL_TYPE_QUERY:
|
|
|
|
cs->ss_req_type = SS_CONTROL_TYPE_QUERY;
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->clir_query(cs, clir_ss_query_callback, cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SS_CONTROL_TYPE_DEACTIVATION:
|
|
|
|
case SS_CONTROL_TYPE_ERASURE:
|
|
|
|
cs->ss_req_type = SS_CONTROL_TYPE_DEACTIVATION;
|
2010-11-22 22:29:46 +00:00
|
|
|
cs->driver->clir_set(cs, OFONO_CLIR_OPTION_INVOCATION,
|
2009-08-13 20:00:36 +00:00
|
|
|
clir_ss_set_callback, cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void cs_register_ss_controls(struct ofono_call_settings *cs)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2010-12-06 20:12:39 +00:00
|
|
|
__ofono_ussd_ssc_register(cs->ussd, "30", clip_cnap_colp_colr_ss,
|
|
|
|
cs, NULL);
|
2009-08-17 19:49:43 +00:00
|
|
|
__ofono_ussd_ssc_register(cs->ussd, "31", clir_ss_control, cs, NULL);
|
2010-12-06 20:12:39 +00:00
|
|
|
__ofono_ussd_ssc_register(cs->ussd, "76", clip_cnap_colp_colr_ss,
|
|
|
|
cs, NULL);
|
|
|
|
__ofono_ussd_ssc_register(cs->ussd, "300", clip_cnap_colp_colr_ss,
|
|
|
|
cs, NULL);
|
2009-08-14 20:54:52 +00:00
|
|
|
|
2009-08-17 19:49:43 +00:00
|
|
|
__ofono_ussd_ssc_register(cs->ussd, "43", cw_ss_control, cs, NULL);
|
2009-05-28 18:50:25 +00:00
|
|
|
|
2011-02-02 08:45:44 +00:00
|
|
|
if (cs->driver->colr_query != NULL)
|
2009-08-17 19:49:43 +00:00
|
|
|
__ofono_ussd_ssc_register(cs->ussd, "77",
|
2010-12-06 20:12:39 +00:00
|
|
|
clip_cnap_colp_colr_ss, cs, NULL);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void cs_unregister_ss_controls(struct ofono_call_settings *cs)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2009-08-17 19:49:43 +00:00
|
|
|
__ofono_ussd_ssc_unregister(cs->ussd, "30");
|
|
|
|
__ofono_ussd_ssc_unregister(cs->ussd, "31");
|
|
|
|
__ofono_ussd_ssc_unregister(cs->ussd, "76");
|
2010-12-06 20:12:39 +00:00
|
|
|
__ofono_ussd_ssc_unregister(cs->ussd, "300");
|
2009-08-14 20:54:52 +00:00
|
|
|
|
2009-08-17 19:49:43 +00:00
|
|
|
__ofono_ussd_ssc_unregister(cs->ussd, "43");
|
2009-05-28 18:50:25 +00:00
|
|
|
|
2011-02-02 08:45:44 +00:00
|
|
|
if (cs->driver->colr_query != NULL)
|
2009-08-17 19:49:43 +00:00
|
|
|
__ofono_ussd_ssc_unregister(cs->ussd, "77");
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2010-09-09 12:31:51 +00:00
|
|
|
gboolean __ofono_call_settings_is_busy(struct ofono_call_settings *cs)
|
|
|
|
{
|
|
|
|
return cs->pending ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static DBusMessage *generate_get_properties_reply(struct ofono_call_settings *cs,
|
2009-05-06 04:13:14 +00:00
|
|
|
DBusMessage *msg)
|
|
|
|
{
|
|
|
|
DBusMessage *reply;
|
|
|
|
DBusMessageIter iter;
|
|
|
|
DBusMessageIter dict;
|
|
|
|
const char *str;
|
|
|
|
|
|
|
|
reply = dbus_message_new_method_return(msg);
|
2010-11-27 19:39:03 +00:00
|
|
|
if (reply == NULL)
|
2009-05-06 04:13:14 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
dbus_message_iter_init_append(reply, &iter);
|
|
|
|
|
|
|
|
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
|
2009-07-29 15:26:38 +00:00
|
|
|
OFONO_PROPERTIES_ARRAY_SIGNATURE,
|
|
|
|
&dict);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
str = clip_status_to_string(cs->clip);
|
2009-07-29 15:26:55 +00:00
|
|
|
ofono_dbus_dict_append(&dict, "CallingLinePresentation",
|
2009-05-06 04:13:14 +00:00
|
|
|
DBUS_TYPE_STRING, &str);
|
|
|
|
|
2010-12-29 02:40:59 +00:00
|
|
|
str = cnap_status_to_string(cs->cnap);
|
2010-12-06 20:12:39 +00:00
|
|
|
ofono_dbus_dict_append(&dict, "CallingNamePresentation",
|
|
|
|
DBUS_TYPE_STRING, &str);
|
|
|
|
|
2009-05-06 04:13:14 +00:00
|
|
|
str = colp_status_to_string(cs->colp);
|
2010-12-29 02:41:00 +00:00
|
|
|
ofono_dbus_dict_append(&dict, "ConnectedLinePresentation",
|
2009-05-06 04:13:14 +00:00
|
|
|
DBUS_TYPE_STRING, &str);
|
|
|
|
|
|
|
|
str = colr_status_to_string(cs->colr);
|
2010-12-29 02:41:00 +00:00
|
|
|
ofono_dbus_dict_append(&dict, "ConnectedLineRestriction",
|
2009-05-06 04:13:14 +00:00
|
|
|
DBUS_TYPE_STRING, &str);
|
|
|
|
|
2011-01-12 11:27:44 +00:00
|
|
|
str = cdip_status_to_string(cs->cdip);
|
|
|
|
ofono_dbus_dict_append(&dict, "CalledLinePresentation",
|
|
|
|
DBUS_TYPE_STRING, &str);
|
|
|
|
|
2009-05-06 04:13:14 +00:00
|
|
|
str = clir_status_to_string(cs->clir);
|
2009-07-29 15:26:55 +00:00
|
|
|
ofono_dbus_dict_append(&dict, "CallingLineRestriction",
|
2009-05-06 04:13:14 +00:00
|
|
|
DBUS_TYPE_STRING, &str);
|
|
|
|
|
|
|
|
str = hide_callerid_to_string(cs->clir_setting);
|
2009-07-29 15:26:55 +00:00
|
|
|
ofono_dbus_dict_append(&dict, "HideCallerId", DBUS_TYPE_STRING, &str);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-05-28 18:50:25 +00:00
|
|
|
property_append_cw_conditions(&dict, cs->cw, BEARER_CLASS_VOICE);
|
|
|
|
|
2009-05-06 04:13:14 +00:00
|
|
|
dbus_message_iter_close_container(&iter, &dict);
|
|
|
|
|
|
|
|
return reply;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cs_clir_callback(const struct ofono_error *error,
|
|
|
|
int override_setting, int network_setting,
|
|
|
|
void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
|
|
|
|
goto out;
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
set_clir_network(cs, network_setting);
|
|
|
|
set_clir_override(cs, override_setting);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
cs->flags |= CALL_SETTINGS_FLAG_CACHED;
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (cs->pending) {
|
2009-08-13 20:00:36 +00:00
|
|
|
DBusMessage *reply = generate_get_properties_reply(cs,
|
2009-05-06 04:13:14 +00:00
|
|
|
cs->pending);
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending, reply);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void query_clir(struct ofono_call_settings *cs)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2010-11-27 19:39:03 +00:00
|
|
|
if (cs->driver->clir_query == NULL) {
|
2009-05-06 04:13:14 +00:00
|
|
|
if (cs->pending) {
|
|
|
|
DBusMessage *reply =
|
2009-08-13 20:00:36 +00:00
|
|
|
generate_get_properties_reply(cs,
|
2009-05-06 04:13:14 +00:00
|
|
|
cs->pending);
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending, reply);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-07 22:40:54 +00:00
|
|
|
return;
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->clir_query(cs, cs_clir_callback, cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2011-01-12 11:27:44 +00:00
|
|
|
static void cs_cdip_callback(const struct ofono_error *error,
|
|
|
|
int state, void *data)
|
|
|
|
{
|
|
|
|
struct ofono_call_settings *cs = data;
|
|
|
|
|
|
|
|
if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
|
|
|
|
set_cdip(cs, state);
|
|
|
|
|
|
|
|
query_clir(cs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void query_cdip(struct ofono_call_settings *cs)
|
|
|
|
{
|
|
|
|
if (cs->driver->cdip_query == NULL) {
|
|
|
|
query_clir(cs);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cs->driver->cdip_query(cs, cs_cdip_callback, cs);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-06 20:12:39 +00:00
|
|
|
static void cs_cnap_callback(const struct ofono_error *error,
|
|
|
|
int state, void *data)
|
|
|
|
{
|
|
|
|
struct ofono_call_settings *cs = data;
|
|
|
|
|
|
|
|
if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
|
|
|
|
set_cnap(cs, state);
|
|
|
|
|
2011-01-12 11:27:44 +00:00
|
|
|
query_cdip(cs);
|
2010-12-06 20:12:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void query_cnap(struct ofono_call_settings *cs)
|
|
|
|
{
|
|
|
|
if (cs->driver->cnap_query == NULL) {
|
2011-01-12 11:27:44 +00:00
|
|
|
query_cdip(cs);
|
2010-12-06 20:12:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cs->driver->cnap_query(cs, cs_cnap_callback, cs);
|
|
|
|
}
|
|
|
|
|
2009-05-06 04:13:14 +00:00
|
|
|
static void cs_clip_callback(const struct ofono_error *error,
|
|
|
|
int state, void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
|
2009-08-13 20:00:36 +00:00
|
|
|
set_clip(cs, state);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2010-12-06 20:12:39 +00:00
|
|
|
query_cnap(cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void query_clip(struct ofono_call_settings *cs)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2010-11-27 19:39:03 +00:00
|
|
|
if (cs->driver->clip_query == NULL) {
|
2009-08-13 20:00:36 +00:00
|
|
|
query_clir(cs);
|
2009-08-07 22:40:54 +00:00
|
|
|
return;
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->clip_query(cs, cs_clip_callback, cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cs_colp_callback(const struct ofono_error *error,
|
|
|
|
int state, void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
|
2009-08-13 20:00:36 +00:00
|
|
|
set_colp(cs, state);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
query_clip(cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void query_colp(struct ofono_call_settings *cs)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2010-11-27 19:39:03 +00:00
|
|
|
if (cs->driver->colp_query == NULL) {
|
2009-08-13 20:00:36 +00:00
|
|
|
query_clip(cs);
|
2009-08-07 22:40:54 +00:00
|
|
|
return;
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->colp_query(cs, cs_colp_callback, cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cs_colr_callback(const struct ofono_error *error,
|
|
|
|
int state, void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
|
2009-08-13 20:00:36 +00:00
|
|
|
set_colr(cs, state);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
query_colp(cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void query_colr(struct ofono_call_settings *cs)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2010-11-27 19:39:03 +00:00
|
|
|
if (cs->driver->colr_query == NULL) {
|
2009-08-13 20:00:36 +00:00
|
|
|
query_colp(cs);
|
2009-08-07 22:40:54 +00:00
|
|
|
return;
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->colr_query(cs, cs_colr_callback, cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-05-28 18:50:25 +00:00
|
|
|
static void cs_cw_callback(const struct ofono_error *error, int status,
|
|
|
|
void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
|
2009-08-13 20:00:36 +00:00
|
|
|
set_cw(cs, status, BEARER_CLASS_VOICE);
|
2009-05-28 18:50:25 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
query_colr(cs);
|
2009-05-28 18:50:25 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static void query_cw(struct ofono_call_settings *cs)
|
2009-05-28 18:50:25 +00:00
|
|
|
{
|
2010-11-27 19:39:03 +00:00
|
|
|
if (cs->driver->cw_query == NULL) {
|
2009-08-13 20:00:36 +00:00
|
|
|
query_colr(cs);
|
2009-08-07 22:40:54 +00:00
|
|
|
return;
|
2009-05-28 18:50:25 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->cw_query(cs, BEARER_CLASS_DEFAULT, cs_cw_callback, cs);
|
2009-05-28 18:50:25 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 04:13:14 +00:00
|
|
|
static DBusMessage *cs_get_properties(DBusConnection *conn, DBusMessage *msg,
|
|
|
|
void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2010-09-21 10:21:17 +00:00
|
|
|
if (__ofono_call_settings_is_busy(cs) || __ofono_ussd_is_busy(cs->ussd))
|
2009-07-29 00:11:32 +00:00
|
|
|
return __ofono_error_busy(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
if (cs->flags & CALL_SETTINGS_FLAG_CACHED)
|
2009-08-13 20:00:36 +00:00
|
|
|
return generate_get_properties_reply(cs, msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
/* Query the settings and report back */
|
|
|
|
cs->pending = dbus_message_ref(msg);
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
query_cw(cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void clir_set_query_callback(const struct ofono_error *error,
|
|
|
|
int override_setting,
|
|
|
|
int network_setting, void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-06 04:13:14 +00:00
|
|
|
DBusMessage *reply;
|
|
|
|
|
2010-09-21 10:21:17 +00:00
|
|
|
if (!__ofono_call_settings_is_busy(cs))
|
2009-05-06 04:13:14 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
|
2009-05-28 18:50:25 +00:00
|
|
|
ofono_error("set clir successful, but the query was not");
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
cs->flags &= ~CALL_SETTINGS_FLAG_CACHED;
|
|
|
|
|
2009-07-29 00:11:32 +00:00
|
|
|
reply = __ofono_error_failed(cs->pending);
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending, reply);
|
2009-05-06 04:13:14 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
reply = dbus_message_new_method_return(cs->pending);
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending, reply);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
set_clir_override(cs, override_setting);
|
|
|
|
set_clir_network(cs, network_setting);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void clir_set_callback(const struct ofono_error *error, void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
|
2010-02-08 17:54:03 +00:00
|
|
|
DBG("setting clir failed");
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending,
|
2009-07-29 00:11:32 +00:00
|
|
|
__ofono_error_failed(cs->pending));
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Assume that if we have clir_set, we have clir_query */
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->clir_query(cs, clir_set_query_callback, cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static DBusMessage *set_clir(DBusMessage *msg, struct ofono_call_settings *cs,
|
2009-05-06 04:13:14 +00:00
|
|
|
const char *setting)
|
|
|
|
{
|
|
|
|
int clir = -1;
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
if (cs->driver->clir_set == NULL)
|
2009-07-29 00:11:32 +00:00
|
|
|
return __ofono_error_not_implemented(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
if (!strcmp(setting, "default"))
|
2011-01-25 23:46:08 +00:00
|
|
|
clir = CLIR_STATUS_NOT_PROVISIONED;
|
2009-05-06 04:13:14 +00:00
|
|
|
else if (!strcmp(setting, "enabled"))
|
2011-01-25 23:46:08 +00:00
|
|
|
clir = CLIR_STATUS_PROVISIONED_PERMANENT;
|
2009-05-06 04:13:14 +00:00
|
|
|
else if (!strcmp(setting, "disabled"))
|
2011-01-25 23:46:08 +00:00
|
|
|
clir = CLIR_STATUS_UNKNOWN;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
if (clir == -1)
|
2009-07-29 00:11:32 +00:00
|
|
|
return __ofono_error_invalid_format(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
cs->pending = dbus_message_ref(msg);
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->clir_set(cs, clir, clir_set_callback, cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-05-28 18:50:25 +00:00
|
|
|
static void cw_set_query_callback(const struct ofono_error *error, int status,
|
|
|
|
void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
|
|
|
|
ofono_error("CW set succeeded, but query failed!");
|
|
|
|
|
|
|
|
cs->flags &= ~CALL_SETTINGS_FLAG_CACHED;
|
|
|
|
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending,
|
2009-07-29 00:11:32 +00:00
|
|
|
__ofono_error_failed(cs->pending));
|
2009-05-28 18:50:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending,
|
2009-05-28 18:50:25 +00:00
|
|
|
dbus_message_new_method_return(cs->pending));
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
set_cw(cs, status, BEARER_CLASS_VOICE);
|
2009-05-28 18:50:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cw_set_callback(const struct ofono_error *error, void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
|
2010-02-08 17:54:03 +00:00
|
|
|
DBG("Error occurred during CW set");
|
2009-05-28 18:50:25 +00:00
|
|
|
|
2009-07-29 15:40:17 +00:00
|
|
|
__ofono_dbus_pending_reply(&cs->pending,
|
2009-07-29 00:11:32 +00:00
|
|
|
__ofono_error_failed(cs->pending));
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->cw_query(cs, BEARER_CLASS_DEFAULT,
|
|
|
|
cw_set_query_callback, cs);
|
2009-05-28 18:50:25 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
static DBusMessage *set_cw_req(DBusMessage *msg, struct ofono_call_settings *cs,
|
2009-05-28 18:50:25 +00:00
|
|
|
const char *setting, int cls)
|
|
|
|
{
|
|
|
|
int cw;
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
if (cs->driver->cw_set == NULL)
|
2009-07-29 00:11:32 +00:00
|
|
|
return __ofono_error_not_implemented(msg);
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
if (!strcmp(setting, "enabled"))
|
|
|
|
cw = 1;
|
|
|
|
else if (!strcmp(setting, "disabled"))
|
|
|
|
cw = 0;
|
|
|
|
else
|
2009-07-29 00:11:32 +00:00
|
|
|
return __ofono_error_invalid_format(msg);
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
cs->pending = dbus_message_ref(msg);
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->cw_set(cs, cw, cls, cw_set_callback, cs);
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean is_cw_property(const char *property, int mask, int *out_cls)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int len;
|
|
|
|
const char *prefix;
|
|
|
|
|
|
|
|
for (i = 1; i <= BEARER_CLASS_PAD; i = i << 1) {
|
|
|
|
if ((i & mask) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
prefix = bearer_class_to_string(i);
|
|
|
|
|
|
|
|
len = strlen(prefix);
|
|
|
|
|
|
|
|
if (strncmp(property, prefix, len))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!strcmp(property+len, "CallWaiting")) {
|
|
|
|
*out_cls = i;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-05-06 04:13:14 +00:00
|
|
|
static DBusMessage *cs_set_property(DBusConnection *conn, DBusMessage *msg,
|
|
|
|
void *data)
|
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = data;
|
2009-05-06 04:13:14 +00:00
|
|
|
DBusMessageIter iter;
|
|
|
|
DBusMessageIter var;
|
|
|
|
const char *property;
|
2009-05-28 18:50:25 +00:00
|
|
|
int cls;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2010-09-21 10:21:17 +00:00
|
|
|
if (__ofono_call_settings_is_busy(cs) || __ofono_ussd_is_busy(cs->ussd))
|
2009-07-29 00:11:32 +00:00
|
|
|
return __ofono_error_busy(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
if (!dbus_message_iter_init(msg, &iter))
|
2009-07-29 00:11:32 +00:00
|
|
|
return __ofono_error_invalid_args(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
|
2009-07-29 00:11:32 +00:00
|
|
|
return __ofono_error_invalid_args(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
dbus_message_iter_get_basic(&iter, &property);
|
|
|
|
dbus_message_iter_next(&iter);
|
|
|
|
|
|
|
|
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
|
2009-07-29 00:11:32 +00:00
|
|
|
return __ofono_error_invalid_args(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
dbus_message_iter_recurse(&iter, &var);
|
|
|
|
|
|
|
|
if (!strcmp(property, "HideCallerId")) {
|
|
|
|
const char *setting;
|
|
|
|
|
|
|
|
if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
|
2009-08-05 05:17:10 +00:00
|
|
|
return __ofono_error_invalid_args(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
dbus_message_iter_get_basic(&var, &setting);
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
return set_clir(msg, cs, setting);
|
2009-05-28 18:50:25 +00:00
|
|
|
} else if (is_cw_property(property, BEARER_CLASS_VOICE, &cls)) {
|
|
|
|
const char *setting;
|
|
|
|
|
|
|
|
if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
|
2009-08-05 05:17:10 +00:00
|
|
|
return __ofono_error_invalid_args(msg);
|
2009-05-28 18:50:25 +00:00
|
|
|
|
|
|
|
dbus_message_iter_get_basic(&var, &setting);
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
return set_cw_req(msg, cs, setting, cls);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:11:32 +00:00
|
|
|
return __ofono_error_invalid_args(msg);
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2012-05-20 05:07:25 +00:00
|
|
|
static const GDBusMethodTable cs_methods[] = {
|
2012-05-20 05:07:32 +00:00
|
|
|
{ GDBUS_ASYNC_METHOD("GetProperties",
|
|
|
|
NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
|
|
|
|
cs_get_properties) },
|
|
|
|
{ GDBUS_ASYNC_METHOD("SetProperty",
|
|
|
|
GDBUS_ARGS({ "property", "s" }, { "value", "v" }),
|
|
|
|
NULL, cs_set_property) },
|
2009-05-06 04:13:14 +00:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2012-05-20 05:07:26 +00:00
|
|
|
static const GDBusSignalTable cs_signals[] = {
|
2012-05-20 05:07:32 +00:00
|
|
|
{ GDBUS_SIGNAL("PropertyChanged",
|
2012-05-20 05:07:29 +00:00
|
|
|
GDBUS_ARGS({ "property", "s" }, { "value", "v" })) },
|
2009-05-06 04:13:14 +00:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
int ofono_call_settings_driver_register(const struct ofono_call_settings_driver *d)
|
|
|
|
{
|
|
|
|
DBG("driver: %p, name: %s", d, d->name);
|
|
|
|
|
|
|
|
if (d->probe == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-11-19 13:57:22 +00:00
|
|
|
g_drivers = g_slist_prepend(g_drivers, (void *) d);
|
2009-08-13 20:00:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ofono_call_settings_driver_unregister(const struct ofono_call_settings_driver *d)
|
|
|
|
{
|
|
|
|
DBG("driver: %p, name: %s", d, d->name);
|
|
|
|
|
2010-11-19 13:57:22 +00:00
|
|
|
g_drivers = g_slist_remove(g_drivers, (void *) d);
|
2009-08-13 20:00:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void call_settings_unregister(struct ofono_atom *atom)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2009-08-13 20:00:36 +00:00
|
|
|
struct ofono_call_settings *cs = __ofono_atom_get_data(atom);
|
2009-08-14 20:54:52 +00:00
|
|
|
const char *path = __ofono_atom_get_path(cs->atom);
|
2009-07-28 20:56:11 +00:00
|
|
|
DBusConnection *conn = ofono_dbus_get_connection();
|
2009-08-14 20:54:52 +00:00
|
|
|
struct ofono_modem *modem = __ofono_atom_get_modem(cs->atom);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-14 21:15:09 +00:00
|
|
|
ofono_modem_remove_interface(modem, OFONO_CALL_SETTINGS_INTERFACE);
|
|
|
|
g_dbus_unregister_interface(conn, path, OFONO_CALL_SETTINGS_INTERFACE);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-17 19:49:43 +00:00
|
|
|
if (cs->ussd)
|
|
|
|
cs_unregister_ss_controls(cs);
|
2009-08-17 20:14:05 +00:00
|
|
|
|
|
|
|
if (cs->ussd_watch)
|
|
|
|
__ofono_modem_remove_atom_watch(modem, cs->ussd_watch);
|
2009-08-13 20:00:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void call_settings_remove(struct ofono_atom *atom)
|
|
|
|
{
|
|
|
|
struct ofono_call_settings *cs = __ofono_atom_get_data(atom);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
DBG("atom: %p", atom);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
if (cs == NULL)
|
|
|
|
return;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2011-02-02 08:45:44 +00:00
|
|
|
if (cs->driver != NULL && cs->driver->remove != NULL)
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->driver->remove(cs);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
g_free(cs);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ofono_call_settings *ofono_call_settings_create(struct ofono_modem *modem,
|
2009-09-02 02:39:02 +00:00
|
|
|
unsigned int vendor,
|
2009-08-13 20:00:36 +00:00
|
|
|
const char *driver,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
struct ofono_call_settings *cs;
|
|
|
|
GSList *l;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
if (driver == NULL)
|
|
|
|
return NULL;
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
cs = g_try_new0(struct ofono_call_settings, 1);
|
|
|
|
|
|
|
|
if (cs == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Set all the settings to unknown state */
|
2011-01-25 23:46:08 +00:00
|
|
|
cs->clip = CLIP_STATUS_UNKNOWN;
|
|
|
|
cs->cnap = CNAP_STATUS_UNKNOWN;
|
|
|
|
cs->clir = CLIR_STATUS_UNKNOWN;
|
|
|
|
cs->colp = COLP_STATUS_UNKNOWN;
|
|
|
|
cs->colr = COLR_STATUS_UNKNOWN;
|
2009-08-13 20:00:36 +00:00
|
|
|
cs->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_CALL_SETTINGS,
|
|
|
|
call_settings_remove, cs);
|
|
|
|
|
|
|
|
for (l = g_drivers; l; l = l->next) {
|
|
|
|
const struct ofono_call_settings_driver *drv = l->data;
|
|
|
|
|
|
|
|
if (g_strcmp0(drv->name, driver))
|
|
|
|
continue;
|
|
|
|
|
2009-09-01 22:14:58 +00:00
|
|
|
if (drv->probe(cs, vendor, data) < 0)
|
2009-08-13 20:00:36 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
cs->driver = drv;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cs;
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-17 19:49:43 +00:00
|
|
|
static void ussd_watch(struct ofono_atom *atom,
|
|
|
|
enum ofono_atom_watch_condition cond, void *data)
|
|
|
|
{
|
|
|
|
struct ofono_call_settings *cs = data;
|
|
|
|
|
|
|
|
if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
|
|
|
|
cs->ussd = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cs->ussd = __ofono_atom_get_data(atom);
|
|
|
|
cs_register_ss_controls(cs);
|
|
|
|
}
|
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
void ofono_call_settings_register(struct ofono_call_settings *cs)
|
2009-05-06 04:13:14 +00:00
|
|
|
{
|
2009-07-28 20:56:11 +00:00
|
|
|
DBusConnection *conn = ofono_dbus_get_connection();
|
2009-08-14 20:54:52 +00:00
|
|
|
const char *path = __ofono_atom_get_path(cs->atom);
|
|
|
|
struct ofono_modem *modem = __ofono_atom_get_modem(cs->atom);
|
2009-08-13 20:00:36 +00:00
|
|
|
|
2009-08-14 21:15:09 +00:00
|
|
|
if (!g_dbus_register_interface(conn, path,
|
|
|
|
OFONO_CALL_SETTINGS_INTERFACE,
|
2009-08-13 20:00:36 +00:00
|
|
|
cs_methods, cs_signals, NULL, cs,
|
|
|
|
NULL)) {
|
|
|
|
ofono_error("Could not create %s interface",
|
2009-08-14 21:15:09 +00:00
|
|
|
OFONO_CALL_SETTINGS_INTERFACE);
|
2009-05-06 04:13:14 +00:00
|
|
|
|
|
|
|
return;
|
2009-08-13 20:00:36 +00:00
|
|
|
}
|
2009-05-06 04:13:14 +00:00
|
|
|
|
2009-08-14 21:15:09 +00:00
|
|
|
ofono_modem_add_interface(modem, OFONO_CALL_SETTINGS_INTERFACE);
|
2009-08-17 19:49:43 +00:00
|
|
|
|
2009-08-17 20:14:05 +00:00
|
|
|
cs->ussd_watch = __ofono_modem_add_atom_watch(modem,
|
|
|
|
OFONO_ATOM_TYPE_USSD,
|
2009-08-17 19:49:43 +00:00
|
|
|
ussd_watch, cs, NULL);
|
2009-08-17 20:14:05 +00:00
|
|
|
|
2009-08-13 20:00:36 +00:00
|
|
|
__ofono_atom_register(cs->atom, call_settings_unregister);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ofono_call_settings_remove(struct ofono_call_settings *cs)
|
|
|
|
{
|
2009-08-14 20:39:30 +00:00
|
|
|
__ofono_atom_free(cs->atom);
|
2009-08-13 20:00:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ofono_call_settings_set_data(struct ofono_call_settings *cs, void *data)
|
|
|
|
{
|
|
|
|
cs->driver_data = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *ofono_call_settings_get_data(struct ofono_call_settings *cs)
|
|
|
|
{
|
|
|
|
return cs->driver_data;
|
2009-05-06 04:13:14 +00:00
|
|
|
}
|