mirror of git://git.sysmocom.de/ofono
Add isimodem drivers for call barring, forwarding and waiting
This commit is contained in:
parent
d1d870ba7a
commit
a781e3b1d9
|
@ -71,6 +71,7 @@ if ISIMODEM
|
|||
builtin_modules += isimodem
|
||||
builtin_sources += $(gisi_sources) \
|
||||
drivers/isimodem/isi.h \
|
||||
drivers/isimodem/ss.h \
|
||||
drivers/isimodem/isimodem.c \
|
||||
drivers/isimodem/phonebook.c \
|
||||
drivers/isimodem/devinfo.c \
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
*
|
||||
* Contact: Aki Niemi <aki.niemi@nokia.com>
|
||||
* Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -34,42 +34,403 @@
|
|||
#include <glib.h>
|
||||
|
||||
#include <gisi/client.h>
|
||||
#include <gisi/iter.h>
|
||||
|
||||
#include <ofono/log.h>
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/call-barring.h>
|
||||
#include "util.h"
|
||||
|
||||
#include "isi.h"
|
||||
#include "ss.h"
|
||||
|
||||
#define PN_SS 0x06
|
||||
|
||||
struct call_barring_data {
|
||||
struct barr_data {
|
||||
GIsiClient *client;
|
||||
struct isi_version version;
|
||||
};
|
||||
|
||||
static bool set_resp_cb(GIsiClient *client, const void *restrict data,
|
||||
size_t len, uint16_t object, void *opaque)
|
||||
{
|
||||
const unsigned char *msg = data;
|
||||
struct isi_cb_data *cbd = opaque;
|
||||
ofono_call_barring_set_cb_t cb = cbd->cb;
|
||||
|
||||
if (!msg) {
|
||||
DBG("ISI client error: %d", g_isi_client_error(client));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (len < 3 || msg[0] != SS_SERVICE_COMPLETED_RESP)
|
||||
goto error;
|
||||
|
||||
if (msg[1] != SS_ACTIVATION && msg[1] != SS_DEACTIVATION)
|
||||
goto error;
|
||||
|
||||
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
||||
goto out;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||
|
||||
out:
|
||||
g_free(cbd);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void isi_set(struct ofono_call_barring *barr, const char *lock,
|
||||
int enable, const char *passwd, int cls,
|
||||
ofono_call_barring_set_cb_t cb, void *data)
|
||||
{
|
||||
struct barr_data *bd = ofono_call_barring_get_data(barr);
|
||||
struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
|
||||
int ss_code;
|
||||
char *ucs2 = NULL;
|
||||
|
||||
unsigned char msg[] = {
|
||||
SS_SERVICE_REQ,
|
||||
enable ? SS_ACTIVATION : SS_DEACTIVATION,
|
||||
SS_ALL_TELE_AND_BEARER,
|
||||
0, 0, /* Supplementary services code */
|
||||
SS_SEND_ADDITIONAL_INFO,
|
||||
1, /* Subblock count */
|
||||
SS_GSM_PASSWORD,
|
||||
28, /* Subblock length */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* Password */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* Filler */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* Filler */
|
||||
0, 0 /* Filler */
|
||||
};
|
||||
|
||||
DBG("lock code %s enable %d class %d password %s\n",
|
||||
lock, enable, cls, passwd);
|
||||
|
||||
if (!cbd || !passwd || strlen(passwd) > 4 || cls != 7)
|
||||
goto error;
|
||||
|
||||
if (strcmp(lock, "AO") == 0)
|
||||
ss_code = SS_GSM_BARR_ALL_OUT;
|
||||
else if (strcmp(lock, "OI") == 0)
|
||||
ss_code = SS_GSM_BARR_OUT_INTER;
|
||||
else if (strcmp(lock, "OX") == 0)
|
||||
ss_code = SS_GSM_BARR_OUT_INTER_EXC_HOME;
|
||||
else if (strcmp(lock, "AI") == 0)
|
||||
ss_code = SS_GSM_BARR_ALL_IN;
|
||||
else if (strcmp(lock, "IR") == 0)
|
||||
ss_code = SS_GSM_BARR_ALL_IN_ROAM;
|
||||
else if (strcmp(lock, "AB") == 0)
|
||||
ss_code = SS_GSM_ALL_BARRINGS;
|
||||
else if (strcmp(lock, "AG") == 0)
|
||||
ss_code = SS_GSM_BARR_ALL_OUT;
|
||||
else if (strcmp(lock, "AC") == 0)
|
||||
ss_code = SS_GSM_BARR_ALL_IN;
|
||||
else
|
||||
goto error;
|
||||
|
||||
msg[3] = ss_code >> 8;
|
||||
msg[4] = ss_code & 0xFF;
|
||||
|
||||
ucs2 = g_convert(passwd, 4, "UCS-2BE", "UTF-8//TRANSLIT",
|
||||
NULL, NULL, NULL);
|
||||
if (ucs2 == NULL)
|
||||
goto error;
|
||||
|
||||
memcpy((char *)msg + 9, ucs2, 8);
|
||||
g_free(ucs2);
|
||||
|
||||
if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
|
||||
set_resp_cb, cbd))
|
||||
return;
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
g_free(cbd);
|
||||
}
|
||||
|
||||
static void update_status_mask(unsigned int *mask, int bsc)
|
||||
{
|
||||
switch (bsc) {
|
||||
|
||||
case SS_GSM_TELEPHONY:
|
||||
*mask |= 1;
|
||||
break;
|
||||
|
||||
case SS_GSM_ALL_DATA_TELE:
|
||||
*mask |= 1 << 1;
|
||||
break;
|
||||
|
||||
case SS_GSM_FACSIMILE:
|
||||
*mask |= 1 << 2;
|
||||
break;
|
||||
|
||||
case SS_GSM_SMS:
|
||||
*mask |= 1 << 3;
|
||||
break;
|
||||
|
||||
case SS_GSM_ALL_DATA_CIRCUIT_SYNC:
|
||||
*mask |= 1 << 4;
|
||||
break;
|
||||
|
||||
case SS_GSM_ALL_DATA_CIRCUIT_ASYNC:
|
||||
*mask |= 1 << 5;
|
||||
break;
|
||||
|
||||
case SS_GSM_ALL_DATA_PACKET_SYNC:
|
||||
*mask |= 1 << 6;
|
||||
break;
|
||||
|
||||
case SS_GSM_ALL_PAD_ACCESS:
|
||||
*mask |= 1 << 7;
|
||||
break;
|
||||
|
||||
default:
|
||||
DBG("Unknown BSC: 0x%04X\n", bsc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static bool query_resp_cb(GIsiClient *client, const void *restrict data,
|
||||
size_t len, uint16_t object, void *opaque)
|
||||
{
|
||||
GIsiSubBlockIter iter;
|
||||
const unsigned char *msg = data;
|
||||
struct isi_cb_data *cbd = opaque;
|
||||
ofono_call_barring_query_cb_t cb = cbd->cb;
|
||||
|
||||
guint32 mask = 0;
|
||||
|
||||
if (!msg) {
|
||||
DBG("ISI client error: %d", g_isi_client_error(client));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (len < 7 || msg[0] != SS_SERVICE_COMPLETED_RESP)
|
||||
goto error;
|
||||
|
||||
if (msg[1] != SS_INTERROGATION)
|
||||
goto error;
|
||||
|
||||
for (g_isi_sb_iter_init(&iter, msg, len, 7);
|
||||
g_isi_sb_iter_is_valid(&iter);
|
||||
g_isi_sb_iter_next(&iter)) {
|
||||
|
||||
switch (g_isi_sb_iter_get_id(&iter)) {
|
||||
|
||||
case SS_STATUS_RESULT:
|
||||
break;
|
||||
|
||||
case SS_GSM_BSC_INFO: {
|
||||
|
||||
guint8 count = 0;
|
||||
guint8 i;
|
||||
|
||||
if (!g_isi_sb_iter_get_byte(&iter, &count, 2))
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
|
||||
guint8 bsc = 0;
|
||||
|
||||
if (!g_isi_sb_iter_get_byte(&iter, &bsc, 3 + i))
|
||||
goto error;
|
||||
|
||||
update_status_mask(&mask, bsc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SS_GSM_ADDITIONAL_INFO:
|
||||
break;
|
||||
|
||||
default:
|
||||
DBG("Skipping sub-block: 0x%04X (%zu bytes)",
|
||||
g_isi_sb_iter_get_id(&iter),
|
||||
g_isi_sb_iter_get_len(&iter));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DBG("mask=0x%04X\n", mask);
|
||||
CALLBACK_WITH_SUCCESS(cb, mask, cbd->data);
|
||||
goto out;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, 0, cbd->data);
|
||||
|
||||
out:
|
||||
g_free(cbd);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
static void isi_query(struct ofono_call_barring *barr, const char *lock, int cls,
|
||||
ofono_call_barring_query_cb_t cb, void *data)
|
||||
{
|
||||
struct barr_data *bd = ofono_call_barring_get_data(barr);
|
||||
struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
|
||||
int ss_code;
|
||||
|
||||
unsigned char msg[] = {
|
||||
SS_SERVICE_REQ,
|
||||
SS_INTERROGATION,
|
||||
SS_ALL_TELE_AND_BEARER,
|
||||
0, 0, /* Supplementary services code */
|
||||
SS_SEND_ADDITIONAL_INFO,
|
||||
0 /* Subblock count */
|
||||
};
|
||||
|
||||
DBG("barring query lock code %s class %d\n", lock, cls);
|
||||
|
||||
if (!cbd || cls != 7)
|
||||
goto error;
|
||||
|
||||
if (strcmp(lock, "AO") == 0)
|
||||
ss_code = SS_GSM_BARR_ALL_OUT;
|
||||
else if (strcmp(lock, "OI") == 0)
|
||||
ss_code = SS_GSM_BARR_OUT_INTER;
|
||||
else if (strcmp(lock, "OX") == 0)
|
||||
ss_code = SS_GSM_BARR_OUT_INTER_EXC_HOME;
|
||||
else if (strcmp(lock, "AI") == 0)
|
||||
ss_code = SS_GSM_BARR_ALL_IN;
|
||||
else if (strcmp(lock, "IR") == 0)
|
||||
ss_code = SS_GSM_BARR_ALL_IN_ROAM;
|
||||
else
|
||||
goto error;
|
||||
|
||||
msg[3] = ss_code >> 8;
|
||||
msg[4] = ss_code & 0xFF;
|
||||
|
||||
if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
|
||||
query_resp_cb, cbd))
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, 0, data);
|
||||
g_free(cbd);
|
||||
}
|
||||
|
||||
static bool set_passwd_resp_cb(GIsiClient *client, const void *restrict data,
|
||||
size_t len, uint16_t object, void *opaque)
|
||||
{
|
||||
const unsigned char *msg = data;
|
||||
struct isi_cb_data *cbd = opaque;
|
||||
ofono_call_barring_set_cb_t cb = cbd->cb;
|
||||
|
||||
if (!msg) {
|
||||
DBG("ISI client error: %d", g_isi_client_error(client));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (len < 3 || msg[0] != SS_SERVICE_COMPLETED_RESP)
|
||||
goto error;
|
||||
|
||||
if (msg[1] != SS_GSM_PASSWORD_REGISTRATION)
|
||||
goto error;
|
||||
|
||||
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
||||
goto out;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||
|
||||
out:
|
||||
g_free(cbd);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void isi_set_passwd(struct ofono_call_barring *barr, const char *lock,
|
||||
const char *old_passwd, const char *new_passwd,
|
||||
ofono_call_barring_set_cb_t cb, void *data)
|
||||
{
|
||||
struct barr_data *bd = ofono_call_barring_get_data(barr);
|
||||
struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
|
||||
int ss_code;
|
||||
char *ucs2 = NULL;
|
||||
|
||||
unsigned char msg[] = {
|
||||
SS_SERVICE_REQ,
|
||||
SS_GSM_PASSWORD_REGISTRATION,
|
||||
SS_ALL_TELE_AND_BEARER,
|
||||
0, 0, /* Supplementary services code */
|
||||
SS_SEND_ADDITIONAL_INFO,
|
||||
1, /* Subblock count */
|
||||
SS_GSM_PASSWORD,
|
||||
28, /* Subblock length */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* Old password */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* New password */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* New password */
|
||||
0, 0 /* Filler */
|
||||
};
|
||||
|
||||
if (!cbd || strlen(old_passwd) > 4 || strlen(new_passwd) > 4)
|
||||
goto error;
|
||||
|
||||
DBG("lock code %s old password %s new password %s\n",
|
||||
lock, old_passwd, new_passwd);
|
||||
|
||||
if (strcmp(lock, "AB") == 0)
|
||||
ss_code = SS_GSM_ALL_BARRINGS;
|
||||
else
|
||||
goto error;
|
||||
|
||||
msg[3] = ss_code >> 8;
|
||||
msg[4] = ss_code & 0xFF;
|
||||
|
||||
ucs2 = g_convert(old_passwd, 4, "UCS-2BE", "UTF-8//TRANSLIT",
|
||||
NULL, NULL, NULL);
|
||||
if (ucs2 == NULL)
|
||||
goto error;
|
||||
|
||||
memcpy((char *)msg + 9, ucs2, 8);
|
||||
g_free(ucs2);
|
||||
|
||||
ucs2 = g_convert(new_passwd, 4, "UCS-2BE", "UTF-8//TRANSLIT",
|
||||
NULL, NULL, NULL);
|
||||
if (ucs2 == NULL)
|
||||
goto error;
|
||||
|
||||
memcpy((char *)msg + 17, ucs2, 8);
|
||||
memcpy((char *)msg + 25, ucs2, 8);
|
||||
g_free(ucs2);
|
||||
|
||||
if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
|
||||
set_passwd_resp_cb, cbd))
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
g_free(cbd);
|
||||
}
|
||||
|
||||
static gboolean isi_call_barring_register(gpointer user)
|
||||
{
|
||||
struct ofono_call_barring *cb = user;
|
||||
|
||||
ofono_call_barring_register(cb);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void reachable_cb(GIsiClient *client, bool alive, void *opaque)
|
||||
{
|
||||
struct ofono_call_barring *barr = opaque;
|
||||
|
||||
if (alive == true) {
|
||||
DBG("Resource 0x%02X, with version %03d.%03d reachable",
|
||||
g_isi_client_resource(client),
|
||||
g_isi_version_major(client),
|
||||
g_isi_version_minor(client));
|
||||
g_idle_add(isi_call_barring_register, barr);
|
||||
return;
|
||||
}
|
||||
DBG("Unable to bootsrap call barring driver");
|
||||
}
|
||||
|
||||
|
||||
static int isi_call_barring_probe(struct ofono_call_barring *barr,
|
||||
unsigned int vendor, void *user)
|
||||
{
|
||||
GIsiModem *idx = user;
|
||||
struct call_barring_data *data = g_try_new0(struct call_barring_data, 1);
|
||||
struct barr_data *data = g_try_new0(struct barr_data, 1);
|
||||
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
@ -79,13 +440,15 @@ static int isi_call_barring_probe(struct ofono_call_barring *barr,
|
|||
return -ENOMEM;
|
||||
|
||||
ofono_call_barring_set_data(barr, data);
|
||||
if (!g_isi_verify(data->client, reachable_cb, barr))
|
||||
DBG("Unable to verify reachability");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void isi_call_barring_remove(struct ofono_call_barring *barr)
|
||||
{
|
||||
struct call_barring_data *data = ofono_call_barring_get_data(barr);
|
||||
struct barr_data *data = ofono_call_barring_get_data(barr);
|
||||
|
||||
if (data) {
|
||||
g_isi_client_destroy(data->client);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
*
|
||||
* Contact: Aki Niemi <aki.niemi@nokia.com>
|
||||
* Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -34,24 +34,131 @@
|
|||
#include <glib.h>
|
||||
|
||||
#include <gisi/client.h>
|
||||
#include <gisi/iter.h>
|
||||
|
||||
#include <ofono/log.h>
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/call-forwarding.h>
|
||||
|
||||
#include "isi.h"
|
||||
#include "ss.h"
|
||||
|
||||
#define PN_SS 0x06
|
||||
|
||||
struct call_forwarding_data {
|
||||
struct forw_data {
|
||||
GIsiClient *client;
|
||||
struct isi_version version;
|
||||
};
|
||||
|
||||
static void isi_activation(struct ofono_call_forwarding *cf,
|
||||
int type, int cls,
|
||||
ofono_call_forwarding_set_cb_t cb, void *data)
|
||||
static int forw_type_to_isi_code(int type)
|
||||
{
|
||||
int ss_code;
|
||||
switch (type) {
|
||||
case 0:
|
||||
ss_code = SS_GSM_FORW_UNCONDITIONAL;
|
||||
break;
|
||||
case 1:
|
||||
ss_code = SS_GSM_FORW_BUSY;
|
||||
break;
|
||||
case 2:
|
||||
ss_code = SS_GSM_FORW_NO_REPLY;
|
||||
break;
|
||||
case 3:
|
||||
ss_code = SS_GSM_FORW_NO_REACH;
|
||||
break;
|
||||
case 4:
|
||||
ss_code = SS_GSM_ALL_FORWARDINGS;
|
||||
break;
|
||||
case 5:
|
||||
ss_code = SS_GSM_ALL_COND_FORWARDINGS;
|
||||
break;
|
||||
default:
|
||||
DBG("Unknown forwarding type %d\n", type);
|
||||
ss_code = -1;
|
||||
break;
|
||||
}
|
||||
return ss_code;
|
||||
}
|
||||
|
||||
static bool registration_resp_cb(GIsiClient *client, const void *restrict data,
|
||||
size_t len, uint16_t object, void *opaque)
|
||||
{
|
||||
GIsiSubBlockIter iter;
|
||||
const unsigned char *msg = data;
|
||||
struct isi_cb_data *cbd = opaque;
|
||||
ofono_call_forwarding_set_cb_t cb = cbd->cb;
|
||||
|
||||
if (!msg) {
|
||||
DBG("ISI client error: %d", g_isi_client_error(client));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (len < 7 || msg[0] != SS_SERVICE_COMPLETED_RESP)
|
||||
goto error;
|
||||
|
||||
if (msg[1] != SS_REGISTRATION)
|
||||
goto error;
|
||||
|
||||
for (g_isi_sb_iter_init(&iter, msg, len, 7);
|
||||
g_isi_sb_iter_is_valid(&iter);
|
||||
g_isi_sb_iter_next(&iter)) {
|
||||
|
||||
switch (g_isi_sb_iter_get_id(&iter)) {
|
||||
|
||||
case SS_GSM_ADDITIONAL_INFO:
|
||||
break;
|
||||
|
||||
case SS_GSM_FORWARDING_INFO: {
|
||||
|
||||
GIsiSubBlockIter iter_fw;
|
||||
|
||||
if (g_isi_sb_iter_get_len(&iter) < 4)
|
||||
goto error;
|
||||
|
||||
for (g_isi_sb_iter_init(&iter_fw, iter.start,
|
||||
g_isi_sb_iter_get_len(&iter), 4);
|
||||
g_isi_sb_iter_is_valid(&iter_fw);
|
||||
g_isi_sb_iter_next(&iter_fw)) {
|
||||
|
||||
switch (g_isi_sb_iter_get_id(&iter_fw)) {
|
||||
|
||||
case SS_GSM_FORWARDING_FEATURE: {
|
||||
|
||||
guint8 status;
|
||||
|
||||
if (!g_isi_sb_iter_get_byte(&iter_fw,
|
||||
&status, 3))
|
||||
goto error;
|
||||
|
||||
if (!(status & SS_GSM_ACTIVE)
|
||||
|| !(status & SS_GSM_REGISTERED))
|
||||
goto error;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DBG("Skipping sub-sub-block: 0x%04X (%zu bytes)",
|
||||
g_isi_sb_iter_get_id(&iter_fw),
|
||||
g_isi_sb_iter_get_len(&iter_fw));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DBG("Skipping sub-block: 0x%04X (%zu bytes)",
|
||||
g_isi_sb_iter_get_id(&iter),
|
||||
g_isi_sb_iter_get_len(&iter));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
||||
goto out;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||
|
||||
out:
|
||||
g_free(cbd);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void isi_registration(struct ofono_call_forwarding *cf,
|
||||
|
@ -60,32 +167,384 @@ static void isi_registration(struct ofono_call_forwarding *cf,
|
|||
int time,
|
||||
ofono_call_forwarding_set_cb_t cb, void *data)
|
||||
{
|
||||
struct forw_data *fd = ofono_call_forwarding_get_data(cf);
|
||||
struct isi_cb_data *cbd = isi_cb_data_new(cf, cb, data);
|
||||
int ss_code;
|
||||
int num_filler;
|
||||
char *ucs2 = NULL;
|
||||
|
||||
unsigned char msg[100] = {
|
||||
SS_SERVICE_REQ,
|
||||
SS_REGISTRATION,
|
||||
SS_GSM_TELEPHONY,
|
||||
0, 0, /* Supplementary services code */
|
||||
SS_SEND_ADDITIONAL_INFO,
|
||||
1, /* Subblock count */
|
||||
SS_FORWARDING,
|
||||
0, /* Variable subblock length, because of phone number */
|
||||
number->type,
|
||||
time,
|
||||
strlen(number->number),
|
||||
0 /* Sub address length */
|
||||
};
|
||||
/* Followed by number in UCS-2, zero sub address bytes, and 0
|
||||
* to 3 bytes of filler */
|
||||
|
||||
DBG("forwarding type %d class %d\n", type, cls);
|
||||
|
||||
if (!cbd || !number->number || strlen(number->number) > 28)
|
||||
goto error;
|
||||
|
||||
ss_code = forw_type_to_isi_code(type);
|
||||
if (ss_code < 0)
|
||||
goto error;
|
||||
|
||||
msg[3] = ss_code >> 8;
|
||||
msg[4] = ss_code & 0xFF;
|
||||
|
||||
num_filler = (6 + 2 * strlen(number->number)) % 4;
|
||||
if (num_filler != 0)
|
||||
num_filler = 4 - num_filler;
|
||||
|
||||
msg[8] = 6 + 2 * strlen(number->number) + num_filler;
|
||||
|
||||
ucs2 = g_convert(number->number, strlen(number->number), "UCS-2BE",
|
||||
"UTF-8//TRANSLIT", NULL, NULL, NULL);
|
||||
if (ucs2 == NULL)
|
||||
goto error;
|
||||
|
||||
memcpy((char *)msg + 13, ucs2, strlen(number->number) * 2);
|
||||
g_free(ucs2);
|
||||
|
||||
if (g_isi_request_make(fd->client, msg, 7 + msg[8], SS_TIMEOUT,
|
||||
registration_resp_cb, cbd))
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
g_free(cbd);
|
||||
}
|
||||
|
||||
static void isi_deactivation(struct ofono_call_forwarding *cf,
|
||||
int type, int cls,
|
||||
ofono_call_forwarding_set_cb_t cb, void *data)
|
||||
static bool erasure_resp_cb(GIsiClient *client, const void *restrict data,
|
||||
size_t len, uint16_t object, void *opaque)
|
||||
{
|
||||
GIsiSubBlockIter iter;
|
||||
const unsigned char *msg = data;
|
||||
struct isi_cb_data *cbd = opaque;
|
||||
ofono_call_forwarding_set_cb_t cb = cbd->cb;
|
||||
|
||||
if (!msg) {
|
||||
DBG("ISI client error: %d", g_isi_client_error(client));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (len < 7 || msg[0] != SS_SERVICE_COMPLETED_RESP)
|
||||
goto error;
|
||||
|
||||
if (msg[1] != SS_ERASURE)
|
||||
goto error;
|
||||
|
||||
for (g_isi_sb_iter_init(&iter, msg, len, 7);
|
||||
g_isi_sb_iter_is_valid(&iter);
|
||||
g_isi_sb_iter_next(&iter)) {
|
||||
|
||||
switch (g_isi_sb_iter_get_id(&iter)) {
|
||||
|
||||
case SS_GSM_ADDITIONAL_INFO:
|
||||
break;
|
||||
|
||||
case SS_GSM_FORWARDING_INFO: {
|
||||
|
||||
GIsiSubBlockIter iter_fw;
|
||||
|
||||
if (g_isi_sb_iter_get_len(&iter) < 4)
|
||||
goto error;
|
||||
|
||||
for (g_isi_sb_iter_init(&iter_fw, iter.start,
|
||||
g_isi_sb_iter_get_len(&iter), 4);
|
||||
g_isi_sb_iter_is_valid(&iter_fw);
|
||||
g_isi_sb_iter_next(&iter_fw)) {
|
||||
|
||||
switch (g_isi_sb_iter_get_id(&iter_fw)) {
|
||||
|
||||
case SS_GSM_FORWARDING_FEATURE: {
|
||||
|
||||
guint8 status;
|
||||
|
||||
if (!g_isi_sb_iter_get_byte(&iter_fw,
|
||||
&status, 3))
|
||||
goto error;
|
||||
|
||||
if ((status & SS_GSM_ACTIVE)
|
||||
|| (status & SS_GSM_REGISTERED))
|
||||
goto error;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DBG("Skipping sub-sub-block: 0x%04X (%zu bytes)",
|
||||
g_isi_sb_iter_get_id(&iter_fw),
|
||||
g_isi_sb_iter_get_len(&iter_fw));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DBG("Skipping sub-block: 0x%04X (%zu bytes)",
|
||||
g_isi_sb_iter_get_id(&iter),
|
||||
g_isi_sb_iter_get_len(&iter));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
||||
goto out;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||
|
||||
out:
|
||||
g_free(cbd);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void isi_erasure(struct ofono_call_forwarding *cf, int type, int cls,
|
||||
ofono_call_forwarding_set_cb_t cb, void *data)
|
||||
{
|
||||
struct forw_data *fd = ofono_call_forwarding_get_data(cf);
|
||||
struct isi_cb_data *cbd = isi_cb_data_new(cf, cb, data);
|
||||
int ss_code;
|
||||
|
||||
unsigned char msg[] = {
|
||||
SS_SERVICE_REQ,
|
||||
SS_ERASURE,
|
||||
SS_GSM_TELEPHONY,
|
||||
0, 0, /* Supplementary services code */
|
||||
SS_SEND_ADDITIONAL_INFO,
|
||||
0 /* Subblock count */
|
||||
};
|
||||
|
||||
DBG("forwarding type %d class %d\n", type, cls);
|
||||
|
||||
if (!cbd)
|
||||
goto error;
|
||||
|
||||
ss_code = forw_type_to_isi_code(type);
|
||||
if (ss_code < 0)
|
||||
goto error;
|
||||
|
||||
msg[3] = ss_code >> 8;
|
||||
msg[4] = ss_code & 0xFF;
|
||||
|
||||
if (g_isi_request_make(fd->client, msg, sizeof(msg), SS_TIMEOUT,
|
||||
erasure_resp_cb, cbd))
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
g_free(cbd);
|
||||
}
|
||||
|
||||
static bool query_resp_cb(GIsiClient *client, const void *restrict data,
|
||||
size_t len, uint16_t object, void *opaque)
|
||||
{
|
||||
GIsiSubBlockIter iter;
|
||||
const unsigned char *msg = data;
|
||||
struct isi_cb_data *cbd = opaque;
|
||||
ofono_call_forwarding_query_cb_t cb = cbd->cb;
|
||||
|
||||
struct ofono_call_forwarding_condition list;
|
||||
list.status = 0;
|
||||
list.cls = 7;
|
||||
list.time = 0;
|
||||
list.phone_number.number[0] = 0;
|
||||
list.phone_number.type = 0;
|
||||
|
||||
if (!msg) {
|
||||
DBG("ISI client error: %d", g_isi_client_error(client));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (len < 7 || msg[0] != SS_SERVICE_COMPLETED_RESP)
|
||||
goto error;
|
||||
|
||||
if (msg[1] != SS_INTERROGATION)
|
||||
goto error;
|
||||
|
||||
for (g_isi_sb_iter_init(&iter, msg, len, 7);
|
||||
g_isi_sb_iter_is_valid(&iter);
|
||||
g_isi_sb_iter_next(&iter)) {
|
||||
|
||||
switch (g_isi_sb_iter_get_id(&iter)) {
|
||||
|
||||
case SS_STATUS_RESULT:
|
||||
break;
|
||||
|
||||
case SS_GSM_ADDITIONAL_INFO:
|
||||
break;
|
||||
|
||||
case SS_GSM_FORWARDING_INFO: {
|
||||
|
||||
GIsiSubBlockIter iter_fw;
|
||||
|
||||
if (g_isi_sb_iter_get_len(&iter) < 4)
|
||||
goto error;
|
||||
|
||||
for (g_isi_sb_iter_init(&iter_fw, iter.start,
|
||||
g_isi_sb_iter_get_len(&iter), 4);
|
||||
g_isi_sb_iter_is_valid(&iter_fw);
|
||||
g_isi_sb_iter_next(&iter_fw)) {
|
||||
|
||||
switch (g_isi_sb_iter_get_id(&iter_fw)) {
|
||||
|
||||
case SS_GSM_FORWARDING_FEATURE: {
|
||||
|
||||
guint8 status;
|
||||
guint8 ton;
|
||||
guint8 norply;
|
||||
guint8 numlen;
|
||||
char* number = NULL;
|
||||
|
||||
if (!g_isi_sb_iter_get_byte(&iter_fw,
|
||||
&status, 3))
|
||||
goto error;
|
||||
|
||||
if (!g_isi_sb_iter_get_byte(&iter_fw,
|
||||
&ton, 4))
|
||||
goto error;
|
||||
|
||||
if (!g_isi_sb_iter_get_byte(&iter_fw,
|
||||
&norply, 5))
|
||||
goto error;
|
||||
|
||||
if (!g_isi_sb_iter_get_byte(&iter_fw,
|
||||
&numlen, 7))
|
||||
goto error;
|
||||
|
||||
if (!g_isi_sb_iter_get_alpha_tag(&iter_fw,
|
||||
&number, numlen * 2, 10))
|
||||
goto error;
|
||||
|
||||
list.status = status & (SS_GSM_ACTIVE
|
||||
| SS_GSM_REGISTERED
|
||||
| SS_GSM_PROVISIONED);
|
||||
|
||||
list.time = norply;
|
||||
|
||||
strncpy(list.phone_number.number, number,
|
||||
OFONO_MAX_PHONE_NUMBER_LENGTH);
|
||||
list.phone_number.number[OFONO_MAX_PHONE_NUMBER_LENGTH] = '\0';
|
||||
g_free(number);
|
||||
|
||||
list.phone_number.type = ton | 128;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DBG("Skipping sub-sub-block: 0x%04X (%zu bytes)",
|
||||
g_isi_sb_iter_get_id(&iter_fw),
|
||||
g_isi_sb_iter_get_len(&iter_fw));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DBG("Skipping sub-block: 0x%04X (%zu bytes)",
|
||||
g_isi_sb_iter_get_id(&iter),
|
||||
g_isi_sb_iter_get_len(&iter));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DBG("forwarding query: %d, %d, %s(%d) - %d sec",
|
||||
list.status, list.cls,
|
||||
list.phone_number.number,
|
||||
list.phone_number.type, list.time);
|
||||
CALLBACK_WITH_SUCCESS(cb, 1, &list, cbd->data);
|
||||
goto out;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, 0, NULL, cbd->data);
|
||||
|
||||
out:
|
||||
g_free(cbd);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void isi_query(struct ofono_call_forwarding *cf, int type, int cls,
|
||||
ofono_call_forwarding_query_cb_t cb,
|
||||
void *data)
|
||||
{
|
||||
struct forw_data *fd = ofono_call_forwarding_get_data(cf);
|
||||
struct isi_cb_data *cbd = isi_cb_data_new(cf, cb, data);
|
||||
int ss_code;
|
||||
|
||||
unsigned char msg[] = {
|
||||
SS_SERVICE_REQ,
|
||||
SS_INTERROGATION,
|
||||
SS_GSM_TELEPHONY,
|
||||
0, 0, /* Supplementary services code */
|
||||
SS_SEND_ADDITIONAL_INFO,
|
||||
0 /* Subblock count */
|
||||
};
|
||||
|
||||
DBG("forwarding type %d class %d\n", type, cls);
|
||||
|
||||
if (!cbd || cls != 7)
|
||||
goto error;
|
||||
|
||||
ss_code = forw_type_to_isi_code(type);
|
||||
if (ss_code < 0)
|
||||
goto error;
|
||||
|
||||
msg[3] = ss_code >> 8;
|
||||
msg[4] = ss_code & 0xFF;
|
||||
|
||||
if (g_isi_request_make(fd->client, msg, sizeof(msg), SS_TIMEOUT,
|
||||
query_resp_cb, cbd))
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, 0, NULL, data);
|
||||
g_free(cbd);
|
||||
}
|
||||
|
||||
static gboolean isi_call_forwarding_register(gpointer user)
|
||||
{
|
||||
struct ofono_call_forwarding *cf = user;
|
||||
|
||||
ofono_call_forwarding_register(cf);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void reachable_cb(GIsiClient *client, bool alive, void *opaque)
|
||||
{
|
||||
struct ofono_call_forwarding *cf = opaque;
|
||||
|
||||
if (alive == true) {
|
||||
DBG("Resource 0x%02X, with version %03d.%03d reachable",
|
||||
g_isi_client_resource(client),
|
||||
g_isi_version_major(client),
|
||||
g_isi_version_minor(client));
|
||||
g_idle_add(isi_call_forwarding_register, cf);
|
||||
return;
|
||||
}
|
||||
DBG("Unable to bootsrap call forwarding driver");
|
||||
}
|
||||
|
||||
|
||||
static int isi_call_forwarding_probe(struct ofono_call_forwarding *cf,
|
||||
unsigned int vendor, void *user)
|
||||
{
|
||||
GIsiModem *idx = user;
|
||||
struct call_forwarding_data *data;
|
||||
struct forw_data *data;
|
||||
|
||||
data = g_try_new0(struct call_forwarding_data, 1);
|
||||
data = g_try_new0(struct forw_data, 1);
|
||||
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
@ -95,13 +554,15 @@ static int isi_call_forwarding_probe(struct ofono_call_forwarding *cf,
|
|||
return -ENOMEM;
|
||||
|
||||
ofono_call_forwarding_set_data(cf, data);
|
||||
if (!g_isi_verify(data->client, reachable_cb, cf))
|
||||
DBG("Unable to verify reachability");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void isi_call_forwarding_remove(struct ofono_call_forwarding *cf)
|
||||
{
|
||||
struct call_forwarding_data *data = ofono_call_forwarding_get_data(cf);
|
||||
struct forw_data *data = ofono_call_forwarding_get_data(cf);
|
||||
|
||||
if (data) {
|
||||
g_isi_client_destroy(data->client);
|
||||
|
@ -113,9 +574,9 @@ static struct ofono_call_forwarding_driver driver = {
|
|||
.name = "isimodem",
|
||||
.probe = isi_call_forwarding_probe,
|
||||
.remove = isi_call_forwarding_remove,
|
||||
.activation = isi_activation,
|
||||
.activation = NULL,
|
||||
.registration = isi_registration,
|
||||
.deactivation = isi_deactivation,
|
||||
.deactivation = NULL,
|
||||
.erasure = isi_erasure,
|
||||
.query = isi_query
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
*
|
||||
* Contact: Aki Niemi <aki.niemi@nokia.com>
|
||||
* Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -40,56 +40,276 @@
|
|||
#include <ofono/call-settings.h>
|
||||
|
||||
#include "isi.h"
|
||||
#include "ss.h"
|
||||
#include "iter.h"
|
||||
|
||||
#define PN_SS 0x06
|
||||
|
||||
struct call_settings_data {
|
||||
struct settings_data {
|
||||
GIsiClient *client;
|
||||
struct isi_version version;
|
||||
};
|
||||
|
||||
static void isi_clip_query(struct ofono_call_settings *cs,
|
||||
ofono_call_settings_status_cb_t cb, void *data)
|
||||
static void update_status_mask(unsigned int *mask, int bsc)
|
||||
{
|
||||
switch (bsc) {
|
||||
|
||||
case SS_GSM_TELEPHONY:
|
||||
*mask |= 1;
|
||||
break;
|
||||
|
||||
case SS_GSM_ALL_DATA_TELE:
|
||||
*mask |= 1 << 1;
|
||||
break;
|
||||
|
||||
case SS_GSM_FACSIMILE:
|
||||
*mask |= 1 << 2;
|
||||
break;
|
||||
|
||||
case SS_GSM_SMS:
|
||||
*mask |= 1 << 3;
|
||||
break;
|
||||
|
||||
case SS_GSM_ALL_DATA_CIRCUIT_SYNC:
|
||||
*mask |= 1 << 4;
|
||||
break;
|
||||
|
||||
case SS_GSM_ALL_DATA_CIRCUIT_ASYNC:
|
||||
*mask |= 1 << 5;
|
||||
break;
|
||||
|
||||
case SS_GSM_ALL_DATA_PACKET_SYNC:
|
||||
*mask |= 1 << 6;
|
||||
break;
|
||||
|
||||
case SS_GSM_ALL_PAD_ACCESS:
|
||||
*mask |= 1 << 7;
|
||||
break;
|
||||
|
||||
default:
|
||||
DBG("Unknown BSC value %d, please report\n", bsc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void isi_colp_query(struct ofono_call_settings *cs,
|
||||
ofono_call_settings_status_cb_t cb, void *data)
|
||||
static bool query_resp_cb(GIsiClient *client, const void *restrict data,
|
||||
size_t len, uint16_t object, void *opaque)
|
||||
{
|
||||
}
|
||||
GIsiSubBlockIter iter;
|
||||
const unsigned char *msg = data;
|
||||
struct isi_cb_data *cbd = opaque;
|
||||
ofono_call_settings_status_cb_t cb = cbd->cb;
|
||||
guint32 mask = 0;
|
||||
|
||||
static void isi_clir_query(struct ofono_call_settings *cs,
|
||||
ofono_call_settings_clir_cb_t cb, void *data)
|
||||
{
|
||||
}
|
||||
if (!msg) {
|
||||
DBG("ISI client error: %d", g_isi_client_error(client));
|
||||
goto error;
|
||||
}
|
||||
|
||||
static void isi_colr_query(struct ofono_call_settings *cs,
|
||||
ofono_call_settings_status_cb_t cb, void *data)
|
||||
{
|
||||
}
|
||||
if (len < 7 || msg[0] != SS_SERVICE_COMPLETED_RESP)
|
||||
goto error;
|
||||
|
||||
if (msg[1] != SS_INTERROGATION)
|
||||
goto error;
|
||||
|
||||
for (g_isi_sb_iter_init(&iter, msg, len, 7);
|
||||
g_isi_sb_iter_is_valid(&iter);
|
||||
g_isi_sb_iter_next(&iter)) {
|
||||
|
||||
switch (g_isi_sb_iter_get_id(&iter)) {
|
||||
|
||||
case SS_STATUS_RESULT:
|
||||
break;
|
||||
|
||||
case SS_GSM_ADDITIONAL_INFO:
|
||||
break;
|
||||
|
||||
case SS_GSM_BSC_INFO: {
|
||||
|
||||
guint8 bsc;
|
||||
guint8 count;
|
||||
guint8 i;
|
||||
|
||||
if (!g_isi_sb_iter_get_byte(&iter, &count, 2))
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (!g_isi_sb_iter_get_byte(&iter, &bsc, 3 + i))
|
||||
goto error;
|
||||
update_status_mask(&mask, bsc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DBG("Skipping sub-block: 0x%04X (%zu bytes)",
|
||||
g_isi_sb_iter_get_id(&iter),
|
||||
g_isi_sb_iter_get_len(&iter));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DBG("status_mask %d\n", mask);
|
||||
CALLBACK_WITH_SUCCESS(cb, mask, cbd->data);
|
||||
goto out;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, 0, cbd->data);
|
||||
|
||||
out:
|
||||
g_free(cbd);
|
||||
return true;
|
||||
|
||||
static void isi_clir_set(struct ofono_call_settings *cs, int mode,
|
||||
ofono_call_settings_set_cb_t cb, void *data)
|
||||
{
|
||||
}
|
||||
|
||||
static void isi_cw_query(struct ofono_call_settings *cs, int cls,
|
||||
ofono_call_settings_status_cb_t cb, void *data)
|
||||
{
|
||||
struct settings_data *sd = ofono_call_settings_get_data(cs);
|
||||
struct isi_cb_data *cbd = isi_cb_data_new(cs, cb, data);
|
||||
|
||||
unsigned char msg[] = {
|
||||
SS_SERVICE_REQ,
|
||||
SS_INTERROGATION,
|
||||
SS_ALL_TELE_AND_BEARER,
|
||||
SS_GSM_CALL_WAITING >> 8, /* Supplementary services */
|
||||
SS_GSM_CALL_WAITING & 0xFF, /* code */
|
||||
SS_SEND_ADDITIONAL_INFO,
|
||||
0 /* Subblock count */
|
||||
};
|
||||
|
||||
DBG("waiting class %d\n", cls);
|
||||
|
||||
if (!cbd)
|
||||
goto error;
|
||||
|
||||
if (g_isi_request_make(sd->client, msg, sizeof(msg), SS_TIMEOUT,
|
||||
query_resp_cb, cbd))
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, 0, data);
|
||||
g_free(cbd);
|
||||
}
|
||||
|
||||
static bool set_resp_cb(GIsiClient *client, const void *restrict data,
|
||||
size_t len, uint16_t object, void *opaque)
|
||||
{
|
||||
GIsiSubBlockIter iter;
|
||||
const unsigned char *msg = data;
|
||||
struct isi_cb_data *cbd = opaque;
|
||||
ofono_call_settings_set_cb_t cb = cbd->cb;
|
||||
|
||||
if (len < 7 || msg[0] != SS_SERVICE_COMPLETED_RESP)
|
||||
goto error;
|
||||
|
||||
if (msg[1] != SS_ACTIVATION && msg[1] != SS_DEACTIVATION)
|
||||
goto error;
|
||||
|
||||
for (g_isi_sb_iter_init(&iter, msg, len, 7);
|
||||
g_isi_sb_iter_is_valid(&iter);
|
||||
g_isi_sb_iter_next(&iter)) {
|
||||
|
||||
switch (g_isi_sb_iter_get_id(&iter)) {
|
||||
|
||||
case SS_GSM_ADDITIONAL_INFO:
|
||||
break;
|
||||
|
||||
case SS_GSM_DATA: {
|
||||
|
||||
guint8 status;
|
||||
|
||||
if (!g_isi_sb_iter_get_byte(&iter, &status, 2))
|
||||
goto error;
|
||||
|
||||
if ((status & SS_GSM_ACTIVE)
|
||||
&& (msg[1] == SS_DEACTIVATION))
|
||||
goto error;
|
||||
|
||||
if (!(status & SS_GSM_ACTIVE)
|
||||
&& (msg[1] == SS_ACTIVATION))
|
||||
goto error;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DBG("Skipping sub-block: 0x%04X (%zu bytes)",
|
||||
g_isi_sb_iter_get_id(&iter),
|
||||
g_isi_sb_iter_get_len(&iter));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
||||
goto out;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||
|
||||
out:
|
||||
g_free(cbd);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
static void isi_cw_set(struct ofono_call_settings *cs, int mode, int cls,
|
||||
ofono_call_settings_set_cb_t cb, void *data)
|
||||
{
|
||||
struct settings_data *sd = ofono_call_settings_get_data(cs);
|
||||
struct isi_cb_data *cbd = isi_cb_data_new(cs, cb, data);
|
||||
|
||||
unsigned char msg[] = {
|
||||
SS_SERVICE_REQ,
|
||||
mode ? SS_ACTIVATION : SS_DEACTIVATION,
|
||||
SS_ALL_TELE_AND_BEARER,
|
||||
SS_GSM_CALL_WAITING >> 8, /* Supplementary services */
|
||||
SS_GSM_CALL_WAITING & 0xFF, /* code */
|
||||
SS_SEND_ADDITIONAL_INFO,
|
||||
0 /* Subblock count */
|
||||
};
|
||||
|
||||
DBG("waiting mode %d class %d\n", mode, cls);
|
||||
|
||||
if (!cbd)
|
||||
goto error;
|
||||
|
||||
if (g_isi_request_make(sd->client, msg, sizeof(msg), SS_TIMEOUT,
|
||||
set_resp_cb, cbd))
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
g_free(cbd);
|
||||
}
|
||||
|
||||
static gboolean isi_call_settings_register(gpointer user)
|
||||
{
|
||||
struct ofono_call_settings *cs = user;
|
||||
|
||||
ofono_call_settings_register(cs);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void reachable_cb(GIsiClient *client, bool alive, void *opaque)
|
||||
{
|
||||
struct ofono_call_settings *cs = opaque;
|
||||
|
||||
if (alive == true) {
|
||||
DBG("Resource 0x%02X, with version %03d.%03d reachable",
|
||||
g_isi_client_resource(client),
|
||||
g_isi_version_major(client),
|
||||
g_isi_version_minor(client));
|
||||
g_idle_add(isi_call_settings_register, cs);
|
||||
return;
|
||||
}
|
||||
DBG("Unable to bootsrap call settings driver");
|
||||
}
|
||||
|
||||
|
||||
static int isi_call_settings_probe(struct ofono_call_settings *cs, unsigned int vendor,
|
||||
void *user)
|
||||
{
|
||||
GIsiModem *idx = user;
|
||||
struct call_settings_data *data;
|
||||
struct settings_data *data;
|
||||
|
||||
data = g_try_new0(struct call_settings_data, 1);
|
||||
data = g_try_new0(struct settings_data, 1);
|
||||
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
@ -100,13 +320,15 @@ static int isi_call_settings_probe(struct ofono_call_settings *cs, unsigned int
|
|||
return -ENOMEM;
|
||||
|
||||
ofono_call_settings_set_data(cs, data);
|
||||
if (!g_isi_verify(data->client, reachable_cb, cs))
|
||||
DBG("Unable to verify reachability");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void isi_call_settings_remove(struct ofono_call_settings *cs)
|
||||
{
|
||||
struct call_settings_data *data = ofono_call_settings_get_data(cs);
|
||||
struct settings_data *data = ofono_call_settings_get_data(cs);
|
||||
|
||||
if (data) {
|
||||
g_isi_client_destroy(data->client);
|
||||
|
@ -118,11 +340,11 @@ static struct ofono_call_settings_driver driver = {
|
|||
.name = "isimodem",
|
||||
.probe = isi_call_settings_probe,
|
||||
.remove = isi_call_settings_remove,
|
||||
.clip_query = isi_clip_query,
|
||||
.colp_query = isi_colp_query,
|
||||
.clir_query = isi_clir_query,
|
||||
.colr_query = isi_colr_query,
|
||||
.clir_set = isi_clir_set,
|
||||
.clip_query = NULL,
|
||||
.colp_query = NULL,
|
||||
.clir_query = NULL,
|
||||
.colr_query = NULL,
|
||||
.clir_set = NULL,
|
||||
.cw_query = isi_cw_query,
|
||||
.cw_set = isi_cw_set
|
||||
};
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* This file is part of oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
*
|
||||
* Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ISIMODEM_SS_H
|
||||
#define __ISIMODEM_SS_H
|
||||
|
||||
#define PN_SS 0x06
|
||||
#define SS_TIMEOUT 15
|
||||
|
||||
enum ss_message_id {
|
||||
SS_SERVICE_REQ = 0x00,
|
||||
SS_SERVICE_COMPLETED_RESP = 0x01,
|
||||
SS_SERVICE_FAILED_RESP = 0x02
|
||||
};
|
||||
|
||||
enum ss_operations {
|
||||
SS_ACTIVATION = 0x01,
|
||||
SS_DEACTIVATION = 0x02,
|
||||
SS_REGISTRATION = 0x03,
|
||||
SS_ERASURE = 0x04,
|
||||
SS_INTERROGATION = 0x05,
|
||||
SS_GSM_PASSWORD_REGISTRATION = 0x06
|
||||
};
|
||||
|
||||
enum ss_basic_service_codes {
|
||||
SS_ALL_TELE_AND_BEARER = 0x00,
|
||||
SS_GSM_ALL_TELE = 0x0A,
|
||||
SS_GSM_TELEPHONY = 0x0B,
|
||||
SS_GSM_ALL_DATA_TELE = 0x0C,
|
||||
SS_GSM_FACSIMILE = 0x0D,
|
||||
SS_GSM_SMS = 0x10,
|
||||
SS_GSM_VOICE_GROUP = 0x11,
|
||||
SS_GSM_ALL_TELE_EXC_SMS = 0x13,
|
||||
SS_GSM_ALL_BEARER = 0x14,
|
||||
SS_GSM_ALL_ASYNC = 0x15,
|
||||
SS_GSM_ALL_SYNC = 0x16,
|
||||
SS_GSM_ALL_DATA_CIRCUIT_SYNC = 0x18,
|
||||
SS_GSM_ALL_DATA_CIRCUIT_ASYNC = 0x19,
|
||||
SS_GSM_ALL_DATA_PACKET_SYNC = 0x1A,
|
||||
SS_GSM_ALL_PAD_ACCESS = 0x1B
|
||||
};
|
||||
|
||||
enum ss_codes {
|
||||
SS_GSM_ALL_FORWARDINGS = 0x02,
|
||||
SS_GSM_ALL_COND_FORWARDINGS = 0x04,
|
||||
SS_GSM_FORW_UNCONDITIONAL = 0x15,
|
||||
SS_GSM_BARR_ALL_OUT = 0x21,
|
||||
SS_GSM_BARR_ALL_IN = 0x23,
|
||||
SS_GSM_CALL_WAITING = 0x2B,
|
||||
SS_GSM_FORW_NO_REPLY = 0x3D,
|
||||
SS_GSM_FORW_NO_REACH = 0x3E,
|
||||
SS_GSM_FORW_BUSY = 0x43,
|
||||
SS_GSM_ALL_BARRINGS = 0x014A,
|
||||
SS_GSM_BARR_OUT_INTER = 0x014B,
|
||||
SS_GSM_BARR_OUT_INTER_EXC_HOME = 0x014C,
|
||||
SS_GSM_BARR_ALL_IN_ROAM = 0x015F
|
||||
};
|
||||
|
||||
enum ss_response_data {
|
||||
SS_SEND_ADDITIONAL_INFO = 0x01
|
||||
};
|
||||
|
||||
enum ss_sub_block_id {
|
||||
SS_FORWARDING = 0x00,
|
||||
SS_STATUS_RESULT = 0x01,
|
||||
SS_GSM_PASSWORD = 0x03,
|
||||
SS_GSM_FORWARDING_INFO = 0x04,
|
||||
SS_GSM_FORWARDING_FEATURE = 0x05,
|
||||
SS_GSM_DATA = 0x08,
|
||||
SS_GSM_BSC_INFO = 0x09,
|
||||
SS_GSM_PASSWORD_INFO = 0x0B,
|
||||
SS_GSM_INDICATE_PASSWORD_ERROR = 0x0D,
|
||||
SS_GSM_INDICATE_ERROR = 0x0E,
|
||||
SS_GSM_ADDITIONAL_INFO = 0x2F
|
||||
};
|
||||
|
||||
enum ss_status_codes {
|
||||
SS_GSM_ACTIVE = 0x01,
|
||||
SS_GSM_REGISTERED = 0x02,
|
||||
SS_GSM_PROVISIONED = 0x04,
|
||||
SS_GSM_QUIESCENT = 0x08
|
||||
};
|
||||
|
||||
#endif /* __ISIMODEM_SS_H */
|
Loading…
Reference in New Issue