2009-08-24 12:47:17 +00:00
|
|
|
/*
|
|
|
|
*
|
2010-10-14 07:50:08 +00:00
|
|
|
* oFono - Open Source Telephony
|
2009-08-24 12:47:17 +00:00
|
|
|
*
|
2010-10-14 07:50:08 +00:00
|
|
|
* Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
2009-08-24 12:47:17 +00:00
|
|
|
*
|
2010-10-14 07:50:08 +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.
|
2009-08-24 12:47:17 +00:00
|
|
|
*
|
2010-10-14 07:50:08 +00:00
|
|
|
* 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
|
2009-08-24 12:47:17 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <gisi/client.h>
|
2010-11-14 16:31:54 +00:00
|
|
|
#include <gisi/message.h>
|
2009-10-08 15:44:44 +00:00
|
|
|
#include <gisi/iter.h>
|
2009-08-24 12:47:17 +00:00
|
|
|
|
|
|
|
#include <ofono/log.h>
|
|
|
|
#include <ofono/modem.h>
|
|
|
|
#include <ofono/call-barring.h>
|
2009-10-08 15:44:44 +00:00
|
|
|
#include "util.h"
|
2009-08-24 12:47:17 +00:00
|
|
|
|
2010-01-08 08:57:01 +00:00
|
|
|
#include "isimodem.h"
|
|
|
|
#include "isiutil.h"
|
2009-10-08 15:44:44 +00:00
|
|
|
#include "ss.h"
|
2010-01-12 11:18:03 +00:00
|
|
|
#include "debug.h"
|
2009-08-24 12:47:17 +00:00
|
|
|
|
2009-10-08 15:44:44 +00:00
|
|
|
struct barr_data {
|
2009-08-24 12:47:17 +00:00
|
|
|
GIsiClient *client;
|
|
|
|
};
|
|
|
|
|
2011-03-03 11:25:10 +00:00
|
|
|
static int lock_code_to_mmi(const char *lock)
|
2010-03-29 18:17:51 +00:00
|
|
|
{
|
|
|
|
if (strcmp(lock, "AO") == 0)
|
|
|
|
return SS_GSM_BARR_ALL_OUT;
|
|
|
|
else if (strcmp(lock, "OI") == 0)
|
|
|
|
return SS_GSM_BARR_OUT_INTER;
|
|
|
|
else if (strcmp(lock, "OX") == 0)
|
|
|
|
return SS_GSM_BARR_OUT_INTER_EXC_HOME;
|
|
|
|
else if (strcmp(lock, "AI") == 0)
|
|
|
|
return SS_GSM_BARR_ALL_IN;
|
|
|
|
else if (strcmp(lock, "IR") == 0)
|
|
|
|
return SS_GSM_BARR_ALL_IN_ROAM;
|
|
|
|
else if (strcmp(lock, "AB") == 0)
|
|
|
|
return SS_GSM_ALL_BARRINGS;
|
|
|
|
else if (strcmp(lock, "AG") == 0)
|
|
|
|
return SS_GSM_OUTGOING_BARR_SERV;
|
|
|
|
else if (strcmp(lock, "AC") == 0)
|
|
|
|
return SS_GSM_INCOMING_BARR_SERV;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
static void update_status_mask(uint32_t *mask, uint8_t bsc)
|
2009-10-08 15:44:44 +00:00
|
|
|
{
|
2011-03-03 08:46:23 +00:00
|
|
|
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", bsc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean check_resp(const GIsiMessage *msg, uint8_t msgid, uint8_t type)
|
|
|
|
{
|
|
|
|
uint8_t service;
|
|
|
|
|
2010-11-14 16:31:54 +00:00
|
|
|
if (g_isi_msg_error(msg) < 0) {
|
2011-03-03 08:46:23 +00:00
|
|
|
DBG("Error: %s", g_isi_msg_strerror(msg));
|
2010-11-14 16:31:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_isi_msg_id(msg) != msgid) {
|
|
|
|
DBG("Unexpected msg: %s",
|
|
|
|
ss_message_id_name(g_isi_msg_id(msg)));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-03-03 08:46:23 +00:00
|
|
|
|
|
|
|
if (!g_isi_msg_data_get_byte(msg, 0, &service) || service != type) {
|
|
|
|
DBG("Unexpected service type: 0x%02X", service);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-11-14 16:31:54 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
static gboolean decode_gsm_bsc_info(GIsiSubBlockIter *iter, uint32_t *mask)
|
2010-11-14 16:31:54 +00:00
|
|
|
{
|
2011-03-03 08:46:23 +00:00
|
|
|
uint8_t *bsc;
|
|
|
|
uint8_t num, i;
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
if (!g_isi_sb_iter_get_byte(iter, &num, 2))
|
|
|
|
return FALSE;
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
if (!g_isi_sb_iter_get_struct(iter, (void **) &bsc, num, 3))
|
|
|
|
return FALSE;
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
update_status_mask(mask, bsc[i]);
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
static gboolean decode_gsm_barring_info(GIsiSubBlockIter *outer, uint32_t *mask)
|
|
|
|
{
|
|
|
|
GIsiSubBlockIter iter;
|
|
|
|
uint8_t status;
|
|
|
|
uint8_t bsc;
|
|
|
|
|
|
|
|
for (g_isi_sb_subiter_init(outer, &iter, 4);
|
|
|
|
g_isi_sb_iter_is_valid(&iter);
|
|
|
|
g_isi_sb_iter_next(&iter)) {
|
|
|
|
|
|
|
|
if (g_isi_sb_iter_get_id(&iter) != SS_GSM_BARRING_FEATURE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!g_isi_sb_iter_get_byte(&iter, &bsc, 2))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!g_isi_sb_iter_get_byte(&iter, &status, 3))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (status & SS_GSM_ACTIVE)
|
|
|
|
update_status_mask(mask, bsc);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2009-10-08 15:44:44 +00:00
|
|
|
}
|
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
static void unset_resp_cb(const GIsiMessage *msg, void *data)
|
|
|
|
{
|
|
|
|
struct isi_cb_data *cbd = data;
|
|
|
|
ofono_call_barring_set_cb_t cb = cbd->cb;
|
|
|
|
|
|
|
|
if (check_resp(msg, SS_SERVICE_COMPLETED_RESP, SS_DEACTIVATION))
|
|
|
|
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
|
|
|
else
|
|
|
|
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_resp_cb(const GIsiMessage *msg, void *data)
|
|
|
|
{
|
|
|
|
struct isi_cb_data *cbd = data;
|
|
|
|
ofono_call_barring_set_cb_t cb = cbd->cb;
|
|
|
|
|
|
|
|
if (check_resp(msg, SS_SERVICE_COMPLETED_RESP, SS_ACTIVATION))
|
|
|
|
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
|
|
|
else
|
|
|
|
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
|
|
|
}
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2009-08-24 12:47:17 +00:00
|
|
|
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)
|
|
|
|
{
|
2009-10-08 15:44:44 +00:00
|
|
|
struct barr_data *bd = ofono_call_barring_get_data(barr);
|
|
|
|
struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
|
2010-03-29 18:17:51 +00:00
|
|
|
int ss_code = lock_code_to_mmi(lock);
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2010-11-14 16:31:54 +00:00
|
|
|
const uint8_t msg[] = {
|
2009-10-08 15:44:44 +00:00
|
|
|
SS_SERVICE_REQ,
|
|
|
|
enable ? SS_ACTIVATION : SS_DEACTIVATION,
|
|
|
|
SS_ALL_TELE_AND_BEARER,
|
2010-04-24 01:58:01 +00:00
|
|
|
ss_code >> 8, ss_code & 0xFF, /* Service code */
|
|
|
|
SS_SEND_ADDITIONAL_INFO,
|
|
|
|
1, /* Subblock count */
|
2009-10-08 15:44:44 +00:00
|
|
|
SS_GSM_PASSWORD,
|
2010-04-24 01:58:01 +00:00
|
|
|
28, /* Subblock length */
|
|
|
|
0, passwd[0], 0, passwd[1],
|
2010-03-29 18:17:51 +00:00
|
|
|
0, passwd[2], 0, passwd[3],
|
2010-04-24 01:58:01 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, /* Filler */
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, /* Filler */
|
2011-03-03 08:46:23 +00:00
|
|
|
0, 0, /* Filler */
|
2009-10-08 15:44:44 +00:00
|
|
|
};
|
|
|
|
|
2010-11-25 10:51:03 +00:00
|
|
|
DBG("lock code %s enable %d class %d password %s",
|
2009-10-08 15:44:44 +00:00
|
|
|
lock, enable, cls, passwd);
|
|
|
|
|
2010-11-27 19:38:56 +00:00
|
|
|
if (cbd == NULL || bd == NULL)
|
2010-10-19 08:28:06 +00:00
|
|
|
goto error;
|
|
|
|
|
2011-01-04 15:48:33 +00:00
|
|
|
if (g_isi_client_send(bd->client, msg, sizeof(msg),
|
2011-03-03 08:46:23 +00:00
|
|
|
enable ? set_resp_cb : unset_resp_cb,
|
|
|
|
cbd, g_free))
|
2009-10-08 15:44:44 +00:00
|
|
|
return;
|
2010-03-29 18:17:51 +00:00
|
|
|
|
2010-10-19 08:28:06 +00:00
|
|
|
error:
|
2009-10-08 15:44:44 +00:00
|
|
|
CALLBACK_WITH_FAILURE(cb, data);
|
|
|
|
g_free(cbd);
|
|
|
|
}
|
|
|
|
|
2010-11-14 16:31:54 +00:00
|
|
|
static void query_resp_cb(const GIsiMessage *msg, void *data)
|
2009-10-08 15:44:44 +00:00
|
|
|
{
|
2010-11-14 16:31:54 +00:00
|
|
|
struct isi_cb_data *cbd = data;
|
2009-10-08 15:44:44 +00:00
|
|
|
ofono_call_barring_query_cb_t cb = cbd->cb;
|
2010-11-14 16:31:54 +00:00
|
|
|
GIsiSubBlockIter iter;
|
|
|
|
uint32_t mask = 0;
|
2011-03-03 08:46:23 +00:00
|
|
|
uint8_t status;
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
if (!check_resp(msg, SS_SERVICE_COMPLETED_RESP, SS_INTERROGATION))
|
2010-11-14 16:31:54 +00:00
|
|
|
goto error;
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2010-11-14 16:31:54 +00:00
|
|
|
for (g_isi_sb_iter_init(&iter, msg, 6);
|
|
|
|
g_isi_sb_iter_is_valid(&iter);
|
|
|
|
g_isi_sb_iter_next(&iter)) {
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2011-02-23 11:43:23 +00:00
|
|
|
switch (g_isi_sb_iter_get_id(&iter)) {
|
2011-03-03 08:46:23 +00:00
|
|
|
case SS_STATUS_RESULT:
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
if (!g_isi_sb_iter_get_byte(&iter, &status, 2))
|
2011-02-23 11:43:23 +00:00
|
|
|
goto error;
|
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
if (status & SS_GSM_ACTIVE)
|
2011-02-23 11:43:23 +00:00
|
|
|
mask = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
case SS_GSM_BARRING_INFO:
|
2011-02-23 11:43:23 +00:00
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
if (!decode_gsm_barring_info(&iter, &mask))
|
2011-02-23 11:43:23 +00:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
case SS_GSM_BSC_INFO:
|
2011-02-23 11:43:23 +00:00
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
if (!decode_gsm_bsc_info(&iter, &mask))
|
2009-10-08 15:44:44 +00:00
|
|
|
goto error;
|
|
|
|
|
2011-02-23 11:43:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SS_GSM_ADDITIONAL_INFO:
|
|
|
|
break;
|
|
|
|
|
2009-10-08 15:44:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-25 10:51:03 +00:00
|
|
|
DBG("mask=0x%04X", mask);
|
2009-10-08 15:44:44 +00:00
|
|
|
CALLBACK_WITH_SUCCESS(cb, mask, cbd->data);
|
2010-11-14 16:31:54 +00:00
|
|
|
return;
|
2009-10-08 15:44:44 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
CALLBACK_WITH_FAILURE(cb, 0, cbd->data);
|
2009-08-24 12:47:17 +00:00
|
|
|
}
|
|
|
|
|
2010-04-24 01:58:01 +00:00
|
|
|
static void isi_query(struct ofono_call_barring *barr, const char *lock,
|
|
|
|
int cls, ofono_call_barring_query_cb_t cb, void *data)
|
2009-08-24 12:47:17 +00:00
|
|
|
{
|
2009-10-08 15:44:44 +00:00
|
|
|
struct barr_data *bd = ofono_call_barring_get_data(barr);
|
|
|
|
struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
|
2010-03-29 18:17:51 +00:00
|
|
|
int ss_code = lock_code_to_mmi(lock);
|
2009-10-08 15:44:44 +00:00
|
|
|
|
|
|
|
unsigned char msg[] = {
|
|
|
|
SS_SERVICE_REQ,
|
|
|
|
SS_INTERROGATION,
|
|
|
|
SS_ALL_TELE_AND_BEARER,
|
2010-04-24 01:58:01 +00:00
|
|
|
ss_code >> 8, ss_code & 0xFF, /* services code */
|
|
|
|
SS_SEND_ADDITIONAL_INFO, /* Get BER-encoded result */
|
2009-10-08 15:44:44 +00:00
|
|
|
0 /* Subblock count */
|
|
|
|
};
|
|
|
|
|
2010-11-25 10:51:03 +00:00
|
|
|
DBG("barring query lock code %s", lock);
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2010-11-27 19:38:56 +00:00
|
|
|
if (cbd == NULL || bd == NULL)
|
2010-10-19 08:28:06 +00:00
|
|
|
goto error;
|
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
if (g_isi_client_send(bd->client, msg, sizeof(msg), query_resp_cb,
|
|
|
|
cbd, g_free))
|
2009-10-08 15:44:44 +00:00
|
|
|
return;
|
|
|
|
|
2010-10-19 08:28:06 +00:00
|
|
|
error:
|
2009-10-08 15:44:44 +00:00
|
|
|
CALLBACK_WITH_FAILURE(cb, 0, data);
|
|
|
|
g_free(cbd);
|
|
|
|
}
|
|
|
|
|
2010-11-14 16:31:54 +00:00
|
|
|
static void set_passwd_resp_cb(const GIsiMessage *msg, void *data)
|
2009-10-08 15:44:44 +00:00
|
|
|
{
|
2010-11-14 16:31:54 +00:00
|
|
|
struct isi_cb_data *cbd = data;
|
2009-10-08 15:44:44 +00:00
|
|
|
ofono_call_barring_set_cb_t cb = cbd->cb;
|
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
if (check_resp(msg, SS_SERVICE_COMPLETED_RESP,
|
|
|
|
SS_GSM_PASSWORD_REGISTRATION))
|
|
|
|
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
|
|
|
else
|
|
|
|
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
2009-08-24 12:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2009-10-08 15:44:44 +00:00
|
|
|
struct barr_data *bd = ofono_call_barring_get_data(barr);
|
|
|
|
struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
|
2010-03-29 18:17:51 +00:00
|
|
|
int ss_code = lock_code_to_mmi(lock);
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2010-11-14 16:31:54 +00:00
|
|
|
const uint8_t msg[] = {
|
2009-10-08 15:44:44 +00:00
|
|
|
SS_SERVICE_REQ,
|
|
|
|
SS_GSM_PASSWORD_REGISTRATION,
|
|
|
|
SS_ALL_TELE_AND_BEARER,
|
2010-04-24 01:58:01 +00:00
|
|
|
ss_code >> 8, ss_code & 0xFF, /* Service code */
|
2009-10-08 15:44:44 +00:00
|
|
|
SS_SEND_ADDITIONAL_INFO,
|
|
|
|
1, /* Subblock count */
|
|
|
|
SS_GSM_PASSWORD,
|
|
|
|
28, /* Subblock length */
|
2010-03-29 18:17:51 +00:00
|
|
|
0, old_passwd[0], 0, old_passwd[1],
|
|
|
|
0, old_passwd[2], 0, old_passwd[3],
|
|
|
|
0, new_passwd[0], 0, new_passwd[1],
|
|
|
|
0, new_passwd[2], 0, new_passwd[3],
|
|
|
|
0, new_passwd[0], 0, new_passwd[1],
|
|
|
|
0, new_passwd[2], 0, new_passwd[3],
|
2011-03-03 08:46:23 +00:00
|
|
|
0, 0, /* Filler */
|
2009-10-08 15:44:44 +00:00
|
|
|
};
|
|
|
|
|
2010-11-25 10:51:03 +00:00
|
|
|
DBG("lock code %s (%u) old password %s new password %s",
|
2010-03-29 18:17:51 +00:00
|
|
|
lock, ss_code, old_passwd, new_passwd);
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2010-11-27 19:38:56 +00:00
|
|
|
if (cbd == NULL || bd == NULL)
|
2010-10-19 08:28:06 +00:00
|
|
|
goto error;
|
|
|
|
|
2011-03-03 08:46:23 +00:00
|
|
|
if (g_isi_client_send(bd->client, msg, sizeof(msg), set_passwd_resp_cb,
|
|
|
|
cbd, g_free))
|
2009-10-08 15:44:44 +00:00
|
|
|
return;
|
|
|
|
|
2010-10-19 08:28:06 +00:00
|
|
|
error:
|
2009-10-08 15:44:44 +00:00
|
|
|
CALLBACK_WITH_FAILURE(cb, data);
|
|
|
|
g_free(cbd);
|
|
|
|
}
|
|
|
|
|
2010-11-14 16:31:54 +00:00
|
|
|
static void reachable_cb(const GIsiMessage *msg, void *data)
|
2009-10-08 15:44:44 +00:00
|
|
|
{
|
2010-11-14 16:31:54 +00:00
|
|
|
struct ofono_call_barring *barr = data;
|
2009-10-08 15:44:44 +00:00
|
|
|
|
2011-03-31 08:28:53 +00:00
|
|
|
if (g_isi_msg_error(msg) < 0) {
|
|
|
|
ofono_call_barring_remove(barr);
|
2009-10-08 15:44:44 +00:00
|
|
|
return;
|
2011-03-31 08:28:53 +00:00
|
|
|
}
|
2010-01-12 11:18:03 +00:00
|
|
|
|
2011-04-11 15:02:35 +00:00
|
|
|
ISI_RESOURCE_DBG(msg);
|
2010-01-12 11:18:03 +00:00
|
|
|
|
2010-11-14 16:31:54 +00:00
|
|
|
ofono_call_barring_register(barr);
|
2009-08-24 12:47:17 +00:00
|
|
|
}
|
|
|
|
|
2009-09-02 02:39:02 +00:00
|
|
|
static int isi_call_barring_probe(struct ofono_call_barring *barr,
|
|
|
|
unsigned int vendor, void *user)
|
2009-08-24 12:47:17 +00:00
|
|
|
{
|
2010-11-14 16:31:54 +00:00
|
|
|
GIsiModem *modem = user;
|
|
|
|
struct barr_data *bd;
|
2009-08-24 12:47:17 +00:00
|
|
|
|
2010-11-14 16:31:54 +00:00
|
|
|
bd = g_try_new0(struct barr_data, 1);
|
|
|
|
if (bd == NULL)
|
2009-08-24 12:47:17 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2010-11-14 16:31:54 +00:00
|
|
|
bd->client = g_isi_client_create(modem, PN_SS);
|
|
|
|
if (bd->client == NULL) {
|
|
|
|
g_free(bd);
|
2009-08-24 12:47:17 +00:00
|
|
|
return -ENOMEM;
|
2010-11-14 16:31:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ofono_call_barring_set_data(barr, bd);
|
2009-08-24 12:47:17 +00:00
|
|
|
|
2010-11-14 16:31:54 +00:00
|
|
|
g_isi_client_verify(bd->client, reachable_cb, barr, NULL);
|
2009-08-24 12:47:17 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-09-02 03:27:08 +00:00
|
|
|
static void isi_call_barring_remove(struct ofono_call_barring *barr)
|
2009-08-24 12:47:17 +00:00
|
|
|
{
|
2009-10-08 15:44:44 +00:00
|
|
|
struct barr_data *data = ofono_call_barring_get_data(barr);
|
2009-08-24 12:47:17 +00:00
|
|
|
|
2010-11-14 16:31:54 +00:00
|
|
|
ofono_call_barring_set_data(barr, NULL);
|
|
|
|
|
2010-11-27 19:38:56 +00:00
|
|
|
if (data == NULL)
|
2010-04-27 12:10:55 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
g_isi_client_destroy(data->client);
|
|
|
|
g_free(data);
|
2009-08-24 12:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct ofono_call_barring_driver driver = {
|
2009-09-02 03:35:14 +00:00
|
|
|
.name = "isimodem",
|
2009-08-24 12:47:17 +00:00
|
|
|
.probe = isi_call_barring_probe,
|
|
|
|
.remove = isi_call_barring_remove,
|
|
|
|
.set = isi_set,
|
|
|
|
.query = isi_query,
|
|
|
|
.set_passwd = isi_set_passwd
|
|
|
|
};
|
|
|
|
|
2011-01-12 10:52:14 +00:00
|
|
|
void isi_call_barring_init(void)
|
2009-08-24 12:47:17 +00:00
|
|
|
{
|
|
|
|
ofono_call_barring_driver_register(&driver);
|
|
|
|
}
|
|
|
|
|
2011-01-12 10:52:14 +00:00
|
|
|
void isi_call_barring_exit(void)
|
2009-08-24 12:47:17 +00:00
|
|
|
{
|
|
|
|
ofono_call_barring_driver_unregister(&driver);
|
|
|
|
}
|