forked from sailfishos/ofono
Compare commits
12 Commits
mer/1.23+g
...
mer/1.19+g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b098ad0d5c | ||
|
|
b018b49e91 | ||
|
|
9031009858 | ||
|
|
48cbd95277 | ||
|
|
883b7d7b6c | ||
|
|
137600e58e | ||
|
|
d9b386a8a9 | ||
|
|
a78b7818e9 | ||
|
|
d00b999cf6 | ||
|
|
476243be6a | ||
|
|
adca340f4b | ||
|
|
709bb7e596 |
@@ -593,11 +593,20 @@ builtin_modules += nettime
|
||||
builtin_sources += plugins/nettime.c
|
||||
endif
|
||||
|
||||
if SAILFISH_PROVISION
|
||||
builtin_sources += plugins/sailfish_provision.c
|
||||
PROVISION = 1
|
||||
else
|
||||
if PROVISION
|
||||
builtin_sources += plugins/provision.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if PROVISION
|
||||
builtin_sources += plugins/mbpi.h plugins/mbpi.c
|
||||
|
||||
builtin_modules += provision
|
||||
builtin_sources += plugins/provision.h plugins/provision.c
|
||||
builtin_sources += plugins/provision.h
|
||||
|
||||
builtin_modules += cdma_provision
|
||||
builtin_sources += plugins/cdma-provision.c
|
||||
@@ -920,9 +929,9 @@ unit_test_caif_LDADD = @GLIB_LIBS@
|
||||
unit_objects += $(unit_test_caif_OBJECTS)
|
||||
|
||||
unit_test_provision_SOURCES = unit/test-provision.c \
|
||||
plugins/provision.h plugins/provision.c \
|
||||
plugins/mbpi.c src/gprs-provision.c \
|
||||
src/log.c
|
||||
plugins/provision.h plugins/mbpi.c \
|
||||
plugins/sailfish_provision.c \
|
||||
src/gprs-provision.c src/log.c
|
||||
unit_test_provision_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_provision_OBJECTS)
|
||||
|
||||
|
||||
@@ -217,6 +217,11 @@ AC_ARG_ENABLE(sailfishos, AC_HELP_STRING([--enable-sailfishos],
|
||||
[enable sailfishos plugin]), [enable_sailfishos=${enableval}])
|
||||
AM_CONDITIONAL(SAILFISHFOS, test "${enable_sailfishos}" = "yes")
|
||||
|
||||
AC_ARG_ENABLE(sailfish-provision, AC_HELP_STRING([--enable-sailfish-provision],
|
||||
[enable Sailfish OS provisioning plugin]),
|
||||
[enable_sailfish_provision=${enableval}])
|
||||
AM_CONDITIONAL(SAILFISH_PROVISION, test "${enable_sailfish_provision=$}" = "yes")
|
||||
|
||||
AC_ARG_ENABLE(nettime, AC_HELP_STRING([--disable-nettime],
|
||||
[disable Nettime plugin]),
|
||||
[enable_nettime=${enableval}])
|
||||
|
||||
@@ -247,6 +247,8 @@ static void at_gprs_activate_primary(struct ofono_gprs_context *gc,
|
||||
|
||||
/* We only support CHAP and PAP */
|
||||
switch (ctx->auth_method) {
|
||||
case OFONO_GPRS_AUTH_METHOD_ANY:
|
||||
case OFONO_GPRS_AUTH_METHOD_NONE:
|
||||
case OFONO_GPRS_AUTH_METHOD_CHAP:
|
||||
gcd->auth_method = G_AT_PPP_AUTH_METHOD_CHAP;
|
||||
break;
|
||||
@@ -294,6 +296,8 @@ static void at_gprs_activate_primary(struct ofono_gprs_context *gc,
|
||||
* prefix, this is the least invasive place to set it.
|
||||
*/
|
||||
switch (ctx->auth_method) {
|
||||
case OFONO_GPRS_AUTH_METHOD_ANY:
|
||||
case OFONO_GPRS_AUTH_METHOD_NONE:
|
||||
case OFONO_GPRS_AUTH_METHOD_CHAP:
|
||||
snprintf(buf + len, sizeof(buf) - len - 3,
|
||||
",\"CHAP:%s\"", ctx->apn);
|
||||
|
||||
@@ -788,7 +788,7 @@ static gboolean ril_data_call_setup_submit(struct ril_data_request *req)
|
||||
struct ril_data_priv *priv = req->data->priv;
|
||||
const char *proto_str = ril_data_ofono_protocol_to_ril(setup->proto);
|
||||
GRilIoRequest* ioreq;
|
||||
int tech, auth;
|
||||
int tech, auth = RIL_AUTH_NONE;
|
||||
|
||||
GASSERT(proto_str);
|
||||
|
||||
@@ -811,14 +811,22 @@ static gboolean ril_data_call_setup_submit(struct ril_data_request *req)
|
||||
tech = RADIO_TECH_HSPA;
|
||||
}
|
||||
|
||||
/*
|
||||
* We do the same as in $AOSP/frameworks/opt/telephony/src/java/com/
|
||||
* android/internal/telephony/dataconnection/DataConnection.java,
|
||||
* onConnect(), and use authentication or not depending on whether
|
||||
* the user field is empty or not.
|
||||
*/
|
||||
auth = (setup->username && setup->username[0]) ?
|
||||
RIL_AUTH_BOTH : RIL_AUTH_NONE;
|
||||
if (setup->username && setup->username[0]) {
|
||||
switch (setup->auth_method) {
|
||||
case OFONO_GPRS_AUTH_METHOD_ANY:
|
||||
auth = RIL_AUTH_BOTH;
|
||||
break;
|
||||
case OFONO_GPRS_AUTH_METHOD_NONE:
|
||||
auth = RIL_AUTH_NONE;
|
||||
break;
|
||||
case OFONO_GPRS_AUTH_METHOD_CHAP:
|
||||
auth = RIL_AUTH_CHAP;
|
||||
break;
|
||||
case OFONO_GPRS_AUTH_METHOD_PAP:
|
||||
auth = RIL_AUTH_PAP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: add comments about tethering, other non-public
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2016 Jolla Ltd.
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -17,16 +17,24 @@
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include <gutil_idlequeue.h>
|
||||
|
||||
/*
|
||||
* TODO: No public RIL api to query manufacturer or model.
|
||||
* Check where to get, could /system/build.prop be updated to have good values?
|
||||
*/
|
||||
|
||||
enum ril_devinfo_cb_tag {
|
||||
DEVINFO_QUERY_SERIAL = 1,
|
||||
DEVINFO_QUERY_SVN
|
||||
};
|
||||
|
||||
struct ril_devinfo {
|
||||
struct ofono_devinfo *info;
|
||||
GRilIoQueue *q;
|
||||
guint register_id;
|
||||
guint imei_id;
|
||||
GUtilIdleQueue *iq;
|
||||
char *log_prefix;
|
||||
char *imeisv;
|
||||
char *imei;
|
||||
};
|
||||
|
||||
@@ -36,6 +44,7 @@ struct ril_devinfo_cbd {
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
#define DBG_(self,fmt,args...) DBG("%s" fmt, (self)->log_prefix, ##args)
|
||||
#define ril_devinfo_cbd_free g_free
|
||||
|
||||
static inline struct ril_devinfo *ril_devinfo_get_data(
|
||||
@@ -62,7 +71,7 @@ static void ril_devinfo_query_unsupported(struct ofono_devinfo *info,
|
||||
cb(ril_error_failure(&error), "", data);
|
||||
}
|
||||
|
||||
static void ril_devinfo_query_cb(GRilIoChannel *io, int status,
|
||||
static void ril_devinfo_query_revision_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
@@ -73,7 +82,7 @@ static void ril_devinfo_query_cb(GRilIoChannel *io, int status,
|
||||
GRilIoParser rilp;
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
res = grilio_parser_get_utf8(&rilp);
|
||||
DBG("%s", res);
|
||||
DBG_(cbd->di, "%s", res);
|
||||
cbd->cb(ril_error_ok(&error), res ? res : "", cbd->data);
|
||||
g_free(res);
|
||||
} else {
|
||||
@@ -86,23 +95,46 @@ static void ril_devinfo_query_revision(struct ofono_devinfo *info,
|
||||
{
|
||||
struct ril_devinfo *di = ril_devinfo_get_data(info);
|
||||
|
||||
DBG("");
|
||||
grilio_queue_send_request_full(di->q, NULL, RIL_REQUEST_BASEBAND_VERSION,
|
||||
ril_devinfo_query_cb, ril_devinfo_cbd_free,
|
||||
DBG_(di, "");
|
||||
grilio_queue_send_request_full(di->q, NULL,
|
||||
RIL_REQUEST_BASEBAND_VERSION,
|
||||
ril_devinfo_query_revision_cb,
|
||||
ril_devinfo_cbd_free,
|
||||
ril_devinfo_cbd_new(di, cb, data));
|
||||
}
|
||||
|
||||
static gboolean ril_devinfo_query_serial_cb(void *user_data)
|
||||
static void ril_devinfo_query_serial_cb(gpointer user_data)
|
||||
{
|
||||
struct ril_devinfo_cbd *cbd = user_data;
|
||||
struct ril_devinfo *di = cbd->di;
|
||||
struct ofono_error error;
|
||||
|
||||
GASSERT(di->imei_id);
|
||||
di->imei_id = 0;
|
||||
|
||||
DBG_(di, "%s", di->imei);
|
||||
cbd->cb(ril_error_ok(&error), di->imei, cbd->data);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void ril_devinfo_query_svn_cb(gpointer user_data)
|
||||
{
|
||||
struct ril_devinfo_cbd *cbd = user_data;
|
||||
struct ril_devinfo *di = cbd->di;
|
||||
struct ofono_error error;
|
||||
|
||||
DBG_(di, "%s", di->imeisv);
|
||||
if (di->imeisv && di->imeisv[0]) {
|
||||
cbd->cb(ril_error_ok(&error), di->imeisv, cbd->data);
|
||||
} else {
|
||||
cbd->cb(ril_error_failure(&error), "", cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_devinfo_query(struct ril_devinfo *di,
|
||||
enum ril_devinfo_cb_tag tag, GUtilIdleFunc fn,
|
||||
ofono_devinfo_query_cb_t cb, void *data)
|
||||
{
|
||||
GVERIFY_FALSE(gutil_idle_queue_cancel_tag(di->iq, tag));
|
||||
gutil_idle_queue_add_tag_full(di->iq, tag, fn,
|
||||
ril_devinfo_cbd_new(di, cb, data),
|
||||
ril_devinfo_cbd_free);
|
||||
}
|
||||
|
||||
static void ril_devinfo_query_serial(struct ofono_devinfo *info,
|
||||
@@ -111,29 +143,28 @@ static void ril_devinfo_query_serial(struct ofono_devinfo *info,
|
||||
{
|
||||
struct ril_devinfo *di = ril_devinfo_get_data(info);
|
||||
|
||||
GASSERT(!di->imei_id);
|
||||
if (di->imei_id) {
|
||||
g_source_remove(di->imei_id);
|
||||
di->imei_id = 0;
|
||||
}
|
||||
|
||||
DBG("%s", di->imei);
|
||||
di->imei_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
|
||||
ril_devinfo_query_serial_cb,
|
||||
ril_devinfo_cbd_new(di, cb, data),
|
||||
ril_devinfo_cbd_free);
|
||||
DBG_(di, "");
|
||||
ril_devinfo_query(di, DEVINFO_QUERY_SERIAL,
|
||||
ril_devinfo_query_serial_cb, cb, data);
|
||||
}
|
||||
|
||||
static gboolean ril_devinfo_register(gpointer user_data)
|
||||
static void ril_devinfo_query_svn(struct ofono_devinfo *info,
|
||||
ofono_devinfo_query_cb_t cb,
|
||||
void *data)
|
||||
{
|
||||
struct ril_devinfo *di = ril_devinfo_get_data(info);
|
||||
|
||||
DBG_(di, "");
|
||||
ril_devinfo_query(di, DEVINFO_QUERY_SVN,
|
||||
ril_devinfo_query_svn_cb, cb, data);
|
||||
}
|
||||
|
||||
static void ril_devinfo_register(gpointer user_data)
|
||||
{
|
||||
struct ril_devinfo *di = user_data;
|
||||
|
||||
DBG("");
|
||||
di->register_id = 0;
|
||||
DBG_(di, "");
|
||||
ofono_devinfo_register(di->info);
|
||||
|
||||
/* This makes the timeout a single-shot */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int ril_devinfo_probe(struct ofono_devinfo *info, unsigned int vendor,
|
||||
@@ -142,13 +173,18 @@ static int ril_devinfo_probe(struct ofono_devinfo *info, unsigned int vendor,
|
||||
struct ril_modem *modem = data;
|
||||
struct ril_devinfo *di = g_new0(struct ril_devinfo, 1);
|
||||
|
||||
DBG("%s %s %p", ril_modem_get_path(modem), modem->imei, di);
|
||||
di->log_prefix = (modem->log_prefix && modem->log_prefix[0]) ?
|
||||
g_strconcat(modem->log_prefix, " ", NULL) : g_strdup("");
|
||||
|
||||
DBG_(di, "%s", modem->imei);
|
||||
GASSERT(modem->imei);
|
||||
|
||||
di->q = grilio_queue_new(ril_modem_io(modem));
|
||||
di->info = info;
|
||||
di->imeisv = g_strdup(modem->imeisv);
|
||||
di->imei = g_strdup(modem->imei);
|
||||
|
||||
di->register_id = g_idle_add(ril_devinfo_register, di);
|
||||
di->iq = gutil_idle_queue_new();
|
||||
gutil_idle_queue_add(di->iq, ril_devinfo_register, di);
|
||||
ofono_devinfo_set_data(info, di);
|
||||
return 0;
|
||||
}
|
||||
@@ -157,19 +193,14 @@ static void ril_devinfo_remove(struct ofono_devinfo *info)
|
||||
{
|
||||
struct ril_devinfo *di = ril_devinfo_get_data(info);
|
||||
|
||||
DBG("%p", di);
|
||||
DBG_(di, "");
|
||||
ofono_devinfo_set_data(info, NULL);
|
||||
|
||||
if (di->register_id > 0) {
|
||||
g_source_remove(di->register_id);
|
||||
}
|
||||
|
||||
if (di->imei_id > 0) {
|
||||
g_source_remove(di->imei_id);
|
||||
}
|
||||
|
||||
gutil_idle_queue_cancel_all(di->iq);
|
||||
gutil_idle_queue_unref(di->iq);
|
||||
grilio_queue_cancel_all(di->q, FALSE);
|
||||
grilio_queue_unref(di->q);
|
||||
g_free(di->log_prefix);
|
||||
g_free(di->imeisv);
|
||||
g_free(di->imei);
|
||||
g_free(di);
|
||||
}
|
||||
@@ -178,10 +209,11 @@ const struct ofono_devinfo_driver ril_devinfo_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_devinfo_probe,
|
||||
.remove = ril_devinfo_remove,
|
||||
.query_manufacturer = ril_devinfo_query_unsupported,
|
||||
/* query_revision won't be called if query_model is missing */
|
||||
.query_model = ril_devinfo_query_unsupported,
|
||||
.query_revision = ril_devinfo_query_revision,
|
||||
.query_serial = ril_devinfo_query_serial
|
||||
.query_serial = ril_devinfo_query_serial,
|
||||
.query_svn = ril_devinfo_query_svn
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2016 Jolla Ltd.
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -52,6 +52,7 @@ struct ril_modem_data {
|
||||
struct ril_modem modem;
|
||||
GRilIoQueue *q;
|
||||
char *log_prefix;
|
||||
char *imeisv;
|
||||
char *imei;
|
||||
char *ecclist_file;
|
||||
gboolean pre_sim_done;
|
||||
@@ -433,6 +434,7 @@ static void ril_modem_remove(struct ofono_modem *ofono)
|
||||
grilio_queue_unref(md->q);
|
||||
g_free(md->ecclist_file);
|
||||
g_free(md->log_prefix);
|
||||
g_free(md->imeisv);
|
||||
g_free(md->imei);
|
||||
g_free(md);
|
||||
}
|
||||
@@ -460,6 +462,7 @@ struct ril_modem *ril_modem_create(GRilIoChannel *io, const char *log_prefix,
|
||||
/* Copy config */
|
||||
modem->config = *slot->config;
|
||||
modem->imei = md->imei = g_strdup(slot->imei);
|
||||
modem->imeisv = md->imeisv = g_strdup(slot->imeisv);
|
||||
modem->log_prefix = log_prefix;
|
||||
modem->ecclist_file =
|
||||
md->ecclist_file = g_strdup(slot->ecclist_file);
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
#include "ofono.h"
|
||||
#include "storage.h"
|
||||
|
||||
#define RIL_DEVICE_IDENTITY_RETRIES_LAST 2
|
||||
|
||||
#define RADIO_GID 1001
|
||||
#define RADIO_UID 1001
|
||||
#define RIL_SUB_SIZE 4
|
||||
@@ -130,6 +132,7 @@ struct ril_slot {
|
||||
struct ril_slot_info pub;
|
||||
char *path;
|
||||
char *imei;
|
||||
char *imeisv;
|
||||
char *name;
|
||||
char *sockpath;
|
||||
char *sub;
|
||||
@@ -157,6 +160,7 @@ struct ril_slot {
|
||||
gulong io_event_id[IO_EVENT_COUNT];
|
||||
gulong imei_req_id;
|
||||
gulong sim_card_state_event_id;
|
||||
gboolean received_sim_status;
|
||||
guint trace_id;
|
||||
guint dump_id;
|
||||
guint retry_id;
|
||||
@@ -175,6 +179,7 @@ static void ril_debug_grilio_notify(struct ofono_debug_desc *desc);
|
||||
static void ril_debug_mce_notify(struct ofono_debug_desc *desc);
|
||||
static void ril_plugin_debug_notify(struct ofono_debug_desc *desc);
|
||||
static void ril_plugin_retry_init_io(struct ril_slot *slot);
|
||||
static void ril_plugin_check_modem(struct ril_slot *slot);
|
||||
|
||||
GLOG_MODULE_DEFINE("rilmodem");
|
||||
|
||||
@@ -247,7 +252,7 @@ static void ril_plugin_foreach_slot(struct ril_plugin_priv *plugin,
|
||||
|
||||
static void ril_plugin_send_screen_state(struct ril_slot *slot)
|
||||
{
|
||||
if (slot->io) {
|
||||
if (slot->io && slot->io->connected) {
|
||||
GRilIoRequest *req = grilio_request_sized_new(8);
|
||||
grilio_request_append_int32(req, 1); /* Number of params */
|
||||
grilio_request_append_int32(req, slot->plugin->display_on);
|
||||
@@ -353,6 +358,7 @@ static void ril_plugin_shutdown_slot(struct ril_slot *slot, gboolean kill_io)
|
||||
ril_sim_card_unref(slot->sim_card);
|
||||
slot->sim_card_state_event_id = 0;
|
||||
slot->sim_card = NULL;
|
||||
slot->received_sim_status = FALSE;
|
||||
}
|
||||
|
||||
if (slot->io) {
|
||||
@@ -484,14 +490,23 @@ static int ril_plugin_update_modem_paths(struct ril_plugin_priv *plugin)
|
||||
if (plugin->default_data_imsi) {
|
||||
slot = ril_plugin_find_slot_imsi(plugin->slots,
|
||||
plugin->default_data_imsi);
|
||||
} else if (plugin->data_slot) {
|
||||
/* Make sure that the slot is enabled and SIM is in */
|
||||
slot = ril_plugin_find_slot_imsi(plugin->slots,
|
||||
} else if (!ril_plugin_multisim(plugin)) {
|
||||
if (plugin->data_slot) {
|
||||
/* Make sure that the slot is enabled and SIM is in */
|
||||
slot = ril_plugin_find_slot_imsi(plugin->slots,
|
||||
plugin->data_slot->modem ?
|
||||
ofono_sim_get_imsi(plugin->data_slot->sim) :
|
||||
NULL);
|
||||
} else {
|
||||
/* Check if anything is available */
|
||||
slot = ril_plugin_find_slot_imsi(plugin->slots, NULL);
|
||||
}
|
||||
} else {
|
||||
slot = ril_plugin_find_slot_imsi(plugin->slots, NULL);
|
||||
/*
|
||||
* Should we automatically select the default data sim
|
||||
* on a multisim phone that has only one sim inserted?
|
||||
*/
|
||||
slot = NULL;
|
||||
}
|
||||
|
||||
if (slot && !slot->radio->online) {
|
||||
@@ -583,14 +598,79 @@ static void ril_plugin_update_ready(struct ril_plugin_priv *plugin)
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_plugin_device_identity_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_slot *slot = user_data;
|
||||
char *imei = NULL;
|
||||
char *imeisv = NULL;
|
||||
|
||||
GASSERT(slot->imei_req_id);
|
||||
slot->imei_req_id = 0;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
GRilIoParser rilp;
|
||||
guint32 n;
|
||||
|
||||
/*
|
||||
* RIL_REQUEST_DEVICE_IDENTITY
|
||||
*
|
||||
* "response" is const char **
|
||||
* ((const char **)response)[0] is IMEI (for GSM)
|
||||
* ((const char **)response)[1] is IMEISV (for GSM)
|
||||
* ((const char **)response)[2] is ESN (for CDMA)
|
||||
* ((const char **)response)[3] is MEID (for CDMA)
|
||||
*/
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
if (grilio_parser_get_uint32(&rilp, &n) && n >= 2) {
|
||||
imei = grilio_parser_get_utf8(&rilp);
|
||||
imeisv = grilio_parser_get_utf8(&rilp);
|
||||
DBG("%s %s", imei, imeisv);
|
||||
} else {
|
||||
DBG("parsing failure!");
|
||||
}
|
||||
|
||||
/*
|
||||
* slot->imei should be either NULL (when we get connected
|
||||
* to rild the very first time) or match the already known
|
||||
* IMEI (if rild crashed and we have reconnected)
|
||||
*/
|
||||
if (slot->imei && imei && strcmp(slot->imei, imei)) {
|
||||
ofono_warn("IMEI has changed \"%s\" -> \"%s\"",
|
||||
slot->imei, imei);
|
||||
}
|
||||
} else {
|
||||
ofono_error("Slot %u IMEI query error: %s", slot->config.slot,
|
||||
ril_error_to_string(status));
|
||||
}
|
||||
|
||||
if (slot->imei) {
|
||||
/* We assume that IMEI never changes */
|
||||
g_free(imei);
|
||||
} else {
|
||||
slot->pub.imei =
|
||||
slot->imei = imei ? imei : g_strdup_printf("%d", slot->index);
|
||||
}
|
||||
|
||||
if (slot->imeisv) {
|
||||
g_free(imeisv);
|
||||
} else {
|
||||
slot->pub.imeisv =
|
||||
slot->imeisv = (imeisv ? imeisv : g_strdup(""));
|
||||
}
|
||||
|
||||
ril_plugin_check_modem(slot);
|
||||
ril_plugin_update_ready(slot->plugin);
|
||||
}
|
||||
|
||||
static void ril_plugin_sim_state_changed(struct ril_sim_card *card, void *data)
|
||||
{
|
||||
struct ril_slot *slot = data;
|
||||
struct ril_plugin_priv *plugin = slot->plugin;
|
||||
const struct ril_sim_card_status *status = card->status;
|
||||
gboolean present;
|
||||
|
||||
if (card && card->status &&
|
||||
card->status->card_state == RIL_CARDSTATE_PRESENT) {
|
||||
if (status && status->card_state == RIL_CARDSTATE_PRESENT) {
|
||||
DBG("SIM found in slot %u", slot->config.slot);
|
||||
present = TRUE;
|
||||
} else {
|
||||
@@ -598,6 +678,36 @@ static void ril_plugin_sim_state_changed(struct ril_sim_card *card, void *data)
|
||||
present = FALSE;
|
||||
}
|
||||
|
||||
if (status) {
|
||||
if (!slot->received_sim_status && slot->imei_req_id) {
|
||||
/*
|
||||
* We have received the SIM status but haven't yet
|
||||
* got IMEI from the modem. Some RILs behave this
|
||||
* way if the modem doesn't have IMEI initialized
|
||||
* yet. Cancel the current request (with unlimited
|
||||
* number of retries) and give a few more tries
|
||||
* (this time, limited number).
|
||||
*
|
||||
* Some RILs fail RIL_REQUEST_DEVICE_IDENTITY until
|
||||
* the modem hasn't been properly initialized.
|
||||
*/
|
||||
GRilIoRequest* req = grilio_request_new();
|
||||
|
||||
DBG("Giving slot %u last chance", slot->config.slot);
|
||||
grilio_request_set_retry(req, RIL_RETRY_MS,
|
||||
RIL_DEVICE_IDENTITY_RETRIES_LAST);
|
||||
grilio_channel_cancel_request(slot->io,
|
||||
slot->imei_req_id, FALSE);
|
||||
slot->imei_req_id =
|
||||
grilio_channel_send_request_full(slot->io,
|
||||
req, RIL_REQUEST_DEVICE_IDENTITY,
|
||||
ril_plugin_device_identity_cb,
|
||||
NULL, slot);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
slot->received_sim_status = TRUE;
|
||||
}
|
||||
|
||||
if (slot->pub.sim_present != present) {
|
||||
slot->pub.sim_present = present;
|
||||
ril_plugin_dbus_signal_sim(plugin->dbus, slot->index, present);
|
||||
@@ -912,42 +1022,6 @@ static void ril_plugin_check_modem(struct ril_slot *slot)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void ril_plugin_imei_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_slot *slot = user_data;
|
||||
char *imei = NULL;
|
||||
|
||||
GASSERT(slot->imei_req_id);
|
||||
slot->imei_req_id = 0;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
GRilIoParser rilp;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
imei = grilio_parser_get_utf8(&rilp);
|
||||
|
||||
DBG("%s", imei);
|
||||
|
||||
/*
|
||||
* slot->imei should be either NULL (when we get connected
|
||||
* to rild the very first time) or match the already known
|
||||
* IMEI (if rild crashed and we have reconnected)
|
||||
*/
|
||||
GASSERT(!slot->imei || !g_strcmp0(slot->imei, imei));
|
||||
} else {
|
||||
ofono_error("Slot %u IMEI query error: %s", slot->config.slot,
|
||||
ril_error_to_string(status));
|
||||
}
|
||||
|
||||
g_free(slot->imei);
|
||||
slot->pub.imei = slot->imei = (imei ? imei : g_strdup("ERROR"));
|
||||
|
||||
ril_plugin_check_modem(slot);
|
||||
ril_plugin_update_ready(slot->plugin);
|
||||
}
|
||||
|
||||
/*
|
||||
* It seems to be necessary to kick (with RIL_REQUEST_RADIO_POWER) the
|
||||
* modems with power on after one of the modems has been powered off.
|
||||
@@ -983,17 +1057,19 @@ static void ril_plugin_slot_connected(struct ril_slot *slot)
|
||||
GASSERT(!slot->io_event_id[IO_EVENT_CONNECTED]);
|
||||
|
||||
/*
|
||||
* Modem will be registered after RIL_REQUEST_GET_IMEI successfully
|
||||
* completes. By the time ofono starts, rild may not be completely
|
||||
* functional. Waiting until it responds to RIL_REQUEST_GET_IMEI
|
||||
* (and retrying the request on failure) gives rild time to finish
|
||||
* whatever it's doing during initialization.
|
||||
* Modem will be registered after RIL_REQUEST_DEVICE_IDENTITY
|
||||
* successfully completes. By the time ofono starts, rild may
|
||||
* not be completely functional. Waiting until it responds to
|
||||
* RIL_REQUEST_DEVICE_IDENTITY (and retrying the request on
|
||||
* failure) gives rild time to finish whatever it's doing during
|
||||
* initialization.
|
||||
*/
|
||||
GASSERT(!slot->imei_req_id);
|
||||
req = grilio_request_new();
|
||||
grilio_request_set_retry(req, RIL_RETRY_MS, -1);
|
||||
slot->imei_req_id = grilio_channel_send_request_full(slot->io, req,
|
||||
RIL_REQUEST_GET_IMEI, ril_plugin_imei_cb, NULL, slot);
|
||||
slot->imei_req_id = grilio_channel_send_request_full(slot->io,
|
||||
req, RIL_REQUEST_DEVICE_IDENTITY,
|
||||
ril_plugin_device_identity_cb, NULL, slot);
|
||||
grilio_request_unref(req);
|
||||
|
||||
GASSERT(!slot->radio);
|
||||
@@ -1010,6 +1086,10 @@ static void ril_plugin_slot_connected(struct ril_slot *slot)
|
||||
slot->sim_flags);
|
||||
slot->sim_card_state_event_id = ril_sim_card_add_state_changed_handler(
|
||||
slot->sim_card, ril_plugin_sim_state_changed, slot);
|
||||
/* ril_sim_card is expected to perform RIL_REQUEST_GET_SIM_STATUS
|
||||
* asynchronously and report back when request has completed: */
|
||||
GASSERT(!slot->sim_card->status);
|
||||
GASSERT(!slot->received_sim_status);
|
||||
|
||||
GASSERT(!slot->network);
|
||||
slot->network = ril_network_new(slot->io, log_prefix, slot->radio,
|
||||
@@ -1318,6 +1398,7 @@ static void ril_plugin_delete_slot(struct ril_slot *slot)
|
||||
g_hash_table_destroy(slot->pub.errors);
|
||||
g_free(slot->path);
|
||||
g_free(slot->imei);
|
||||
g_free(slot->imeisv);
|
||||
g_free(slot->name);
|
||||
g_free(slot->sockpath);
|
||||
g_free(slot->sub);
|
||||
|
||||
@@ -48,6 +48,7 @@ typedef struct ril_slot_info const *ril_slot_info_ptr;
|
||||
struct ril_slot_info {
|
||||
const char *path;
|
||||
const char *imei;
|
||||
const char *imeisv;
|
||||
const char *ecclist_file;
|
||||
gboolean enabled;
|
||||
gboolean sim_present;
|
||||
@@ -69,6 +70,7 @@ struct ril_plugin {
|
||||
struct ril_modem {
|
||||
GRilIoChannel *io;
|
||||
const char *imei;
|
||||
const char *imeisv;
|
||||
const char *log_prefix;
|
||||
const char *ecclist_file;
|
||||
struct ofono_modem *ofono;
|
||||
|
||||
@@ -46,7 +46,7 @@ struct ril_plugin_dbus {
|
||||
|
||||
#define RIL_DBUS_PATH "/"
|
||||
#define RIL_DBUS_INTERFACE "org.nemomobile.ofono.ModemManager"
|
||||
#define RIL_DBUS_INTERFACE_VERSION (6)
|
||||
#define RIL_DBUS_INTERFACE_VERSION (7)
|
||||
|
||||
#define RIL_DBUS_SIGNAL_ENABLED_MODEMS_CHANGED "EnabledModemsChanged"
|
||||
#define RIL_DBUS_SIGNAL_PRESENT_SIMS_CHANGED "PresentSimsChanged"
|
||||
@@ -77,6 +77,11 @@ static const char *ril_plugin_dbus_imei(const struct ril_slot_info *slot)
|
||||
return slot->imei;
|
||||
}
|
||||
|
||||
static const char *ril_plugin_dbus_imeisv(const struct ril_slot_info *slot)
|
||||
{
|
||||
return slot->imeisv;
|
||||
}
|
||||
|
||||
static void ril_plugin_dbus_append_path_array(DBusMessageIter *it,
|
||||
struct ril_plugin_dbus *dbus, ril_plugin_dbus_slot_select_fn selector)
|
||||
{
|
||||
@@ -440,6 +445,13 @@ static void ril_plugin_dbus_append_all6(DBusMessageIter *it,
|
||||
ril_plugin_dbus_append_modem_errors(it, dbus);
|
||||
}
|
||||
|
||||
static void ril_plugin_dbus_append_all7(DBusMessageIter *it,
|
||||
struct ril_plugin_dbus *dbus)
|
||||
{
|
||||
ril_plugin_dbus_append_all6(it, dbus);
|
||||
ril_plugin_dbus_append_string_array(it, dbus, ril_plugin_dbus_imeisv);
|
||||
}
|
||||
|
||||
static DBusMessage *ril_plugin_dbus_get_all(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
@@ -482,6 +494,13 @@ static DBusMessage *ril_plugin_dbus_get_all6(DBusConnection *conn,
|
||||
ril_plugin_dbus_append_all6);
|
||||
}
|
||||
|
||||
static DBusMessage *ril_plugin_dbus_get_all7(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
return ril_plugin_dbus_imei_reply(msg, (struct ril_plugin_dbus *)data,
|
||||
ril_plugin_dbus_append_all7);
|
||||
}
|
||||
|
||||
static DBusMessage *ril_plugin_dbus_get_interface_version(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
@@ -529,6 +548,19 @@ static DBusMessage *ril_plugin_dbus_get_imei(DBusConnection *conn,
|
||||
ril_plugin_dbus_append_imei_array);
|
||||
}
|
||||
|
||||
static void ril_plugin_dbus_append_imeisv_array(DBusMessageIter *it,
|
||||
struct ril_plugin_dbus *dbus)
|
||||
{
|
||||
ril_plugin_dbus_append_string_array(it, dbus, ril_plugin_dbus_imeisv);
|
||||
}
|
||||
|
||||
static DBusMessage *ril_plugin_dbus_get_imeisv(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
return ril_plugin_dbus_imei_reply(msg, (struct ril_plugin_dbus *)data,
|
||||
ril_plugin_dbus_append_imeisv_array);
|
||||
}
|
||||
|
||||
static DBusMessage *ril_plugin_dbus_reply_with_string(DBusMessage *msg,
|
||||
const char *str)
|
||||
{
|
||||
@@ -790,6 +822,7 @@ static DBusMessage *ril_plugin_dbus_set_mms_sim(DBusConnection *conn,
|
||||
#define RIL_DBUS_READY_ARG {"ready" , "b"}
|
||||
#define RIL_DBUS_MODEM_ERRORS_ARG {"errors" , \
|
||||
"aa(" RIL_DBUS_ERROR_SIGNATURE ")"}
|
||||
#define RIL_DBUS_IMEISV_ARG {"imeisv" , "as"}
|
||||
#define RIL_DBUS_GET_ALL_ARGS \
|
||||
RIL_DBUS_VERSION_ARG, \
|
||||
RIL_DBUS_AVAILABLE_MODEMS_ARG, \
|
||||
@@ -814,6 +847,9 @@ static DBusMessage *ril_plugin_dbus_set_mms_sim(DBusConnection *conn,
|
||||
#define RIL_DBUS_GET_ALL6_ARGS \
|
||||
RIL_DBUS_GET_ALL5_ARGS, \
|
||||
RIL_DBUS_MODEM_ERRORS_ARG
|
||||
#define RIL_DBUS_GET_ALL7_ARGS \
|
||||
RIL_DBUS_GET_ALL6_ARGS, \
|
||||
RIL_DBUS_IMEISV_ARG
|
||||
static const GDBusMethodTable ril_plugin_dbus_methods[] = {
|
||||
{ GDBUS_METHOD("GetAll",
|
||||
NULL, GDBUS_ARGS(RIL_DBUS_GET_ALL_ARGS),
|
||||
@@ -833,6 +869,9 @@ static const GDBusMethodTable ril_plugin_dbus_methods[] = {
|
||||
{ GDBUS_ASYNC_METHOD("GetAll6",
|
||||
NULL, GDBUS_ARGS(RIL_DBUS_GET_ALL6_ARGS),
|
||||
ril_plugin_dbus_get_all6) },
|
||||
{ GDBUS_ASYNC_METHOD("GetAll7",
|
||||
NULL, GDBUS_ARGS(RIL_DBUS_GET_ALL7_ARGS),
|
||||
ril_plugin_dbus_get_all7) },
|
||||
{ GDBUS_METHOD("GetInterfaceVersion",
|
||||
NULL, GDBUS_ARGS(RIL_DBUS_VERSION_ARG),
|
||||
ril_plugin_dbus_get_interface_version) },
|
||||
@@ -848,6 +887,9 @@ static const GDBusMethodTable ril_plugin_dbus_methods[] = {
|
||||
{ GDBUS_ASYNC_METHOD("GetIMEI",
|
||||
NULL, GDBUS_ARGS(RIL_DBUS_IMEI_ARG),
|
||||
ril_plugin_dbus_get_imei) },
|
||||
{ GDBUS_ASYNC_METHOD("GetIMEISV",
|
||||
NULL, GDBUS_ARGS(RIL_DBUS_IMEISV_ARG),
|
||||
ril_plugin_dbus_get_imeisv) },
|
||||
{ GDBUS_METHOD("GetDefaultDataSim",
|
||||
NULL, GDBUS_ARGS(RIL_DBUS_DEFAULT_DATA_SIM_ARG),
|
||||
ril_plugin_dbus_get_default_data_sim) },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2016 Jolla Ltd.
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -85,6 +85,7 @@ struct ril_sim {
|
||||
ofono_sim_passwd_cb_t query_passwd_state_cb;
|
||||
void *query_passwd_state_cb_data;
|
||||
guint query_passwd_state_timeout_id;
|
||||
gulong query_passwd_state_sim_status_refresh_id;
|
||||
};
|
||||
|
||||
struct ril_sim_io_response {
|
||||
@@ -691,6 +692,12 @@ static void ril_sim_finish_passwd_state_query(struct ril_sim *sd,
|
||||
sd->query_passwd_state_timeout_id = 0;
|
||||
}
|
||||
|
||||
if (sd->query_passwd_state_sim_status_refresh_id) {
|
||||
ril_sim_card_remove_handler(sd->card,
|
||||
sd->query_passwd_state_sim_status_refresh_id);
|
||||
sd->query_passwd_state_sim_status_refresh_id = 0;
|
||||
}
|
||||
|
||||
if (sd->query_passwd_state_cb) {
|
||||
ofono_sim_passwd_cb_t cb = sd->query_passwd_state_cb;
|
||||
void *data = sd->query_passwd_state_cb_data;
|
||||
@@ -884,6 +891,15 @@ static void ril_sim_query_pin_retries(struct ofono_sim *sim,
|
||||
cb(ril_error_ok(&error), sd->retries, data);
|
||||
}
|
||||
|
||||
static void ril_sim_query_passwd_state_complete_cb(struct ril_sim_card *sc,
|
||||
void *user_data)
|
||||
{
|
||||
struct ril_sim *sd = user_data;
|
||||
|
||||
GASSERT(sd->query_passwd_state_sim_status_refresh_id);
|
||||
ril_sim_finish_passwd_state_query(sd, ril_sim_passwd_state(sd));
|
||||
}
|
||||
|
||||
static gboolean ril_sim_query_passwd_state_timeout_cb(gpointer user_data)
|
||||
{
|
||||
struct ril_sim *sd = user_data;
|
||||
@@ -899,29 +915,41 @@ static void ril_sim_query_passwd_state(struct ofono_sim *sim,
|
||||
ofono_sim_passwd_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_sim *sd = ril_sim_get_data(sim);
|
||||
enum ofono_sim_password_type passwd_state = ril_sim_passwd_state(sd);
|
||||
struct ofono_error error;
|
||||
|
||||
if (sd->query_passwd_state_timeout_id) {
|
||||
g_source_remove(sd->query_passwd_state_timeout_id);
|
||||
sd->query_passwd_state_timeout_id = 0;
|
||||
}
|
||||
|
||||
if (passwd_state != OFONO_SIM_PASSWORD_INVALID) {
|
||||
DBG_(sd, "%d", passwd_state);
|
||||
sd->query_passwd_state_cb = NULL;
|
||||
sd->query_passwd_state_cb_data = NULL;
|
||||
sd->ofono_passwd_state = passwd_state;
|
||||
cb(ril_error_ok(&error), passwd_state, data);
|
||||
if (!sd->query_passwd_state_sim_status_refresh_id) {
|
||||
ril_sim_card_remove_handler(sd->card,
|
||||
sd->query_passwd_state_sim_status_refresh_id);
|
||||
sd->query_passwd_state_sim_status_refresh_id = 0;
|
||||
}
|
||||
|
||||
/* Always request fresh status, just in case. */
|
||||
ril_sim_card_request_status(sd->card);
|
||||
sd->query_passwd_state_cb = cb;
|
||||
sd->query_passwd_state_cb_data = data;
|
||||
|
||||
if (ril_sim_passwd_state(sd) != OFONO_SIM_PASSWORD_INVALID) {
|
||||
/* Just wait for GET_SIM_STATUS completion */
|
||||
DBG_(sd, "waiting for SIM status query to complete");
|
||||
sd->query_passwd_state_sim_status_refresh_id =
|
||||
ril_sim_card_add_status_received_handler(sd->card,
|
||||
ril_sim_query_passwd_state_complete_cb, sd);
|
||||
} else {
|
||||
/* Wait for the state to change */
|
||||
DBG_(sd, "waiting for the SIM state to change");
|
||||
sd->query_passwd_state_cb = cb;
|
||||
sd->query_passwd_state_cb_data = data;
|
||||
sd->query_passwd_state_timeout_id =
|
||||
g_timeout_add_seconds(SIM_STATE_CHANGE_TIMEOUT_SECS,
|
||||
ril_sim_query_passwd_state_timeout_cb, sd);
|
||||
}
|
||||
|
||||
/*
|
||||
* We still need to complete the request somehow, even if
|
||||
* GET_STATUS never completes or SIM status never changes.
|
||||
*/
|
||||
sd->query_passwd_state_timeout_id =
|
||||
g_timeout_add_seconds(SIM_STATE_CHANGE_TIMEOUT_SECS,
|
||||
ril_sim_query_passwd_state_timeout_cb, sd);
|
||||
}
|
||||
|
||||
static gboolean ril_sim_pin_change_state_timeout_cb(gpointer user_data)
|
||||
@@ -1280,6 +1308,11 @@ static void ril_sim_remove(struct ofono_sim *sim)
|
||||
g_source_remove(sd->query_passwd_state_timeout_id);
|
||||
}
|
||||
|
||||
if (sd->query_passwd_state_sim_status_refresh_id) {
|
||||
ril_sim_card_remove_handler(sd->card,
|
||||
sd->query_passwd_state_sim_status_refresh_id);
|
||||
}
|
||||
|
||||
ril_sim_card_remove_handler(sd->card, sd->card_status_id);
|
||||
ril_sim_card_unref(sd->card);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2016 Jolla Ltd.
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -64,8 +64,6 @@ G_DEFINE_TYPE(RilSimCard, ril_sim_card, G_TYPE_OBJECT)
|
||||
#define RIL_SIMCARD_STATE_CHANGED (0x01)
|
||||
#define RIL_SIMCARD_STATUS_CHANGED (0x02)
|
||||
|
||||
static void ril_sim_card_request_status(struct ril_sim_card *self);
|
||||
|
||||
static gboolean ril_sim_card_app_equal(const struct ril_sim_card_app *a1,
|
||||
const struct ril_sim_card_app *a2)
|
||||
{
|
||||
@@ -365,7 +363,7 @@ static void ril_sim_card_status_cb(GRilIoChannel *io, int ril_status,
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_sim_card_request_status(struct ril_sim_card *self)
|
||||
void ril_sim_card_request_status(struct ril_sim_card *self)
|
||||
{
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2016 Jolla Ltd.
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -55,6 +55,7 @@ typedef void (*ril_sim_card_cb_t)(struct ril_sim_card *sc, void *arg);
|
||||
struct ril_sim_card *ril_sim_card_new(GRilIoChannel *io, guint slot, int flags);
|
||||
struct ril_sim_card *ril_sim_card_ref(struct ril_sim_card *sc);
|
||||
void ril_sim_card_unref(struct ril_sim_card *sc);
|
||||
void ril_sim_card_request_status(struct ril_sim_card *self);
|
||||
gboolean ril_sim_card_ready(struct ril_sim_card *sc);
|
||||
gulong ril_sim_card_add_status_received_handler(struct ril_sim_card *sc,
|
||||
ril_sim_card_cb_t cb, void *arg);
|
||||
|
||||
@@ -261,6 +261,7 @@ static void ublox_send_uauthreq(struct ofono_gprs_context *gc,
|
||||
case OFONO_GPRS_AUTH_METHOD_PAP:
|
||||
auth = 1;
|
||||
break;
|
||||
case OFONO_GPRS_AUTH_METHOD_ANY:
|
||||
case OFONO_GPRS_AUTH_METHOD_CHAP:
|
||||
auth = 2;
|
||||
break;
|
||||
|
||||
@@ -49,7 +49,9 @@ enum ofono_gprs_context_type {
|
||||
};
|
||||
|
||||
enum ofono_gprs_auth_method {
|
||||
OFONO_GPRS_AUTH_METHOD_CHAP = 0,
|
||||
OFONO_GPRS_AUTH_METHOD_ANY = 0,
|
||||
OFONO_GPRS_AUTH_METHOD_NONE,
|
||||
OFONO_GPRS_AUTH_METHOD_CHAP,
|
||||
OFONO_GPRS_AUTH_METHOD_PAP,
|
||||
};
|
||||
|
||||
|
||||
@@ -53,6 +53,9 @@ const char *mbpi_database = MBPI_DATABASE;
|
||||
enum ofono_gprs_proto mbpi_default_internet_proto = OFONO_GPRS_PROTO_IPV4V6;
|
||||
enum ofono_gprs_proto mbpi_default_mms_proto = OFONO_GPRS_PROTO_IP;
|
||||
enum ofono_gprs_proto mbpi_default_proto = OFONO_GPRS_PROTO_IP;
|
||||
enum ofono_gprs_auth_method mbpi_default_auth_method = OFONO_GPRS_AUTH_METHOD_ANY;
|
||||
|
||||
#define OFONO_GPRS_AUTH_METHOD_UNSPECIFIED ((enum ofono_gprs_auth_method)(-1))
|
||||
|
||||
#define _(x) case x: return (#x)
|
||||
|
||||
@@ -166,6 +169,10 @@ static void authentication_start(GMarkupParseContext *context,
|
||||
*auth_method = OFONO_GPRS_AUTH_METHOD_CHAP;
|
||||
else if (strcmp(text, "pap") == 0)
|
||||
*auth_method = OFONO_GPRS_AUTH_METHOD_PAP;
|
||||
else if (strcmp(text, "any") == 0)
|
||||
*auth_method = OFONO_GPRS_AUTH_METHOD_ANY;
|
||||
else if (strcmp(text, "none") == 0)
|
||||
*auth_method = OFONO_GPRS_AUTH_METHOD_NONE;
|
||||
else
|
||||
mbpi_g_set_error(context, error, G_MARKUP_ERROR,
|
||||
G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
|
||||
@@ -344,7 +351,7 @@ static void apn_handler(GMarkupParseContext *context, struct gsm_data *gsm,
|
||||
ap->apn = g_strdup(apn);
|
||||
ap->type = OFONO_GPRS_CONTEXT_TYPE_INTERNET;
|
||||
ap->proto = mbpi_default_proto;
|
||||
ap->auth_method = OFONO_GPRS_AUTH_METHOD_CHAP;
|
||||
ap->auth_method = OFONO_GPRS_AUTH_METHOD_UNSPECIFIED;
|
||||
|
||||
g_markup_parse_context_push(context, &apn_parser, ap);
|
||||
}
|
||||
@@ -414,6 +421,17 @@ static void gsm_end(GMarkupParseContext *context, const gchar *element_name,
|
||||
if (ap == NULL)
|
||||
return;
|
||||
|
||||
/* Fix the authentication method if none was specified */
|
||||
if (ap->auth_method == OFONO_GPRS_AUTH_METHOD_UNSPECIFIED) {
|
||||
if ((!ap->username || !ap->username[0]) &&
|
||||
(!ap->password || !ap->password[0])) {
|
||||
/* No username or password => no authentication */
|
||||
ap->auth_method = OFONO_GPRS_AUTH_METHOD_NONE;
|
||||
} else {
|
||||
ap->auth_method = mbpi_default_auth_method;
|
||||
}
|
||||
}
|
||||
|
||||
if (gsm->allow_duplicates == FALSE) {
|
||||
GSList *l;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ extern const char *mbpi_database;
|
||||
extern enum ofono_gprs_proto mbpi_default_internet_proto;
|
||||
extern enum ofono_gprs_proto mbpi_default_mms_proto;
|
||||
extern enum ofono_gprs_proto mbpi_default_proto;
|
||||
extern enum ofono_gprs_auth_method mbpi_default_auth_method;
|
||||
|
||||
const char *mbpi_ap_type(enum ofono_gprs_context_type type);
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2013-2016 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -24,7 +23,6 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -37,114 +35,9 @@
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/gprs-provision.h>
|
||||
|
||||
#include "provision.h"
|
||||
#include "mbpi.h"
|
||||
|
||||
struct provision_ap_defaults {
|
||||
enum ofono_gprs_context_type type;
|
||||
const char *name;
|
||||
const char *apn;
|
||||
};
|
||||
|
||||
static gboolean provision_match_name(const struct ofono_gprs_provision_data *ap,
|
||||
const char* spn)
|
||||
{
|
||||
return (ap->provider_name && strcasestr(ap->provider_name, spn)) ||
|
||||
(ap->name && strcasestr(ap->name, spn)) ||
|
||||
(ap->apn && strcasestr(ap->apn, spn));
|
||||
}
|
||||
|
||||
static void provision_free_ap(gpointer data)
|
||||
{
|
||||
mbpi_ap_free(data);
|
||||
}
|
||||
|
||||
static gint provision_compare_ap(gconstpointer a, gconstpointer b, gpointer data)
|
||||
{
|
||||
const struct ofono_gprs_provision_data *ap1 = a;
|
||||
const struct ofono_gprs_provision_data *ap2 = b;
|
||||
const char* spn = data;
|
||||
|
||||
if (spn) {
|
||||
const gboolean match1 = provision_match_name(ap1, spn);
|
||||
const gboolean match2 = provision_match_name(ap2, spn);
|
||||
if (match1 && !match2) {
|
||||
return -1;
|
||||
} else if (match2 && !match1) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ap1->provider_primary && !ap2->provider_primary) {
|
||||
return -1;
|
||||
} else if (ap2->provider_primary && !ap1->provider_primary) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Picks best ap, deletes the rest. Creates one if necessary */
|
||||
static GSList *provision_pick_best_ap(GSList *list, const char* spn,
|
||||
const enum ofono_gprs_proto default_proto,
|
||||
const struct provision_ap_defaults *defaults)
|
||||
{
|
||||
/* Sort the list */
|
||||
list = g_slist_sort_with_data(list, provision_compare_ap, (void*)spn);
|
||||
if (list) {
|
||||
/* Pick the best one, delete the rest */
|
||||
GSList *best = list;
|
||||
g_slist_free_full(g_slist_remove_link(list, best),
|
||||
provision_free_ap);
|
||||
return best;
|
||||
} else {
|
||||
/* or create one from the default data */
|
||||
struct ofono_gprs_provision_data *ap =
|
||||
g_new0(struct ofono_gprs_provision_data, 1);
|
||||
|
||||
ap->proto = default_proto;
|
||||
ap->type = defaults->type;
|
||||
ap->name = g_strdup(defaults->name);
|
||||
ap->apn = g_strdup(defaults->apn);
|
||||
return g_slist_append(NULL, ap);
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns the list containing exactly one INTERNET and one MMS access point */
|
||||
static GSList *provision_normalize_apn_list(GSList *apns, const char* spn)
|
||||
{
|
||||
static const struct provision_ap_defaults internet_defaults =
|
||||
{ OFONO_GPRS_CONTEXT_TYPE_INTERNET, "Internet", "internet" };
|
||||
static const struct provision_ap_defaults mms_defaults =
|
||||
{ OFONO_GPRS_CONTEXT_TYPE_MMS, "MMS", "mms" };
|
||||
|
||||
GSList *internet_apns = NULL;
|
||||
GSList *mms_apns = NULL;
|
||||
|
||||
/* Split internet and mms apns, delete all others */
|
||||
while (apns) {
|
||||
GSList *link = apns;
|
||||
struct ofono_gprs_provision_data *ap = link->data;
|
||||
|
||||
apns = g_slist_remove_link(apns, link);
|
||||
if (ap->type == OFONO_GPRS_CONTEXT_TYPE_INTERNET) {
|
||||
internet_apns = g_slist_concat(internet_apns, link);
|
||||
} else if (ap->type == OFONO_GPRS_CONTEXT_TYPE_MMS) {
|
||||
mms_apns = g_slist_concat(mms_apns, link);
|
||||
} else {
|
||||
g_slist_free_full(link, provision_free_ap);
|
||||
}
|
||||
}
|
||||
|
||||
/* Pick the best ap of each type and concatenate them */
|
||||
return g_slist_concat(
|
||||
provision_pick_best_ap(internet_apns, spn,
|
||||
mbpi_default_internet_proto, &internet_defaults),
|
||||
provision_pick_best_ap(mms_apns, spn,
|
||||
mbpi_default_mms_proto, &mms_defaults));
|
||||
}
|
||||
|
||||
int provision_get_settings(const char *mcc, const char *mnc,
|
||||
static int provision_get_settings(const char *mcc, const char *mnc,
|
||||
const char *spn,
|
||||
struct ofono_gprs_provision_data **settings,
|
||||
int *count)
|
||||
@@ -155,26 +48,21 @@ int provision_get_settings(const char *mcc, const char *mnc,
|
||||
int ap_count;
|
||||
int i;
|
||||
|
||||
ofono_info("Provisioning for MCC %s, MNC %s, SPN '%s'", mcc, mnc, spn);
|
||||
DBG("Provisioning for MCC %s, MNC %s, SPN '%s'", mcc, mnc, spn);
|
||||
|
||||
/*
|
||||
* Passing FALSE to mbpi_lookup_apn() would return
|
||||
* an empty list if duplicates are found.
|
||||
*/
|
||||
apns = mbpi_lookup_apn(mcc, mnc, TRUE, &error);
|
||||
if (error != NULL) {
|
||||
ofono_error("%s", error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
apns = mbpi_lookup_apn(mcc, mnc, FALSE, &error);
|
||||
if (apns == NULL) {
|
||||
if (error != NULL) {
|
||||
ofono_error("%s", error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
|
||||
ofono_info("Found %d APs in MBPI", g_slist_length(apns));
|
||||
apns = provision_normalize_apn_list(apns, spn);
|
||||
if (apns == NULL)
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
ap_count = g_slist_length(apns);
|
||||
|
||||
ofono_info("Provisioning %d APs", ap_count);
|
||||
DBG("Found %d APs", ap_count);
|
||||
|
||||
*settings = g_try_new0(struct ofono_gprs_provision_data, ap_count);
|
||||
if (*settings == NULL) {
|
||||
@@ -193,11 +81,11 @@ int provision_get_settings(const char *mcc, const char *mnc,
|
||||
for (l = apns, i = 0; l; l = l->next, i++) {
|
||||
struct ofono_gprs_provision_data *ap = l->data;
|
||||
|
||||
ofono_info("Name: '%s'", ap->name);
|
||||
ofono_info("APN: '%s'", ap->apn);
|
||||
ofono_info("Type: %s", mbpi_ap_type(ap->type));
|
||||
ofono_info("Username: '%s'", ap->username);
|
||||
ofono_info("Password: '%s'", ap->password);
|
||||
DBG("Name: '%s'", ap->name);
|
||||
DBG("APN: '%s'", ap->apn);
|
||||
DBG("Type: %s", mbpi_ap_type(ap->type));
|
||||
DBG("Username: '%s'", ap->username);
|
||||
DBG("Password: '%s'", ap->password);
|
||||
|
||||
memcpy(*settings + i, ap,
|
||||
sizeof(struct ofono_gprs_provision_data));
|
||||
|
||||
251
ofono/plugins/sailfish_provision.c
Normal file
251
ofono/plugins/sailfish_provision.c
Normal file
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2013-2017 Jolla Ltd.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#define OFONO_API_SUBJECT_TO_CHANGE
|
||||
#include <ofono/log.h>
|
||||
#include <ofono/plugin.h>
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/gprs-provision.h>
|
||||
|
||||
#include "provision.h"
|
||||
#include "mbpi.h"
|
||||
|
||||
struct provision_ap_defaults {
|
||||
enum ofono_gprs_context_type type;
|
||||
const char *name;
|
||||
const char *apn;
|
||||
};
|
||||
|
||||
static gint provision_match_strings(const char *s1, const char *s2)
|
||||
{
|
||||
gint match = 0;
|
||||
|
||||
/* Caller checks s2 for NULL */
|
||||
if (s1) {
|
||||
const gssize len1 = strlen(s1);
|
||||
const gssize len2 = strlen(s2);
|
||||
|
||||
if (len1 == len2 && !strcmp(s1, s2)) {
|
||||
/* Best match ever */
|
||||
match = 3;
|
||||
} else if (g_utf8_validate(s1, len1, NULL) &&
|
||||
g_utf8_validate(s2, len2, NULL)) {
|
||||
char *d1 = g_utf8_strdown(s1, len1);
|
||||
char *d2 = g_utf8_strdown(s2, len2);
|
||||
|
||||
if (len1 == len2 && !strcmp(d1, d2)) {
|
||||
/* Case insensitive match */
|
||||
match = 2;
|
||||
} else if ((len1 > len2 && strstr(d1, d2)) ||
|
||||
(len2 > len1 && strstr(d2, d1))) {
|
||||
/* Partial case insensitive match */
|
||||
match = 1;
|
||||
}
|
||||
|
||||
g_free(d1);
|
||||
g_free(d2);
|
||||
}
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
static gint provision_match_spn(const struct ofono_gprs_provision_data *ap,
|
||||
const char *spn)
|
||||
{
|
||||
return provision_match_strings(ap->provider_name, spn) * 4 +
|
||||
provision_match_strings(ap->name, spn);
|
||||
}
|
||||
|
||||
static void provision_free_ap(gpointer data)
|
||||
{
|
||||
mbpi_ap_free(data);
|
||||
}
|
||||
|
||||
static gint provision_compare_ap(gconstpointer a, gconstpointer b,
|
||||
gpointer data)
|
||||
{
|
||||
const struct ofono_gprs_provision_data *ap1 = a;
|
||||
const struct ofono_gprs_provision_data *ap2 = b;
|
||||
const char *spn = data;
|
||||
|
||||
if (spn) {
|
||||
const gint result = provision_match_spn(ap2, spn) -
|
||||
provision_match_spn(ap1, spn);
|
||||
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (ap1->provider_primary && !ap2->provider_primary) {
|
||||
return -1;
|
||||
} else if (ap2->provider_primary && !ap1->provider_primary) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Picks best ap, deletes the rest. Creates one if necessary */
|
||||
static GSList *provision_pick_best_ap(GSList *list, const char *spn,
|
||||
const enum ofono_gprs_proto default_proto,
|
||||
const struct provision_ap_defaults *defaults)
|
||||
{
|
||||
/* Sort the list */
|
||||
list = g_slist_sort_with_data(list, provision_compare_ap, (void*)spn);
|
||||
if (list) {
|
||||
/* Pick the best one, delete the rest */
|
||||
GSList *best = list;
|
||||
g_slist_free_full(g_slist_remove_link(list, best),
|
||||
provision_free_ap);
|
||||
return best;
|
||||
} else {
|
||||
/* or create one from the default data */
|
||||
struct ofono_gprs_provision_data *ap =
|
||||
g_new0(struct ofono_gprs_provision_data, 1);
|
||||
|
||||
ap->proto = default_proto;
|
||||
ap->type = defaults->type;
|
||||
ap->name = g_strdup(defaults->name);
|
||||
ap->apn = g_strdup(defaults->apn);
|
||||
ap->auth_method = OFONO_GPRS_AUTH_METHOD_NONE;
|
||||
return g_slist_append(NULL, ap);
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns the list containing exactly one INTERNET and one MMS access point */
|
||||
static GSList *provision_normalize_apn_list(GSList *apns, const char *spn)
|
||||
{
|
||||
static const struct provision_ap_defaults internet_defaults =
|
||||
{ OFONO_GPRS_CONTEXT_TYPE_INTERNET, "Internet", "internet" };
|
||||
static const struct provision_ap_defaults mms_defaults =
|
||||
{ OFONO_GPRS_CONTEXT_TYPE_MMS, "MMS", "mms" };
|
||||
|
||||
GSList *internet_apns = NULL;
|
||||
GSList *mms_apns = NULL;
|
||||
|
||||
/* Split internet and mms apns, delete all others */
|
||||
while (apns) {
|
||||
GSList *link = apns;
|
||||
struct ofono_gprs_provision_data *ap = link->data;
|
||||
|
||||
apns = g_slist_remove_link(apns, link);
|
||||
if (ap->type == OFONO_GPRS_CONTEXT_TYPE_INTERNET) {
|
||||
internet_apns = g_slist_concat(internet_apns, link);
|
||||
} else if (ap->type == OFONO_GPRS_CONTEXT_TYPE_MMS) {
|
||||
mms_apns = g_slist_concat(mms_apns, link);
|
||||
} else {
|
||||
g_slist_free_full(link, provision_free_ap);
|
||||
}
|
||||
}
|
||||
|
||||
/* Pick the best ap of each type and concatenate them */
|
||||
return g_slist_concat(
|
||||
provision_pick_best_ap(internet_apns, spn,
|
||||
mbpi_default_internet_proto, &internet_defaults),
|
||||
provision_pick_best_ap(mms_apns, spn,
|
||||
mbpi_default_mms_proto, &mms_defaults));
|
||||
}
|
||||
|
||||
int provision_get_settings(const char *mcc, const char *mnc,
|
||||
const char *spn,
|
||||
struct ofono_gprs_provision_data **settings,
|
||||
int *count)
|
||||
{
|
||||
GSList *l;
|
||||
GSList *apns;
|
||||
GError *error = NULL;
|
||||
int ap_count;
|
||||
int i;
|
||||
|
||||
ofono_info("Provisioning for MCC %s, MNC %s, SPN '%s'", mcc, mnc, spn);
|
||||
|
||||
/*
|
||||
* Passing FALSE to mbpi_lookup_apn() would return
|
||||
* an empty list if duplicates are found.
|
||||
*/
|
||||
apns = mbpi_lookup_apn(mcc, mnc, TRUE, &error);
|
||||
if (error != NULL) {
|
||||
ofono_error("%s", error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
|
||||
DBG("Found %d APs in MBPI", g_slist_length(apns));
|
||||
apns = provision_normalize_apn_list(apns, spn);
|
||||
ap_count = g_slist_length(apns);
|
||||
|
||||
DBG("Provisioning %d APs", ap_count);
|
||||
*settings = g_new0(struct ofono_gprs_provision_data, ap_count);
|
||||
*count = ap_count;
|
||||
|
||||
for (l = apns, i = 0; l; l = l->next, i++) {
|
||||
struct ofono_gprs_provision_data *ap = l->data;
|
||||
|
||||
ofono_info("Name: '%s'", ap->name);
|
||||
ofono_info(" APN: '%s'", ap->apn);
|
||||
ofono_info(" Type: %s", mbpi_ap_type(ap->type));
|
||||
ofono_info(" Username: '%s'", ap->username);
|
||||
ofono_info(" Password: '%s'", ap->password);
|
||||
|
||||
memcpy(*settings + i, ap,
|
||||
sizeof(struct ofono_gprs_provision_data));
|
||||
|
||||
g_free(ap);
|
||||
}
|
||||
|
||||
g_slist_free(apns);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct ofono_gprs_provision_driver provision_driver = {
|
||||
.name = "Provisioning",
|
||||
.get_settings = provision_get_settings
|
||||
};
|
||||
|
||||
static int provision_init(void)
|
||||
{
|
||||
DBG("");
|
||||
return ofono_gprs_provision_driver_register(&provision_driver);
|
||||
}
|
||||
|
||||
static void provision_exit(void)
|
||||
{
|
||||
DBG("");
|
||||
ofono_gprs_provision_driver_unregister(&provision_driver);
|
||||
}
|
||||
|
||||
OFONO_PLUGIN_DEFINE(provision, "Provisioning Plugin", VERSION,
|
||||
OFONO_PLUGIN_PRIORITY_DEFAULT,
|
||||
provision_init, provision_exit)
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <net/route.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <gdbus.h>
|
||||
@@ -258,6 +259,10 @@ static gboolean gprs_proto_from_string(const char *str,
|
||||
static const char *gprs_auth_method_to_string(enum ofono_gprs_auth_method auth)
|
||||
{
|
||||
switch (auth) {
|
||||
case OFONO_GPRS_AUTH_METHOD_ANY:
|
||||
return "any";
|
||||
case OFONO_GPRS_AUTH_METHOD_NONE:
|
||||
return "none";
|
||||
case OFONO_GPRS_AUTH_METHOD_CHAP:
|
||||
return "chap";
|
||||
case OFONO_GPRS_AUTH_METHOD_PAP:
|
||||
@@ -276,6 +281,12 @@ static gboolean gprs_auth_method_from_string(const char *str,
|
||||
} else if (g_str_equal(str, "pap")) {
|
||||
*auth = OFONO_GPRS_AUTH_METHOD_PAP;
|
||||
return TRUE;
|
||||
} else if (g_str_equal(str, "any")) {
|
||||
*auth = OFONO_GPRS_AUTH_METHOD_ANY;
|
||||
return TRUE;
|
||||
} else if (g_str_equal(str, "none")) {
|
||||
*auth = OFONO_GPRS_AUTH_METHOD_NONE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@@ -641,7 +652,48 @@ static gboolean pri_parse_proxy(struct pri_context *ctx, const char *proxy)
|
||||
}
|
||||
|
||||
g_free(ctx->proxy_host);
|
||||
ctx->proxy_host = g_strdup(host);
|
||||
ctx->proxy_host = NULL;
|
||||
|
||||
if (host[0] == '0' || strstr(host, ".0")) {
|
||||
/*
|
||||
* Some operators provide IP address of the MMS proxy
|
||||
* prepending zeros to each number shorter then 3 digits,
|
||||
* e.g. "192.168.094.023" instead of "192.168.94.23".
|
||||
* That may look nicer but it's actually wrong because
|
||||
* the numbers starting with zeros are interpreted as
|
||||
* octal numbers. In the example above 023 actually means
|
||||
* 16 and 094 is not a valid number at all.
|
||||
*
|
||||
* In addition to publishing these broken settings on their
|
||||
* web sites, some of the operators send them over the air,
|
||||
* in which case we can't even blame the user for entering
|
||||
* an invalid IP address. We better be prepared to deal with
|
||||
* those.
|
||||
*
|
||||
* Since nobody in the world seems to be actually using the
|
||||
* octal notation to write an IP address, let's remove the
|
||||
* leading zeros if we find them in the host part of the MMS
|
||||
* proxy URL.
|
||||
*/
|
||||
char** parts = g_strsplit(host, ".", -1);
|
||||
guint count = g_strv_length(parts);
|
||||
if (count == 4) {
|
||||
char** ptr = parts;
|
||||
while (*ptr) {
|
||||
char* part = *ptr;
|
||||
while (part[0] == '0' && isdigit(part[1])) {
|
||||
memmove(part, part+1, strlen(part));
|
||||
}
|
||||
*ptr++ = part;
|
||||
}
|
||||
ctx->proxy_host = g_strjoinv(".", parts);
|
||||
DBG("%s => %s", host, ctx->proxy_host);
|
||||
}
|
||||
g_strfreev(parts);
|
||||
}
|
||||
|
||||
if (!ctx->proxy_host)
|
||||
ctx->proxy_host = g_strdup(host);
|
||||
|
||||
g_free(scheme);
|
||||
return TRUE;
|
||||
@@ -892,6 +944,13 @@ static void pri_reset_context_properties(struct pri_context *ctx,
|
||||
gprs_proto_to_string(ctx->context.proto));
|
||||
}
|
||||
|
||||
if (ctx->context.auth_method != ap->auth_method) {
|
||||
ctx->context.auth_method = ap->auth_method;
|
||||
changed = TRUE;
|
||||
pri_str_signal_change(ctx, "AuthenticationMethod",
|
||||
gprs_auth_method_to_string(ctx->context.auth_method));
|
||||
}
|
||||
|
||||
if (ap->type == OFONO_GPRS_CONTEXT_TYPE_MMS) {
|
||||
if (pri_str_update(ctx->message_proxy, ap->message_proxy,
|
||||
sizeof(ctx->message_proxy))) {
|
||||
|
||||
@@ -226,6 +226,9 @@ void sim_fs_notify_file_watches(struct sim_fs *fs, int id)
|
||||
struct ofono_sim_context *context = l->data;
|
||||
GSList *k;
|
||||
|
||||
if (context->file_watches == NULL)
|
||||
continue;
|
||||
|
||||
for (k = context->file_watches->items; k; k = k->next) {
|
||||
struct file_watch *w = k->data;
|
||||
ofono_sim_file_changed_cb_t notify = w->item.notify;
|
||||
|
||||
@@ -514,6 +514,20 @@ void ofono_ussd_notify(struct ofono_ussd *ussd, int status, int dcs,
|
||||
DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID);
|
||||
|
||||
ussd_change_state(ussd, new_state);
|
||||
goto free;
|
||||
} else if (ussd->state == USSD_STATE_USER_ACTION &&
|
||||
status != OFONO_USSD_STATUS_ACTION_REQUIRED) {
|
||||
ussd_change_state(ussd, USSD_STATE_IDLE);
|
||||
|
||||
if (status == OFONO_USSD_STATUS_NOTIFY && str && str[0]) {
|
||||
const char *path = __ofono_atom_get_path(ussd->atom);
|
||||
|
||||
g_dbus_emit_signal(conn, path,
|
||||
OFONO_SUPPLEMENTARY_SERVICES_INTERFACE,
|
||||
"NotificationReceived", DBUS_TYPE_STRING,
|
||||
&str, DBUS_TYPE_INVALID);
|
||||
}
|
||||
|
||||
goto free;
|
||||
} else {
|
||||
ofono_error("Received an unsolicited USSD but can't handle.");
|
||||
|
||||
@@ -11,7 +11,7 @@ Requires: dbus
|
||||
Requires: systemd
|
||||
Requires: ofono-configs
|
||||
Requires: libgrilio >= 1.0.10
|
||||
Requires: libglibutil >= 1.0.19
|
||||
Requires: libglibutil >= 1.0.22
|
||||
Requires(preun): systemd
|
||||
Requires(post): systemd
|
||||
Requires(postun): systemd
|
||||
@@ -21,7 +21,7 @@ BuildRequires: pkgconfig(libudev) >= 145
|
||||
BuildRequires: pkgconfig(mobile-broadband-provider-info)
|
||||
BuildRequires: pkgconfig(libwspcodec) >= 2.0
|
||||
BuildRequires: pkgconfig(libgrilio) >= 1.0.10
|
||||
BuildRequires: pkgconfig(libglibutil) >= 1.0.19
|
||||
BuildRequires: pkgconfig(libglibutil) >= 1.0.22
|
||||
BuildRequires: pkgconfig(libdbuslogserver-dbus)
|
||||
BuildRequires: pkgconfig(libmce-glib)
|
||||
BuildRequires: libtool
|
||||
@@ -72,6 +72,7 @@ autoreconf --force --install
|
||||
--enable-debuglog \
|
||||
--enable-jolla-rilmodem \
|
||||
--enable-sailfishos \
|
||||
--enable-sailfish-provision \
|
||||
--disable-add-remove-context \
|
||||
--disable-isimodem \
|
||||
--disable-qmimodem \
|
||||
|
||||
Reference in New Issue
Block a user