#include "common.h"
#include "sim.h"
#include "simutil.h"
+#include "util.h"
#define NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration"
#define NETWORK_OPERATOR_INTERFACE "org.ofono.NetworkOperator"
int flags;
DBusMessage *pending;
int signal_strength;
- char display_name[OFONO_MAX_OPERATOR_NAME_LENGTH];
char *spname;
GSList *pnn_list;
};
{
struct network_registration_data *netreg = modem->network_registration;
const char *plmn;
- char *name = netreg->display_name;
- int len = sizeof(netreg->display_name);
+ static char name[1024];
+ int len = sizeof(name);
int home_or_spdi;
/* The name displayed to user depends on whether we're in a home
ofono_signal_strength_notify(modem, strength);
}
-static void ofono_update_spn(struct ofono_modem *modem, const char *spn,
- int home_plmn_dpy, int roaming_spn_dpy)
-{
- struct network_registration_data *netreg = modem->network_registration;
- DBusConnection *conn = dbus_gsm_connection();
- const char *operator;
-
- if (!netreg)
- return;
-
- if (!strlen(spn))
- return;
-
- if (netreg->spname)
- g_free(netreg->spname);
- netreg->spname = g_strdup(spn);
-
- if (home_plmn_dpy)
- netreg->flags |= NETWORK_REGISTRATION_FLAG_HOME_SHOW_PLMN;
-
- if (roaming_spn_dpy)
- netreg->flags |= NETWORK_REGISTRATION_FLAG_ROAMING_SHOW_SPN;
-
- if (!netreg->current_operator)
- return;
-
- operator = get_operator_display_name(modem);
-
- dbus_gsm_signal_property_changed(conn, modem->path,
- NETWORK_REGISTRATION_INTERFACE,
- "Operator", DBUS_TYPE_STRING,
- &operator);
-}
-
static void sim_pnn_read_cb(struct ofono_modem *modem, int ok,
enum ofono_sim_file_structure structure,
int length, int record,
ofono_sim_read(modem, SIM_EFOPL_FILEID, sim_opl_read_cb, NULL);
}
+static void sim_spn_read_cb(struct ofono_modem *modem, int ok,
+ enum ofono_sim_file_structure structure,
+ int length, int record,
+ const unsigned char *data,
+ int record_length, void *userdata)
+{
+ struct network_registration_data *netreg = modem->network_registration;
+ DBusConnection *conn = dbus_gsm_connection();
+ const char *operator;
+ unsigned char dcbyte;
+ char *spn;
+
+ if (!ok)
+ return;
+
+ if (structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
+ return;
+
+ dcbyte = data[0];
+
+ /* TS 31.102 says:
+ *
+ * the string shall use:
+ *
+ * - either the SMS default 7-bit coded alphabet as defined in
+ * TS 23.038 [5] with bit 8 set to 0. The string shall be left
+ * justified. Unused bytes shall be set to 'FF'.
+ *
+ * - or one of the UCS2 code options defined in the annex of TS
+ * 31.101 [11].
+ *
+ * 31.101 has no such annex though. 51.101 refers to Annex B of
+ * itself which is not there either. 11.11 contains the same
+ * paragraph as 51.101 and has an Annex B which we implement.
+ */
+ spn = sim_string_to_utf8(data + 1, length - 1);
+
+ if (!spn) {
+ ofono_error("EFspn read successfully, but couldn't parse");
+ return;
+ }
+
+ if (strlen(spn) == 0) {
+ g_free(spn);
+ return;
+ }
+
+ if (dcbyte & SIM_EFSPN_DC_HOME_PLMN_BIT)
+ netreg->flags |= NETWORK_REGISTRATION_FLAG_HOME_SHOW_PLMN;
+
+ if (!(dcbyte & SIM_EFSPN_DC_ROAMING_SPN_BIT))
+ netreg->flags |= NETWORK_REGISTRATION_FLAG_ROAMING_SHOW_SPN;
+
+ if (!netreg->current_operator)
+ return;
+
+ operator = get_operator_display_name(modem);
+
+ dbus_gsm_signal_property_changed(conn, modem->path,
+ NETWORK_REGISTRATION_INTERFACE,
+ "Operator", DBUS_TYPE_STRING,
+ &operator);
+}
+
static void sim_ready(struct ofono_modem *modem)
{
ofono_sim_read(modem, SIM_EFPNN_FILEID, sim_pnn_read_cb, NULL);
+ ofono_sim_read(modem, SIM_EFSPN_FILEID, sim_spn_read_cb, NULL);
}
int ofono_network_registration_register(struct ofono_modem *modem,
initialize_network_registration(modem);
- ofono_spn_update_notify_register(modem, ofono_update_spn);
-
if (ops->registration_status)
ops->registration_status(modem, init_registration_status,
modem);
{
DBusConnection *conn = dbus_gsm_connection();
- ofono_spn_update_notify_unregister(modem, ofono_update_spn);
-
g_dbus_unregister_interface(conn, modem->path,
NETWORK_REGISTRATION_INTERFACE);
modem_remove_interface(modem, NETWORK_REGISTRATION_INTERFACE);
gboolean ready;
GQueue *simop_q;
- int dcbyte;
-
GSList *spdi;
GSList *opl;
static GDBusSignalTable sim_manager_signals[] = { { } };
-static void sim_spn_read_cb(const struct ofono_error *error,
- const unsigned char *sdata, int length, void *data)
-{
- struct ofono_modem *modem = data;
- struct sim_manager_data *sim = modem->sim_manager;
- unsigned char *endp;
- GSList *l;
-
- if (error->type != OFONO_ERROR_TYPE_NO_ERROR || length <= 1)
- return;
-
- sim->dcbyte = sdata[0];
- sdata++;
- length--;
-
- /* Successfully read the SPN from the SIM DB */
- endp = memchr(sdata, 0xff, length);
- if (endp)
- length = endp - sdata;
-
- /* TS 31.102 says:
- *
- * the string shall use:
- *
- * - either the SMS default 7-bit coded alphabet as defined in
- * TS 23.038 [5] with bit 8 set to 0. The string shall be left
- * justified. Unused bytes shall be set to 'FF'.
- *
- * - or one of the UCS2 code options defined in the annex of TS
- * 31.101 [11].
- *
- * 31.101 has no such annex though. 51.101 refers to Annex B of
- * itself which is not there either. 11.11 contains the same
- * paragraph as 51.101 and has an Annex B which we implement.
- */
- sim->spn = sim_string_to_utf8(sdata, length);
-
- for (l = sim->update_spn_notify; l; l = l->next)
- sim_spn_notify(modem, l->data);
-}
-
-static void sim_spn_info_cb(const struct ofono_error *error, int length,
- enum ofono_sim_file_structure structure,
- int dummy, void *data)
-{
- struct ofono_modem *modem = data;
- struct sim_manager_data *sim = modem->sim_manager;
-
- if (error->type != OFONO_ERROR_TYPE_NO_ERROR || length <= 1 ||
- structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
- return;
-
- sim->ops->read_file_transparent(modem, SIM_EFSPN_FILEID, 0, length,
- sim_spn_read_cb, modem);
-}
-
-static gboolean sim_retrieve_spn(void *user_data)
-{
- struct ofono_modem *modem = user_data;
- struct sim_manager_data *sim = modem->sim_manager;
-
- sim->ops->read_file_info(modem, SIM_EFSPN_FILEID,
- sim_spn_info_cb, modem);
-
- return FALSE;
-}
static void sim_msisdn_read_cb(struct ofono_modem *modem, int ok,
enum ofono_sim_file_structure structure,