[-]
[+]
|
Changed |
_service:tar_git:ofono.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:ofono.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -1,7 +1,7 @@
<services>
<service name="tar_git">
<param name="url">https://git.merproject.org/slava/ofono.git</param>
- <param name="branch">optionalmodem</param>
- <param name="revision">81299a0</param>
+ <param name="branch">master</param>
+ <param name="revision">2d18086</param>
</service>
</services>
|
[-]
[+]
|
Deleted |
_service:tar_git:ofono-1.19+git12+optionalmodem.20170515084831.1.g81299a0.tar.bz2/ofono/drivers/ril/ril_mtu.c
^
|
@@ -1,223 +0,0 @@
-/*
- * oFono - Open Source Telephony - RIL-based devices
- *
- * Copyright (C) 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
- * 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.
- */
-
-#include "ril_mtu.h"
-#include "ril_log.h"
-
-#include <net/if.h>
-#include <sys/ioctl.h>
-
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>
-
-struct ril_mtu_watch {
- int max_mtu;
- char *ifname;
- void *buf;
- int bufsize;
- GIOChannel *channel;
- guint io_watch;
- int fd;
-};
-
-static void ril_mtu_watch_limit_mtu(struct ril_mtu_watch *self)
-{
- int fd = socket(PF_INET, SOCK_DGRAM, 0);
- if (fd >= 0) {
- struct ifreq ifr;
- memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, self->ifname, IFNAMSIZ);
- if (ioctl(fd, SIOCGIFMTU, &ifr) < 0 ||
- ifr.ifr_mtu > self->max_mtu) {
- DBG("%s mtu %d => %d", self->ifname, ifr.ifr_mtu,
- self->max_mtu);
- ifr.ifr_mtu = self->max_mtu;
- if (ioctl(fd, SIOCSIFMTU, &ifr) < 0) {
- ofono_error("Failed to set MTU");
- }
- }
- close(fd);
- }
-}
-
-static void ril_mtu_watch_handle_rtattr(struct ril_mtu_watch *self,
- const struct rtattr *rta, int len)
-{
- int mtu = 0;
- const char *ifname = NULL;
- while (len > 0 && RTA_OK(rta, len) && (!mtu || !ifname)) {
- switch (rta->rta_type) {
- case IFLA_IFNAME:
- ifname = RTA_DATA(rta);
- break;
- case IFLA_MTU:
- mtu = *((int*)RTA_DATA(rta));
- break;
- }
- rta = RTA_NEXT(rta, len);
- }
- if (mtu > self->max_mtu && !g_strcmp0(ifname, self->ifname)) {
- DBG("%s %d", ifname, mtu);
- ril_mtu_watch_limit_mtu(self);
- }
-}
-
-static void ril_mtu_watch_handle_ifinfomsg(struct ril_mtu_watch *self,
- const struct ifinfomsg *ifi, int len)
-{
- if (ifi->ifi_flags & IFF_UP) {
- const struct rtattr *rta = IFLA_RTA(ifi);
- ril_mtu_watch_handle_rtattr(self, rta,
- len - ((char*)rta - (char*)ifi));
- }
-}
-
-static void ril_mtu_watch_handle_nlmsg(struct ril_mtu_watch *self,
- const struct nlmsghdr *hdr, int len)
-{
- while (len > 0 && NLMSG_OK(hdr, len)) {
- if (hdr->nlmsg_type == RTM_NEWLINK) {
- ril_mtu_watch_handle_ifinfomsg(self, NLMSG_DATA(hdr),
- IFLA_PAYLOAD(hdr));
- }
- hdr = NLMSG_NEXT(hdr, len);
- }
-}
-
-static gboolean ril_mtu_watch_event(GIOChannel *ch, GIOCondition cond,
- gpointer data)
-{
- struct ril_mtu_watch *self = data;
- struct sockaddr_nl addr;
- socklen_t addrlen = sizeof(addr);
- ssize_t result = recvfrom(self->fd, self->buf, self->bufsize, 0,
- (struct sockaddr *)&addr, &addrlen);
- if (result > 0) {
- if (!addr.nl_pid) {
- ril_mtu_watch_handle_nlmsg(self, self->buf, result);
- }
- return G_SOURCE_CONTINUE;
- } else if (result == 0 || errno == EINTR || errno == EAGAIN) {
- return G_SOURCE_CONTINUE;
- } else {
- DBG("%s error %d", self->ifname, errno);
- self->io_watch = 0;
- return G_SOURCE_REMOVE;
- }
-}
-
-static gboolean ril_mtu_watch_open_socket(struct ril_mtu_watch *self)
-{
- GASSERT(self->fd < 0);
- self->fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
- if (self->fd >= 0) {
- struct sockaddr_nl nl;
- memset(&nl, 0, sizeof(nl));
- nl.nl_pid = getpid();
- nl.nl_family = AF_NETLINK;
- nl.nl_groups = RTMGRP_IPV4_IFADDR | RTMGRP_IPV4_ROUTE |
- RTMGRP_IPV6_IFADDR | RTMGRP_IPV6_ROUTE |
- RTMGRP_LINK;
-
- if (bind(self->fd, (struct sockaddr*)&nl, sizeof(nl)) >= 0) {
- return TRUE;
- }
- close(self->fd);
- self->fd = -1;
- }
- return FALSE;
-}
-
-static gboolean ril_mtu_watch_start(struct ril_mtu_watch *self)
-{
- if (self->fd >= 0) {
- return TRUE;
- } else if (ril_mtu_watch_open_socket(self)) {
- GASSERT(!self->channel);
- GASSERT(!self->io_watch);
- self->channel = g_io_channel_unix_new(self->fd);
- if (self->channel) {
- g_io_channel_set_encoding(self->channel, NULL, NULL);
- g_io_channel_set_buffered(self->channel, FALSE);
- self->io_watch = g_io_add_watch(self->channel,
- G_IO_IN | G_IO_NVAL | G_IO_HUP,
- ril_mtu_watch_event, self);
- return TRUE;
- }
- close(self->fd);
- self->fd = -1;
- }
- return FALSE;
-}
-
-static void ril_mtu_watch_stop(struct ril_mtu_watch *self)
-{
- if (self->io_watch) {
- g_source_remove(self->io_watch);
- self->io_watch = 0;
- }
- if (self->channel) {
- g_io_channel_shutdown(self->channel, TRUE, NULL);
- g_io_channel_unref(self->channel);
- self->channel = NULL;
- }
- if (self->fd >= 0) {
- close(self->fd);
- self->fd = -1;
- }
-}
-
-struct ril_mtu_watch *ril_mtu_watch_new(int max_mtu)
-{
- struct ril_mtu_watch *self = g_new0(struct ril_mtu_watch, 1);
- self->fd = -1;
- self->max_mtu = max_mtu;
- self->bufsize = 4096;
- self->buf = g_malloc(self->bufsize);
- return self;
-}
-
-void ril_mtu_watch_free(struct ril_mtu_watch *self)
-{
- if (self) {
- ril_mtu_watch_stop(self);
- g_free(self->ifname);
- g_free(self->buf);
- g_free(self);
- }
|
[-]
[+]
|
Deleted |
_service:tar_git:ofono-1.19+git12+optionalmodem.20170515084831.1.g81299a0.tar.bz2/ofono/drivers/ril/ril_mtu.h
^
|
@@ -1,33 +0,0 @@
-/*
- * oFono - Open Source Telephony - RIL-based devices
- *
- * Copyright (C) 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
- * 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.
- */
-
-#ifndef RIL_MTU_H
-#define RIL_MTU_H
-
-#include "ril_types.h"
-
-struct ril_mtu_watch *ril_mtu_watch_new(int max_mtu);
-void ril_mtu_watch_free(struct ril_mtu_watch *mw);
-void ril_mtu_watch_set_ifname(struct ril_mtu_watch *mw, const char *ifname);
-
-#endif /* RIL_MTU_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 8
- * indent-tabs-mode: t
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:ofono-1.19+git12+optionalmodem.20170515084831.1.g81299a0.tar.bz2/ofono/drivers/ril/ril_plugin_dbus.c
^
|
@@ -1,956 +0,0 @@
-/*
- * oFono - Open Source Telephony - RIL-based devices
- *
- * 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
- * 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.
- */
-
-#include "ril_plugin.h"
-
-#include <ofono/log.h>
-#include <ofono/dbus.h>
-
-#include <gutil_strv.h>
-#include <gutil_log.h>
-#include <gdbus.h>
-
-#include "ofono.h"
-
-typedef void (*ril_plugin_dbus_append_fn)(DBusMessageIter *it,
- struct ril_plugin_dbus *dbus);
-typedef gboolean (*ril_plugin_dbus_slot_select_fn)
- (const struct ril_slot_info *slot);
-typedef const char *(*ril_plugin_dbus_slot_string_fn)
- (const struct ril_slot_info *slot);
-
-struct ril_plugin_dbus_request {
- DBusMessage *msg;
- ril_plugin_dbus_append_fn fn;
-};
-
-struct ril_plugin_dbus {
- struct ril_plugin *plugin;
- DBusConnection *conn;
- gboolean block_imei_req;
- GSList *blocked_imei_req;
- guint mms_watch;
-};
-
-#define RIL_DBUS_PATH "/"
-#define RIL_DBUS_INTERFACE "org.nemomobile.ofono.ModemManager"
-#define RIL_DBUS_INTERFACE_VERSION (6)
-
-#define RIL_DBUS_SIGNAL_ENABLED_MODEMS_CHANGED "EnabledModemsChanged"
-#define RIL_DBUS_SIGNAL_PRESENT_SIMS_CHANGED "PresentSimsChanged"
-#define RIL_DBUS_SIGNAL_DEFAULT_VOICE_SIM_CHANGED "DefaultVoiceSimChanged"
-#define RIL_DBUS_SIGNAL_DEFAULT_DATA_SIM_CHANGED "DefaultDataSimChanged"
-#define RIL_DBUS_SIGNAL_DEFAULT_VOICE_MODEM_CHANGED "DefaultVoiceModemChanged"
-#define RIL_DBUS_SIGNAL_DEFAULT_DATA_MODEM_CHANGED "DefaultDataModemChanged"
-#define RIL_DBUS_SIGNAL_MMS_SIM_CHANGED "MmsSimChanged"
-#define RIL_DBUS_SIGNAL_MMS_MODEM_CHANGED "MmsModemChanged"
-#define RIL_DBUS_SIGNAL_READY_CHANGED "ReadyChanged"
-#define RIL_DBUS_SIGNAL_MODEM_ERROR "ModemError"
-#define RIL_DBUS_IMSI_AUTO "auto"
-
-#define RIL_DBUS_ERROR_SIGNATURE "si"
-
-static gboolean ril_plugin_dbus_enabled(const struct ril_slot_info *slot)
-{
- return slot->enabled;
-}
-
-static gboolean ril_plugin_dbus_present(const struct ril_slot_info *slot)
-{
- return slot->sim_present;
-}
-
-static const char *ril_plugin_dbus_imei(const struct ril_slot_info *slot)
-{
- return slot->imei;
-}
-
-static void ril_plugin_dbus_append_path_array(DBusMessageIter *it,
- struct ril_plugin_dbus *dbus, ril_plugin_dbus_slot_select_fn selector)
-{
- DBusMessageIter array;
- const struct ril_slot_info *const *ptr = dbus->plugin->slots;
-
- dbus_message_iter_open_container(it, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &array);
-
- while (*ptr) {
- const struct ril_slot_info *slot = *ptr++;
- if (!selector || selector(slot)) {
- const char *path = slot->path;
- dbus_message_iter_append_basic(&array,
- DBUS_TYPE_OBJECT_PATH, &path);
- }
- }
-
- dbus_message_iter_close_container(it, &array);
-}
-
-static void ril_plugin_dbus_append_string_array(DBusMessageIter *it,
- struct ril_plugin_dbus *dbus, ril_plugin_dbus_slot_string_fn fn)
-{
- DBusMessageIter array;
- const struct ril_slot_info *const *ptr = dbus->plugin->slots;
-
- dbus_message_iter_open_container(it, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING_AS_STRING, &array);
-
- while (*ptr) {
- const struct ril_slot_info *slot = *ptr++;
- const char *str = fn(slot);
-
- if (!str) str = "";
- dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, &str);
- }
-
- dbus_message_iter_close_container(it, &array);
-}
-
-static void ril_plugin_dbus_append_boolean_array(DBusMessageIter *it,
- struct ril_plugin_dbus *dbus, ril_plugin_dbus_slot_select_fn value)
-{
- DBusMessageIter array;
- const struct ril_slot_info *const *ptr = dbus->plugin->slots;
-
- dbus_message_iter_open_container(it, DBUS_TYPE_ARRAY,
- DBUS_TYPE_BOOLEAN_AS_STRING, &array);
-
- while (*ptr) {
- const struct ril_slot_info *slot = *ptr++;
- dbus_bool_t b = value(slot);
-
- dbus_message_iter_append_basic(&array, DBUS_TYPE_BOOLEAN, &b);
- }
-
- dbus_message_iter_close_container(it, &array);
-}
-
-static void ril_plugin_dbus_append_boolean(DBusMessageIter *it, dbus_bool_t b)
-{
- dbus_message_iter_append_basic(it, DBUS_TYPE_BOOLEAN, &b);
-}
-
-static void ril_plugin_dbus_append_string(DBusMessageIter *it, const char *str)
-{
- if (!str) str = "";
- dbus_message_iter_append_basic(it, DBUS_TYPE_STRING, &str);
-}
-
-static void ril_plugin_dbus_append_imsi(DBusMessageIter *it, const char *imsi)
-{
- if (!imsi) imsi = RIL_DBUS_IMSI_AUTO;
- dbus_message_iter_append_basic(it, DBUS_TYPE_STRING, &imsi);
-}
-
-static void ril_plugin_dbus_append_path(DBusMessageIter *it, const char *path)
-{
- if (!path) path = "";
- /* It's DBUS_TYPE_STRING because DBUS_TYPE_OBJECT_PATH can't be empty */
- dbus_message_iter_append_basic(it, DBUS_TYPE_STRING, &path);
-}
-
-static void ril_plugin_dbus_message_append_path_array(DBusMessage *msg,
- struct ril_plugin_dbus *dbus, ril_plugin_dbus_slot_select_fn fn)
-{
- DBusMessageIter iter;
-
- dbus_message_iter_init_append(msg, &iter);
- ril_plugin_dbus_append_path_array(&iter, dbus, fn);
-}
-
-static void ril_plugin_dbus_append_modem_error(DBusMessageIter *it,
- const char *id, dbus_uint32_t count)
-{
- DBusMessageIter sub;
- dbus_message_iter_open_container(it, DBUS_TYPE_STRUCT, NULL, &sub);
- dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &id);
- dbus_message_iter_append_basic(&sub, DBUS_TYPE_INT32, &count);
- dbus_message_iter_close_container(it, &sub);
-}
-
-static void ril_plugin_dbus_append_modem_errors(DBusMessageIter *it,
- struct ril_plugin_dbus *dbus)
-{
- DBusMessageIter slots;
- const struct ril_slot_info *const *ptr = dbus->plugin->slots;
-
- dbus_message_iter_open_container(it, DBUS_TYPE_ARRAY,
- "a(" RIL_DBUS_ERROR_SIGNATURE ")", &slots);
-
- while (*ptr) {
- const struct ril_slot_info *slot = *ptr++;
- DBusMessageIter errors;
-
- dbus_message_iter_open_container(&slots, DBUS_TYPE_ARRAY,
- "(" RIL_DBUS_ERROR_SIGNATURE ")", &errors);
-
- if (g_hash_table_size(slot->errors)) {
|
[-]
[+]
|
Deleted |
_service:tar_git:ofono-1.19+git12+optionalmodem.20170515084831.1.g81299a0.tar.bz2/ofono/drivers/ril/ril_sim_info.c
^
|
@@ -1,668 +0,0 @@
-/*
- * oFono - Open Source Telephony - RIL-based devices
- *
- * Copyright (C) 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
- * 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.
- */
-
-#include "ril_sim_info.h"
-#include "ril_network.h"
-#include "ril_log.h"
-
-#include <ofono/sim.h>
-
-#include "ofono.h"
-#include "storage.h"
-
-#define RIL_SIM_INFO_STORE "cache"
-#define RIL_SIM_INFO_STORE_GROUP "sim"
-#define RIL_SIM_INFO_STORE_SPN "spn"
-
-/* ICCID -> IMSI map */
-#define RIL_SIM_ICCID_MAP "iccidmap"
-#define RIL_SIM_ICCID_MAP_IMSI "imsi"
-
-#define RIL_SIM_DEFAULT_SPN_BUFSIZE 8
-G_STATIC_ASSERT(RIL_SIM_DEFAULT_SPN_BUFSIZE >= \
- OFONO_MAX_MCC_LENGTH + OFONO_MAX_MNC_LENGTH + 1);
-
-typedef GObjectClass RilSimInfoClass;
-typedef struct ril_sim_info RilSimInfo;
-
-typedef void (*ril_sim_info_remove_cb_t)(struct ofono_sim *sim,
- unsigned int id);
-typedef void (*ril_sim_info_set_value_cb_t)(struct ril_sim_info *info,
- const char *value);
-
-struct ril_sim_info_watch {
- ril_sim_info_set_value_cb_t set_value;
- ril_sim_info_remove_cb_t remove;
- struct ril_sim_info *info;
- unsigned int id;
-};
-
-struct ril_sim_info_priv {
- char *log_prefix;
- char *iccid;
- char *imsi;
- char *cached_spn;
- char *sim_spn;
- char *public_spn;
- char default_spn[RIL_SIM_DEFAULT_SPN_BUFSIZE];
- int public_spn_block;
- struct ofono_sim *sim;
- struct ril_sim_info_watch state_watch;
- struct ril_sim_info_watch iccid_watch;
- struct ril_sim_info_watch imsi_watch;
- struct ril_sim_info_watch spn_watch;
- struct ril_network *network;
- gulong network_operator_changed_id;
- gboolean update_imsi_cache;
- gboolean update_iccid_map;
-};
-
-enum ril_sim_info_signal {
- SIGNAL_ICCID_CHANGED,
- SIGNAL_IMSI_CHANGED,
- SIGNAL_SPN_CHANGED,
- SIGNAL_COUNT
-};
-
-#define SIGNAL_ICCID_CHANGED_NAME "ril-sim-info-iccid-changed"
-#define SIGNAL_IMSI_CHANGED_NAME "ril-sim-info-imsi-changed"
-#define SIGNAL_SPN_CHANGED_NAME "ril-sim-info-spn-changed"
-
-static guint ril_sim_info_signals[SIGNAL_COUNT] = { 0 };
-
-G_DEFINE_TYPE(RilSimInfo, ril_sim_info, G_TYPE_OBJECT)
-#define RIL_SIMINFO_TYPE (ril_sim_info_get_type())
-#define RIL_SIMINFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
- RIL_SIMINFO_TYPE, RilSimInfo))
-
-#define NEW_SIGNAL(klass,name) \
- ril_sim_info_signals[SIGNAL_##name##_CHANGED] = \
- g_signal_new(SIGNAL_##name##_CHANGED_NAME, \
- G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
- 0, NULL, NULL, NULL, G_TYPE_NONE, 0)
-
-#define DBG_(info,fmt,args...) DBG("%s" fmt, (info)->priv->log_prefix, ##args)
-
-static void ril_sim_info_signal_emit(struct ril_sim_info *self,
- enum ril_sim_info_signal id)
-{
- g_signal_emit(self, ril_sim_info_signals[id], 0);
-}
-
-static void ril_sim_info_watch_remove(struct ril_sim_info_watch *watch)
-{
- if (watch->id) {
- struct ril_sim_info_priv *priv = watch->info->priv;
-
- GASSERT(priv->sim);
- if (priv->sim) {
- watch->remove(priv->sim, watch->id);
- GASSERT(!watch->id);
- }
-
- watch->id = 0;
- }
-
- if (watch->set_value) {
- watch->set_value(watch->info, NULL);
- }
-}
-
-static void ril_sim_info_remove_spn_watch(struct ofono_sim *sim,
- unsigned int id)
-{
- ofono_sim_remove_spn_watch(sim, &id);
-}
-
-static void ril_sim_info_update_imsi_cache(struct ril_sim_info *self)
-{
- struct ril_sim_info_priv *priv = self->priv;
-
- if (priv->update_imsi_cache && priv->imsi && priv->imsi[0] &&
- priv->cached_spn && priv->cached_spn[0]) {
- gboolean save = FALSE;
- const char *store = RIL_SIM_INFO_STORE;
- GKeyFile *cache = storage_open(priv->imsi, store);
- char *spn = g_key_file_get_string(cache,
- RIL_SIM_INFO_STORE_GROUP,
- RIL_SIM_INFO_STORE_SPN, NULL);
-
- if (g_strcmp0(priv->cached_spn, spn)) {
- save = TRUE;
- g_key_file_set_string(cache, RIL_SIM_INFO_STORE_GROUP,
- RIL_SIM_INFO_STORE_SPN, priv->cached_spn);
- }
-
- /*
- * Since we are most likely running on flash which
- * supports a limited number of writes, don't overwrite
- * the file unless something has actually changed.
- */
- if (save) {
- DBG_(self, "updating " STORAGEDIR "/%s/%s",
- priv->imsi, store);
- storage_close(priv->imsi, store, cache, TRUE);
- } else {
- g_key_file_free(cache);
- }
-
- g_free(spn);
- priv->update_imsi_cache = FALSE;
- }
-}
-
-static void ril_sim_info_update_iccid_map(struct ril_sim_info *self)
-{
- struct ril_sim_info_priv *priv = self->priv;
-
- if (priv->update_iccid_map && priv->iccid && priv->iccid[0] &&
- priv->imsi && priv->imsi[0]) {
- const char *store = RIL_SIM_ICCID_MAP;
- GKeyFile *map = storage_open(NULL, store);
- char *imsi = g_key_file_get_string(map, RIL_SIM_ICCID_MAP_IMSI,
- priv->iccid, NULL);
-
- /*
- * Since we are most likely running on flash which
- * supports a limited number of writes, don't overwrite
- * the file unless something has actually changed.
- */
- if (g_strcmp0(imsi, priv->imsi)) {
- DBG_(self, "updating " STORAGEDIR "/%s", store);
- g_key_file_set_string(map, RIL_SIM_ICCID_MAP_IMSI,
- priv->iccid, priv->imsi);
- storage_close(NULL, store, map, TRUE);
- } else {
- g_key_file_free(map);
- }
-
- g_free(imsi);
- priv->update_iccid_map = FALSE;
- }
-}
-
-static void ril_sim_info_set_imsi(struct ril_sim_info *self, const char *imsi)
-{
- struct ril_sim_info_priv *priv = self->priv;
-
|
[-]
[+]
|
Deleted |
_service:tar_git:ofono-1.19+git12+optionalmodem.20170515084831.1.g81299a0.tar.bz2/ofono/drivers/ril/ril_sim_info_dbus.c
^
|
@@ -1,246 +0,0 @@
-/*
- * oFono - Open Source Telephony - RIL-based devices
- *
- * Copyright (C) 2016-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.
- */
-
-#include "ril_plugin.h"
-#include "ril_sim_info.h"
-#include "ril_log.h"
-
-#include <gutil_misc.h>
-
-#include <ofono/dbus.h>
-
-#include <gdbus.h>
-
-#include "ofono.h"
-#include "storage.h"
-
-enum sim_info_event_id {
- SIM_INFO_EVENT_ICCID,
- SIM_INFO_EVENT_IMSI,
- SIM_INFO_EVENT_SPN,
- SIM_INFO_EVENT_COUNT
-};
-
-struct ril_sim_info_dbus {
- struct ril_modem *modem;
- struct ril_sim_info *info;
- DBusConnection *conn;
- char *path;
- gulong handler_id[SIM_INFO_EVENT_COUNT];
-};
-
-#define RIL_SIM_INFO_DBUS_INTERFACE "org.nemomobile.ofono.SimInfo"
-#define RIL_SIM_INFO_DBUS_INTERFACE_VERSION (1)
-
-#define RIL_SIM_INFO_DBUS_ICCID_CHANGED_SIGNAL "CardIdentifierChanged"
-#define RIL_SIM_INFO_DBUS_IMSI_CHANGED_SIGNAL "SubscriberIdentityChanged"
-#define RIL_SIM_INFO_DBUS_SPN_CHANGED_SIGNAL "ServiceProviderNameChanged"
-
-static void ril_sim_info_dbus_append_string(DBusMessageIter *it, const char *s)
-{
- if (!s) s = "";
- dbus_message_iter_append_basic(it, DBUS_TYPE_STRING, &s);
-}
-
-static DBusMessage *ril_sim_info_dbus_reply_with_string(DBusMessage *msg,
- const char *str)
-{
- DBusMessage *reply = dbus_message_new_method_return(msg);
- DBusMessageIter iter;
-
- dbus_message_iter_init_append(reply, &iter);
- ril_sim_info_dbus_append_string(&iter, str);
- return reply;
-}
-
-static DBusMessage *ril_sim_info_dbus_get_all(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct ril_sim_info_dbus *dbus = data;
- struct ril_sim_info *info = dbus->info;
- DBusMessage *reply = dbus_message_new_method_return(msg);
- const dbus_int32_t version = RIL_SIM_INFO_DBUS_INTERFACE_VERSION;
- DBusMessageIter iter;
-
- dbus_message_iter_init_append(reply, &iter);
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &version);
- ril_sim_info_dbus_append_string(&iter, info->iccid);
- ril_sim_info_dbus_append_string(&iter, info->imsi);
- ril_sim_info_dbus_append_string(&iter, info->spn);
- return reply;
-}
-
-static DBusMessage *ril_sim_info_dbus_get_version(DBusConnection *dc,
- DBusMessage *msg, void *data)
-{
- DBusMessage *reply = dbus_message_new_method_return(msg);
- dbus_int32_t version = RIL_SIM_INFO_DBUS_INTERFACE_VERSION;
- DBusMessageIter iter;
-
- dbus_message_iter_init_append(reply, &iter);
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &version);
- return reply;
-}
-
-static DBusMessage *ril_sim_info_dbus_get_iccid(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct ril_sim_info_dbus *dbus = data;
- return ril_sim_info_dbus_reply_with_string(msg, dbus->info->iccid);
-}
-
-static DBusMessage *ril_sim_info_dbus_get_imsi(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct ril_sim_info_dbus *dbus = data;
- return ril_sim_info_dbus_reply_with_string(msg, dbus->info->imsi);
-}
-
-static DBusMessage *ril_sim_info_dbus_get_spn(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct ril_sim_info_dbus *dbus = data;
- return ril_sim_info_dbus_reply_with_string(msg, dbus->info->spn);
-}
-
-#define RIL_SIM_INFO_DBUS_VERSION_ARG {"version", "i"}
-#define RIL_SIM_INFO_DBUS_ICCID_ARG {"iccid", "s"}
-#define RIL_SIM_INFO_DBUS_IMSI_ARG {"imsi", "s"}
-#define RIL_SIM_INFO_DBUS_SPN_ARG {"spn" , "s"}
-
-#define RIL_SIM_INFO_DBUS_GET_ALL_ARGS \
- RIL_SIM_INFO_DBUS_VERSION_ARG, \
- RIL_SIM_INFO_DBUS_ICCID_ARG, \
- RIL_SIM_INFO_DBUS_IMSI_ARG, \
- RIL_SIM_INFO_DBUS_SPN_ARG
-
-static const GDBusMethodTable ril_sim_info_dbus_methods[] = {
- { GDBUS_METHOD("GetAll",
- NULL, GDBUS_ARGS(RIL_SIM_INFO_DBUS_GET_ALL_ARGS),
- ril_sim_info_dbus_get_all) },
- { GDBUS_METHOD("GetInterfaceVersion",
- NULL, GDBUS_ARGS(RIL_SIM_INFO_DBUS_VERSION_ARG),
- ril_sim_info_dbus_get_version) },
- { GDBUS_METHOD("GetCardIdentifier",
- NULL, GDBUS_ARGS(RIL_SIM_INFO_DBUS_ICCID_ARG),
- ril_sim_info_dbus_get_iccid) },
- { GDBUS_METHOD("GetSubscriberIdentity",
- NULL, GDBUS_ARGS(RIL_SIM_INFO_DBUS_IMSI_ARG),
- ril_sim_info_dbus_get_imsi) },
- { GDBUS_METHOD("GetServiceProviderName",
- NULL, GDBUS_ARGS(RIL_SIM_INFO_DBUS_SPN_ARG),
- ril_sim_info_dbus_get_spn) },
- { }
-};
-
-static const GDBusSignalTable ril_sim_info_dbus_signals[] = {
- { GDBUS_SIGNAL(RIL_SIM_INFO_DBUS_ICCID_CHANGED_SIGNAL,
- GDBUS_ARGS(RIL_SIM_INFO_DBUS_ICCID_ARG)) },
- { GDBUS_SIGNAL(RIL_SIM_INFO_DBUS_IMSI_CHANGED_SIGNAL,
- GDBUS_ARGS(RIL_SIM_INFO_DBUS_IMSI_ARG)) },
- { GDBUS_SIGNAL(RIL_SIM_INFO_DBUS_SPN_CHANGED_SIGNAL,
- GDBUS_ARGS(RIL_SIM_INFO_DBUS_SPN_ARG)) },
- { }
-};
-
-static void ril_sim_info_dbus_emit(struct ril_sim_info_dbus *dbus,
- const char *signal, const char *value)
-{
- const char *arg = value;
- if (!arg) arg = "";
- g_dbus_emit_signal(dbus->conn, dbus->path, RIL_SIM_INFO_DBUS_INTERFACE,
- signal, DBUS_TYPE_STRING, &arg, DBUS_TYPE_INVALID);
-}
-
-static void ril_sim_info_dbus_iccid_cb(struct ril_sim_info *info, void *arg)
-{
- ril_sim_info_dbus_emit((struct ril_sim_info_dbus *)arg,
- RIL_SIM_INFO_DBUS_ICCID_CHANGED_SIGNAL, info->iccid);
-}
-
-static void ril_sim_info_dbus_imsi_cb(struct ril_sim_info *info, void *arg)
-{
- ril_sim_info_dbus_emit((struct ril_sim_info_dbus *)arg,
- RIL_SIM_INFO_DBUS_IMSI_CHANGED_SIGNAL, info->imsi);
-}
-
-static void ril_sim_info_dbus_spn_cb(struct ril_sim_info *info, void *arg)
-{
- ril_sim_info_dbus_emit((struct ril_sim_info_dbus *)arg,
- RIL_SIM_INFO_DBUS_SPN_CHANGED_SIGNAL, info->spn);
-}
-
-struct ril_sim_info_dbus *ril_sim_info_dbus_new(struct ril_modem *md,
- struct ril_sim_info *info)
-{
- struct ril_sim_info_dbus *dbus = g_new0(struct ril_sim_info_dbus, 1);
-
- DBG("%s", ril_modem_get_path(md));
- dbus->modem = md;
- dbus->path = g_strdup(ril_modem_get_path(md));
- dbus->info = ril_sim_info_ref(info);
- dbus->conn = dbus_connection_ref(ofono_dbus_get_connection());
-
- /* Register D-Bus interface */
- if (g_dbus_register_interface(dbus->conn, dbus->path,
- RIL_SIM_INFO_DBUS_INTERFACE, ril_sim_info_dbus_methods,
- ril_sim_info_dbus_signals, NULL, dbus, NULL)) {
|
[-]
[+]
|
Deleted |
_service:tar_git:ofono-1.19+git12+optionalmodem.20170515084831.1.g81299a0.tar.bz2/ofono/plugins/push-forwarder.c
^
|
@@ -1,541 +0,0 @@
-/*
- * Copyright (C) 2013-2014 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
-
-#include <glib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/inotify.h>
-#include <wspcodec.h>
-
-#define OFONO_API_SUBJECT_TO_CHANGE
-#include <ofono.h>
-#include <plugin.h>
-
-/*
- * Push forwarder plugin is looking for configuration files in
- * /etc/ofono/push_forwarder.d directory. Confiration files are
- * glib key files that look like this:
- *
- * [Jolla MMS Handler]
- * ContentType = application/vnd.wap.mms-message
- * Interface = com.jolla.MmsEngine.
- * Service = com.jolla.MmsEngine
- * Method = HandlePush
- * Path = /
- *
- * Only files with .conf suffix are loaded. In addition to the keys
- * from the above example, SourcePort and DestinationPort port keys
- * are supported. All other keys are ignored. One file may describe
- * several push handlers. See pf_parse_config() function for details.
- *
- * When push fowarder receives a WAP push, it goes through the list
- * of registered handlers and invokes all of them that match content
- * type and/or port numbers. The rest is up to the D-Bus service
- * handling the call.
- */
-
-#define PF_CONFIG_DIR CONFIGDIR "/push_forwarder.d"
-
-struct pf_modem {
- struct ofono_modem *modem;
- struct ofono_sms *sms;
- struct ofono_sim *sim;
- unsigned int sim_watch_id;
- unsigned int sms_watch_id;
- unsigned int push_watch_id;
-};
-
-struct push_datagram_handler {
- char *name;
- char *content_type;
- char *interface;
- char *service;
- char *method;
- char *path;
- int dst_port;
- int src_port;
-};
-
-static GSList *handlers;
-static GSList *modems;
-static unsigned int modem_watch_id;
-static int inotify_fd = -1;
-static int inotify_watch_id = -1;
-static guint inotify_watch_source_id;
-static GIOChannel *inotify_watch_channel;
-
-static void pf_notify_handler(struct push_datagram_handler *h,
- const char *imsi, const char *from, const struct tm *remote,
- const struct tm *local, int dst, int src,
- const char *ct, const void *data, unsigned int len)
-{
- struct tm remote_tm = *remote;
- struct tm local_tm = *local;
- dbus_uint32_t remote_time_arg = mktime(&remote_tm);
- dbus_uint32_t local_time_arg = mktime(&local_tm);
- dbus_int32_t dst_arg = dst;
- dbus_int32_t src_arg = src;
- DBusMessageIter iter, array;
- DBusMessage *msg = dbus_message_new_method_call(h->service,
- h->path, h->interface, h->method);
-
- dbus_message_append_args(msg,
- DBUS_TYPE_STRING, &imsi,
- DBUS_TYPE_STRING, &from,
- DBUS_TYPE_UINT32, &remote_time_arg,
- DBUS_TYPE_UINT32, &local_time_arg,
- DBUS_TYPE_INT32, &dst_arg,
- DBUS_TYPE_INT32, &src_arg,
- DBUS_TYPE_STRING, &ct,
- DBUS_TYPE_INVALID);
- dbus_message_iter_init_append(msg, &iter);
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- DBUS_TYPE_BYTE_AS_STRING, &array);
- dbus_message_iter_append_fixed_array(&array,
- DBUS_TYPE_BYTE, &data, len);
- dbus_message_iter_close_container(&iter, &array);
- dbus_message_set_no_reply(msg, TRUE);
- dbus_connection_send(ofono_dbus_get_connection(), msg, NULL);
- dbus_message_unref(msg);
-}
-
-static gboolean pf_match_port(int port, int expected_port)
-{
- if (expected_port < 0)
- return TRUE;
-
- if (expected_port == port)
- return TRUE;
-
- return FALSE;
-}
-
-static gboolean pf_match_handler(struct push_datagram_handler *h,
- const char *ct, int dst, int src)
-{
- if (pf_match_port(dst, h->dst_port) == FALSE)
- return FALSE;
-
- if (pf_match_port(src, h->src_port) == FALSE)
- return FALSE;
-
- if (h->content_type == NULL)
- return TRUE;
-
- if (strcmp(h->content_type, ct) == 0)
- return TRUE;
-
- return FALSE;
-}
-
-static void pf_handle_datagram(const char *from,
- const struct tm *remote, const struct tm *local, int dst,
- int src, const unsigned char *buffer, unsigned int len,
- void *userdata)
-{
- struct pf_modem *pm = userdata;
- guint remain;
- const guint8 *data;
- unsigned int hdrlen;
- unsigned int off;
- const void *ct;
- const char *imsi;
- GSList *link;
-
- DBG("received push of size: %u", len);
-
- if (pm->sim == NULL)
- return;
-
- imsi = ofono_sim_get_imsi(pm->sim);
- if (len < 3)
- return;
-
- if (buffer[1] != 6)
- return;
-
- remain = len - 2;
- data = buffer + 2;
-
- if (wsp_decode_uintvar(data, remain, &hdrlen, &off) == FALSE)
- return;
-
- if ((off + hdrlen) > remain)
- return;
-
- data += off;
- remain -= off;
-
- DBG(" WAP header %u bytes", hdrlen);
-
- if (wsp_decode_content_type(data, hdrlen, &ct, &off, NULL) == FALSE)
- return;
-
- data += hdrlen;
- remain -= hdrlen;
-
- DBG(" content type %s", (char *)ct);
- DBG(" imsi %s", imsi);
- DBG(" data size %u", remain);
-
- link = handlers;
-
- while (link) {
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/.gitignore
^
|
@@ -49,6 +49,19 @@
unit/test-*.log
unit/test-*.trs
+unit/test-grilreply
+unit/test-grilrequest
+unit/test-grilunsol
+unit/test-provision
+unit/html
+
+drivers/*/*.gcda
+drivers/*/*.gcno
+drivers/*/*.gcov
+*/*.gcda
+*/*.gcno
+*/*.gcov
+
tools/huawei-audio
tools/auto-enable
tools/get-location
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/Makefile.am
^
|
@@ -27,6 +27,11 @@
nodist_pkginclude_HEADERS = include/version.h
+if SAILFISH_MANAGER
+nodist_pkginclude_HEADERS += include/sailfish_manager.h \
+ include/sailfish_watch.h
+endif
+
local_headers = $(foreach file,$(pkginclude_HEADERS) \
$(nodist_pkginclude_HEADERS), \
include/ofono/$(notdir $(file)))
@@ -116,8 +121,17 @@
builtin_sources += plugins/udevng.c
endif
+if SAILFISH_MANAGER
+builtin_modules += sailfish_manager
+builtin_sources += plugins/sailfish_manager/sailfish_manager.c \
+ plugins/sailfish_manager/sailfish_manager_dbus.c \
+ plugins/sailfish_manager/sailfish_sim_info.c \
+ plugins/sailfish_manager/sailfish_sim_info_dbus.c \
+ plugins/sailfish_manager/sailfish_watch.c
+endif
+
if RILMODEM
-if JOLLA_RILMODEM
+if SAILFISH_RILMODEM
builtin_modules += ril
builtin_sources += drivers/ril/ril_call_barring.c \
@@ -134,20 +148,17 @@
drivers/ril/ril_gprs.c \
drivers/ril/ril_gprs_context.c \
drivers/ril/ril_modem.c \
- drivers/ril/ril_mtu.c \
drivers/ril/ril_netmon.c \
drivers/ril/ril_netreg.c \
drivers/ril/ril_network.c \
drivers/ril/ril_oem_raw.c \
drivers/ril/ril_phonebook.c \
drivers/ril/ril_plugin.c \
- drivers/ril/ril_plugin_dbus.c \
drivers/ril/ril_radio.c \
+ drivers/ril/ril_radio_caps.c \
drivers/ril/ril_radio_settings.c \
drivers/ril/ril_sim.c \
drivers/ril/ril_sim_card.c \
- drivers/ril/ril_sim_info.c \
- drivers/ril/ril_sim_info_dbus.c \
drivers/ril/ril_sim_settings.c \
drivers/ril/ril_sms.c \
drivers/ril/ril_stk.c \
@@ -576,9 +587,9 @@
builtin_modules += hfp_ag_bluez5
builtin_sources += plugins/hfp_ag_bluez5.c plugins/bluez5.h
-if SAILFISHFOS
+if SAILFISH_BT
builtin_modules += sfos_bt
-builtin_sources += plugins/sfos_bt.c
+builtin_sources += plugins/sailfish_bt.c
endif
endif
@@ -593,11 +604,25 @@
builtin_sources += plugins/nettime.c
endif
+if SAILFISH_DEBUGLOG
+builtin_modules += debuglog
+builtin_sources += plugins/sailfish_debuglog.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
@@ -635,16 +660,9 @@
builtin_modules += push_notification
builtin_sources += plugins/push-notification.c
-if PUSHFORWARDER
-builtin_modules += push_forwarder
-builtin_sources += plugins/push-forwarder.c
-builtin_cflags += @WSPCODEC_CFLAGS@
-builtin_libadd += @WSPCODEC_LIBS@
-endif
-
-if DEBUGLOG
-builtin_modules += debuglog
-builtin_sources += plugins/debuglog.c
+if SAILFISH_PUSHFORWARDER
+builtin_modules += pushforwarder
+builtin_sources += plugins/sailfish_pushforwarder.c
endif
builtin_modules += sms_history
@@ -656,6 +674,7 @@
sbin_PROGRAMS = src/ofonod
src_ofonod_SOURCES = $(builtin_sources) $(gatchat_sources) src/ofono.ver \
+ src/mtu-watch.c \
src/main.c src/ofono.h src/log.c src/plugin.c \
src/modem.c src/common.h src/common.c \
src/manager.c src/dbus.c src/util.h src/util.c \
@@ -849,6 +868,9 @@
dist_man_MANS = doc/ofonod.8
+if TEST_COVERAGE
+COVERAGE_OPT = --coverage
+endif
unit_objects =
@@ -857,8 +879,33 @@
unit/test-sms unit/test-cdmasms \
unit/test-provision
+if SAILFISH_MANAGER
+
+unit_test_sailfish_sim_info_SOURCES = unit/test-sailfish_sim_info.c \
+ unit/fake_sailfish_watch.c \
+ plugins/sailfish_manager/sailfish_sim_info.c \
+ src/storage.c src/watch.c src/log.c
+unit_test_sailfish_sim_info_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS) \
+ -DSTORAGEDIR='"/tmp/ofono"' -Iplugins/sailfish_manager
+unit_test_sailfish_sim_info_LDADD = @GLIB_LIBS@ -ldl
+unit_objects += $(unit_test_sailfish_sim_info_OBJECTS)
+unit_tests += unit/test-sailfish_sim_info
+
+unit_test_sailfish_manager_SOURCES = unit/test-sailfish_manager.c \
+ unit/fake_sailfish_watch.c \
+ plugins/sailfish_manager/sailfish_manager.c \
+ plugins/sailfish_manager/sailfish_sim_info.c \
+ src/storage.c src/log.c
+unit_test_sailfish_manager_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
+ -DSTORAGEDIR='"/tmp/ofono"' -Iplugins/sailfish_manager
+unit_test_sailfish_manager_LDADD = @GLIB_LIBS@ -ldl
+unit_objects += $(unit_test_sailfish_manager_OBJECTS)
+unit_tests += unit/test-sailfish_manager
+
+endif
+
if RILMODEM
-if JOLLA_RILMODEM
+if SAILFISH_RILMODEM
unit_tests += unit/test-rilmodem-cs \
unit/test-rilmodem-cs \
@@ -873,19 +920,23 @@
unit/test-sms-root unit/test-mux unit/test-caif
unit_test_common_SOURCES = unit/test-common.c src/common.c src/util.c
+unit_test_common_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_common_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_common_OBJECTS)
unit_test_util_SOURCES = unit/test-util.c src/util.c
+unit_test_util_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_util_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_utils_OBJECTS)
unit_test_idmap_SOURCES = unit/test-idmap.c src/idmap.c
+unit_test_idmap_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_idmap_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_idmap_OBJECTS)
unit_test_simutil_SOURCES = unit/test-simutil.c src/util.c \
src/simutil.c src/smsutil.c src/storage.c
+unit_test_simutil_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_simutil_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_simutil_OBJECTS)
@@ -893,19 +944,23 @@
src/util.c \
src/storage.c src/smsutil.c \
src/simutil.c src/stkutil.c
+unit_test_stkutil_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_stkutil_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_stkutil_OBJECTS)
unit_test_sms_SOURCES = unit/test-sms.c src/util.c src/smsutil.c src/storage.c
+unit_test_sms_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_sms_LDADD = @GLIB_LIBS@
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/configure.ac
^
|
@@ -69,6 +69,16 @@
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
+PKG_CHECK_MODULES(GOBJECT, gobject-2.0, dummy=yes,
+ AC_MSG_ERROR(GObject is required))
+GLIB_CFLAGS="$GLIB_CFLAGS $GOBJECT_CFLAGS"
+GLIB_LIBS="$GLIB_LIBS $GOBJECT_LIBS"
+
+PKG_CHECK_MODULES(GIO, gio-2.0, dummy=yes,
+ AC_MSG_ERROR(GIO is required))
+GLIB_CFLAGS="$GLIB_CFLAGS $GIO_CFLAGS"
+GLIB_LIBS="$GLIB_LIBS $GIO_LIBS"
+
if (test "${enable_threads}" = "yes"); then
AC_DEFINE(NEED_THREADS, 1, [Define if threading support is required])
PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
@@ -167,22 +177,31 @@
[enable_rilmodem=${enableval}])
AM_CONDITIONAL(RILMODEM, test "${enable_rilmodem}" != "no")
-AC_ARG_ENABLE(jolla-rilmodem,
- AC_HELP_STRING([--enable-jolla-rilmodem], [enable Jolla RIL modem]),
- [enable_jolla_rilmodem=${enableval}], [enable_jolla_rilmodem="no"])
-AM_CONDITIONAL(JOLLA_RILMODEM, test "${enable_jolla_rilmodem}" != "no")
-
-if (test "${enable_jolla_rilmodem}" = "yes"); then
- PKG_CHECK_MODULES(GRILIO, libgrilio >= 1.0.6, dummy=yes,
- AC_MSG_ERROR(libgrilio >= 1.0.6 is required))
- PKG_CHECK_MODULES(GLIBUTIL, libglibutil >= 1.0.5, dummy=yes,
- AC_MSG_ERROR(libglibutil >= 1.0.5 is required))
+AC_ARG_ENABLE(sailfish-rilmodem, AC_HELP_STRING([--enable-sailfish-rilmodem],
+ [enable Sailfish RIL modem]),
+ [enable_sailfish_rilmodem=${enableval}],
+ [enable_sailfish_rilmodem="no"])
+AM_CONDITIONAL(SAILFISH_RILMODEM, test "${enable_sailfish_rilmodem}" != "no")
+
+if (test "${enable_sailfish_rilmodem}" = "yes"); then
+ PKG_CHECK_MODULES(GRILIO, libgrilio >= 1.0.16, dummy=yes,
+ AC_MSG_ERROR(libgrilio >= 1.0.16 is required))
+ PKG_CHECK_MODULES(GLIBUTIL, libglibutil >= 1.0.23, dummy=yes,
+ AC_MSG_ERROR(libglibutil >= 1.0.23 is required))
PKG_CHECK_MODULES(LIBMCE, libmce-glib, dummy=yes,
AC_MSG_ERROR(libmce-glib is required))
- CFLAGS="$CFLAGS $GRILIO_CFLAGS $GLIBUTIL_CFLAGS $LIBMCE_CFLAGS"
- LIBS="$LIBS $GRILIO_LIBS $GLIBUTIL_LIBS $LIBMCE_LIBS"
+ CFLAGS="$CFLAGS $GRILIO_CFLAGS $LIBMCE_CFLAGS"
+ LIBS="$LIBS $GRILIO_LIBS $LIBMCE_LIBS"
+ enable_sailfish_manager=yes
+ need_glibutil=yes
fi
+AC_ARG_ENABLE(sailfish-manager,
+ AC_HELP_STRING([--enable-sailfish-manager],
+ [enable Sailfish OS modem manager plugin]),
+ [enable_sailfish_manager=${enableval}])
+AM_CONDITIONAL(SAILFISH_MANAGER, test "${enable_sailfish_manager}" = "yes")
+
AC_ARG_ENABLE(add-remove-context, AC_HELP_STRING([--disable-add-remove-context],
[don't allow to add or remove connection context over D-Bus]), [
if (test "${enableval}" = "no"); then
@@ -190,6 +209,12 @@
fi
])
+AC_ARG_ENABLE(test-coverage,
+ AC_HELP_STRING([--enable-test-coverage], [enable test code coverage]),
+ [enable_test_coverage=${enableval}],
+ [enable_test_coverage="no"])
+AM_CONDITIONAL(TEST_COVERAGE, test "${enable_test_coverage}" != "no")
+
AC_ARG_ENABLE(qmimodem, AC_HELP_STRING([--disable-qmimodem],
[disable Qualcomm QMI modem support]),
[enable_qmimodem=${enableval}])
@@ -213,9 +238,15 @@
AM_CONDITIONAL(BLUEZ4, test "${enable_bluetooth}" != "no" && test "${enable_bluez4}" = "yes")
AM_CONDITIONAL(BLUETOOTH, test "${enable_bluetooth}" != "no")
-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-bt, AC_HELP_STRING([--enable-sailfish-bt],
+ [enable Sailfish OS Bluetooth plugin]),
+ [enable_sailfish_bt=${enableval}])
+AM_CONDITIONAL(SAILFISH_BT, test "${enable_sailfish_bt}" = "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]),
@@ -259,28 +290,38 @@
[enable_datafiles=${enableval}])
AM_CONDITIONAL(DATAFILES, test "${enable_datafiles}" != "no")
-AC_ARG_ENABLE(pushforwarder, AC_HELP_STRING([--disable-pushforwarder],
- [disable Push Forwarder plugin]),
- [enable_pushforwarder=${enableval}])
-AM_CONDITIONAL(PUSHFORWARDER, test "${enable_pushforwarder}" != "no")
-if (test "${enable_pushforwarder}" != "no"); then
+AC_ARG_ENABLE(sailfish-pushforwarder, AC_HELP_STRING([--enable-sailfish-pushforwarder],
+ [enable Sailfish OS push forwarder plugin]),
+ [enable_sailfish_pushforwarder=${enableval}],
+ [enable_sailfish_pushforwarder="no"])
+AM_CONDITIONAL(SAILFISH_PUSHFORWARDER, test "${enable_sailfish_pushforwarder}" != "no")
+if (test "${enable_sailfish_pushforwarder}" != "no"); then
+ PKG_CHECK_MODULES(GLIBUTIL, libglibutil >= 1.0.15, dummy=yes,
+ AC_MSG_ERROR(libglibutil >= 1.0.15 is required))
PKG_CHECK_MODULES(WSPCODEC, libwspcodec >= 2.0, dummy=yes,
- AC_MSG_ERROR(WSP decoder is required))
- AC_SUBST(WSPCODEC_CFLAGS)
- AC_SUBST(WSPCODEC_LIBS)
+ AC_MSG_ERROR(WSP decoder is required))
+ CFLAGS="$CFLAGS $WSPCODEC_CFLAGS"
+ LIBS="$LIBS $WSPCODEC_LIBS"
+ need_glibutil=yes
fi
-AC_ARG_ENABLE(debuglog,
- AC_HELP_STRING([--enable-debuglog], [enable log control plugin]),
- [enable_debuglog=${enableval}], [enable_debuglog="no"])
-AM_CONDITIONAL(DEBUGLOG, test "${enable_debuglog}" != "no")
-if (test "${enable_debuglog}" = "yes"); then
+AC_ARG_ENABLE(sailfish-debuglog, AC_HELP_STRING([--enable-sailfish-debuglog],
+ [enable Sailfish OS debug log plugin]),
+ [enable_sailfish_debuglog=${enableval}],
+ [enable_sailfish_debuglog="no"])
+AM_CONDITIONAL(SAILFISH_DEBUGLOG, test "${enable_sailfish_debuglog}" != "no")
+if (test "${enable_sailfish_debuglog}" = "yes"); then
PKG_CHECK_MODULES(DBUSLOG, libdbuslogserver-dbus, dummy=yes,
AC_MSG_ERROR(libdbuslogserver-dbus is required))
CFLAGS="$CFLAGS $DBUSLOG_CFLAGS"
LIBS="$LIBS $DBUSLOG_LIBS"
fi
+if (test "${need_glibutil}" = "yes"); then
+ CFLAGS="$CFLAGS $GLIBUTIL_CFLAGS"
+ LIBS="$LIBS $GLIBUTIL_LIBS"
+fi
+
if (test "${prefix}" = "NONE"); then
dnl no prefix and no localstatedir, so default to /var
if (test "$localstatedir" = '${prefix}/var'); then
@@ -295,7 +336,7 @@
else
storagedir="${localstatedir}/lib/ofono"
fi
-AC_DEFINE_UNQUOTED(STORAGEDIR, "${storagedir}",
+AC_DEFINE_UNQUOTED(DEFAULT_STORAGEDIR, "${storagedir}",
[Directory for the storage files])
if (test "$sysconfdir" = '${prefix}/etc'); then
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/atmodem/gprs-context.c
^
|
@@ -247,6 +247,8 @@
/* 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 @@
* 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);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_call_barring.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015 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
@@ -16,7 +16,6 @@
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
-#include "ril_constants.h"
#include "common.h"
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_call_forward.c
^
|
@@ -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
@@ -16,7 +16,6 @@
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
-#include "ril_constants.h"
#include "common.h"
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_call_settings.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015 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
@@ -16,7 +16,6 @@
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
-#include "ril_constants.h"
#include "common.h"
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_call_volume.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015 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
@@ -16,7 +16,6 @@
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
-#include "ril_constants.h"
struct ril_call_volume {
struct ofono_call_volume *v;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_cbs.c
^
|
@@ -184,11 +184,14 @@
cd->q = grilio_queue_new(cd->io);
/*
- * RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG often fails at startup.
- * We may have to retry a few times.
+ * RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG often fails at startup
+ * especially if other RIL requests are running in parallel. We may
+ * have to retry a few times. Also, make it blocking in order to
+ * improve the chance of success.
*/
grilio_request_set_retry(req, RIL_CBS_CHECK_RETRY_MS,
RIL_CBS_CHECK_RETRY_COUNT);
+ grilio_request_set_blocking(req, TRUE);
grilio_queue_send_request_full(cd->q, req,
RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG,
ril_cbs_probe_done_cb, NULL, cd);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_cell_info_dbus.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2016 Jolla Ltd.
+ * Copyright (C) 2016-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
@@ -28,7 +28,6 @@
};
struct ril_cell_info_dbus {
- struct ril_modem *md;
struct ril_cell_info *info;
DBusConnection *conn;
char *path;
@@ -523,7 +522,6 @@
struct ril_cell_info_dbus *dbus = g_new0(struct ril_cell_info_dbus, 1);
DBG("%s", ril_modem_get_path(md));
- dbus->md = md;
dbus->path = g_strdup(ril_modem_get_path(md));
dbus->conn = dbus_connection_ref(ofono_dbus_get_connection());
dbus->info = ril_cell_info_ref(info);
@@ -553,8 +551,6 @@
DBG("%s", dbus->path);
g_dbus_unregister_interface(dbus->conn, dbus->path,
RIL_CELL_INFO_DBUS_INTERFACE);
- ofono_modem_remove_interface(dbus->md->ofono,
- RIL_CELL_INFO_DBUS_INTERFACE);
/* Unregister cells */
l = dbus->entries;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_config.c
^
|
@@ -14,6 +14,7 @@
*/
#include "ril_config.h"
+#include "ril_log.h"
#include <gutil_intarray.h>
#include <gutil_ints.h>
@@ -134,6 +135,50 @@
}
}
+gboolean ril_config_get_enum(GKeyFile *file, const char *group,
+ const char *key, int *result,
+ const char *name, int value, ...)
+{
+ char *str = ril_config_get_string(file, group, key);
+
+ if (str) {
+ /*
+ * Some people are thinking that # is a comment
+ * anywhere on the line, not just at the beginning
+ */
+ char *comment = strchr(str, '#');
+
+ if (comment) *comment = 0;
+ g_strstrip(str);
+ if (strcasecmp(str, name)) {
+ va_list args;
+ va_start(args, value);
+ while ((name = va_arg(args, char*)) != NULL) {
+ value = va_arg(args, int);
+ if (!strcasecmp(str, name)) {
+ break;
+ }
+ }
+ va_end(args);
+ }
+
+ if (!name) {
+ ofono_error("Invalid %s config value (%s)", key, str);
+ }
+
+ g_free(str);
+
+ if (name) {
+ if (result) {
+ *result = value;
+ }
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
GUtilInts *ril_config_get_ints(GKeyFile *file, const char *group,
const char *key)
{
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_config.h
^
|
@@ -32,6 +32,9 @@
const char *key, gboolean *value);
gboolean ril_config_get_flag(GKeyFile *file, const char *group,
const char *key, int flag, int *flags);
+gboolean ril_config_get_enum(GKeyFile *file, const char *group,
+ const char *key, int *result,
+ const char *name, int value, ...);
GUtilInts *ril_config_get_ints(GKeyFile *file, const char *group,
const char *key);
char *ril_config_ints_to_string(GUtilInts *ints, char separator);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_constants.h
^
|
@@ -19,37 +19,70 @@
#ifndef __RIL_CONSTANTS_H
#define __RIL_CONSTANTS_H 1
+#define RIL_MAX_UUID_LENGTH 64
+
/* Error Codes */
-#define RIL_E_SUCCESS 0
-#define RIL_E_RADIO_NOT_AVAILABLE 1
-#define RIL_E_GENERIC_FAILURE 2
-#define RIL_E_PASSWORD_INCORRECT 3
-#define RIL_E_SIM_PIN2 4
-#define RIL_E_SIM_PUK2 5
-#define RIL_E_REQUEST_NOT_SUPPORTED 6
-#define RIL_E_CANCELLED 7
-#define RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL 8
-#define RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW 9
-#define RIL_E_SMS_SEND_FAIL_RETRY 10
-#define RIL_E_SIM_ABSENT 11
-#define RIL_E_SUBSCRIPTION_NOT_AVAILABLE 12
-#define RIL_E_MODE_NOT_SUPPORTED 13
-#define RIL_E_FDN_CHECK_FAILURE 14
-#define RIL_E_ILLEGAL_SIM_OR_ME 15
-#define RIL_E_UNUSED 16
-#define RIL_E_DIAL_MODIFIED_TO_USSD 17
-#define RIL_E_DIAL_MODIFIED_TO_SS 18
-#define RIL_E_DIAL_MODIFIED_TO_DIAL 19
-#define RIL_E_USSD_MODIFIED_TO_DIAL 20
-#define RIL_E_USSD_MODIFIED_TO_SS 21
-#define RIL_E_USSD_MODIFIED_TO_USSD 22
-#define RIL_E_SS_MODIFIED_TO_DIAL 23
-#define RIL_E_SS_MODIFIED_TO_USSD 24
-#define RIL_E_SS_MODIFIED_TO_SS 25
-#define RIL_E_SUBSCRIPTION_NOT_SUPPORTED 26
-#define RIL_E_MISSING_RESOURCE 27
-#define RIL_E_NO_SUCH_ELEMENT 28
-#define RIL_E_INVALID_PARAMETER 29
+enum ril_status {
+ RIL_E_SUCCESS = 0,
+ RIL_E_RADIO_NOT_AVAILABLE = 1,
+ RIL_E_GENERIC_FAILURE = 2,
+ RIL_E_PASSWORD_INCORRECT = 3,
+ RIL_E_SIM_PIN2 = 4,
+ RIL_E_SIM_PUK2 = 5,
+ RIL_E_REQUEST_NOT_SUPPORTED = 6,
+ RIL_E_CANCELLED = 7,
+ RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL = 8,
+ RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW = 9,
+ RIL_E_SMS_SEND_FAIL_RETRY = 10,
+ RIL_E_SIM_ABSENT = 11,
+ RIL_E_SUBSCRIPTION_NOT_AVAILABLE = 12,
+ RIL_E_MODE_NOT_SUPPORTED = 13,
+ RIL_E_FDN_CHECK_FAILURE = 14,
+ RIL_E_ILLEGAL_SIM_OR_ME = 15,
+ RIL_E_MISSING_RESOURCE = 16,
+ RIL_E_NO_SUCH_ELEMENT = 17,
+ RIL_E_DIAL_MODIFIED_TO_USSD = 18,
+ RIL_E_DIAL_MODIFIED_TO_SS = 19,
+ RIL_E_DIAL_MODIFIED_TO_DIAL = 20,
+ RIL_E_USSD_MODIFIED_TO_DIAL = 21,
+ RIL_E_USSD_MODIFIED_TO_SS = 22,
+ RIL_E_USSD_MODIFIED_TO_USSD = 23,
+ RIL_E_SS_MODIFIED_TO_DIAL = 24,
+ RIL_E_SS_MODIFIED_TO_USSD = 25,
+ RIL_E_SUBSCRIPTION_NOT_SUPPORTED = 26,
+ RIL_E_SS_MODIFIED_TO_SS = 27,
+ RIL_E_LCE_NOT_SUPPORTED = 36,
+ RIL_E_NO_MEMORY = 37,
+ RIL_E_INTERNAL_ERR = 38,
+ RIL_E_SYSTEM_ERR = 39,
+ RIL_E_MODEM_ERR = 40,
+ RIL_E_INVALID_STATE = 41,
+ RIL_E_NO_RESOURCES = 42,
+ RIL_E_SIM_ERR = 43,
+ RIL_E_INVALID_ARGUMENTS = 44,
+ RIL_E_INVALID_SIM_STATE = 45,
+ RIL_E_INVALID_MODEM_STATE = 46,
+ RIL_E_INVALID_CALL_ID = 47,
+ RIL_E_NO_SMS_TO_ACK = 48,
+ RIL_E_NETWORK_ERR = 49,
+ RIL_E_REQUEST_RATE_LIMITED = 50,
+ RIL_E_SIM_BUSY = 51,
+ RIL_E_SIM_FULL = 52,
+ RIL_E_NETWORK_REJECT = 53,
+ RIL_E_OPERATION_NOT_ALLOWED = 54,
+ RIL_E_EMPTY_RECORD = 55,
+ RIL_E_INVALID_SMS_FORMAT = 56,
+ RIL_E_ENCODING_ERR = 57,
+ RIL_E_INVALID_SMSC_ADDRESS = 58,
+ RIL_E_NO_SUCH_ENTRY = 59,
+ RIL_E_NETWORK_NOT_READY = 60,
+ RIL_E_NOT_PROVISIONED = 61,
+ RIL_E_NO_SUBSCRIPTION = 62,
+ RIL_E_NO_NETWORK_FOUND = 63,
+ RIL_E_DEVICE_IN_USE = 64,
+ RIL_E_ABORTED = 65,
+ RIL_E_INVALID_RESPONSE = 66
+};
/* call states */
enum ril_call_state {
@@ -113,7 +146,60 @@
RADIO_TECH_HSPAP = 15,
RADIO_TECH_GSM = 16,
RADIO_TECH_TD_SCDMA = 17,
- RADIO_TECH_IWLAN = 18
+ RADIO_TECH_IWLAN = 18,
+ RADIO_TECH_LTE_CA = 19
+};
+
+/* Radio capabilities */
+enum ril_radio_access_family {
+ RAF_GPRS = (1 << RADIO_TECH_GPRS),
+ RAF_EDGE = (1 << RADIO_TECH_EDGE),
+ RAF_UMTS = (1 << RADIO_TECH_UMTS),
+ RAF_IS95A = (1 << RADIO_TECH_IS95A),
+ RAF_IS95B = (1 << RADIO_TECH_IS95B),
+ RAF_1xRTT = (1 << RADIO_TECH_1xRTT),
+ RAF_EVDO_0 = (1 << RADIO_TECH_EVDO_0),
+ RAF_EVDO_A = (1 << RADIO_TECH_EVDO_A),
+ RAF_HSDPA = (1 << RADIO_TECH_HSDPA),
+ RAF_HSUPA = (1 << RADIO_TECH_HSUPA),
+ RAF_HSPA = (1 << RADIO_TECH_HSPA),
+ RAF_EVDO_B = (1 << RADIO_TECH_EVDO_B),
+ RAF_EHRPD = (1 << RADIO_TECH_EHRPD),
+ RAF_LTE = (1 << RADIO_TECH_LTE),
+ RAF_HSPAP = (1 << RADIO_TECH_HSPAP),
+ RAF_GSM = (1 << RADIO_TECH_GSM),
+ RAF_TD_SCDMA = (1 << RADIO_TECH_TD_SCDMA),
+ RAF_LTE_CA = (1 << RADIO_TECH_LTE_CA)
+};
+
+enum ril_radio_capability_phase {
+ RC_PHASE_CONFIGURED = 0,
+ RC_PHASE_START = 1,
+ RC_PHASE_APPLY = 2,
+ RC_PHASE_UNSOL_RSP = 3,
+ RC_PHASE_FINISH = 4
+};
+
+enum ril_radio_capability_status {
+ RC_STATUS_NONE = 0,
+ RC_STATUS_SUCCESS = 1,
+ RC_STATUS_FAIL = 2
+};
+
+#define RIL_RADIO_CAPABILITY_VERSION 1
+
+struct ril_radio_capability {
+ int version;
+ int session;
+ enum ril_radio_capability_phase phase;
+ enum ril_radio_access_family rat;
+ char logicalModemUuid[RIL_MAX_UUID_LENGTH];
+ int status;
+};
+
+enum ril_uicc_subscription_action {
+ RIL_UICC_SUBSCRIPTION_DEACTIVATE = 0,
+ RIL_UICC_SUBSCRIPTION_ACTIVATE = 1
};
/* See RIL_REQUEST_LAST_CALL_FAIL_CAUSE */
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_data.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2016 Jolla Ltd.
+ * Copyright (C) 2016-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
@@ -27,9 +27,7 @@
#include <grilio_parser.h>
#include <grilio_request.h>
-#define SETUP_DATA_CALL_PARAMS 7
#define DATA_PROFILE_DEFAULT_STR "0"
-#define DEACTIVATE_DATA_CALL_PARAMS 2
#define PROTO_IP_STR "IP"
#define PROTO_IPV6_STR "IPV6"
@@ -170,9 +168,9 @@
int cid;
};
-struct ril_data_request_2g {
+struct ril_data_request_allow_data {
struct ril_data_request req;
- gulong handler_id;
+ gboolean allow;
};
static void ril_data_manager_check_data(struct ril_data_manager *dm);
@@ -185,6 +183,26 @@
}
/*==========================================================================*
+ * RIL requests
+ *==========================================================================*/
+
+GRilIoRequest *ril_request_allow_data_new(gboolean allow)
+{
+ return grilio_request_array_int32_new(1, allow);
+}
+
+GRilIoRequest *ril_request_deactivate_data_call_new(int cid)
+{
+ GRilIoRequest *req = grilio_request_new();
+
+ grilio_request_append_int32(req, 2 /* Parameter count */);
+ grilio_request_append_format(req, "%d", cid);
+ grilio_request_append_format(req, "%d",
+ RIL_DEACTIVATE_DATA_CALL_NO_REASON);
+ return req;
+}
+
+/*==========================================================================*
* ril_data_call
*==========================================================================*/
@@ -787,8 +805,8 @@
G_CAST(req, struct ril_data_request_setup, 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;
+ GRilIoRequest *ioreq;
+ int tech, auth = RIL_AUTH_NONE;
GASSERT(proto_str);
@@ -811,21 +829,29 @@
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
* profiles...
*/
ioreq = grilio_request_new();
- grilio_request_append_int32(ioreq, SETUP_DATA_CALL_PARAMS);
+ grilio_request_append_int32(ioreq, 7 /* Parameter count */);
grilio_request_append_format(ioreq, "%d", tech);
grilio_request_append_utf8(ioreq, DATA_PROFILE_DEFAULT_STR);
grilio_request_append_utf8(ioreq, setup->apn);
@@ -924,6 +950,10 @@
ril_data_call_free(call);
ril_data_signal_emit(data, SIGNAL_CALLS_CHANGED);
}
+ } else {
+ /* Something seems to be slightly broken, request the
+ * current state */
+ ril_data_poll_call_state(data);
}
if (req->cb.deact) {
@@ -938,12 +968,8 @@
struct ril_data_request_deact *deact =
G_CAST(req, struct ril_data_request_deact, req);
struct ril_data_priv *priv = req->data->priv;
- GRilIoRequest* ioreq = grilio_request_new();
-
- grilio_request_append_int32(ioreq, DEACTIVATE_DATA_CALL_PARAMS);
- grilio_request_append_format(ioreq, "%d", deact->cid);
- grilio_request_append_format(ioreq, "%d",
- RIL_DEACTIVATE_DATA_CALL_NO_REASON);
+ GRilIoRequest *ioreq =
+ ril_request_deactivate_data_call_new(deact->cid);
req->pending_id = grilio_queue_send_request_full(priv->q, ioreq,
RIL_REQUEST_DEACTIVATE_DATA_CALL,
@@ -975,15 +1001,6 @@
* ril_data_allow_request
*==========================================================================*/
-static GRilIoRequest *ril_data_allow_req(gboolean allow)
-{
- GRilIoRequest *req = grilio_request_sized_new(8);
-
- grilio_request_append_int32(req, 1);
- grilio_request_append_int32(req, allow != FALSE);
- return req;
-}
-
static void ril_data_allow_cb(GRilIoChannel *io, int ril_status,
const void *req_data, guint len, void *user_data)
{
@@ -993,13 +1010,22 @@
ril_data_request_completed(req);
- if (ril_status == RIL_E_SUCCESS &&
- (priv->flags & RIL_DATA_FLAG_ALLOWED)) {
- GASSERT(!ril_data_allowed(data));
- priv->flags |= RIL_DATA_FLAG_ON;
- GASSERT(ril_data_allowed(data));
- DBG_(data, "data on");
- ril_data_signal_emit(data, SIGNAL_ALLOW_CHANGED);
+ if (ril_status == RIL_E_SUCCESS) {
+ const gboolean was_allowed = ril_data_allowed(data);
+ struct ril_data_request_allow_data *ad =
+ G_CAST(req, struct ril_data_request_allow_data, req);
+
+ if (ad->allow) {
+ priv->flags |= RIL_DATA_FLAG_ON;
+ DBG_(data, "data on");
+ } else {
+ priv->flags &= ~RIL_DATA_FLAG_ON;
+ DBG_(data, "data off");
+ }
+
+ if (ril_data_allowed(data) != was_allowed) {
+ ril_data_signal_emit(data, SIGNAL_ALLOW_CHANGED);
+ }
}
ril_data_request_finish(req);
@@ -1007,25 +1033,32 @@
static gboolean ril_data_allow_submit(struct ril_data_request *req)
{
- GRilIoRequest *ioreq = ril_data_allow_req(TRUE);
+ struct ril_data_request_allow_data *ad =
+ G_CAST(req, struct ril_data_request_allow_data, req);
+ GRilIoRequest *ioreq = ril_request_allow_data_new(ad->allow);
struct ril_data_priv *priv = req->data->priv;
grilio_request_set_retry(ioreq, RIL_RETRY_SECS*1000, -1);
+ grilio_request_set_blocking(ioreq, TRUE);
req->pending_id = grilio_queue_send_request_full(priv->q, ioreq,
RIL_REQUEST_ALLOW_DATA, ril_data_allow_cb, NULL, req);
grilio_request_unref(ioreq);
return TRUE;
}
-static struct ril_data_request *ril_data_allow_new(struct ril_data *data)
+static struct ril_data_request *ril_data_allow_new(struct ril_data *data,
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_data.h
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2016 Jolla Ltd.
+ * Copyright (C) 2016-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
@@ -56,8 +56,8 @@
enum ril_data_allow_data_opt {
RIL_ALLOW_DATA_AUTO,
- RIL_ALLOW_DATA_ON,
- RIL_ALLOW_DATA_OFF
+ RIL_ALLOW_DATA_ENABLED,
+ RIL_ALLOW_DATA_DISABLED
};
enum ril_data_call_format {
@@ -84,6 +84,7 @@
struct ril_data_manager *ril_data_manager_new(enum ril_data_manager_flags flg);
struct ril_data_manager *ril_data_manager_ref(struct ril_data_manager *dm);
void ril_data_manager_unref(struct ril_data_manager *dm);
+void ril_data_manager_assert_data_on(struct ril_data_manager *dm);
typedef void (*ril_data_cb_t)(struct ril_data *data, void *arg);
typedef void (*ril_data_call_setup_cb_t)(struct ril_data *data,
@@ -99,6 +100,7 @@
struct ril_data *ril_data_ref(struct ril_data *data);
void ril_data_unref(struct ril_data *data);
gboolean ril_data_allowed(struct ril_data *data);
+void ril_data_poll_call_state(struct ril_data *data);
gulong ril_data_add_allow_changed_handler(struct ril_data *data,
ril_data_cb_t cb, void *arg);
@@ -122,6 +124,10 @@
struct ril_data_call *ril_data_call_find(struct ril_data_call_list *list,
int cid);
+/* Constructors of various kinds of RIL requests */
+GRilIoRequest *ril_request_allow_data_new(gboolean allow);
+GRilIoRequest *ril_request_deactivate_data_call_new(int cid);
+
#endif /* RIL_DATA_H */
/*
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_gprs_context.c
^
|
@@ -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,7 +17,6 @@
#include "ril_network.h"
#include "ril_data.h"
#include "ril_util.h"
-#include "ril_mtu.h"
#include "ril_log.h"
#include <gutil_strv.h>
@@ -25,6 +24,7 @@
#include <arpa/inet.h>
#include "common.h"
+#include "mtu-watch.h"
#define CTX_ID_NONE ((unsigned int)(-1))
@@ -43,7 +43,7 @@
struct ril_data *data;
guint active_ctx_cid;
gulong calls_changed_id;
- struct ril_mtu_watch *mtu_watch;
+ struct mtu_watch *mtu_watch;
struct ril_data_call *active_call;
struct ril_gprs_context_call activate;
struct ril_gprs_context_call deactivate;
@@ -95,7 +95,7 @@
gcd->calls_changed_id = 0;
}
if (gcd->mtu_watch) {
- ril_mtu_watch_free(gcd->mtu_watch);
+ mtu_watch_free(gcd->mtu_watch);
gcd->mtu_watch = NULL;
}
}
@@ -107,9 +107,9 @@
ril_data_call_free(gcd->active_call);
gcd->active_call = ril_data_call_dup(call);
if (!gcd->mtu_watch) {
- gcd->mtu_watch = ril_mtu_watch_new(MAX_MTU);
+ gcd->mtu_watch = mtu_watch_new(MAX_MTU);
}
- ril_mtu_watch_set_ifname(gcd->mtu_watch, call->ifname);
+ mtu_watch_set_ifname(gcd->mtu_watch, call->ifname);
} else {
ril_gprs_context_free_active_call(gcd);
}
@@ -575,7 +575,7 @@
ril_data_unref(gcd->data);
ril_network_unref(gcd->network);
ril_data_call_free(gcd->active_call);
- ril_mtu_watch_free(gcd->mtu_watch);
+ mtu_watch_free(gcd->mtu_watch);
g_free(gcd);
}
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_modem.c
^
|
@@ -25,6 +25,8 @@
#include "ofono.h"
+#include "sailfish_watch.h"
+
#define MAX_PDP_CONTEXTS (2)
#define ONLINE_TIMEOUT_SECS (15) /* 20 sec is hardcoded in ofono core */
@@ -50,6 +52,7 @@
struct ril_modem_data {
struct ril_modem modem;
+ struct sailfish_watch *watch;
GRilIoQueue *q;
char *log_prefix;
char *imeisv;
@@ -57,18 +60,12 @@
char *ecclist_file;
gboolean pre_sim_done;
gboolean allow_data;
- gulong sim_imsi_event_id;
+ gulong imsi_event_id;
guint online_check_id;
enum ril_modem_power_state power_state;
gulong radio_state_event_id;
- ril_modem_cb_t removed_cb;
- void *removed_cb_data;
-
- ril_modem_online_cb_t online_cb;
- void *online_cb_data;
-
struct ril_modem_online_request set_online;
struct ril_modem_online_request set_offline;
};
@@ -84,11 +81,6 @@
return md;
}
-static struct ril_modem_data *ril_modem_data_from_modem(struct ril_modem *m)
-{
- return m ? G_CAST(m, struct ril_modem_data, modem) : NULL;
-}
-
static void *ril_modem_get_atom_data(struct ril_modem *modem,
enum ofono_atom_type type)
{
@@ -132,24 +124,6 @@
}
}
-void ril_modem_set_removed_cb(struct ril_modem *modem, ril_modem_cb_t cb,
- void *data)
-{
- struct ril_modem_data *md = ril_modem_data_from_modem(modem);
-
- md->removed_cb = cb;
- md->removed_cb_data = data;
-}
-
-void ril_modem_set_online_cb(struct ril_modem *modem, ril_modem_online_cb_t cb,
- void *data)
-{
- struct ril_modem_data *md = ril_modem_data_from_modem(modem);
-
- md->online_cb = cb;
- md->online_cb_data = data;
-}
-
static void ril_modem_online_request_ok(struct ril_modem_online_request *req)
{
if (req->timeout_id) {
@@ -234,7 +208,7 @@
static void ril_modem_update_radio_settings(struct ril_modem_data *md)
{
struct ril_modem *m = &md->modem;
- if (m->radio->state == RADIO_STATE_ON && m->sim_settings->imsi) {
+ if (m->radio->state == RADIO_STATE_ON && md->watch->imsi) {
/* radio-settings.c assumes that IMSI is available */
if (!ril_modem_radio_settings(m)) {
DBG_(md, "initializing radio settings interface");
@@ -262,11 +236,11 @@
ril_modem_update_online_state(md);
}
-static void ril_modem_imsi_cb(struct ril_sim_settings *settings, void *data)
+static void ril_modem_imsi_cb(struct sailfish_watch *watch, void *data)
{
struct ril_modem_data *md = data;
- GASSERT(md->modem.sim_settings == settings);
+ GASSERT(md->watch == watch);
ril_modem_update_radio_settings(md);
}
@@ -278,7 +252,9 @@
md->pre_sim_done = TRUE;
ofono_devinfo_create(modem, 0, RILMODEM_DRIVER, md);
ofono_sim_create(modem, 0, RILMODEM_DRIVER, md);
- ofono_voicecall_create(modem, 0, RILMODEM_DRIVER, md);
+ if (md->modem.config.enable_voicecall) {
+ ofono_voicecall_create(modem, 0, RILMODEM_DRIVER, md);
+ }
if (!md->radio_state_event_id) {
md->radio_state_event_id =
ril_radio_add_state_changed_handler(md->modem.radio,
@@ -337,10 +313,6 @@
DBG("%s going %sline", ofono_modem_get_path(modem),
online ? "on" : "off");
- if (md->online_cb) {
- md->online_cb(&md->modem, online, md->online_cb_data);
- }
-
if (online) {
ril_radio_power_on(md->modem.radio, RADIO_POWER_TAG(md));
req = &md->set_online;
@@ -394,25 +366,16 @@
struct ril_modem *modem = &md->modem;
DBG("%s", ril_modem_get_path(modem));
- if (md->removed_cb) {
- ril_modem_cb_t cb = md->removed_cb;
- void *data = md->removed_cb_data;
-
- md->removed_cb = NULL;
- md->removed_cb_data = NULL;
- cb(modem, data);
- }
-
ofono_modem_set_data(ofono, NULL);
ril_radio_remove_handler(modem->radio, md->radio_state_event_id);
ril_radio_power_off(modem->radio, RADIO_POWER_TAG(md));
ril_radio_unref(modem->radio);
-
- ril_sim_settings_remove_handler(modem->sim_settings,
- md->sim_imsi_event_id);
ril_sim_settings_unref(modem->sim_settings);
+ sailfish_watch_remove_handler(md->watch, md->imsi_event_id);
+ sailfish_watch_unref(md->watch);
+
if (md->online_check_id) {
g_source_remove(md->online_check_id);
}
@@ -440,13 +403,15 @@
}
struct ril_modem *ril_modem_create(GRilIoChannel *io, const char *log_prefix,
- const struct ril_slot_info *slot, struct ril_radio *radio,
- struct ril_network *network, struct ril_sim_card *card,
- struct ril_data *data, struct ril_sim_settings *settings,
+ const char *path, const char *imei, const char *imeisv,
+ const char *ecclist_file, const struct ril_slot_config *config,
+ struct ril_radio *radio, struct ril_network *network,
+ struct ril_sim_card *card, struct ril_data *data,
+ struct ril_sim_settings *settings,
struct ril_cell_info *cell_info)
{
/* Skip the slash from the path, it looks like "/ril_0" */
- struct ofono_modem *ofono = ofono_modem_create(slot->path + 1,
+ struct ofono_modem *ofono = ofono_modem_create(path + 1,
RILMODEM_DRIVER);
if (ofono) {
int err;
@@ -457,15 +422,14 @@
* ril_plugin.c must wait until IMEI becomes known before
* creating the modem
*/
- GASSERT(slot->imei);
+ GASSERT(imei);
/* 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);
+ modem->config = *config;
+ modem->imei = md->imei = g_strdup(imei);
+ modem->imeisv = md->imeisv = g_strdup(imeisv);
+ modem->log_prefix = log_prefix; /* No need to strdup */
+ modem->ecclist_file = ecclist_file; /* No need to strdup */
md->log_prefix = (log_prefix && log_prefix[0]) ?
g_strconcat(log_prefix, " ", NULL) : g_strdup("");
@@ -478,14 +442,10 @@
modem->data = ril_data_ref(data);
modem->io = grilio_channel_ref(io);
md->q = grilio_queue_new(io);
+ md->watch = sailfish_watch_new(path);
- /*
- * modem->sim_settings->imsi follows IMSI known to the ofono
- * core, unlike ril_sim_info->imsi which may point to the
- * cached IMSI even before the PIN code is entered.
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_network.c
^
|
@@ -20,6 +20,8 @@
#include "ril_util.h"
#include "ril_log.h"
+#include "sailfish_watch.h"
+
#include <grilio_queue.h>
#include <grilio_request.h>
#include <grilio_parser.h>
@@ -41,18 +43,30 @@
TIMER_COUNT
};
+enum ril_network_watch_events {
+ WATCH_EVENT_ONLINE,
+ WATCH_EVENT_COUNT
+};
+
enum ril_network_radio_event {
RADIO_EVENT_STATE_CHANGED,
RADIO_EVENT_ONLINE_CHANGED,
RADIO_EVENT_COUNT
};
+enum ril_network_unsol_event {
+ UNSOL_EVENT_NETWORK_STATE,
+ UNSOL_EVENT_RADIO_CAPABILITY,
+ UNSOL_EVENT_COUNT
+};
+
struct ril_network_priv {
GRilIoChannel *io;
GRilIoQueue *q;
struct ril_radio *radio;
struct ril_sim_card *sim_card;
- enum ofono_radio_access_mode max_pref_mode;
+ struct sailfish_watch *watch;
+ gulong watch_event_id[WATCH_EVENT_COUNT];
int rat;
char *log_prefix;
guint operator_poll_id;
@@ -61,11 +75,12 @@
guint timer[TIMER_COUNT];
gulong query_rat_id;
gulong set_rat_id;
- gulong ril_event_id;
+ gulong unsol_event_id[UNSOL_EVENT_COUNT];
gulong settings_event_id;
gulong sim_status_event_id;
gulong radio_event_id[RADIO_EVENT_COUNT];
struct ofono_network_operator operator;
+ gboolean assert_rat;
};
enum ril_network_signal {
@@ -73,13 +88,15 @@
SIGNAL_VOICE_STATE_CHANGED,
SIGNAL_DATA_STATE_CHANGED,
SIGNAL_PREF_MODE_CHANGED,
+ SIGNAL_MAX_PREF_MODE_CHANGED,
SIGNAL_COUNT
};
-#define SIGNAL_OPERATOR_CHANGED_NAME "ril-network-operator-changed"
-#define SIGNAL_VOICE_STATE_CHANGED_NAME "ril-network-voice-state-changed"
-#define SIGNAL_DATA_STATE_CHANGED_NAME "ril-network-data-state-changed"
-#define SIGNAL_PREF_MODE_CHANGED_NAME "ril-network-pref-mode-changed"
+#define SIGNAL_OPERATOR_CHANGED_NAME "ril-network-operator-changed"
+#define SIGNAL_VOICE_STATE_CHANGED_NAME "ril-network-voice-state-changed"
+#define SIGNAL_DATA_STATE_CHANGED_NAME "ril-network-data-state-changed"
+#define SIGNAL_PREF_MODE_CHANGED_NAME "ril-network-pref-mode-changed"
+#define SIGNAL_MAX_PREF_MODE_CHANGED_NAME "ril-network-max-pref-mode-changed"
static guint ril_network_signals[SIGNAL_COUNT] = { 0 };
@@ -450,7 +467,7 @@
* it becomes necessary.
*/
const enum ofono_radio_access_mode max_pref_mode =
- (priv->radio->state == RADIO_STATE_ON) ? priv->max_pref_mode :
+ (priv->radio->state == RADIO_STATE_ON) ? self->max_pref_mode :
OFONO_RADIO_ACCESS_MODE_GSM;
/*
@@ -470,7 +487,7 @@
{
struct ril_network_priv *priv = self->priv;
- return priv->radio->online && ril_sim_card_ready(priv->sim_card);
+ return priv->watch->online && ril_sim_card_ready(priv->sim_card);
}
static gboolean ril_network_set_rat_holdoff_cb(gpointer user_data)
@@ -489,7 +506,7 @@
* and SIM card state change callbacks will schedule a new check
* when it's appropriate.
*/
- if (priv->rat != rat) {
+ if (priv->rat != rat || priv->assert_rat) {
if (ril_network_can_set_pref_mode(self)) {
ril_network_set_pref_mode(self, rat);
} else {
@@ -530,6 +547,9 @@
ril_network_set_pref_mode_cb, NULL, self);
grilio_request_unref(req);
+ /* We have submitted the request, clear the assertion flag */
+ priv->assert_rat = FALSE;
+
/* Don't do it too often */
GASSERT(!priv->timer[TIMER_SET_RAT_HOLDOFF]);
priv->timer[TIMER_SET_RAT_HOLDOFF] =
@@ -557,8 +577,7 @@
ril_network_stop_timer(self, TIMER_SET_RAT_HOLDOFF);
}
- if (priv->rat != rat) {
- /* Something isn't right, we need to fix it */
+ if (priv->rat != rat || priv->assert_rat) {
if (!priv->timer[TIMER_SET_RAT_HOLDOFF]) {
ril_network_set_pref_mode(self, rat);
} else {
@@ -647,17 +666,25 @@
enum ofono_radio_access_mode max_mode,
gboolean force_check)
{
- if (G_LIKELY(self)) {
- struct ril_network_priv *priv = self->priv;
- if (priv->max_pref_mode != max_mode || force_check) {
+ if (self && (self->max_pref_mode != max_mode || force_check)) {
+ if (self->max_pref_mode != max_mode) {
DBG_(self, "rat mode %d (%s)", max_mode,
ofono_radio_access_mode_to_string(max_mode));
- priv->max_pref_mode = max_mode;
- ril_network_check_pref_mode(self, TRUE);
+ self->max_pref_mode = max_mode;
+ ril_network_emit(self, SIGNAL_MAX_PREF_MODE_CHANGED);
}
+ ril_network_check_pref_mode(self, TRUE);
}
}
+void ril_network_assert_pref_mode(struct ril_network *self, gboolean immediate)
+{
+ struct ril_network_priv *priv = self->priv;
+
+ priv->assert_rat = TRUE;
+ ril_network_check_pref_mode(self, immediate);
+}
+
gulong ril_network_add_operator_changed_handler(struct ril_network *self,
ril_network_cb_t cb, void *arg)
{
@@ -686,6 +713,13 @@
SIGNAL_PREF_MODE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
+gulong ril_network_add_max_pref_mode_changed_handler(struct ril_network *self,
+ ril_network_cb_t cb, void *arg)
+{
+ return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
+ SIGNAL_MAX_PREF_MODE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
+}
+
void ril_network_remove_handler(struct ril_network *self, gulong id)
{
if (G_LIKELY(self) && G_LIKELY(id)) {
@@ -698,7 +732,7 @@
gutil_disconnect_handlers(self, ids, n);
}
-static void ril_network_voice_state_changed_cb(GRilIoChannel *io, guint code,
+static void ril_network_state_changed_cb(GRilIoChannel *io, guint code,
const void *data, guint len, void *user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
@@ -708,6 +742,16 @@
ril_network_poll_state(self);
}
+static void ril_network_radio_capability_changed_cb(GRilIoChannel *io,
+ guint code, const void *data, guint len, void *user_data)
+{
+ struct ril_network *self = RIL_NETWORK(user_data);
+
+ DBG_(self, "");
+ GASSERT(code == RIL_UNSOL_RADIO_CAPABILITY);
+ ril_network_assert_pref_mode(self, FALSE);
+}
+
static void ril_network_radio_state_cb(struct ril_radio *radio, void *data)
{
struct ril_network *self = RIL_NETWORK(data);
@@ -718,7 +762,7 @@
}
}
-static void ril_network_radio_online_cb(struct ril_radio *radio, void *data)
+static void ril_network_online_cb(struct sailfish_watch *watch, void *data)
{
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_network.h
^
|
@@ -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
@@ -18,8 +18,6 @@
#include "ril_types.h"
-#include <ofono/radio-settings.h>
-
struct ofono_network_operator;
struct ril_registration_state {
@@ -38,14 +36,16 @@
struct ril_registration_state data;
const struct ofono_network_operator *operator;
enum ofono_radio_access_mode pref_mode;
+ enum ofono_radio_access_mode max_pref_mode;
struct ril_sim_settings *settings;
};
struct ofono_sim;
typedef void (*ril_network_cb_t)(struct ril_network *net, void *arg);
-struct ril_network *ril_network_new(GRilIoChannel *io, const char *log_prefix,
- struct ril_radio *radio, struct ril_sim_card *sim_card,
+struct ril_network *ril_network_new(const char *path, GRilIoChannel *io,
+ const char *log_prefix, struct ril_radio *radio,
+ struct ril_sim_card *sim_card,
struct ril_sim_settings *settings);
struct ril_network *ril_network_ref(struct ril_network *net);
void ril_network_unref(struct ril_network *net);
@@ -53,6 +53,7 @@
void ril_network_set_max_pref_mode(struct ril_network *net,
enum ofono_radio_access_mode max_pref_mode,
gboolean force_check);
+void ril_network_assert_pref_mode(struct ril_network *net, gboolean immediate);
gulong ril_network_add_operator_changed_handler(struct ril_network *net,
ril_network_cb_t cb, void *arg);
gulong ril_network_add_voice_state_changed_handler(struct ril_network *net,
@@ -61,6 +62,8 @@
ril_network_cb_t cb, void *arg);
gulong ril_network_add_pref_mode_changed_handler(struct ril_network *net,
ril_network_cb_t cb, void *arg);
+gulong ril_network_add_max_pref_mode_changed_handler(struct ril_network *net,
+ ril_network_cb_t cb, void *arg);
void ril_network_remove_handler(struct ril_network *net, gulong id);
void ril_network_remove_handlers(struct ril_network *net, gulong *ids, int n);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_oem_raw.c
^
|
@@ -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
@@ -24,7 +24,6 @@
#define RIL_OEM_RAW_TIMEOUT (60*1000) /* 60 sec */
struct ril_oem_raw {
- struct ril_modem *modem;
GRilIoQueue *q;
DBusConnection *conn;
char *path;
@@ -118,7 +117,6 @@
struct ril_oem_raw *oem = g_new0(struct ril_oem_raw, 1);
DBG("%s", ril_modem_get_path(modem));
- oem->modem = modem;
oem->path = g_strdup(ril_modem_get_path(modem));
oem->conn = dbus_connection_ref(ofono_dbus_get_connection());
oem->q = grilio_queue_new(ril_modem_io(modem));
@@ -144,8 +142,6 @@
DBG("%s", oem->path);
g_dbus_unregister_interface(oem->conn, oem->path,
RIL_OEM_RAW_INTERFACE);
- ofono_modem_remove_interface(oem->modem->ofono,
- RIL_OEM_RAW_INTERFACE);
dbus_connection_unref(oem->conn);
grilio_queue_cancel_all(oem->q, TRUE);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_plugin.c
^
|
@@ -16,21 +16,24 @@
#include "ril_plugin.h"
#include "ril_config.h"
#include "ril_sim_card.h"
-#include "ril_sim_info.h"
#include "ril_sim_settings.h"
#include "ril_cell_info.h"
#include "ril_network.h"
#include "ril_radio.h"
+#include "ril_radio_caps.h"
#include "ril_data.h"
#include "ril_util.h"
#include "ril_log.h"
-#include <gdbus.h>
+#include <sailfish_manager.h>
+#include <sailfish_watch.h>
+
#include <gutil_ints.h>
-#include <gutil_strv.h>
-#include <gutil_misc.h>
+#include <gutil_macros.h>
+
#include <mce_display.h>
#include <mce_log.h>
+
#include <linux/capability.h>
#include <sys/types.h>
#include <sys/syscall.h>
@@ -39,13 +42,13 @@
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
#include "ofono.h"
-#include "storage.h"
#define OFONO_RADIO_ACCESS_MODE_ALL (OFONO_RADIO_ACCESS_MODE_GSM |\
OFONO_RADIO_ACCESS_MODE_UMTS |\
OFONO_RADIO_ACCESS_MODE_LTE)
#define RIL_DEVICE_IDENTITY_RETRIES_LAST 2
+#define RIL_START_TIMEOUT_SEC 20 /* seconds */
#define RADIO_GID 1001
#define RADIO_UID 1001
@@ -56,9 +59,9 @@
#define RILMODEM_DEFAULT_SOCK2 "/dev/socket/rild2"
#define RILMODEM_DEFAULT_SUB "SUB1"
#define RILMODEM_DEFAULT_TECHS OFONO_RADIO_ACCESS_MODE_ALL
+#define RILMODEM_DEFAULT_ENABLE_VOICECALL TRUE
#define RILMODEM_DEFAULT_SLOT 0xffffffff
#define RILMODEM_DEFAULT_TIMEOUT 0 /* No timeout */
-#define RILMODEM_DEFAULT_OPTIONAL FALSE
#define RILMODEM_DEFAULT_SIM_FLAGS RIL_SIM_CARD_V9_UICC_SUBSCRIPTION_WORKAROUND
#define RILMODEM_DEFAULT_DATA_OPT RIL_ALLOW_DATA_AUTO
#define RILMODEM_DEFAULT_DM_FLAGS RIL_DATA_MANAGER_3GLTE_HANDOVER
@@ -69,6 +72,7 @@
#define RILCONF_SETTINGS_EMPTY "EmptyConfig"
#define RILCONF_SETTINGS_3GHANDOVER "3GLTEHandover"
+#define RILCONF_SETTINGS_SET_RADIO_CAP "SetRadioCapability"
#define RILCONF_DEV_PREFIX "ril_"
#define RILCONF_PATH_PREFIX "/" RILCONF_DEV_PREFIX
@@ -77,8 +81,8 @@
#define RILCONF_SLOT "slot"
#define RILCONF_SUB "sub"
#define RILCONF_TIMEOUT "timeout"
-#define RILCONF_OPTIONAL "optional"
#define RILCONF_4G "enable4G" /* Deprecated */
+#define RILCONF_ENABLE_VOICECALL "enableVoicecall"
#define RILCONF_TECHS "technologies"
#define RILCONF_UICC_WORKAROUND "uiccWorkaround"
#define RILCONF_ECCLIST_FILE "ecclistFile"
@@ -90,18 +94,9 @@
#define RILCONF_LOCAL_HANGUP_REASONS "localHangupReasons"
#define RILCONF_REMOTE_HANGUP_REASONS "remoteHangupReasons"
-#define RIL_STORE "ril"
-#define RIL_STORE_GROUP "Settings"
-#define RIL_STORE_ENABLED_SLOTS "EnabledSlots"
-#define RIL_STORE_DEFAULT_VOICE_SIM "DefaultVoiceSim"
-#define RIL_STORE_DEFAULT_DATA_SIM "DefaultDataSim"
-#define RIL_STORE_SLOTS_SEP ","
-
-/* The file where error statistics is stored */
-#define RIL_ERROR_STORAGE "rilerror"
-
-/* Modem error ids, must be static strings (only one is defined for now) */
-static const char RIL_ERROR_ID_RILD_RESTART[] = "rild-restart";
+/* Modem error ids */
+#define RIL_ERROR_ID_RILD_RESTART "rild-restart"
+#define RIL_ERROR_ID_CAPS_SWITCH_ABORTED "ril-caps-switch-aborted"
enum ril_plugin_io_events {
IO_EVENT_CONNECTED,
@@ -117,26 +112,37 @@
DISPLAY_EVENT_COUNT
};
-struct ril_plugin_priv {
- struct ril_plugin pub;
- struct ril_plugin_dbus *dbus;
+enum ril_plugin_watch_events {
+ WATCH_EVENT_MODEM,
+ WATCH_EVENT_COUNT
+};
+
+enum ril_set_radio_cap_opt {
+ RIL_SET_RADIO_CAP_AUTO,
+ RIL_SET_RADIO_CAP_ENABLED,
+ RIL_SET_RADIO_CAP_DISABLED
+};
+
+struct ril_plugin_settings {
+ int dm_flags;
+ enum ril_set_radio_cap_opt set_radio_cap;
+};
+
+typedef struct sailfish_slot_manager_impl {
+ struct sailfish_slot_manager *handle;
struct ril_data_manager *data_manager;
- MceDisplay *display;
- gboolean display_on;
- gulong display_event_id[DISPLAY_EVENT_COUNT];
+ struct ril_radio_caps_manager *caps_manager;
+ struct ril_plugin_settings settings;
+ gulong caps_manager_event_id;
+ guint start_timeout_id;
GSList *slots;
- ril_slot_info_ptr *slots_info;
- struct ril_slot *voice_slot;
- struct ril_slot *data_slot;
- struct ril_slot *mms_slot;
- char *default_voice_imsi;
- char *default_data_imsi;
- char *mms_imsi;
- GKeyFile *storage;
-};
+} ril_plugin;
-struct ril_slot {
- struct ril_slot_info pub;
+typedef struct sailfish_slot_impl {
+ ril_plugin* plugin;
+ struct sailfish_slot *handle;
+ struct sailfish_watch *watch;
+ gulong watch_event_id[WATCH_EVENT_COUNT];
char *path;
char *imei;
char *imeisv;
@@ -149,44 +155,41 @@
int sim_flags;
struct ril_data_options data_opt;
struct ril_slot_config config;
- struct ril_plugin_priv *plugin;
struct ril_modem *modem;
- struct ofono_sim *sim;
struct ril_radio *radio;
+ struct ril_radio_caps *caps;
struct ril_network *network;
struct ril_sim_card *sim_card;
- struct ril_sim_info *sim_info;
- struct ril_sim_info_dbus *sim_info_dbus;
struct ril_sim_settings *sim_settings;
struct ril_cell_info *cell_info;
struct ril_cell_info_dbus *cell_info_dbus;
struct ril_oem_raw *oem_raw;
struct ril_data *data;
MceDisplay *display;
+ gboolean display_on;
+ gulong display_event_id[DISPLAY_EVENT_COUNT];
GRilIoChannel *io;
gulong io_event_id[IO_EVENT_COUNT];
- gulong imei_req_id;
gulong sim_card_state_event_id;
gboolean received_sim_status;
+ guint serialize_id;
+ guint caps_check_id;
+ guint imei_req_id;
guint trace_id;
guint dump_id;
guint retry_id;
- guint sim_watch_id;
- guint sim_state_watch_id;
- enum ofono_sim_state sim_state;
-};
+} ril_slot;
-struct ril_plugin_settings {
- int dm_flags;
-};
+typedef void (*ril_plugin_slot_cb_t)(ril_slot *slot);
+typedef void (*ril_plugin_slot_param_cb_t)(ril_slot *slot, void *param);
static void ril_debug_trace_notify(struct ofono_debug_desc *desc);
static void ril_debug_dump_notify(struct ofono_debug_desc *desc);
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);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_plugin.h
^
|
@@ -17,6 +17,7 @@
#define RIL_PLUGIN_H
#include "ril_types.h"
+#include "sailfish_manager.h"
#include <ofono/modem.h>
#include <ofono/call-barring.h>
@@ -43,30 +44,6 @@
#define RILMODEM_DRIVER "ril"
-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;
- const struct ril_slot_config *config;
- GHashTable *errors;
-};
-
-struct ril_plugin {
- const char *mms_imsi;
- const char *mms_path;
- const char *default_voice_imsi;
- const char *default_data_imsi;
- const char *default_voice_path;
- const char *default_data_path;
- const ril_slot_info_ptr *slots;
- gboolean ready;
-};
-
struct ril_modem {
GRilIoChannel *io;
const char *imei;
@@ -83,65 +60,27 @@
struct ril_slot_config config;
};
-#define RIL_PLUGIN_SIGNAL_VOICE_IMSI (0x01)
-#define RIL_PLUGIN_SIGNAL_DATA_IMSI (0x02)
-#define RIL_PLUGIN_SIGNAL_VOICE_PATH (0x04)
-#define RIL_PLUGIN_SIGNAL_DATA_PATH (0x08)
-#define RIL_PLUGIN_SIGNAL_ENABLED_SLOTS (0x10)
-#define RIL_PLUGIN_SIGNAL_MMS_IMSI (0x20)
-#define RIL_PLUGIN_SIGNAL_MMS_PATH (0x40)
-#define RIL_PLUGIN_SIGNAL_READY (0x80)
-
-typedef void (*ril_modem_cb_t)(struct ril_modem *modem, void *data);
-typedef void (*ril_modem_online_cb_t)(struct ril_modem *modem, gboolean online,
- void *data);
-
-void ril_plugin_set_enabled_slots(struct ril_plugin *plugin, char **slots);
-gboolean ril_plugin_set_mms_imsi(struct ril_plugin *plugin, const char *imsi);
-void ril_plugin_set_default_voice_imsi(struct ril_plugin *plugin,
- const char *imsi);
-void ril_plugin_set_default_data_imsi(struct ril_plugin *plugin,
- const char *imsi);
-
struct ril_oem_raw;
-struct ril_oem_raw *ril_oem_raw_new(struct ril_modem *md,
+struct ril_oem_raw *ril_oem_raw_new(struct ril_modem *modem,
const char *log_prefix);
void ril_oem_raw_free(struct ril_oem_raw *raw);
-struct ril_sim_info_dbus;
-struct ril_sim_info_dbus *ril_sim_info_dbus_new(struct ril_modem *md,
- struct ril_sim_info *info);
-void ril_sim_info_dbus_free(struct ril_sim_info_dbus *dbus);
-
struct ril_cell_info_dbus;
struct ril_cell_info_dbus *ril_cell_info_dbus_new(struct ril_modem *md,
struct ril_cell_info *info);
void ril_cell_info_dbus_free(struct ril_cell_info_dbus *dbus);
-struct ril_plugin_dbus;
-struct ril_plugin_dbus *ril_plugin_dbus_new(struct ril_plugin *plugin);
-void ril_plugin_dbus_free(struct ril_plugin_dbus *dbus);
-void ril_plugin_dbus_block_imei_requests(struct ril_plugin_dbus *dbus,
- gboolean clock);
-void ril_plugin_dbus_signal(struct ril_plugin_dbus *dbus, int mask);
-void ril_plugin_dbus_signal_sim(struct ril_plugin_dbus *dbus, int index,
- gboolean present);
-void ril_plugin_dbus_signal_modem_error(struct ril_plugin_dbus *dbus,
- int index, const char *id, const char *message);
-
struct ril_modem *ril_modem_create(GRilIoChannel *io, const char *log_prefix,
- const struct ril_slot_info *slot, struct ril_radio *radio,
- struct ril_network *network, struct ril_sim_card *card,
- struct ril_data *data, struct ril_sim_settings *settings,
+ const char *path, const char *imei, const char *imeisv,
+ const char *ecclist_file, const struct ril_slot_config *config,
+ struct ril_radio *radio, struct ril_network *network,
+ struct ril_sim_card *card, struct ril_data *data,
+ struct ril_sim_settings *settings,
struct ril_cell_info *cell_info);
void ril_modem_delete(struct ril_modem *modem);
struct ofono_sim *ril_modem_ofono_sim(struct ril_modem *modem);
struct ofono_gprs *ril_modem_ofono_gprs(struct ril_modem *modem);
struct ofono_netreg *ril_modem_ofono_netreg(struct ril_modem *modem);
-void ril_modem_set_removed_cb(struct ril_modem *modem, ril_modem_cb_t cb,
- void *data);
-void ril_modem_set_online_cb(struct ril_modem *modem, ril_modem_online_cb_t cb,
- void *data);
#define ril_modem_get_path(modem) ofono_modem_get_path((modem)->ofono)
#define ril_modem_4g_enabled(modem) ((modem)->config.enable_4g)
@@ -149,7 +88,7 @@
#define ril_modem_io(modem) ((modem)->io)
int ril_sim_app_type(struct ofono_sim *sim);
-int ril_netreg_check_if_really_roaming(struct ofono_netreg *netreg, gint status);
+int ril_netreg_check_if_really_roaming(struct ofono_netreg *reg, gint status);
extern const struct ofono_call_barring_driver ril_call_barring_driver;
extern const struct ofono_call_forwarding_driver ril_call_forwarding_driver;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_radio.c
^
|
@@ -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
@@ -50,14 +50,12 @@
enum ril_radio_signal {
SIGNAL_STATE_CHANGED,
- SIGNAL_ONLINE_CHANGED,
SIGNAL_COUNT
};
#define POWER_RETRY_SECS (1)
#define SIGNAL_STATE_CHANGED_NAME "ril-radio-state-changed"
-#define SIGNAL_ONLINE_CHANGED_NAME "ril-radio-online-changed"
static guint ril_radio_signals[SIGNAL_COUNT] = { 0 };
@@ -77,8 +75,7 @@
{
struct ril_radio_priv *priv = self->priv;
- return self->online && !priv->power_cycle &&
- g_hash_table_size(priv->req_table) > 0;
+ return !priv->power_cycle && g_hash_table_size(priv->req_table) > 0;
}
static inline gboolean ril_radio_state_off(enum ril_radio_state radio_state)
@@ -99,13 +96,14 @@
static gboolean ril_radio_power_request_retry_cb(gpointer user_data)
{
- struct ril_radio *self = user_data;
+ struct ril_radio *self = RIL_RADIO(user_data);
struct ril_radio_priv *priv = self->priv;
DBG("%s", priv->log_prefix);
GASSERT(priv->retry_id);
priv->retry_id = 0;
- ril_radio_submit_power_request(self, ril_radio_power_should_be_on(self));
+ ril_radio_submit_power_request(self,
+ ril_radio_power_should_be_on(self));
return G_SOURCE_REMOVE;
}
@@ -126,7 +124,7 @@
struct ril_radio_priv *priv = self->priv;
if (!priv->pending_id) {
- const gboolean should_be_on = ril_radio_power_should_be_on(self);
+ gboolean should_be_on = ril_radio_power_should_be_on(self);
if (ril_radio_state_on(self->priv->last_known_state) ==
should_be_on) {
@@ -157,7 +155,7 @@
static void ril_radio_power_request_cb(GRilIoChannel *channel, int ril_status,
const void *data, guint len, void *user_data)
{
- struct ril_radio *self = user_data;
+ struct ril_radio *self = RIL_RADIO(user_data);
struct ril_radio_priv *priv = self->priv;
GASSERT(priv->pending_id);
@@ -177,11 +175,17 @@
static void ril_radio_submit_power_request(struct ril_radio *self, gboolean on)
{
+ /*
+ * RIL_REQUEST_RADIO_POWER
+ *
+ * "data" is int *
+ * ((int *)data)[0] is > 0 for "Radio On"
+ * ((int *)data)[0] is == 0 for "Radio Off"
+ *
+ * "response" is NULL
+ **/
+ GRilIoRequest *req = grilio_request_array_int32_new(1, on);
struct ril_radio_priv *priv = self->priv;
- GRilIoRequest *req = grilio_request_sized_new(8);
-
- grilio_request_append_int32(req, 1);
- grilio_request_append_int32(req, on); /* Radio ON=1, OFF=0 */
priv->next_state_valid = FALSE;
priv->next_state = on;
@@ -189,8 +193,10 @@
ril_radio_cancel_retry(self);
GASSERT(!priv->pending_id);
+ grilio_request_set_blocking(req, TRUE);
priv->pending_id = grilio_queue_send_request_full(priv->q, req,
- RIL_REQUEST_RADIO_POWER, ril_radio_power_request_cb, NULL, self);
+ RIL_REQUEST_RADIO_POWER, ril_radio_power_request_cb,
+ NULL, self);
grilio_request_unref(req);
}
@@ -274,19 +280,6 @@
}
}
-void ril_radio_set_online(struct ril_radio *self, gboolean online)
-{
- if (G_LIKELY(self) && self->online != online) {
- gboolean on, was_on = ril_radio_power_should_be_on(self);
- self->online = online;
- on = ril_radio_power_should_be_on(self);
- if (was_on != on) {
- ril_radio_power_request(self, on, FALSE);
- }
- ril_radio_emit_signal(self, SIGNAL_ONLINE_CHANGED);
- }
-}
-
gulong ril_radio_add_state_changed_handler(struct ril_radio *self,
ril_radio_cb_t cb, void *arg)
{
@@ -294,13 +287,6 @@
SIGNAL_STATE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
-gulong ril_radio_add_online_changed_handler(struct ril_radio *self,
- ril_radio_cb_t cb, void *arg)
-{
- return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
- SIGNAL_ONLINE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
-}
-
void ril_radio_remove_handler(struct ril_radio *self, gulong id)
{
if (G_LIKELY(self) && G_LIKELY(id)) {
@@ -330,7 +316,7 @@
static void ril_radio_state_changed(GRilIoChannel *io, guint code,
const void *data, guint len, void *user_data)
{
- struct ril_radio *self = user_data;
+ struct ril_radio *self = RIL_RADIO(user_data);
enum ril_radio_state radio_state = ril_radio_state_parse(data, len);
GASSERT(code == RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED);
@@ -438,7 +424,6 @@
object_class->finalize = ril_radio_finalize;
g_type_class_add_private(klass, sizeof(struct ril_radio_priv));
NEW_SIGNAL(klass, STATE);
- NEW_SIGNAL(klass, ONLINE);
}
/*
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_radio.h
^
|
@@ -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
@@ -22,7 +22,6 @@
GObject object;
struct ril_radio_priv *priv;
enum ril_radio_state state;
- gboolean online;
};
typedef void (*ril_radio_cb_t)(struct ril_radio *radio, void *arg);
@@ -35,15 +34,15 @@
void ril_radio_power_off(struct ril_radio *radio, gpointer tag);
void ril_radio_power_cycle(struct ril_radio *radio);
void ril_radio_confirm_power_on(struct ril_radio *radio);
-void ril_radio_set_online(struct ril_radio *radio, gboolean online);
gulong ril_radio_add_state_changed_handler(struct ril_radio *radio,
ril_radio_cb_t cb, void *arg);
-gulong ril_radio_add_online_changed_handler(struct ril_radio *radio,
- ril_radio_cb_t cb, void *arg);
void ril_radio_remove_handler(struct ril_radio *radio, gulong id);
void ril_radio_remove_handlers(struct ril_radio *radio, gulong *ids, int n);
enum ril_radio_state ril_radio_state_parse(const void *data, guint len);
+#define ril_radio_remove_all_handlers(r,ids) \
+ ril_radio_remove_handlers(r, ids, G_N_ELEMENTS(ids))
+
#endif /* RIL_RADIO_H */
/*
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_radio_caps.c
^
|
@@ -0,0 +1,1407 @@
+/*
+ * oFono - Open Source Telephony - RIL-based devices
+ *
+ * Copyright (C) 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.
+ */
+
+#include "ril_radio_caps.h"
+#include "ril_radio.h"
+#include "ril_network.h"
+#include "ril_sim_card.h"
+#include "ril_sim_settings.h"
+#include "ril_data.h"
+#include "ril_log.h"
+
+#include <grilio_queue.h>
+#include <grilio_channel.h>
+#include <grilio_parser.h>
+#include <grilio_request.h>
+
+#define SET_CAPS_TIMEOUT_MS (30*1000)
+#define GET_CAPS_TIMEOUT_MS (5*1000)
+#define DATA_OFF_TIMEOUT_MS (10*1000)
+#define DEACTIVATE_TIMEOUT_MS (10*1000)
+#define CHECK_LATER_TIMEOUT_SEC (5)
+
+#define GET_CAPS_RETRIES 60
+
+/*
+ * This code is doing something similar to what
+ * com.android.internal.telephony.ProxyController
+ * is doing.
+ */
+
+enum ril_radio_caps_sim_events {
+ SIM_EVENT_STATE_CHANGED,
+ SIM_EVENT_IO_ACTIVE_CHANGED,
+ SIM_EVENT_COUNT
+};
+
+enum ril_radio_caps_settings_events {
+ SETTINGS_EVENT_PREF_MODE,
+ SETTINGS_EVENT_IMSI,
+ SETTINGS_EVENT_COUNT
+};
+
+enum ril_radio_caps_io_events {
+ IO_EVENT_UNSOL_RADIO_CAPABILITY,
+ IO_EVENT_PENDING,
+ IO_EVENT_OWNER,
+ IO_EVENT_COUNT
+};
+
+struct ril_radio_caps {
+ gint ref_count;
+ guint slot;
+ char *log_prefix;
+ GRilIoQueue *q;
+ GRilIoChannel *io;
+ gulong settings_event_id[SETTINGS_EVENT_COUNT];
+ gulong simcard_event_id[SIM_EVENT_COUNT];
+ gulong io_event_id[IO_EVENT_COUNT];
+ gulong max_pref_mode_event_id;
+ gulong radio_event_id;
+ int tx_id;
+ struct ril_data *data;
+ struct ril_radio *radio;
+ struct ril_network *network;
+ struct ril_sim_card *simcard;
+ struct ril_radio_caps_manager *mgr;
+ struct ril_radio_capability cap;
+ struct ril_radio_capability old_cap;
+ struct ril_radio_capability new_cap;
+};
+
+typedef struct ril_radio_caps_manager {
+ GObject object;
+ GPtrArray *caps_list;
+ guint check_id;
+ int tx_pending;
+ int tx_id;
+ int tx_phase_index;
+ gboolean tx_failed;
+ struct ril_data_manager *data_manager;
+} RilRadioCapsManager;
+
+struct ril_radio_caps_check_data {
+ ril_radio_caps_check_cb_t cb;
+ void *data;
+};
+
+struct ril_radio_caps_request_tx_phase {
+ const char *name;
+ enum ril_radio_capability_phase phase;
+ enum ril_radio_capability_status status;
+ gboolean send_new_cap;
+};
+
+typedef void (*ril_radio_caps_cb_t)(struct ril_radio_caps_manager *self,
+ struct ril_radio_caps *caps);
+
+typedef GObjectClass RilRadioCapsManagerClass;
+G_DEFINE_TYPE(RilRadioCapsManager, ril_radio_caps_manager, G_TYPE_OBJECT)
+#define RADIO_CAPS_MANAGER_TYPE (ril_radio_caps_manager_get_type())
+#define RADIO_CAPS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ RADIO_CAPS_MANAGER_TYPE, RilRadioCapsManager))
+
+enum ril_radio_caps_manager_signal {
+ SIGNAL_ABORTED,
+ SIGNAL_COUNT
+};
+
+#define SIGNAL_ABORTED_NAME "ril-capsmgr-aborted"
+
+static guint ril_radio_caps_manager_signals[SIGNAL_COUNT] = { 0 };
+
+static const struct ril_radio_caps_request_tx_phase
+ ril_radio_caps_tx_phase[] = {
+ { "START", RC_PHASE_START, RC_STATUS_NONE, FALSE },
+ { "APPLY", RC_PHASE_APPLY, RC_STATUS_NONE, TRUE },
+ { "FINISH", RC_PHASE_FINISH, RC_STATUS_SUCCESS, FALSE }
+};
+
+static const struct ril_radio_caps_request_tx_phase
+ ril_radio_caps_fail_phase =
+ { "ABORT", RC_PHASE_FINISH, RC_STATUS_FAIL, FALSE };
+
+#define DBG_(caps, fmt, args...) DBG("%s" fmt, (caps)->log_prefix, ##args)
+
+static void ril_radio_caps_manager_next_phase
+ (struct ril_radio_caps_manager *self);
+static void ril_radio_caps_manager_schedule_check
+ (struct ril_radio_caps_manager *self);
+static void ril_radio_caps_manager_recheck_later
+ (struct ril_radio_caps_manager *self);
+
+static gboolean ril_radio_caps_parse(const char *log_prefix,
+ const void *data, guint len, struct ril_radio_capability *cap)
+{
+ GRilIoParser rilp;
+ guint32 version, tx, phase, rat;
+
+ memset(cap, 0, sizeof(*cap));
+ grilio_parser_init(&rilp, data, len);
+
+ if (grilio_parser_get_uint32(&rilp, &version) &&
+ grilio_parser_get_uint32(&rilp, &tx) &&
+ grilio_parser_get_uint32(&rilp, &phase) &&
+ grilio_parser_get_uint32(&rilp, &rat)) {
+ guint32 status;
+ char *uuid = grilio_parser_get_utf8(&rilp);
+
+ if (grilio_parser_get_uint32(&rilp, &status) &&
+ grilio_parser_at_end(&rilp)) {
+ DBG("%sversion=%d,tx=%d,phase=%d,rat=0x%x,"
+ "uuid=%s,status=%d", log_prefix, version,
+ tx, phase, rat, uuid, status);
+ cap->version = version;
+ cap->session = tx;
+ cap->phase = phase;
+ cap->rat = rat;
+ cap->status = status;
+ if (uuid) {
+ strncpy(cap->logicalModemUuid, uuid,
+ G_N_ELEMENTS(cap->logicalModemUuid));
+ g_free(uuid);
+ }
+ return TRUE;
+ }
+
+ g_free(uuid);
+ }
+
+ return FALSE;
+}
+
+static void ril_radio_caps_check_done(GRilIoChannel *io, int ril_status,
+ const void *data, guint len, void *user_data)
+{
+ struct ril_radio_caps_check_data *check = user_data;
+ const struct ril_radio_capability *result = NULL;
+ struct ril_radio_capability cap;
+
+ if (ril_status == RIL_E_SUCCESS &&
+ ril_radio_caps_parse("", data, len, &cap)) {
+ GASSERT(cap.rat);
+ if (cap.rat) {
+ result = ∩
+ }
+ }
+
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_radio_caps.h
^
|
@@ -0,0 +1,66 @@
+/*
+ * oFono - Open Source Telephony - RIL-based devices
+ *
+ * Copyright (C) 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.
+ */
+
+#ifndef RIL_RADIO_CAPS_H
+#define RIL_RADIO_CAPS_H
+
+#include "ril_types.h"
+
+struct ril_data_manager;
+struct ril_radio_caps;
+struct ril_radio_caps_manager;
+struct ril_radio_capability;
+
+typedef void (*ril_radio_caps_manager_cb_t)(struct ril_radio_caps_manager *mgr,
+ void *user_data);
+/* ril_radio_capability pointer is NULL if functionality is unsupported */
+typedef void (*ril_radio_caps_check_cb_t)
+ (const struct ril_radio_capability *cap, void *user_data);
+
+/* The check can be cancelled with grilio_channel_cancel_request */
+guint ril_radio_caps_check(GRilIoChannel *io, ril_radio_caps_check_cb_t cb,
+ void *user_data);
+
+/* There should be a single ril_radio_caps_manager shared by all all modems */
+struct ril_radio_caps_manager *ril_radio_caps_manager_new
+ (struct ril_data_manager *dm);
+struct ril_radio_caps_manager *ril_radio_caps_manager_ref
+ (struct ril_radio_caps_manager *mgr);
+void ril_radio_caps_manager_unref(struct ril_radio_caps_manager *mgr);
+gulong ril_radio_caps_manager_add_aborted_handler
+ (struct ril_radio_caps_manager *mgr,
+ ril_radio_caps_manager_cb_t cb, void *arg);
+void ril_radio_caps_manager_remove_handler(struct ril_radio_caps_manager *mgr,
+ gulong id);
+
+/* And one ril_radio_caps object per modem */
+struct ril_radio_caps *ril_radio_caps_new(struct ril_radio_caps_manager *mgr,
+ const char *log_prefix, GRilIoChannel *io,
+ struct ril_data *data, struct ril_radio *radio,
+ struct ril_sim_card *sim, struct ril_network *net,
+ const struct ril_slot_config *config,
+ const struct ril_radio_capability *cap);
+struct ril_radio_caps *ril_radio_caps_ref(struct ril_radio_caps *caps);
+void ril_radio_caps_unref(struct ril_radio_caps *caps);
+
+#endif /* RIL_RADIO_CAPS_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_radio_settings.c
^
|
@@ -17,7 +17,6 @@
#include "ril_sim_settings.h"
#include "ril_util.h"
#include "ril_log.h"
-#include "ril_constants.h"
struct ril_radio_settings {
struct ofono_radio_settings *rs;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_sim.c
^
|
@@ -40,13 +40,6 @@
/* FID/path of SIM/USIM root directory */
#define ROOTMF "3F00"
-/* RIL_Request* parameter counts */
-#define GET_IMSI_NUM_PARAMS 1
-#define ENTER_SIM_PIN_PARAMS 2
-#define SET_FACILITY_LOCK_PARAMS 5
-#define ENTER_SIM_PUK_PARAMS 3
-#define CHANGE_SIM_PIN_PARAMS 3
-
/* P2 coding (modes) for READ RECORD and UPDATE RECORD (see TS 102.221) */
#define MODE_SELECTED (0x00) /* Currently selected EF */
#define MODE_CURRENT (0x04) /* P1='00' denotes the current record */
@@ -113,6 +106,7 @@
gpointer ptr;
} cb;
gpointer data;
+ guint req_id;
};
struct ril_sim_pin_cbd {
@@ -429,6 +423,7 @@
struct ofono_error error;
DBG_(sd, "");
+ ril_sim_card_sim_io_finished(sd->card, cbd->req_id);
ril_error_init_failure(&error);
res = ril_sim_parse_io_response(data, len);
@@ -489,8 +484,10 @@
grilio_request_append_utf8(req, NULL); /* pin2; only for writes */
grilio_request_append_utf8(req, ril_sim_app_id(sd));
- grilio_queue_send_request_full(sd->q, req, RIL_REQUEST_SIM_IO,
- cb, ril_sim_cbd_free, cbd);
+ grilio_request_set_blocking(req, TRUE);
+ cbd->req_id = grilio_queue_send_request_full(sd->q, req,
+ RIL_REQUEST_SIM_IO, cb, ril_sim_cbd_free, cbd);
+ ril_sim_card_sim_io_started(sd->card, cbd->req_id);
grilio_request_unref(req);
}
@@ -512,6 +509,8 @@
struct ofono_error err;
DBG_(cbd->sd, "");
+ ril_sim_card_sim_io_finished(cbd->sd->card, cbd->req_id);
+
res = ril_sim_parse_io_response(data, len);
if (ril_sim_io_response_ok(res) && status == RIL_E_SUCCESS) {
cb(ril_error_ok(&err), res->data, res->data_len, cbd->data);
@@ -565,6 +564,8 @@
struct ofono_error err;
DBG_(cbd->sd, "");
+ ril_sim_card_sim_io_finished(cbd->sd->card, cbd->req_id);
+
res = ril_sim_parse_io_response(data, len);
if (ril_sim_io_response_ok(res) && status == RIL_E_SUCCESS) {
cb(ril_error_ok(&err), cbd->data);
@@ -625,6 +626,8 @@
ofono_sim_imsi_cb_t cb = cbd->cb.imsi;
struct ofono_error error;
+ ril_sim_card_sim_io_finished(cbd->sd->card, cbd->req_id);
+
if (status == RIL_E_SUCCESS) {
gchar *imsi;
GRilIoParser rilp;
@@ -649,11 +652,11 @@
void *data)
{
struct ril_sim *sd = ril_sim_get_data(sim);
- GRilIoRequest *req = grilio_request_sized_new(60);
+ const char *app_id = ril_sim_app_id(sd);
+ struct ril_sim_cbd *cbd = ril_sim_cbd_new(sd, cb, data);
+ GRilIoRequest *req = grilio_request_array_utf8_new(1, app_id);
- DBG_(sd, "%s", ril_sim_app_id(sd));
- grilio_request_append_int32(req, GET_IMSI_NUM_PARAMS);
- grilio_request_append_utf8(req, ril_sim_app_id(sd));
+ DBG_(sd, "%s", app_id);
/*
* If we fail the .read_imsi call, ofono gets into "Unable to
@@ -661,9 +664,11 @@
* on failure.
*/
grilio_request_set_retry(req, RIL_RETRY_MS, -1);
- grilio_queue_send_request_full(sd->q, req, RIL_REQUEST_GET_IMSI,
- ril_sim_get_imsi_cb, ril_sim_cbd_free,
- ril_sim_cbd_new(sd, cb, data));
+ grilio_request_set_blocking(req, TRUE);
+ cbd->req_id = grilio_queue_send_request_full(sd->q, req,
+ RIL_REQUEST_GET_IMSI, ril_sim_get_imsi_cb,
+ ril_sim_cbd_free, cbd);
+ ril_sim_card_sim_io_started(sd->card, cbd->req_id);
grilio_request_unref(req);
}
@@ -861,10 +866,10 @@
{
const char *app_id = ril_sim_app_id(sd);
if (app_id) {
- GRilIoRequest *req = grilio_request_new();
- grilio_request_append_int32(req, ENTER_SIM_PIN_PARAMS);
- grilio_request_append_utf8(req, pin);
- grilio_request_append_utf8(req, app_id);
+ GRilIoRequest *req = grilio_request_array_utf8_new(2,
+ pin, app_id);
+
+ grilio_request_set_blocking(req, TRUE);
return req;
}
return NULL;
@@ -875,11 +880,9 @@
{
const char *app_id = ril_sim_app_id(sd);
if (app_id) {
- GRilIoRequest *req = grilio_request_new();
- grilio_request_append_int32(req, ENTER_SIM_PUK_PARAMS);
- grilio_request_append_utf8(req, puk);
- grilio_request_append_utf8(req, pin);
- grilio_request_append_utf8(req, app_id);
+ GRilIoRequest *req = grilio_request_array_utf8_new(3,
+ puk, pin, app_id);
+ grilio_request_set_blocking(req, TRUE);
return req;
}
return NULL;
@@ -1256,26 +1259,23 @@
const char *passwd, ofono_sim_lock_unlock_cb_t cb, void *data)
{
struct ril_sim *sd = ril_sim_get_data(sim);
- struct ofono_error error;
+ const char *app_id = ril_sim_app_id(sd);
const char *type_str = ril_sim_facility_code(passwd_type);
+ struct ofono_error error;
guint id = 0;
- DBG_(sd, "%d,%s,%d,%s,0,aid=%s", passwd_type, type_str, enable, passwd,
- ril_sim_app_id(sd));
+ DBG_(sd, "%d,%s,%d,%s,0,aid=%s", passwd_type, type_str,
+ enable, passwd, app_id);
if (passwd_type == OFONO_SIM_PASSWORD_PHNET_PIN) {
id = ril_perso_change_state(sim, passwd_type, enable, passwd,
cb, data);
} else if (type_str) {
- GRilIoRequest *req = grilio_request_new();
- grilio_request_append_int32(req, SET_FACILITY_LOCK_PARAMS);
- grilio_request_append_utf8(req, type_str);
- grilio_request_append_utf8(req, enable ?
- RIL_FACILITY_LOCK : RIL_FACILITY_UNLOCK);
- grilio_request_append_utf8(req, passwd);
- grilio_request_append_utf8(req, "0"); /* class */
- grilio_request_append_utf8(req, ril_sim_app_id(sd));
+ GRilIoRequest *req = grilio_request_array_utf8_new(5, type_str,
+ enable ? RIL_FACILITY_LOCK : RIL_FACILITY_UNLOCK,
+ passwd, "0" /* class */, app_id);
+ grilio_request_set_blocking(req, TRUE);
id = grilio_queue_send_request_full(sd->q, req,
RIL_REQUEST_SET_FACILITY_LOCK,
ril_sim_pin_change_state_cb, ril_sim_pin_req_done,
@@ -1317,15 +1317,12 @@
ofono_sim_lock_unlock_cb_t cb, void *data)
{
struct ril_sim *sd = ril_sim_get_data(sim);
- GRilIoRequest *req = grilio_request_sized_new(60);
-
- grilio_request_append_int32(req, CHANGE_SIM_PIN_PARAMS);
- grilio_request_append_utf8(req, old_passwd);
- grilio_request_append_utf8(req, new_passwd);
- grilio_request_append_utf8(req, ril_sim_app_id(sd));
+ const char *app_id = ril_sim_app_id(sd);
+ GRilIoRequest *req = grilio_request_array_utf8_new(3,
+ old_passwd, new_passwd, app_id);
- DBG_(sd, "old=%s,new=%s,aid=%s", old_passwd, new_passwd,
- ril_sim_app_id(sd));
+ DBG_(sd, "old=%s,new=%s,aid=%s", old_passwd, new_passwd, app_id);
+ grilio_request_set_blocking(req, TRUE);
grilio_queue_send_request_full(sd->q, req,
(passwd_type == OFONO_SIM_PASSWORD_SIM_PIN2) ?
RIL_REQUEST_CHANGE_SIM_PIN2 : RIL_REQUEST_CHANGE_SIM_PIN,
@@ -1341,6 +1338,8 @@
struct ril_sim_cbd *cbd = user_data;
ofono_query_facility_lock_cb_t cb = cbd->cb.query_facility_lock;
+ ril_sim_card_sim_io_finished(cbd->sd->card, cbd->req_id);
+
if (status == RIL_E_SUCCESS) {
int locked = 0;
GRilIoParser rilp;
@@ -1362,18 +1361,16 @@
ofono_query_facility_lock_cb_t cb, void *data)
{
struct ril_sim *sd = ril_sim_get_data(sim);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_sim_card.c
^
|
@@ -24,6 +24,15 @@
#include <gutil_misc.h>
+#define UICC_SUBSCRIPTION_TIMEOUT_MS (30000)
+
+/* SIM I/O idle timeout is measured in the number of idle loops.
+ * When active SIM I/O is going on, the idle loop count very rarely
+ * exceeds 1 between the requests, so 10 is more than enough. Idle
+ * loop is actually more accurate criteria than a timeout because
+ * it doesn't depend that much on the system load. */
+#define SIM_IO_IDLE_LOOPS (10)
+
typedef GObjectClass RilSimCardClass;
typedef struct ril_sim_card RilSimCard;
@@ -38,7 +47,11 @@
GRilIoQueue *q;
int flags;
guint status_req_id;
+ guint sub_req_id;
gulong event_id[EVENT_COUNT];
+ guint sim_io_idle_id;
+ guint sim_io_idle_count;
+ GHashTable* sim_io_pending;
};
enum ril_sim_card_signal {
@@ -46,13 +59,15 @@
SIGNAL_STATUS_CHANGED,
SIGNAL_STATE_CHANGED,
SIGNAL_APP_CHANGED,
+ SIGNAL_SIM_IO_ACTIVE_CHANGED,
SIGNAL_COUNT
};
-#define SIGNAL_STATUS_RECEIVED_NAME "ril-simcard-status-received"
-#define SIGNAL_STATUS_CHANGED_NAME "ril-simcard-status-changed"
-#define SIGNAL_STATE_CHANGED_NAME "ril-simcard-state-changed"
-#define SIGNAL_APP_CHANGED_NAME "ril-simcard-app-changed"
+#define SIGNAL_STATUS_RECEIVED_NAME "ril-simcard-status-received"
+#define SIGNAL_STATUS_CHANGED_NAME "ril-simcard-status-changed"
+#define SIGNAL_STATE_CHANGED_NAME "ril-simcard-state-changed"
+#define SIGNAL_APP_CHANGED_NAME "ril-simcard-app-changed"
+#define SIGNAL_SIM_IO_ACTIVE_CHANGED_NAME "ril-simcard-sim-io-active-changed"
static guint ril_sim_card_signals[SIGNAL_COUNT] = { 0 };
@@ -61,6 +76,13 @@
#define RIL_SIMCARD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
RIL_SIMCARD_TYPE, RilSimCard))
+#define NEW_SIGNAL(klass,name) NEW_SIGNAL_(klass,name##_CHANGED)
+#define NEW_SIGNAL_(klass,name) \
+ ril_sim_card_signals[SIGNAL_##name] = \
+ g_signal_new(SIGNAL_##name##_NAME, \
+ G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
+ 0, NULL, NULL, NULL, G_TYPE_NONE, 0)
+
#define RIL_SIMCARD_STATE_CHANGED (0x01)
#define RIL_SIMCARD_STATUS_CHANGED (0x02)
@@ -135,22 +157,65 @@
}
}
-static void ril_sim_card_subscribe(struct ril_sim_card *self,
- int app_index, int sub_status)
+static void ril_sim_card_subscription_done(struct ril_sim_card *self)
+{
+ struct ril_sim_card_priv *priv = self->priv;
+
+ if (priv->sub_req_id) {
+ /* Some RILs never reply to SET_UICC_SUBSCRIPTION requst,
+ * so we better drop rather than cancel it (so that it gets
+ * removed from the list of pending requests) */
+ grilio_channel_drop_request(priv->io, priv->sub_req_id);
+ priv->sub_req_id = 0;
+ }
+ grilio_queue_transaction_finish(priv->q);
+}
+
+static void ril_sim_card_subscribe_cb(GRilIoChannel* io, int status,
+ const void* data, guint len, void* user_data)
+{
+ struct ril_sim_card *self = RIL_SIMCARD(user_data);
+ struct ril_sim_card_priv *priv = self->priv;
+
+ GASSERT(status == GRILIO_STATUS_OK);
+ GASSERT(priv->sub_req_id);
+ priv->sub_req_id = 0;
+ DBG("UICC subscription OK for slot %u", self->slot);
+ ril_sim_card_subscription_done(self);
+}
+
+static void ril_sim_card_subscribe(struct ril_sim_card *self, int app_index,
+ enum ril_uicc_subscription_action sub_action)
{
struct ril_sim_card_priv *priv = self->priv;
GRilIoRequest *req = grilio_request_sized_new(16);
const guint sub_id = self->slot;
+ guint code;
- DBG("%u,%d,%u,%d", self->slot, app_index, sub_id, sub_status);
+ DBG("%u,%d,%u,%d", self->slot, app_index, sub_id, sub_action);
grilio_request_append_int32(req, self->slot);
grilio_request_append_int32(req, app_index);
grilio_request_append_int32(req, sub_id);
- grilio_request_append_int32(req, sub_status);
- grilio_queue_send_request(priv->q, req, (priv->io->ril_version <= 9 &&
+ grilio_request_append_int32(req, sub_action);
+
+ grilio_request_set_retry(req, 0, -1);
+ grilio_request_set_timeout(req, UICC_SUBSCRIPTION_TIMEOUT_MS);
+ code = (priv->io->ril_version <= 9 &&
(priv->flags & RIL_SIM_CARD_V9_UICC_SUBSCRIPTION_WORKAROUND)) ?
- RIL_REQUEST_V9_SET_UICC_SUBSCRIPTION :
- RIL_REQUEST_SET_UICC_SUBSCRIPTION);
+ RIL_REQUEST_V9_SET_UICC_SUBSCRIPTION :
+ RIL_REQUEST_SET_UICC_SUBSCRIPTION;
+ if (priv->sub_req_id) {
+ /* Some RILs never reply to SET_UICC_SUBSCRIPTION requst,
+ * so we better drop rather than cancel it (so that it gets
+ * removed from the list of pending requests) */
+ grilio_channel_drop_request(priv->io, priv->sub_req_id);
+ }
+
+ /* Don't allow any requests other that GET_SIM_STATUS until
+ * we are done with the subscription */
+ grilio_queue_transaction_start(priv->q);
+ priv->sub_req_id = grilio_queue_send_request_full(priv->q,
+ req, code, ril_sim_card_subscribe_cb, NULL, self);
grilio_request_unref(req);
}
@@ -183,14 +248,17 @@
if (status->gsm_umts_index >= 0 &&
status->gsm_umts_index < status->num_apps) {
app_index = status->gsm_umts_index;
+ ril_sim_card_subscription_done(self);
} else {
app_index = ril_sim_card_select_app(status);
if (app_index >= 0) {
- ril_sim_card_subscribe(self, app_index, 1);
+ ril_sim_card_subscribe(self, app_index,
+ RIL_UICC_SUBSCRIPTION_ACTIVATE);
}
}
} else {
app_index = -1;
+ ril_sim_card_subscription_done(self);
}
if (app_index >= 0 &&
@@ -201,8 +269,8 @@
}
if (!ril_sim_card_app_equal(old_app, self->app)) {
- g_signal_emit(self,
- ril_sim_card_signals[SIGNAL_APP_CHANGED], 0);
+ g_signal_emit(self, ril_sim_card_signals
+ [SIGNAL_APP_CHANGED], 0);
}
}
@@ -216,23 +284,23 @@
self->status = status;
ril_sim_card_update_app(self);
- g_signal_emit(self, ril_sim_card_signals[
- SIGNAL_STATUS_RECEIVED], 0);
+ g_signal_emit(self, ril_sim_card_signals
+ [SIGNAL_STATUS_RECEIVED], 0);
if (diff & RIL_SIMCARD_STATUS_CHANGED) {
DBG("status changed");
- g_signal_emit(self, ril_sim_card_signals[
- SIGNAL_STATUS_CHANGED], 0);
+ g_signal_emit(self, ril_sim_card_signals
+ [SIGNAL_STATUS_CHANGED], 0);
}
if (diff & RIL_SIMCARD_STATE_CHANGED) {
DBG("state changed");
- g_signal_emit(self, ril_sim_card_signals[
- SIGNAL_STATE_CHANGED], 0);
+ g_signal_emit(self, ril_sim_card_signals
+ [SIGNAL_STATE_CHANGED], 0);
}
ril_sim_card_status_free(old_status);
} else {
ril_sim_card_status_free(status);
- g_signal_emit(self, ril_sim_card_signals[
- SIGNAL_STATUS_RECEIVED], 0);
+ g_signal_emit(self, ril_sim_card_signals
+ [SIGNAL_STATUS_RECEIVED], 0);
}
}
@@ -315,7 +383,8 @@
status->num_apps = num_apps;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_sim_card.h
^
|
@@ -44,6 +44,7 @@
struct ril_sim_card_priv *priv;
struct ril_sim_card_status *status;
const struct ril_sim_card_app *app;
+ gboolean sim_io_active;
guint slot;
};
@@ -55,7 +56,9 @@
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);
+void ril_sim_card_request_status(struct ril_sim_card *sc);
+void ril_sim_card_sim_io_started(struct ril_sim_card *sc, guint id);
+void ril_sim_card_sim_io_finished(struct ril_sim_card *sc, guint id);
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);
@@ -65,6 +68,8 @@
ril_sim_card_cb_t cb, void *arg);
gulong ril_sim_card_add_app_changed_handler(struct ril_sim_card *sc,
ril_sim_card_cb_t cb, void *arg);
+gulong ril_sim_card_add_sim_io_active_changed_handler(struct ril_sim_card *sc,
+ ril_sim_card_cb_t cb, void *arg);
void ril_sim_card_remove_handler(struct ril_sim_card *sc, gulong id);
void ril_sim_card_remove_handlers(struct ril_sim_card *sc, gulong *ids, int n);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_sim_settings.c
^
|
@@ -16,17 +16,14 @@
#include "ril_sim_settings.h"
#include "ril_log.h"
-#include <gutil_misc.h>
+#include "sailfish_watch.h"
-#include <ofono/sim.h>
+#include <gutil_misc.h>
+#include "ofono.h"
#include "storage.h"
-#define RIL_SIM_STORE "ril"
-#define RIL_SIM_STORE_GROUP "Settings"
-#define RIL_SIM_STORE_PREF_MODE "TechnologyPreference"
-
-#define RIL_SIM_STORE_PREF_MODE_DEFAULT(self) (\
+#define RIL_PREF_MODE_DEFAULT(self) (\
((self)->techs & OFONO_RADIO_ACCESS_MODE_LTE) ? \
OFONO_RADIO_ACCESS_MODE_LTE : \
((self)->techs & OFONO_RADIO_ACCESS_MODE_UMTS) ? \
@@ -36,10 +33,14 @@
typedef GObjectClass RilSimSettingsClass;
typedef struct ril_sim_settings RilSimSettings;
+enum sailfish_watch_events {
+ WATCH_EVENT_IMSI,
+ WATCH_EVENT_COUNT
+};
+
struct ril_sim_settings_priv {
- struct ofono_sim *sim;
- guint imsi_watch_id;
- guint state_watch_id;
+ gulong watch_event_id[WATCH_EVENT_COUNT];
+ struct sailfish_watch *watch;
GKeyFile *storage;
char *imsi;
};
@@ -66,175 +67,77 @@
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
0, NULL, NULL, NULL, G_TYPE_NONE, 0)
+/* Skip the leading slash from the modem path: */
+#define DBG_(obj,fmt,args...) DBG("%s " fmt, (obj)->path+1, ##args)
+
static void ril_sim_settings_signal_emit(struct ril_sim_settings *self,
enum ril_sim_settings_signal id)
{
g_signal_emit(self, ril_sim_settings_signals[id], 0);
}
-static void ril_sim_settings_reload(struct ril_sim_settings *self)
-{
- struct ril_sim_settings_priv *priv = self->priv;
-
- if (priv->storage) {
- g_key_file_free(priv->storage);
- priv->storage = NULL;
- }
-
- if (priv->imsi) {
- char *mode_str;
- enum ofono_radio_access_mode mode;
- priv->storage = storage_open(priv->imsi, RIL_SIM_STORE);
- mode_str = g_key_file_get_string(priv->storage,
- RIL_SIM_STORE_GROUP, RIL_SIM_STORE_PREF_MODE, NULL);
- if (ofono_radio_access_mode_from_string(mode_str, &mode)) {
- if (!(self->techs & mode)) {
- mode = OFONO_RADIO_ACCESS_MODE_ANY;
- }
- } else {
- mode = OFONO_RADIO_ACCESS_MODE_ANY;
- }
- if (mode == OFONO_RADIO_ACCESS_MODE_ANY) {
- self->pref_mode = RIL_SIM_STORE_PREF_MODE_DEFAULT(self);
- } else {
- self->pref_mode = mode;
- }
- g_free(mode_str);
- }
-}
-
void ril_sim_settings_set_pref_mode(struct ril_sim_settings *self,
enum ofono_radio_access_mode mode)
{
if (G_LIKELY(self) && self->pref_mode != mode) {
- struct ril_sim_settings_priv *priv = self->priv;
- const char *mode_str = ofono_radio_access_mode_to_string(mode);
-
- GASSERT(priv->storage);
- if (mode_str) {
- if (priv->storage) {
- g_key_file_set_string(priv->storage,
- RIL_SIM_STORE_GROUP,
- RIL_SIM_STORE_PREF_MODE, mode_str);
- storage_sync(self->imsi, RIL_SIM_STORE,
- priv->storage);
- }
- self->pref_mode = mode;
- ril_sim_settings_signal_emit(self,
- SIGNAL_PREF_MODE_CHANGED);
- }
+ self->pref_mode = mode;
+ ril_sim_settings_signal_emit(self, SIGNAL_PREF_MODE_CHANGED);
}
}
-static void ril_sim_settings_set_imsi(struct ril_sim_settings *self,
- const char *imsi)
+static void ril_sim_settings_imsi_changed(struct sailfish_watch *watch,
+ void *user_data)
{
+ struct ril_sim_settings *self = RIL_SIM_SETTINGS(user_data);
struct ril_sim_settings_priv *priv = self->priv;
- if (g_strcmp0(priv->imsi, imsi)) {
- enum ofono_radio_access_mode prev_mode = self->pref_mode;
+
+ if (g_strcmp0(priv->imsi, watch->imsi)) {
g_free(priv->imsi);
- self->imsi = priv->imsi = g_strdup(imsi);
- ril_sim_settings_reload(self);
+ self->imsi = priv->imsi = g_strdup(watch->imsi);
ril_sim_settings_signal_emit(self, SIGNAL_IMSI_CHANGED);
- if (prev_mode != self->pref_mode) {
- ril_sim_settings_signal_emit(self,
- SIGNAL_PREF_MODE_CHANGED);
- }
}
}
-static void ril_sim_settings_imsi_watch_cb(const char *imsi, void *user_data)
-{
- ril_sim_settings_set_imsi(RIL_SIM_SETTINGS(user_data), imsi);
-}
-
-static void ril_sim_settings_imsi_watch_done(void *user_data)
+struct ril_sim_settings *ril_sim_settings_new(const char *path,
+ enum ofono_radio_access_mode techs)
{
- struct ril_sim_settings *self = RIL_SIM_SETTINGS(user_data);
- struct ril_sim_settings_priv *priv = self->priv;
+ struct ril_sim_settings *self = NULL;
- GASSERT(priv->imsi_watch_id);
- priv->imsi_watch_id = 0;
-}
+ if (G_LIKELY(path)) {
+ struct ril_sim_settings_priv *priv;
-static void ril_sim_settings_state_check(struct ril_sim_settings *self,
- enum ofono_sim_state new_state)
-{
- if (new_state != OFONO_SIM_STATE_READY) {
- ril_sim_settings_set_imsi(self, NULL);
+ self = g_object_new(RIL_SIM_SETTINGS_TYPE, NULL);
+ priv = self->priv;
+ self->techs = techs;
+ self->pref_mode = RIL_PREF_MODE_DEFAULT(self);
+ priv->watch = sailfish_watch_new(path);
+ priv->watch_event_id[WATCH_EVENT_IMSI] =
+ sailfish_watch_add_imsi_changed_handler(priv->watch,
+ ril_sim_settings_imsi_changed, self);
+ self->imsi = priv->imsi = g_strdup(priv->watch->imsi);
}
-}
-static void ril_sim_settings_state_watch(enum ofono_sim_state new_state,
- void *user_data)
-{
- ril_sim_settings_state_check(RIL_SIM_SETTINGS(user_data), new_state);
+ return self;
}
-static void ril_sim_settings_state_watch_done(void *user_data)
+struct ril_sim_settings *ril_sim_settings_ref(struct ril_sim_settings *self)
{
- struct ril_sim_settings *self = RIL_SIM_SETTINGS(user_data);
- struct ril_sim_settings_priv *priv = self->priv;
-
- GASSERT(priv->state_watch_id);
- priv->state_watch_id = 0;
+ if (G_LIKELY(self)) {
+ g_object_ref(RIL_SIM_SETTINGS(self));
+ return self;
+ } else {
+ return NULL;
+ }
}
-void ril_sim_settings_set_ofono_sim(struct ril_sim_settings *self,
- struct ofono_sim *sim)
+void ril_sim_settings_unref(struct ril_sim_settings *self)
{
if (G_LIKELY(self)) {
- struct ril_sim_settings_priv *priv = self->priv;
- if (priv->sim != sim) {
- GASSERT(priv->sim || !priv->imsi_watch_id);
- if (priv->imsi_watch_id) {
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_sim_settings.h
^
|
@@ -23,7 +23,6 @@
struct ril_sim_settings {
GObject object;
struct ril_sim_settings_priv *priv;
- guint slot;
const char *imsi;
enum ofono_radio_access_mode techs;
enum ofono_radio_access_mode pref_mode;
@@ -31,7 +30,8 @@
typedef void (*ril_sim_settings_cb_t)(struct ril_sim_settings *s, void *arg);
-struct ril_sim_settings *ril_sim_settings_new(const struct ril_slot_config *sc);
+struct ril_sim_settings *ril_sim_settings_new(const char *path,
+ enum ofono_radio_access_mode techs);
struct ril_sim_settings *ril_sim_settings_ref(struct ril_sim_settings *s);
void ril_sim_settings_unref(struct ril_sim_settings *s);
void ril_sim_settings_set_ofono_sim(struct ril_sim_settings *s,
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_sms.c
^
|
@@ -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
@@ -14,7 +14,6 @@
*/
#include "ril_plugin.h"
-#include "ril_constants.h"
#include "ril_util.h"
#include "ril_log.h"
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_stk.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015 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
@@ -16,7 +16,6 @@
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
-#include "ril_constants.h"
#include "util.h"
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_subscription.conf
^
|
@@ -35,18 +35,22 @@
#
#3GLTEHandover=true
+# RIL_REQUEST_SET_RADIO_CAPABILITY may or may not be supported by your RIL.
+# This option allows you to forcibly enable or disable use of this request.
+# It's involved in 3G/LTE handover between the modems, meaning that it only
+# makes sense if you have more than one slot.
+#
+# Possible values are auto, on and off
+#
+# Default is auto (enable for RIL version >= 11)
+#
+#SetRadioCapability=auto
+
[ril_0]
# Required entry, defines the RIL socket path
socket=/dev/socket/rild
-# If modem entry entry is marked is optional, it will be ignored
-# if the socket path does not exist at the time when ofono starts.
-#
-# The default is false (i.e. keep trying to connect)
-#
-# optional=false
-
# Subscription string. Some (mostly, older) RILs require that 4 bytes
# (usually SUB1 or SUB2) are written to the socket before rild starts
# talking to us.
@@ -113,7 +117,7 @@
# This option allows you to forcibly enable or disable use of this request.
# Possible values are auto, on and off
#
-# Default is auto (usage based on the RIL version)
+# Default is auto (enable for RIL version >= 11)
#
#allowDataReq=auto
@@ -164,3 +168,11 @@
#
#remoteHangupReasons=20
#localHangupReasons=23
+
+# Voice call support. Some devices like USB modems and tablets don't support
+# voice calls. By default, voice calls are enabled and this option allows you
+# to disable voice call handling.
+#
+# Default true
+#
+#enableVoicecall=true
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_types.h
^
|
@@ -40,20 +40,18 @@
#define RIL_RETRY_SECS (2)
#define RIL_RETRY_MS (RIL_RETRY_SECS*1000)
-struct ril_mce;
struct ril_data;
struct ril_modem;
struct ril_radio;
struct ril_network;
struct ril_sim_card;
-struct ril_sim_info;
-struct ril_sim_settings;
struct ril_cell_info;
struct ril_slot_config {
guint slot;
enum ofono_radio_access_mode techs;
gboolean empty_pin_query;
+ gboolean enable_voicecall;
GUtilInts *local_hangup_reasons;
GUtilInts *remote_hangup_reasons;
};
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_ussd.c
^
|
@@ -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
@@ -16,7 +16,6 @@
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
-#include "ril_constants.h"
#include "smsutil.h"
#include "util.h"
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_util.c
^
|
@@ -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
@@ -48,7 +48,8 @@
RIL_E_(MODE_NOT_SUPPORTED);
RIL_E_(FDN_CHECK_FAILURE);
RIL_E_(ILLEGAL_SIM_OR_ME);
- RIL_E_(UNUSED);
+ RIL_E_(MISSING_RESOURCE);
+ RIL_E_(NO_SUCH_ELEMENT);
RIL_E_(DIAL_MODIFIED_TO_USSD);
RIL_E_(DIAL_MODIFIED_TO_SS);
RIL_E_(DIAL_MODIFIED_TO_DIAL);
@@ -57,11 +58,39 @@
RIL_E_(USSD_MODIFIED_TO_USSD);
RIL_E_(SS_MODIFIED_TO_DIAL);
RIL_E_(SS_MODIFIED_TO_USSD);
- RIL_E_(SS_MODIFIED_TO_SS);
RIL_E_(SUBSCRIPTION_NOT_SUPPORTED);
- RIL_E_(MISSING_RESOURCE);
- RIL_E_(NO_SUCH_ELEMENT);
- RIL_E_(INVALID_PARAMETER);
+ RIL_E_(SS_MODIFIED_TO_SS);
+ RIL_E_(LCE_NOT_SUPPORTED);
+ RIL_E_(NO_MEMORY);
+ RIL_E_(INTERNAL_ERR);
+ RIL_E_(SYSTEM_ERR);
+ RIL_E_(MODEM_ERR);
+ RIL_E_(INVALID_STATE);
+ RIL_E_(NO_RESOURCES);
+ RIL_E_(SIM_ERR);
+ RIL_E_(INVALID_ARGUMENTS);
+ RIL_E_(INVALID_SIM_STATE);
+ RIL_E_(INVALID_MODEM_STATE);
+ RIL_E_(INVALID_CALL_ID);
+ RIL_E_(NO_SMS_TO_ACK);
+ RIL_E_(NETWORK_ERR);
+ RIL_E_(REQUEST_RATE_LIMITED);
+ RIL_E_(SIM_BUSY);
+ RIL_E_(SIM_FULL);
+ RIL_E_(NETWORK_REJECT);
+ RIL_E_(OPERATION_NOT_ALLOWED);
+ RIL_E_(EMPTY_RECORD);
+ RIL_E_(INVALID_SMS_FORMAT);
+ RIL_E_(ENCODING_ERR);
+ RIL_E_(INVALID_SMSC_ADDRESS);
+ RIL_E_(NO_SUCH_ENTRY);
+ RIL_E_(NETWORK_NOT_READY);
+ RIL_E_(NOT_PROVISIONED);
+ RIL_E_(NO_SUBSCRIPTION);
+ RIL_E_(NO_NETWORK_FOUND);
+ RIL_E_(DEVICE_IN_USE);
+ RIL_E_(ABORTED);
+ RIL_E_(INVALID_RESPONSE);
default:
snprintf(unknown, sizeof(unknown), "%d", error);
return unknown;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ril/ril_voicecall.c
^
|
@@ -14,7 +14,6 @@
*/
#include "ril_plugin.h"
-#include "ril_constants.h"
#include "ril_ecclist.h"
#include "ril_util.h"
#include "ril_log.h"
@@ -23,9 +22,13 @@
#include <gutil_ints.h>
#include <gutil_ring.h>
+#include <gutil_idlequeue.h>
+#include <gutil_intarray.h>
#define FLAG_NEED_CLIP 1
+#define VOICECALL_BLOCK_TIMEOUT_MS (5*1000)
+
enum ril_voicecall_events {
VOICECALL_EVENT_CALL_STATE_CHANGED,
VOICECALL_EVENT_SUPP_SVC_NOTIFICATION,
@@ -39,11 +42,11 @@
GRilIoQueue *q;
struct ofono_voicecall *vc;
struct ril_ecclist *ecclist;
- unsigned int local_release;
unsigned char flags;
ofono_voicecall_cb_t cb;
void *data;
- guint timer_id;
+ GUtilIntArray *local_release_ids;
+ GUtilIdleQueue *idleq;
GUtilRing *dtmf_queue;
GUtilInts *local_hangup_reasons;
GUtilInts *remote_hangup_reasons;
@@ -55,11 +58,13 @@
gulong ecclist_change_id;
};
-struct ril_voicecall_change_state_req {
+struct ril_voicecall_request_data {
+ int ref_count;
+ int pending_call_count;
+ int success;
struct ofono_voicecall *vc;
ofono_voicecall_cb_t cb;
gpointer data;
- int affected_types;
};
struct lastcause_req {
@@ -70,6 +75,32 @@
static void ril_voicecall_send_one_dtmf(struct ril_voicecall *vd);
static void ril_voicecall_clear_dtmf_queue(struct ril_voicecall *vd);
+struct ril_voicecall_request_data *ril_voicecall_request_data_new
+ (struct ofono_voicecall *vc, ofono_voicecall_cb_t cb, void *data)
+{
+ struct ril_voicecall_request_data *req =
+ g_slice_new0(struct ril_voicecall_request_data);
+
+ req->ref_count = 1;
+ req->vc = vc;
+ req->cb = cb;
+ req->data = data;
+ return req;
+}
+
+static void ril_voicecall_request_data_unref
+ (struct ril_voicecall_request_data *req)
+{
+ if (!--req->ref_count) {
+ g_slice_free(struct ril_voicecall_request_data, req);
+ }
+}
+
+static void ril_voicecall_request_data_free(gpointer data)
+{
+ ril_voicecall_request_data_unref(data);
+}
+
static inline struct ril_voicecall *ril_voicecall_get_data(
struct ofono_voicecall *vc)
{
@@ -319,7 +350,9 @@
struct ofono_call *oc = o ? o->data : NULL;
if (oc && (nc == NULL || (nc->id > oc->id))) {
- if (vd->local_release & (1 << oc->id)) {
+ /* old call is gone */
+ if (gutil_int_array_remove_all_fast(
+ vd->local_release_ids, oc->id)) {
ofono_voicecall_disconnected(vd->vc, oc->id,
OFONO_DISCONNECT_REASON_LOCAL_HANGUP,
NULL);
@@ -399,9 +432,7 @@
}
g_slist_free_full(vd->calls, g_free);
-
vd->calls = calls;
- vd->local_release = 0;
}
static void ril_voicecall_clcc_poll(struct ril_voicecall *vd)
@@ -420,52 +451,47 @@
static void ril_voicecall_request_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
- struct ril_voicecall_change_state_req *req = user_data;
+ struct ril_voicecall_request_data *req = user_data;
struct ril_voicecall *vd = ril_voicecall_get_data(req->vc);
- struct ofono_error error;
+ ril_voicecall_clcc_poll(vd);
+
+ /*
+ * The ofono API call is considered successful if at least one
+ * associated RIL request succeeds.
+ */
if (status == RIL_E_SUCCESS) {
- GSList *l;
+ req->success++;
+ }
- if (req->affected_types) {
- for (l = vd->calls; l; l = l->next) {
- struct ofono_call *call = l->data;
+ /*
+ * Only invoke the callback if this is the last request associated
+ * with this ofono api call (pending call count becomes zero).
+ */
+ GASSERT(req->pending_call_count > 0);
+ if (!--req->pending_call_count && req->cb) {
+ struct ofono_error error;
- if (req->affected_types & (1 << call->status)) {
- vd->local_release |= (1 << call->id);
- }
- }
+ if (req->success) {
+ ril_error_init_ok(&error);
+ } else {
+ ril_error_init_failure(&error);
}
- ril_error_init_ok(&error);
- } else {
- ofono_error("generic fail");
- ril_error_init_failure(&error);
- }
-
- ril_voicecall_clcc_poll(vd);
-
- /* We have to callback after we schedule a poll if required */
- if (req->cb) {
req->cb(&error, req->data);
}
}
-static void ril_voicecall_request(const guint rreq, struct ofono_voicecall *vc,
- unsigned int affected_types, GRilIoRequest *ioreq,
- ofono_voicecall_cb_t cb, void *data)
+static void ril_voicecall_request(const guint code, struct ofono_voicecall *vc,
+ GRilIoRequest *req, ofono_voicecall_cb_t cb, void *data)
{
- struct ril_voicecall *vd = ril_voicecall_get_data(vc);
- struct ril_voicecall_change_state_req *req;
+ struct ril_voicecall_request_data *req_data =
+ ril_voicecall_request_data_new(vc, cb, data);
- req = g_new0(struct ril_voicecall_change_state_req, 1);
- req->vc = vc;
- req->cb = cb;
- req->data = data;
- req->affected_types = affected_types;
-
- grilio_queue_send_request_full(vd->q, ioreq, rreq,
- ril_voicecall_request_cb, g_free, req);
+ req_data->pending_call_count++;
+ grilio_queue_send_request_full(ril_voicecall_get_data(vc)->q, req,
+ code, ril_voicecall_request_cb,
+ ril_voicecall_request_data_free, req_data);
}
static void ril_voicecall_dial_cb(GRilIoChannel *io, int status,
@@ -523,47 +549,68 @@
grilio_request_unref(req);
}
+static void ril_voicecall_submit_hangup_req(struct ofono_voicecall *vc,
+ int id, struct ril_voicecall_request_data *req)
+{
+ struct ril_voicecall *vd = ril_voicecall_get_data(vc);
+ GRilIoRequest *ioreq = grilio_request_array_int32_new(1, id);
+
+ /* Append the call id to the list of calls being released locally */
+ GASSERT(!gutil_int_array_contains(vd->local_release_ids, id));
+ gutil_int_array_append(vd->local_release_ids, id);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/drivers/ubloxmodem/gprs-context.c
^
|
@@ -261,6 +261,7 @@
case OFONO_GPRS_AUTH_METHOD_PAP:
auth = 1;
break;
+ case OFONO_GPRS_AUTH_METHOD_ANY:
case OFONO_GPRS_AUTH_METHOD_CHAP:
auth = 2;
break;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/include/gprs-context.h
^
|
@@ -49,7 +49,9 @@
};
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,
};
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/include/netreg.h
^
|
@@ -114,6 +114,7 @@
int ofono_netreg_get_technology(struct ofono_netreg *netreg);
const char *ofono_netreg_get_mcc(struct ofono_netreg *netreg);
const char *ofono_netreg_get_mnc(struct ofono_netreg *netreg);
+const char *ofono_netreg_get_name(struct ofono_netreg *netreg);
struct sim_spdi *ofono_netreg_get_spdi(struct ofono_netreg *netreg);
#ifdef __cplusplus
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/include/sailfish_manager.h
^
|
@@ -0,0 +1,121 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 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.
+ */
+
+#ifndef SAILFISHOS_MANAGER_H
+#define SAILFISHOS_MANAGER_H
+
+struct ofono_modem;
+
+#include <ofono/types.h>
+#include <ofono/radio-settings.h>
+
+#include <glib.h>
+
+struct sailfish_manager;
+struct sailfish_slot;
+struct sailfish_slot_impl;
+struct sailfish_slot_driver;
+struct sailfish_slot_driver_reg;
+struct sailfish_slot_manager;
+struct sailfish_slot_manager_impl;
+typedef void (*sailfish_slot_manager_impl_cb_t)
+ (struct sailfish_slot_manager_impl *impl, void *user_data);
+
+typedef struct sailfish_slot {
+ const char *path;
+ const char *imei;
+ const char *imeisv;
+ gboolean sim_present;
+ gboolean enabled;
+} const *sailfish_slot_ptr;
+
+struct sailfish_manager {
+ const char *mms_imsi;
+ const char *mms_path;
+ const char *default_voice_imsi;
+ const char *default_data_imsi;
+ const char *default_voice_path;
+ const char *default_data_path;
+ const sailfish_slot_ptr *slots;
+ gboolean ready;
+};
+
+enum sailfish_sim_state {
+ SAILFISH_SIM_STATE_UNKNOWN,
+ SAILFISH_SIM_STATE_ABSENT,
+ SAILFISH_SIM_STATE_PRESENT,
+ SAILFISH_SIM_STATE_ERROR
+};
+
+enum sailfish_data_role {
+ SAILFISH_DATA_ROLE_NONE, /* Data not allowed */
+ SAILFISH_DATA_ROLE_MMS, /* Data is allowed at any speed */
+ SAILFISH_DATA_ROLE_INTERNET /* Data is allowed at full speed */
+};
+
+/* Register/unregister the driver */
+struct sailfish_slot_driver_reg *sailfish_slot_driver_register
+ (const struct sailfish_slot_driver *d);
+void sailfish_slot_driver_unregister(struct sailfish_slot_driver_reg *r);
+
+/* For use by the driver implementations */
+void sailfish_manager_foreach_slot_manager
+ (struct sailfish_slot_driver_reg *r,
+ sailfish_slot_manager_impl_cb_t cb, void *user_data);
+struct sailfish_slot *sailfish_manager_slot_add
+ (struct sailfish_slot_manager *m, struct sailfish_slot_impl *i,
+ const char *path, enum ofono_radio_access_mode techs,
+ const char *imei, const char *imeisv,
+ enum sailfish_sim_state sim_state);
+void sailfish_manager_imei_obtained(struct sailfish_slot *s, const char *imei);
+void sailfish_manager_imeisv_obtained(struct sailfish_slot *s,
+ const char *imeisv);
+void sailfish_manager_set_sim_state(struct sailfish_slot *s,
+ enum sailfish_sim_state state);
+void sailfish_slot_manager_started(struct sailfish_slot_manager *m);
+void sailfish_manager_slot_error(struct sailfish_slot *s, const char *key,
+ const char *message);
+void sailfish_manager_error(struct sailfish_slot_manager *m, const char *key,
+ const char *message);
+
+/* Callbacks provided by slot plugins */
+struct sailfish_slot_driver {
+ const char *name;
+ int priority;
+
+ /* Slot manager methods */
+ struct sailfish_slot_manager_impl *(*manager_create)
+ (struct sailfish_slot_manager *m);
+ guint (*manager_start)(struct sailfish_slot_manager_impl *s);
+ void (*manager_cancel_start)(struct sailfish_slot_manager_impl *s,
+ guint id);
+ void (*manager_free)(struct sailfish_slot_manager_impl *s);
+
+ /* Slot methods */
+ void (*slot_enabled_changed)(struct sailfish_slot_impl *s);
+ void (*slot_set_data_role)(struct sailfish_slot_impl *s,
+ enum sailfish_data_role role);
+ void (*slot_free)(struct sailfish_slot_impl *s);
+};
+
+#endif /* SAILFISHOS_MANAGER_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/include/sailfish_watch.h
^
|
@@ -0,0 +1,81 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 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.
+ */
+
+#ifndef SAILFISH_WATCH_H
+#define SAILFISH_WATCH_H
+
+struct ofono_modem;
+struct ofono_sim;
+struct ofono_netreg;
+
+#include <glib.h>
+#include <glib-object.h>
+
+/* This object watches ofono modem and various related things */
+struct sailfish_watch_priv;
+struct sailfish_watch {
+ GObject object;
+ struct sailfish_watch_priv *priv;
+ const char *path;
+ /* Modem */
+ struct ofono_modem *modem;
+ gboolean online;
+ /* OFONO_ATOM_TYPE_SIM */
+ struct ofono_sim *sim;
+ const char *iccid;
+ const char *imsi;
+ const char *spn;
+ /* OFONO_ATOM_TYPE_NETREG */
+ struct ofono_netreg *netreg;
+};
+
+typedef void (*sailfish_watch_cb_t)(struct sailfish_watch *w, void *user_data);
+
+struct sailfish_watch *sailfish_watch_new(const char *path);
+struct sailfish_watch *sailfish_watch_ref(struct sailfish_watch *w);
+void sailfish_watch_unref(struct sailfish_watch *w);
+
+gulong sailfish_watch_add_modem_changed_handler(struct sailfish_watch *w,
+ sailfish_watch_cb_t cb, void *user_data);
+gulong sailfish_watch_add_online_changed_handler(struct sailfish_watch *w,
+ sailfish_watch_cb_t cb, void *user_data);
+gulong sailfish_watch_add_sim_changed_handler(struct sailfish_watch *w,
+ sailfish_watch_cb_t cb, void *user_data);
+gulong sailfish_watch_add_sim_state_changed_handler(struct sailfish_watch *w,
+ sailfish_watch_cb_t cb, void *user_data);
+gulong sailfish_watch_add_iccid_changed_handler(struct sailfish_watch *w,
+ sailfish_watch_cb_t cb, void *user_data);
+gulong sailfish_watch_add_imsi_changed_handler(struct sailfish_watch *w,
+ sailfish_watch_cb_t cb, void *user_data);
+gulong sailfish_watch_add_spn_changed_handler(struct sailfish_watch *w,
+ sailfish_watch_cb_t cb, void *user_data);
+gulong sailfish_watch_add_netreg_changed_handler(struct sailfish_watch *w,
+ sailfish_watch_cb_t cb, void *user_data);
+void sailfish_watch_remove_handler(struct sailfish_watch *w, gulong id);
+void sailfish_watch_remove_handlers(struct sailfish_watch *w, gulong *ids,
+ int count);
+
+#define sailfish_watch_remove_all_handlers(w,ids) \
+ sailfish_watch_remove_handlers(w, ids, G_N_ELEMENTS(ids))
+
+#endif /* SAILFISH_WATCH_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/plugins/mbpi.c
^
|
@@ -53,6 +53,9 @@
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 @@
*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 @@
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 @@
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;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/plugins/mbpi.h
^
|
@@ -23,6 +23,7 @@
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);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/plugins/provision.c
^
|
@@ -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 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 @@
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));
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/plugins/sailfish_bt.c
^
|
(renamed from ofono/plugins/sfos_bt.c)
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/plugins/sailfish_debuglog.c
^
|
(renamed from ofono/plugins/debuglog.c)
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/plugins/sailfish_manager/sailfish_manager.c
^
|
@@ -0,0 +1,1300 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 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
+
+#include <gutil_log.h>
+#include <gutil_strv.h>
+#include <gutil_macros.h>
+#include <string.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include "ofono.h"
+#include "storage.h"
+
+#include <sailfish_manager.h>
+#include "sailfish_manager_dbus.h"
+#include "sailfish_sim_info.h"
+#include "sailfish_watch.h"
+
+/* How long we wait for all drivers to register (number of idle loops) */
+#define SF_INIT_IDLE_COUNT (5)
+
+enum sailfish_watch_events {
+ WATCH_EVENT_MODEM,
+ WATCH_EVENT_ONLINE,
+ WATCH_EVENT_IMSI,
+ WATCH_EVENT_COUNT
+};
+
+struct sailfish_manager_priv {
+ struct sailfish_manager pub; /* Public part */
+ struct sailfish_slot_driver_reg *drivers;
+ struct sailfish_manager_dbus *dbus;
+ struct sailfish_slot_priv *voice_slot;
+ struct sailfish_slot_priv *data_slot;
+ struct sailfish_slot_priv *mms_slot;
+ sailfish_slot_ptr *slots;
+ int slot_count;
+ guint init_countdown;
+ guint init_id;
+ char *default_voice_imsi;
+ char *default_data_imsi;
+ char *mms_imsi;
+ GKeyFile *storage;
+ GHashTable *errors;
+};
+
+struct sailfish_slot_driver_reg {
+ struct sailfish_slot_driver_reg *next;
+ const struct sailfish_slot_driver *driver;
+ struct sailfish_manager_priv *plugin;
+ struct sailfish_slot_manager *manager;
+ guint init_id;
+};
+
+struct sailfish_slot_manager {
+ const struct sailfish_slot_driver *driver;
+ struct sailfish_manager_priv *plugin;
+ struct sailfish_slot_manager_impl *impl;
+ struct sailfish_slot_priv *slots;
+ gboolean started;
+ guint start_id;
+};
+
+struct sailfish_slot_priv {
+ struct sailfish_slot pub;
+ struct sailfish_slot_priv *next;
+ struct sailfish_slot_manager *manager;
+ struct sailfish_slot_impl *impl;
+ struct sailfish_watch *watch;
+ struct sailfish_sim_info *siminfo;
+ struct sailfish_sim_info_dbus *siminfo_dbus;
+ enum sailfish_sim_state sim_state;
+ gulong watch_event_id[WATCH_EVENT_COUNT];
+ char *imei;
+ char *imeisv;
+ gboolean enabled_changed;
+ GHashTable *errors;
+ int index;
+};
+
+/* "ril" is used for historical reasons */
+#define SF_STORE "ril"
+#define SF_STORE_GROUP "Settings"
+#define SF_STORE_ENABLED_SLOTS "EnabledSlots"
+#define SF_STORE_DEFAULT_VOICE_SIM "DefaultVoiceSim"
+#define SF_STORE_DEFAULT_DATA_SIM "DefaultDataSim"
+#define SF_STORE_SLOTS_SEP ","
+
+/* The file where error statistics is stored. Again "rilerror" is historical */
+#define SF_ERROR_STORAGE "rilerror" /* File name */
+#define SF_ERROR_COMMON_SECTION "common" /* Modem independent section */
+
+/* Path always starts with a slash, skip it */
+#define sailfish_slot_debug_prefix(s) ((s)->pub.path + 1)
+
+static int sailfish_manager_update_modem_paths(struct sailfish_manager_priv *);
+static gboolean sailfish_manager_update_ready(struct sailfish_manager_priv *p);
+
+static inline struct sailfish_manager_priv *sailfish_manager_priv_cast
+ (struct sailfish_manager *m)
+{
+ return G_CAST(m, struct sailfish_manager_priv, pub);
+}
+
+static inline struct sailfish_slot_priv *sailfish_slot_priv_cast
+ (struct sailfish_slot *s)
+{
+ return G_CAST(s, struct sailfish_slot_priv, pub);
+}
+
+static inline const struct sailfish_slot_priv *sailfish_slot_priv_cast_const
+ (const struct sailfish_slot *s)
+{
+ return G_CAST(s, struct sailfish_slot_priv, pub);
+}
+
+static inline void sailfish_slot_set_data_role(struct sailfish_slot_priv *s,
+ enum sailfish_data_role role)
+{
+ const struct sailfish_slot_driver *d = s->manager->driver;
+
+ if (d->slot_set_data_role) {
+ d->slot_set_data_role(s->impl, role);
+ }
+}
+
+/* Update modem paths and emit D-Bus signal if necessary */
+static void sailfish_manager_update_modem_paths_full
+ (struct sailfish_manager_priv *p)
+{
+ sailfish_manager_dbus_signal(p->dbus,
+ sailfish_manager_update_modem_paths(p));
+}
+
+/*
+ * sailfish_manager_foreach_slot() terminates the loop and returns
+ * TRUE if the callback returns TRUE. If all callbacks return FALSE, it
+ * returns FALSE. It there are no slots, it returns FALSE too.
+ */
+
+#define SF_LOOP_CONTINUE (FALSE)
+#define SF_LOOP_DONE (TRUE)
+
+static gboolean sailfish_manager_foreach_slot
+ (struct sailfish_manager_priv *p,
+ gboolean (*fn)(struct sailfish_slot_priv *s, void *user_data),
+ void *user_data)
+{
+ struct sailfish_slot_driver_reg *r = p->drivers;
+ gboolean done = FALSE;
+
+ while (r && !done) {
+ struct sailfish_slot_manager *m = r->manager;
+ struct sailfish_slot_driver_reg *rnext = r->next;
+
+ if (m) {
+ struct sailfish_slot_priv *s = m->slots;
+
+ while (s) {
+ struct sailfish_slot_priv *snext = s->next;
+
+ /* The callback returns TRUE to terminate
+ * the loop */
+ if (fn(s, user_data)) {
+ done = TRUE;
+ break;
+ }
+ s = snext;
+ }
+ }
+ r = rnext;
+ }
+
+ return done;
+}
+
+static void sailfish_manager_slot_modem_changed(struct sailfish_watch *w,
+ void *user_data)
+{
+ struct sailfish_slot_priv *s = user_data;
+ struct sailfish_manager_priv *p = s->manager->plugin;
+
+ sailfish_manager_update_modem_paths_full(p);
+ sailfish_manager_update_ready(p);
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/plugins/sailfish_manager/sailfish_manager_dbus.c
^
|
@@ -0,0 +1,1174 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * 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
+ * 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.
+ */
+
+#include "sailfish_manager_dbus.h"
+
+#include <ofono/log.h>
+#include <ofono/dbus.h>
+
+#include <gutil_strv.h>
+#include <gutil_log.h>
+#include <gdbus.h>
+
+#include "ofono.h"
+
+typedef void (*sailfish_manager_dbus_append_fn)(DBusMessageIter *it,
+ struct sailfish_manager_dbus *dbus);
+typedef gboolean (*sailfish_manager_dbus_slot_select_fn)
+ (const struct sailfish_slot *slot);
+typedef const char *(*sailfish_manager_dbus_slot_string_fn)
+ (const struct sailfish_slot *slot);
+
+struct sailfish_manager_dbus_request {
+ DBusMessage *msg;
+ sailfish_manager_dbus_append_fn fn;
+ enum sailfish_manager_dbus_block block;
+};
+
+struct sailfish_manager_dbus {
+ struct sailfish_manager *manager;
+ const struct sailfish_manager_dbus_cb *cb;
+ DBusConnection *conn;
+ enum sailfish_manager_dbus_block block_mask;
+ GSList *blocked_req;
+ guint mms_watch;
+};
+
+#define SF_DBUS_PATH "/"
+#define SF_DBUS_INTERFACE "org.nemomobile.ofono.ModemManager"
+#define SF_DBUS_INTERFACE_VERSION (8)
+
+#define SF_DBUS_SIGNAL_ENABLED_MODEMS_CHANGED "EnabledModemsChanged"
+#define SF_DBUS_SIGNAL_PRESENT_SIMS_CHANGED "PresentSimsChanged"
+#define SF_DBUS_SIGNAL_DEFAULT_VOICE_SIM_CHANGED "DefaultVoiceSimChanged"
+#define SF_DBUS_SIGNAL_DEFAULT_DATA_SIM_CHANGED "DefaultDataSimChanged"
+#define SF_DBUS_SIGNAL_DEFAULT_VOICE_MODEM_CHANGED "DefaultVoiceModemChanged"
+#define SF_DBUS_SIGNAL_DEFAULT_DATA_MODEM_CHANGED "DefaultDataModemChanged"
+#define SF_DBUS_SIGNAL_MMS_SIM_CHANGED "MmsSimChanged"
+#define SF_DBUS_SIGNAL_MMS_MODEM_CHANGED "MmsModemChanged"
+#define SF_DBUS_SIGNAL_READY_CHANGED "ReadyChanged"
+#define SF_DBUS_SIGNAL_MODEM_ERROR "ModemError"
+#define SF_DBUS_IMSI_AUTO "auto"
+
+#define SF_DBUS_ERROR_SIGNATURE "si"
+
+static gboolean sailfish_manager_dbus_enabled(const struct sailfish_slot *s)
+{
+ return s->enabled;
+}
+
+static gboolean sailfish_manager_dbus_present(const struct sailfish_slot *s)
+{
+ return s->sim_present;
+}
+
+static const char *sailfish_manager_dbus_imei(const struct sailfish_slot *s)
+{
+ return s->imei;
+}
+
+static const char *sailfish_manager_dbus_imeisv(const struct sailfish_slot *s)
+{
+ return s->imeisv;
+}
+
+static void sailfish_manager_dbus_append_path_array(DBusMessageIter *it,
+ struct sailfish_manager_dbus *dbus,
+ sailfish_manager_dbus_slot_select_fn selector)
+{
+ DBusMessageIter array;
+ const sailfish_slot_ptr *ptr = dbus->manager->slots;
+
+ dbus_message_iter_open_container(it, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_OBJECT_PATH_AS_STRING, &array);
+
+ if (ptr) {
+ while (*ptr) {
+ const struct sailfish_slot *slot = *ptr++;
+
+ if (!selector || selector(slot)) {
+ const char *path = slot->path;
+ dbus_message_iter_append_basic(&array,
+ DBUS_TYPE_OBJECT_PATH, &path);
+ }
+ }
+ }
+
+ dbus_message_iter_close_container(it, &array);
+}
+
+static void sailfish_manager_dbus_append_string_array(DBusMessageIter *it,
+ struct sailfish_manager_dbus *dbus,
+ sailfish_manager_dbus_slot_string_fn fn)
+{
+ DBusMessageIter array;
+ const sailfish_slot_ptr *ptr = dbus->manager->slots;
+
+ dbus_message_iter_open_container(it, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_STRING_AS_STRING, &array);
+
+ if (ptr) {
+ while (*ptr) {
+ const struct sailfish_slot *slot = *ptr++;
+ const char *str = fn(slot);
+
+ if (!str) str = "";
+ dbus_message_iter_append_basic(&array,
+ DBUS_TYPE_STRING, &str);
+ }
+ }
+
+ dbus_message_iter_close_container(it, &array);
+}
+
+static void sailfish_manager_dbus_append_boolean_array(DBusMessageIter *it,
+ struct sailfish_manager_dbus *dbus,
+ sailfish_manager_dbus_slot_select_fn value)
+{
+ DBusMessageIter array;
+ const sailfish_slot_ptr *ptr = dbus->manager->slots;
+
+ dbus_message_iter_open_container(it, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_BOOLEAN_AS_STRING, &array);
+
+ if (ptr) {
+ while (*ptr) {
+ const struct sailfish_slot *slot = *ptr++;
+ dbus_bool_t b = value(slot);
+
+ dbus_message_iter_append_basic(&array,
+ DBUS_TYPE_BOOLEAN, &b);
+ }
+ }
+
+ dbus_message_iter_close_container(it, &array);
+}
+
+static void sailfish_manager_dbus_append_boolean(DBusMessageIter *it,
+ dbus_bool_t b)
+{
+ dbus_message_iter_append_basic(it, DBUS_TYPE_BOOLEAN, &b);
+}
+
+static void sailfish_manager_dbus_append_string(DBusMessageIter *it,
+ const char *str)
+{
+ if (!str) str = "";
+ dbus_message_iter_append_basic(it, DBUS_TYPE_STRING, &str);
+}
+
+static void sailfish_manager_dbus_append_imsi(DBusMessageIter *it,
+ const char *imsi)
+{
+ if (!imsi) imsi = SF_DBUS_IMSI_AUTO;
+ dbus_message_iter_append_basic(it, DBUS_TYPE_STRING, &imsi);
+}
+
+static void sailfish_manager_dbus_append_path(DBusMessageIter *it,
+ const char *path)
+{
+ if (!path) path = "";
+ /* It's DBUS_TYPE_STRING since DBUS_TYPE_OBJECT_PATH can't be empty */
+ dbus_message_iter_append_basic(it, DBUS_TYPE_STRING, &path);
+}
+
+static void sailfish_manager_dbus_message_append_path_array(DBusMessage *msg,
+ struct sailfish_manager_dbus *dbus,
+ sailfish_manager_dbus_slot_select_fn fn)
+{
+ DBusMessageIter iter;
+
+ dbus_message_iter_init_append(msg, &iter);
+ sailfish_manager_dbus_append_path_array(&iter, dbus, fn);
+}
+
+static void sailfish_manager_dbus_append_error_count(DBusMessageIter *it,
+ const char *id, dbus_uint32_t count)
+{
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/plugins/sailfish_manager/sailfish_manager_dbus.h
^
|
@@ -0,0 +1,77 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2016-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.
+ */
+
+#ifndef SAILFISH_MANAGER_DBUS_H
+#define SAILFISH_MANAGER_DBUS_H
+
+#include <sailfish_manager.h>
+
+struct sailfish_manager_dbus;
+
+enum sailfish_manager_dbus_block {
+ SAILFISH_MANAGER_DBUS_BLOCK_NONE = 0,
+ SAILFISH_MANAGER_DBUS_BLOCK_MODEM = 0x01,
+ SAILFISH_MANAGER_DBUS_BLOCK_IMEI = 0x02,
+ SAILFISH_MANAGER_DBUS_BLOCK_ALL = 0x03
+};
+
+enum sailfish_manager_dbus_signal {
+ SAILFISH_MANAGER_SIGNAL_NONE = 0,
+ SAILFISH_MANAGER_SIGNAL_VOICE_IMSI = 0x01,
+ SAILFISH_MANAGER_SIGNAL_DATA_IMSI = 0x02,
+ SAILFISH_MANAGER_SIGNAL_VOICE_PATH = 0x04,
+ SAILFISH_MANAGER_SIGNAL_DATA_PATH = 0x08,
+ SAILFISH_MANAGER_SIGNAL_ENABLED_SLOTS = 0x10,
+ SAILFISH_MANAGER_SIGNAL_MMS_IMSI = 0x20,
+ SAILFISH_MANAGER_SIGNAL_MMS_PATH = 0x40,
+ SAILFISH_MANAGER_SIGNAL_READY = 0x80
+};
+
+/* Functionality provided by sailfish_manager to sailfish_manager_dbus */
+struct sailfish_manager_dbus_cb {
+ GHashTable *(*get_errors)(struct sailfish_manager *m);
+ GHashTable *(*get_slot_errors)(const struct sailfish_slot *s);
+ void (*set_enabled_slots)(struct sailfish_manager *m, char **slots);
+ gboolean (*set_mms_imsi)(struct sailfish_manager *m, const char *imsi);
+ void (*set_default_voice_imsi)(struct sailfish_manager *m,
+ const char *imsi);
+ void (*set_default_data_imsi)(struct sailfish_manager *m,
+ const char *imsi);
+};
+
+struct sailfish_manager_dbus *sailfish_manager_dbus_new
+ (struct sailfish_manager *m,
+ const struct sailfish_manager_dbus_cb *cb);
+void sailfish_manager_dbus_free(struct sailfish_manager_dbus *d);
+void sailfish_manager_dbus_set_block(struct sailfish_manager_dbus *d,
+ enum sailfish_manager_dbus_block b);
+void sailfish_manager_dbus_signal(struct sailfish_manager_dbus *d,
+ enum sailfish_manager_dbus_signal m);
+void sailfish_manager_dbus_signal_sim(struct sailfish_manager_dbus *d,
+ int index, gboolean present);
+void sailfish_manager_dbus_signal_error(struct sailfish_manager_dbus *d,
+ const char *id, const char *message);
+void sailfish_manager_dbus_signal_modem_error(struct sailfish_manager_dbus *d,
+ int index, const char *id, const char *msg);
+
+#endif /* SAILFISH_MANAGER_DBUS_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/plugins/sailfish_manager/sailfish_sim_info.c
^
|
@@ -0,0 +1,614 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 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
+
+#include "sailfish_sim_info.h"
+#include "sailfish_watch.h"
+
+#include <gutil_misc.h>
+#include <gutil_log.h>
+
+#include "ofono.h"
+#include "common.h"
+#include "storage.h"
+
+#define SAILFISH_SIM_INFO_STORE "cache"
+#define SAILFISH_SIM_INFO_STORE_GROUP "sim"
+#define SAILFISH_SIM_INFO_STORE_SPN "spn"
+
+/* ICCID -> IMSI map */
+#define SAILFISH_SIM_ICCID_MAP "iccidmap"
+#define SAILFISH_SIM_ICCID_MAP_IMSI "imsi"
+
+#define DEFAULT_SPN_BUFSIZE 8
+G_STATIC_ASSERT(DEFAULT_SPN_BUFSIZE >= \
+ OFONO_MAX_MCC_LENGTH + OFONO_MAX_MNC_LENGTH + 1);
+
+typedef GObjectClass SailfishSimInfoClass;
+typedef struct sailfish_sim_info SailfishSimInfo;
+
+enum sailfish_watch_events {
+ WATCH_EVENT_SIM,
+ WATCH_EVENT_SIM_STATE,
+ WATCH_EVENT_ICCID,
+ WATCH_EVENT_IMSI,
+ WATCH_EVENT_SPN,
+ WATCH_EVENT_NETREG,
+ WATCH_EVENT_COUNT
+};
+
+struct sailfish_sim_info_priv {
+ struct sailfish_watch *watch;
+ struct ofono_netreg *netreg;
+ char *iccid;
+ char *imsi;
+ char *cached_spn;
+ char *sim_spn;
+ char *public_spn;
+ char default_spn[DEFAULT_SPN_BUFSIZE];
+ gulong watch_event_id[WATCH_EVENT_COUNT];
+ guint netreg_status_watch_id;
+ gboolean update_imsi_cache;
+ gboolean update_iccid_map;
+};
+
+enum sailfish_sim_info_signal {
+ SIGNAL_ICCID_CHANGED,
+ SIGNAL_IMSI_CHANGED,
+ SIGNAL_SPN_CHANGED,
+ SIGNAL_COUNT
+};
+
+#define SIGNAL_ICCID_CHANGED_NAME "sailfish-siminfo-iccid-changed"
+#define SIGNAL_IMSI_CHANGED_NAME "sailfish-siminfo-imsi-changed"
+#define SIGNAL_SPN_CHANGED_NAME "sailfish-siminfo-spn-changed"
+
+static guint sailfish_sim_info_signals[SIGNAL_COUNT] = { 0 };
+
+G_DEFINE_TYPE(SailfishSimInfo, sailfish_sim_info, G_TYPE_OBJECT)
+#define SAILFISH_SIMINFO_TYPE (sailfish_sim_info_get_type())
+#define SAILFISH_SIMINFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
+ SAILFISH_SIMINFO_TYPE, SailfishSimInfo))
+
+#define NEW_SIGNAL(klass,name) \
+ sailfish_sim_info_signals[SIGNAL_##name##_CHANGED] = \
+ g_signal_new(SIGNAL_##name##_CHANGED_NAME, \
+ G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
+ 0, NULL, NULL, NULL, G_TYPE_NONE, 0)
+
+/* Skip the leading slash from the modem path: */
+#define DBG_(obj,fmt,args...) DBG("%s " fmt, (obj)->path+1, ##args)
+
+static void sailfish_sim_info_signal_emit(struct sailfish_sim_info *self,
+ enum sailfish_sim_info_signal id)
+{
+ g_signal_emit(self, sailfish_sim_info_signals[id], 0);
+}
+
+static void sailfish_sim_info_update_imsi_cache(struct sailfish_sim_info *self)
+{
+ struct sailfish_sim_info_priv *priv = self->priv;
+
+ if (priv->update_imsi_cache && priv->imsi && priv->imsi[0] &&
+ priv->cached_spn && priv->cached_spn[0]) {
+ gboolean save = FALSE;
+ const char *store = SAILFISH_SIM_INFO_STORE;
+ GKeyFile *cache = storage_open(priv->imsi, store);
+ char *spn = g_key_file_get_string(cache,
+ SAILFISH_SIM_INFO_STORE_GROUP,
+ SAILFISH_SIM_INFO_STORE_SPN, NULL);
+
+ if (g_strcmp0(priv->cached_spn, spn)) {
+ save = TRUE;
+ g_key_file_set_string(cache,
+ SAILFISH_SIM_INFO_STORE_GROUP,
+ SAILFISH_SIM_INFO_STORE_SPN,
+ priv->cached_spn);
+ }
+
+ /*
+ * Since we are most likely running on flash which
+ * supports a limited number of writes, don't overwrite
+ * the file unless something has actually changed.
+ */
+ if (save) {
+ DBG_(self, "updating " STORAGEDIR "/%s/%s",
+ priv->imsi, store);
+ storage_close(priv->imsi, store, cache, TRUE);
+ } else {
+ g_key_file_free(cache);
+ }
+
+ g_free(spn);
+ priv->update_imsi_cache = FALSE;
+ }
+}
+
+static void sailfish_sim_info_update_iccid_map(struct sailfish_sim_info *self)
+{
+ struct sailfish_sim_info_priv *priv = self->priv;
+
+ if (priv->update_iccid_map && priv->iccid && priv->iccid[0] &&
+ priv->imsi && priv->imsi[0]) {
+ const char *store = SAILFISH_SIM_ICCID_MAP;
+ GKeyFile *map = storage_open(NULL, store);
+ char *imsi = g_key_file_get_string(map,
+ SAILFISH_SIM_ICCID_MAP_IMSI, priv->iccid, NULL);
+
+ /*
+ * Since we are most likely running on flash which
+ * supports a limited number of writes, don't overwrite
+ * the file unless something has actually changed.
+ */
+ if (g_strcmp0(imsi, priv->imsi)) {
+ DBG_(self, "updating " STORAGEDIR "/%s", store);
+ g_key_file_set_string(map, SAILFISH_SIM_ICCID_MAP_IMSI,
+ priv->iccid, priv->imsi);
+ storage_close(NULL, store, map, TRUE);
+ } else {
+ g_key_file_free(map);
+ }
+
+ g_free(imsi);
+ priv->update_iccid_map = FALSE;
+ }
+}
+
+static void sailfish_sim_info_update_public_spn(struct sailfish_sim_info *self)
+{
+ struct sailfish_sim_info_priv *priv = self->priv;
+ const char *spn = priv->sim_spn ? priv->sim_spn :
+ priv->cached_spn ? priv->cached_spn :
+ priv->default_spn;
+
+ if (g_strcmp0(priv->public_spn, spn)) {
+ g_free(priv->public_spn);
+ self->spn = priv->public_spn = g_strdup(spn);
+ sailfish_sim_info_signal_emit(self, SIGNAL_SPN_CHANGED);
+ }
+}
+
+static void sailfish_sim_info_set_cached_spn(struct sailfish_sim_info *self,
+ const char *spn)
+{
+ struct sailfish_sim_info_priv *priv = self->priv;
+
+ if (g_strcmp0(priv->cached_spn, spn)) {
+ g_free(priv->cached_spn);
+ if (spn) {
+ DBG_(self, "cached spn \"%s\"", spn);
+ priv->cached_spn = g_strdup(spn);
+ priv->update_imsi_cache = TRUE;
+ sailfish_sim_info_update_imsi_cache(self);
+ } else {
+ priv->cached_spn = NULL;
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/plugins/sailfish_manager/sailfish_sim_info.h
^
|
@@ -0,0 +1,81 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 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.
+ */
+
+#ifndef SAILFISH_SIM_INFO_H
+#define SAILFISH_SIM_INFO_H
+
+#include <ofono/types.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+/*
+ * Note that iccid, imsi and spn provided by this class can be cached,
+ * i.e. become available before the pin code is entered and before those
+ * are known to the ofono core. That's the whole purpose of this thing.
+ *
+ * If you need to follow imsi known to the ofono core, you can use
+ * sailfish_sim_settings for that (or fight with ofono imsi watchers
+ * directly).
+ */
+struct ofono_modem;
+struct sailfish_sim_info_priv;
+struct sailfish_sim_info {
+ GObject object;
+ struct sailfish_sim_info_priv *priv;
+ const char *path;
+ const char *iccid;
+ const char *imsi;
+ const char *spn;
+};
+
+typedef void (*sailfish_sim_info_cb_t)(struct sailfish_sim_info *si,
+ void *user_data);
+
+/* SIM info object associated with the particular slot */
+struct sailfish_sim_info *sailfish_sim_info_new(const char *path);
+struct sailfish_sim_info *sailfish_sim_info_ref(struct sailfish_sim_info *si);
+void sailfish_sim_info_unref(struct sailfish_sim_info *si);
+void sailfish_sim_info_invalidate(struct sailfish_sim_info *si);
+gulong sailfish_sim_info_add_iccid_changed_handler(struct sailfish_sim_info *si,
+ sailfish_sim_info_cb_t cb, void *user_data);
+gulong sailfish_sim_info_add_imsi_changed_handler(struct sailfish_sim_info *si,
+ sailfish_sim_info_cb_t cb, void *user_data);
+gulong sailfish_sim_info_add_spn_changed_handler(struct sailfish_sim_info *si,
+ sailfish_sim_info_cb_t cb, void *user_data);
+void sailfish_sim_info_remove_handler(struct sailfish_sim_info *si, gulong id);
+void sailfish_sim_info_remove_handlers(struct sailfish_sim_info *si,
+ gulong *ids, int count);
+
+#define sailfish_sim_info_remove_all_handlers(si,ids) \
+ sailfish_sim_info_remove_handlers(si, ids, G_N_ELEMENTS(ids))
+
+/* And the D-Bus interface for it */
+struct sailfish_sim_info_dbus;
+struct sailfish_sim_info_dbus *sailfish_sim_info_dbus_new
+ (struct sailfish_sim_info *si);
+struct sailfish_sim_info_dbus *sailfish_sim_info_dbus_new_path
+ (const char *path);
+void sailfish_sim_info_dbus_free(struct sailfish_sim_info_dbus *dbus);
+
+#endif /* SAILFISH_SIM_INFO_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/plugins/sailfish_manager/sailfish_sim_info_dbus.c
^
|
@@ -0,0 +1,296 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 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.
+ */
+
+#include "sailfish_sim_info.h"
+#include "sailfish_watch.h"
+
+#include <ofono/dbus.h>
+
+#include <gdbus.h>
+
+#include "ofono.h"
+
+enum watch_event_id {
+ WATCH_EVENT_MODEM,
+ WATCH_EVENT_COUNT
+};
+
+enum sim_info_event_id {
+ SIM_INFO_EVENT_ICCID,
+ SIM_INFO_EVENT_IMSI,
+ SIM_INFO_EVENT_SPN,
+ SIM_INFO_EVENT_COUNT
+};
+
+struct sailfish_sim_info_dbus {
+ struct sailfish_sim_info *info;
+ struct sailfish_watch *watch;
+ DBusConnection *conn;
+ gulong watch_event_id[WATCH_EVENT_COUNT];
+ gulong info_event_id[SIM_INFO_EVENT_COUNT];
+};
+
+#define SIM_INFO_DBUS_INTERFACE "org.nemomobile.ofono.SimInfo"
+#define SIM_INFO_DBUS_INTERFACE_VERSION (1)
+
+#define SIM_INFO_DBUS_ICCID_CHANGED_SIGNAL "CardIdentifierChanged"
+#define SIM_INFO_DBUS_IMSI_CHANGED_SIGNAL "SubscriberIdentityChanged"
+#define SIM_INFO_DBUS_SPN_CHANGED_SIGNAL "ServiceProviderNameChanged"
+
+static void sailfish_sim_info_dbus_append_version(DBusMessageIter *it)
+{
+ const dbus_int32_t version = SIM_INFO_DBUS_INTERFACE_VERSION;
+
+ dbus_message_iter_append_basic(it, DBUS_TYPE_INT32, &version);
+}
+
+static void sailfish_sim_info_dbus_append_string(DBusMessageIter *it,
+ const char *str)
+{
+ if (!str) str = "";
+ dbus_message_iter_append_basic(it, DBUS_TYPE_STRING, &str);
+}
+
+static DBusMessage *sailfish_sim_info_dbus_reply_with_string(DBusMessage *msg,
+ const char *str)
+{
+ DBusMessage *reply = dbus_message_new_method_return(msg);
+ DBusMessageIter iter;
+
+ dbus_message_iter_init_append(reply, &iter);
+ sailfish_sim_info_dbus_append_string(&iter, str);
+ return reply;
+}
+
+static DBusMessage *sailfish_sim_info_dbus_get_all(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct sailfish_sim_info_dbus *dbus = data;
+ struct sailfish_sim_info *info = dbus->info;
+ DBusMessage *reply = dbus_message_new_method_return(msg);
+ DBusMessageIter it;
+
+ dbus_message_iter_init_append(reply, &it);
+ sailfish_sim_info_dbus_append_version(&it);
+ sailfish_sim_info_dbus_append_string(&it, info->iccid);
+ sailfish_sim_info_dbus_append_string(&it, info->imsi);
+ sailfish_sim_info_dbus_append_string(&it, info->spn);
+ return reply;
+}
+
+static DBusMessage *sailfish_sim_info_dbus_get_version(DBusConnection *dc,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply = dbus_message_new_method_return(msg);
+ DBusMessageIter it;
+
+ dbus_message_iter_init_append(reply, &it);
+ sailfish_sim_info_dbus_append_version(&it);
+ return reply;
+}
+
+static DBusMessage *sailfish_sim_info_dbus_get_iccid(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct sailfish_sim_info_dbus *dbus = data;
+
+ return sailfish_sim_info_dbus_reply_with_string(msg, dbus->info->iccid);
+}
+
+static DBusMessage *sailfish_sim_info_dbus_get_imsi(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct sailfish_sim_info_dbus *dbus = data;
+
+ return sailfish_sim_info_dbus_reply_with_string(msg, dbus->info->imsi);
+}
+
+static DBusMessage *sailfish_sim_info_dbus_get_spn(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct sailfish_sim_info_dbus *dbus = data;
+
+ return sailfish_sim_info_dbus_reply_with_string(msg, dbus->info->spn);
+}
+
+#define SIM_INFO_DBUS_VERSION_ARG {"version", "i"}
+#define SIM_INFO_DBUS_ICCID_ARG {"iccid", "s"}
+#define SIM_INFO_DBUS_IMSI_ARG {"imsi", "s"}
+#define SIM_INFO_DBUS_SPN_ARG {"spn" , "s"}
+
+#define SIM_INFO_DBUS_GET_ALL_ARGS \
+ SIM_INFO_DBUS_VERSION_ARG, \
+ SIM_INFO_DBUS_ICCID_ARG, \
+ SIM_INFO_DBUS_IMSI_ARG, \
+ SIM_INFO_DBUS_SPN_ARG
+
+static const GDBusMethodTable sailfish_sim_info_dbus_methods[] = {
+ { GDBUS_METHOD("GetAll",
+ NULL, GDBUS_ARGS(SIM_INFO_DBUS_GET_ALL_ARGS),
+ sailfish_sim_info_dbus_get_all) },
+ { GDBUS_METHOD("GetInterfaceVersion",
+ NULL, GDBUS_ARGS(SIM_INFO_DBUS_VERSION_ARG),
+ sailfish_sim_info_dbus_get_version) },
+ { GDBUS_METHOD("GetCardIdentifier",
+ NULL, GDBUS_ARGS(SIM_INFO_DBUS_ICCID_ARG),
+ sailfish_sim_info_dbus_get_iccid) },
+ { GDBUS_METHOD("GetSubscriberIdentity",
+ NULL, GDBUS_ARGS(SIM_INFO_DBUS_IMSI_ARG),
+ sailfish_sim_info_dbus_get_imsi) },
+ { GDBUS_METHOD("GetServiceProviderName",
+ NULL, GDBUS_ARGS(SIM_INFO_DBUS_SPN_ARG),
+ sailfish_sim_info_dbus_get_spn) },
+ { }
+};
+
+static const GDBusSignalTable sailfish_sim_info_dbus_signals[] = {
+ { GDBUS_SIGNAL(SIM_INFO_DBUS_ICCID_CHANGED_SIGNAL,
+ GDBUS_ARGS(SIM_INFO_DBUS_ICCID_ARG)) },
+ { GDBUS_SIGNAL(SIM_INFO_DBUS_IMSI_CHANGED_SIGNAL,
+ GDBUS_ARGS(SIM_INFO_DBUS_IMSI_ARG)) },
+ { GDBUS_SIGNAL(SIM_INFO_DBUS_SPN_CHANGED_SIGNAL,
+ GDBUS_ARGS(SIM_INFO_DBUS_SPN_ARG)) },
+ { }
+};
+
+static void sailfish_sim_info_dbus_modem_cb(struct sailfish_watch *watch,
+ void *data)
+{
+ if (watch->modem) {
+ ofono_modem_add_interface(watch->modem,
+ SIM_INFO_DBUS_INTERFACE);
+ }
+}
+
+static void sailfish_sim_info_dbus_emit(struct sailfish_sim_info_dbus *dbus,
+ const char *signal, const char *value)
+{
+ const char *arg = value;
+
+ if (!arg) arg = "";
+ g_dbus_emit_signal(dbus->conn, dbus->info->path,
+ SIM_INFO_DBUS_INTERFACE, signal,
+ DBUS_TYPE_STRING, &arg, DBUS_TYPE_INVALID);
+}
+
+static void sailfish_sim_info_dbus_iccid_cb(struct sailfish_sim_info *info,
+ void *data)
+{
+ sailfish_sim_info_dbus_emit((struct sailfish_sim_info_dbus *)data,
+ SIM_INFO_DBUS_ICCID_CHANGED_SIGNAL, info->iccid);
+}
+
+static void sailfish_sim_info_dbus_imsi_cb(struct sailfish_sim_info *info,
+ void *data)
+{
+ sailfish_sim_info_dbus_emit((struct sailfish_sim_info_dbus *)data,
+ SIM_INFO_DBUS_IMSI_CHANGED_SIGNAL, info->imsi);
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/plugins/sailfish_manager/sailfish_watch.c
^
|
@@ -0,0 +1,680 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 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.
+ */
+
+#include "sailfish_watch.h"
+
+#include <gutil_misc.h>
+#include <gutil_log.h>
+
+#include "ofono.h"
+
+typedef GObjectClass SailfishWatchClass;
+typedef struct sailfish_watch SailfishWatch;
+
+struct sailfish_watch_priv {
+ char *path;
+ char *iccid;
+ char *imsi;
+ char *spn;
+ int signals_suspended;
+ int queued_signals;
+ guint modem_watch_id;
+ guint online_watch_id;
+ guint sim_watch_id;
+ guint sim_state_watch_id;
+ guint iccid_watch_id;
+ guint imsi_watch_id;
+ guint spn_watch_id;
+ guint netreg_watch_id;
+};
+
+enum sailfish_watch_signal {
+ SIGNAL_MODEM_CHANGED,
+ SIGNAL_ONLINE_CHANGED,
+ SIGNAL_SIM_CHANGED,
+ SIGNAL_SIM_STATE_CHANGED,
+ SIGNAL_ICCID_CHANGED,
+ SIGNAL_IMSI_CHANGED,
+ SIGNAL_SPN_CHANGED,
+ SIGNAL_NETREG_CHANGED,
+ SIGNAL_COUNT
+};
+
+#define SIGNAL_MODEM_CHANGED_NAME "sailfish-watch-modem-changed"
+#define SIGNAL_ONLINE_CHANGED_NAME "sailfish-watch-online-changed"
+#define SIGNAL_SIM_CHANGED_NAME "sailfish-watch-sim-changed"
+#define SIGNAL_SIM_STATE_CHANGED_NAME "sailfish-watch-sim-state-changed"
+#define SIGNAL_ICCID_CHANGED_NAME "sailfish-watch-iccid-changed"
+#define SIGNAL_IMSI_CHANGED_NAME "sailfish-watch-imsi-changed"
+#define SIGNAL_SPN_CHANGED_NAME "sailfish-watch-spn-changed"
+#define SIGNAL_NETREG_CHANGED_NAME "sailfish-watch-netreg-changed"
+
+static guint sailfish_watch_signals[SIGNAL_COUNT] = { 0 };
+static GHashTable* sailfish_watch_table = NULL;
+
+G_DEFINE_TYPE(SailfishWatch, sailfish_watch, G_TYPE_OBJECT)
+#define SAILFISH_WATCH_TYPE (sailfish_watch_get_type())
+#define SAILFISH_WATCH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
+ SAILFISH_WATCH_TYPE, SailfishWatch))
+
+#define NEW_SIGNAL(klass,name) \
+ sailfish_watch_signals[SIGNAL_##name##_CHANGED] = \
+ g_signal_new(SIGNAL_##name##_CHANGED_NAME, \
+ G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
+ 0, NULL, NULL, NULL, G_TYPE_NONE, 0)
+
+/* Skip the leading slash from the modem path: */
+#define DBG_(obj,fmt,args...) DBG("%s " fmt, (obj)->path+1, ##args)
+
+static inline int sailfish_watch_signal_bit(enum sailfish_watch_signal id)
+{
+ return (1 << id);
+}
+
+static inline void sailfish_watch_signal_emit(struct sailfish_watch *self,
+ enum sailfish_watch_signal id)
+{
+ self->priv->queued_signals &= ~sailfish_watch_signal_bit(id);
+ g_signal_emit(self, sailfish_watch_signals[id], 0);
+}
+
+static inline void sailfish_watch_signal_queue(struct sailfish_watch *self,
+ enum sailfish_watch_signal id)
+{
+ self->priv->queued_signals |= sailfish_watch_signal_bit(id);
+}
+
+static void sailfish_watch_emit_queued_signals(struct sailfish_watch *self)
+{
+ struct sailfish_watch_priv *priv = self->priv;
+
+ if (priv->signals_suspended < 1) {
+ int i;
+
+ for (i = 0; priv->queued_signals && i < SIGNAL_COUNT; i++) {
+ if (priv->queued_signals &
+ sailfish_watch_signal_bit(i)) {
+ sailfish_watch_signal_emit(self, i);
+ }
+ }
+ }
+}
+
+static inline void sailfish_watch_suspend_signals(struct sailfish_watch *self)
+{
+ self->priv->signals_suspended++;
+}
+
+static inline void sailfish_watch_resume_signals(struct sailfish_watch *self)
+{
+ struct sailfish_watch_priv *priv = self->priv;
+
+ GASSERT(priv->signals_suspended > 0);
+ priv->signals_suspended--;
+ sailfish_watch_emit_queued_signals(self);
+}
+
+static void sailfish_watch_sim_state_notify(enum ofono_sim_state new_state,
+ void *user_data)
+{
+ struct sailfish_watch *self = SAILFISH_WATCH(user_data);
+
+ sailfish_watch_signal_queue(self, SIGNAL_SIM_STATE_CHANGED);
+ sailfish_watch_emit_queued_signals(self);
+}
+
+static void sailfish_watch_sim_state_destroy(void *user_data)
+{
+ struct sailfish_watch *self = SAILFISH_WATCH(user_data);
+ struct sailfish_watch_priv *priv = self->priv;
+
+ GASSERT(priv->sim_state_watch_id);
+ priv->sim_state_watch_id = 0;
+}
+
+static void sailfish_watch_iccid_update(struct sailfish_watch *self,
+ const char *iccid)
+{
+ struct sailfish_watch_priv *priv = self->priv;
+
+ if (g_strcmp0(priv->iccid, iccid)) {
+ g_free(priv->iccid);
+ self->iccid = priv->iccid = g_strdup(iccid);
+ sailfish_watch_signal_queue(self, SIGNAL_ICCID_CHANGED);
+ }
+}
+
+static void sailfish_watch_iccid_notify(const char *iccid, void *user_data)
+{
+ struct sailfish_watch *self = SAILFISH_WATCH(user_data);
+
+ sailfish_watch_iccid_update(self, iccid);
+ sailfish_watch_emit_queued_signals(self);
+}
+
+static void sailfish_watch_iccid_destroy(void *user_data)
+{
+ struct sailfish_watch *self = SAILFISH_WATCH(user_data);
+ struct sailfish_watch_priv *priv = self->priv;
+
+ GASSERT(priv->iccid_watch_id);
+ priv->iccid_watch_id = 0;
+}
+
+static void sailfish_watch_spn_update(struct sailfish_watch *self,
+ const char *spn)
+{
+ struct sailfish_watch_priv *priv = self->priv;
+
+ if (g_strcmp0(priv->spn, spn)) {
+ g_free(priv->spn);
+ self->spn = priv->spn = g_strdup(spn);
+ sailfish_watch_signal_queue(self, SIGNAL_SPN_CHANGED);
+ }
+}
+
+static void sailfish_watch_spn_notify(const char *spn, const char *dc,
+ void *user_data)
+{
+ struct sailfish_watch *self = SAILFISH_WATCH(user_data);
+
+ sailfish_watch_spn_update(self, spn);
+ sailfish_watch_emit_queued_signals(self);
+}
+
+static void sailfish_watch_spn_destroy(void *user_data)
+{
+ struct sailfish_watch *self = SAILFISH_WATCH(user_data);
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/plugins/sailfish_provision.c
^
|
@@ -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);
+
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/plugins/sailfish_pushforwarder.c
^
|
@@ -0,0 +1,476 @@
+/*
+ * 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
+
+#include <gutil_inotify.h>
+#include <sys/inotify.h>
+#include <wspcodec.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono.h>
+#include <plugin.h>
+
+/*
+ * Push forwarder plugin is looking for configuration files in
+ * /etc/ofono/push_forwarder.d directory. Confiration files are
+ * glib key files that look like this:
+ *
+ * [Jolla MMS Handler]
+ * ContentType = application/vnd.wap.mms-message
+ * Interface = com.jolla.MmsEngine.
+ * Service = com.jolla.MmsEngine
+ * Method = HandlePush
+ * Path = /
+ *
+ * Only files with .conf suffix are loaded. In addition to the keys
+ * from the above example, SourcePort and DestinationPort port keys
+ * are supported. All other keys are ignored. One file may describe
+ * several push handlers. See pf_parse_config() function for details.
+ *
+ * When push fowarder receives a WAP push, it goes through the list
+ * of registered handlers and invokes all of them that match content
+ * type and/or port numbers. The rest is up to the D-Bus service
+ * handling the call.
+ */
+
+#define PF_CONFIG_DIR CONFIGDIR "/push_forwarder.d"
+
+struct pf_modem {
+ struct ofono_modem *modem;
+ struct ofono_sms *sms;
+ struct ofono_sim *sim;
+ unsigned int sim_watch_id;
+ unsigned int sms_watch_id;
+ unsigned int push_watch_id;
+};
+
+struct push_datagram_handler {
+ char *name;
+ char *content_type;
+ char *interface;
+ char *service;
+ char *method;
+ char *path;
+ int dst_port;
+ int src_port;
+};
+
+static GSList *handlers;
+static GSList *modems;
+static unsigned int modem_watch_id;
+static GUtilInotifyWatchCallback *inotify_cb;
+
+static void pf_notify_handler(struct push_datagram_handler *h,
+ const char *imsi, const char *from, const struct tm *remote,
+ const struct tm *local, int dst, int src,
+ const char *ct, const void *data, unsigned int len)
+{
+ struct tm remote_tm = *remote;
+ struct tm local_tm = *local;
+ dbus_uint32_t remote_time_arg = mktime(&remote_tm);
+ dbus_uint32_t local_time_arg = mktime(&local_tm);
+ dbus_int32_t dst_arg = dst;
+ dbus_int32_t src_arg = src;
+ DBusMessageIter iter, array;
+ DBusMessage *msg = dbus_message_new_method_call(h->service,
+ h->path, h->interface, h->method);
+
+ dbus_message_append_args(msg,
+ DBUS_TYPE_STRING, &imsi,
+ DBUS_TYPE_STRING, &from,
+ DBUS_TYPE_UINT32, &remote_time_arg,
+ DBUS_TYPE_UINT32, &local_time_arg,
+ DBUS_TYPE_INT32, &dst_arg,
+ DBUS_TYPE_INT32, &src_arg,
+ DBUS_TYPE_STRING, &ct,
+ DBUS_TYPE_INVALID);
+ dbus_message_iter_init_append(msg, &iter);
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_BYTE_AS_STRING, &array);
+ dbus_message_iter_append_fixed_array(&array,
+ DBUS_TYPE_BYTE, &data, len);
+ dbus_message_iter_close_container(&iter, &array);
+ dbus_message_set_no_reply(msg, TRUE);
+ dbus_connection_send(ofono_dbus_get_connection(), msg, NULL);
+ dbus_message_unref(msg);
+}
+
+static gboolean pf_match_port(int port, int expected_port)
+{
+ if (expected_port < 0)
+ return TRUE;
+
+ if (expected_port == port)
+ return TRUE;
+
+ return FALSE;
+}
+
+static gboolean pf_match_handler(struct push_datagram_handler *h,
+ const char *ct, int dst, int src)
+{
+ if (pf_match_port(dst, h->dst_port) == FALSE)
+ return FALSE;
+
+ if (pf_match_port(src, h->src_port) == FALSE)
+ return FALSE;
+
+ if (h->content_type == NULL)
+ return TRUE;
+
+ if (strcmp(h->content_type, ct) == 0)
+ return TRUE;
+
+ return FALSE;
+}
+
+static void pf_handle_datagram(const char *from,
+ const struct tm *remote, const struct tm *local, int dst,
+ int src, const unsigned char *buffer, unsigned int len,
+ void *userdata)
+{
+ struct pf_modem *pm = userdata;
+ guint remain;
+ const guint8 *data;
+ unsigned int hdrlen;
+ unsigned int off;
+ const void *ct;
+ const char *imsi;
+ GSList *link;
+
+ DBG("received push of size: %u", len);
+
+ if (pm->sim == NULL)
+ return;
+
+ imsi = ofono_sim_get_imsi(pm->sim);
+ if (len < 3)
+ return;
+
+ if (buffer[1] != 6)
+ return;
+
+ remain = len - 2;
+ data = buffer + 2;
+
+ if (wsp_decode_uintvar(data, remain, &hdrlen, &off) == FALSE)
+ return;
+
+ if ((off + hdrlen) > remain)
+ return;
+
+ data += off;
+ remain -= off;
+
+ DBG(" WAP header %u bytes", hdrlen);
+
+ if (wsp_decode_content_type(data, hdrlen, &ct, &off, NULL) == FALSE)
+ return;
+
+ data += hdrlen;
+ remain -= hdrlen;
+
+ DBG(" content type %s", (char *)ct);
+ DBG(" imsi %s", imsi);
+ DBG(" data size %u", remain);
+
+ link = handlers;
+
+ while (link) {
+ struct push_datagram_handler *h = link->data;
+
+ if (pf_match_handler(h, ct, dst, src) != FALSE) {
+ DBG("notifying %s", h->name);
+ pf_notify_handler(h, imsi, from, remote, local, dst,
+ src, ct, data, remain);
+ }
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/src/gprs.c
^
|
@@ -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 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 @@
} 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 @@
}
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 @@
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))) {
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/src/mtu-watch.c
^
|
@@ -0,0 +1,219 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2016-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.
+ */
+
+#include "mtu-watch.h"
+
+#include <ofono/log.h>
+
+#include <glib.h>
+
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <net/if.h>
+
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>
+
+struct mtu_watch {
+ int max_mtu;
+ char *ifname;
+ void *buf;
+ int bufsize;
+ GIOChannel *channel;
+ guint io_watch;
+ int fd;
+};
+
+static void mtu_watch_limit_mtu(struct mtu_watch *self)
+{
+ int fd = socket(PF_INET, SOCK_DGRAM, 0);
+ if (fd >= 0) {
+ struct ifreq ifr;
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, self->ifname, IFNAMSIZ);
+ if (ioctl(fd, SIOCGIFMTU, &ifr) < 0 ||
+ ifr.ifr_mtu > self->max_mtu) {
+ DBG("%s mtu %d => %d", self->ifname, ifr.ifr_mtu,
+ self->max_mtu);
+ ifr.ifr_mtu = self->max_mtu;
+ if (ioctl(fd, SIOCSIFMTU, &ifr) < 0) {
+ ofono_error("Failed to set MTU");
+ }
+ }
+ close(fd);
+ }
+}
+
+static void mtu_watch_handle_rtattr(struct mtu_watch *self,
+ const struct rtattr *rta, int len)
+{
+ int mtu = 0;
+ const char *ifname = NULL;
+ while (len > 0 && RTA_OK(rta, len) && (!mtu || !ifname)) {
+ switch (rta->rta_type) {
+ case IFLA_IFNAME:
+ ifname = RTA_DATA(rta);
+ break;
+ case IFLA_MTU:
+ mtu = *((int*)RTA_DATA(rta));
+ break;
+ }
+ rta = RTA_NEXT(rta, len);
+ }
+ if (mtu > self->max_mtu && !g_strcmp0(ifname, self->ifname)) {
+ DBG("%s %d", ifname, mtu);
+ mtu_watch_limit_mtu(self);
+ }
+}
+
+static void mtu_watch_handle_ifinfomsg(struct mtu_watch *self,
+ const struct ifinfomsg *ifi, int len)
+{
+ if (ifi->ifi_flags & IFF_UP) {
+ const struct rtattr *rta = IFLA_RTA(ifi);
+ mtu_watch_handle_rtattr(self, rta,
+ len - ((char*)rta - (char*)ifi));
+ }
+}
+
+static void mtu_watch_handle_nlmsg(struct mtu_watch *self,
+ const struct nlmsghdr *hdr, int len)
+{
+ while (len > 0 && NLMSG_OK(hdr, len)) {
+ if (hdr->nlmsg_type == RTM_NEWLINK) {
+ mtu_watch_handle_ifinfomsg(self, NLMSG_DATA(hdr),
+ IFLA_PAYLOAD(hdr));
+ }
+ hdr = NLMSG_NEXT(hdr, len);
+ }
+}
+
+static gboolean mtu_watch_event(GIOChannel *ch, GIOCondition cond,
+ gpointer data)
+{
+ struct mtu_watch *self = data;
+ struct sockaddr_nl addr;
+ socklen_t addrlen = sizeof(addr);
+ ssize_t result = recvfrom(self->fd, self->buf, self->bufsize, 0,
+ (struct sockaddr *)&addr, &addrlen);
+ if (result > 0) {
+ if (!addr.nl_pid) {
+ mtu_watch_handle_nlmsg(self, self->buf, result);
+ }
+ return G_SOURCE_CONTINUE;
+ } else if (result == 0 || errno == EINTR || errno == EAGAIN) {
+ return G_SOURCE_CONTINUE;
+ } else {
+ DBG("%s error %d", self->ifname, errno);
+ self->io_watch = 0;
+ return G_SOURCE_REMOVE;
+ }
+}
+
+static gboolean mtu_watch_open_socket(struct mtu_watch *self)
+{
+ self->fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+ if (self->fd >= 0) {
+ struct sockaddr_nl nl;
+ memset(&nl, 0, sizeof(nl));
+ nl.nl_pid = getpid();
+ nl.nl_family = AF_NETLINK;
+ nl.nl_groups = RTMGRP_IPV4_IFADDR | RTMGRP_IPV4_ROUTE |
+ RTMGRP_IPV6_IFADDR | RTMGRP_IPV6_ROUTE |
+ RTMGRP_LINK;
+
+ if (bind(self->fd, (struct sockaddr*)&nl, sizeof(nl)) >= 0) {
+ return TRUE;
+ }
+ close(self->fd);
+ self->fd = -1;
+ }
+ return FALSE;
+}
+
+static gboolean mtu_watch_start(struct mtu_watch *self)
+{
+ if (self->fd >= 0) {
+ return TRUE;
+ } else if (mtu_watch_open_socket(self)) {
+ self->channel = g_io_channel_unix_new(self->fd);
+ if (self->channel) {
+ g_io_channel_set_encoding(self->channel, NULL, NULL);
+ g_io_channel_set_buffered(self->channel, FALSE);
+ self->io_watch = g_io_add_watch(self->channel,
+ G_IO_IN | G_IO_NVAL | G_IO_HUP,
+ mtu_watch_event, self);
+ return TRUE;
+ }
+ close(self->fd);
+ self->fd = -1;
+ }
+ return FALSE;
+}
+
+static void mtu_watch_stop(struct mtu_watch *self)
+{
+ if (self->io_watch) {
+ g_source_remove(self->io_watch);
+ self->io_watch = 0;
+ }
+ if (self->channel) {
+ g_io_channel_shutdown(self->channel, TRUE, NULL);
+ g_io_channel_unref(self->channel);
+ self->channel = NULL;
+ }
+ if (self->fd >= 0) {
+ close(self->fd);
+ self->fd = -1;
+ }
+}
+
+struct mtu_watch *mtu_watch_new(int max_mtu)
+{
+ struct mtu_watch *self = g_new0(struct mtu_watch, 1);
+ self->fd = -1;
+ self->max_mtu = max_mtu;
+ self->bufsize = 4096;
+ self->buf = g_malloc(self->bufsize);
+ return self;
+}
+
+void mtu_watch_free(struct mtu_watch *self)
+{
+ if (self) {
+ mtu_watch_stop(self);
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/src/mtu-watch.h
^
|
@@ -0,0 +1,25 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2016-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.
+ */
+
+#ifndef MTU_WATCH_H
+#define MTU_WATCH_H
+
+struct mtu_watch;
+
+struct mtu_watch *mtu_watch_new(int max_mtu);
+void mtu_watch_free(struct mtu_watch *mw);
+void mtu_watch_set_ifname(struct mtu_watch *mw, const char *ifname);
+
+#endif /* MTU_WATCH_H */
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/src/network.c
^
|
@@ -1828,6 +1828,17 @@
return netreg->current_operator->mnc;
}
+const char *ofono_netreg_get_name(struct ofono_netreg *netreg)
+{
+ if (netreg == NULL)
+ return NULL;
+
+ if (netreg->current_operator == NULL)
+ return NULL;
+
+ return netreg->current_operator->name;
+}
+
struct sim_spdi *ofono_netreg_get_spdi(struct ofono_netreg *netreg)
{
if (netreg == NULL)
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/src/radio-settings.c
^
|
@@ -889,9 +889,13 @@
"GsmBand", rs->band_gsm);
}
+ if (error) {
+ g_error_free(error);
+ error = NULL;
+ }
+
rs->pending_band_gsm = rs->band_gsm;
- error = NULL;
rs->band_umts = g_key_file_get_integer(rs->settings, SETTINGS_GROUP,
"UmtsBand", &error);
@@ -901,9 +905,13 @@
"UmtsBand", rs->band_umts);
}
+ if (error) {
+ g_error_free(error);
+ error = NULL;
+ }
+
rs->pending_band_umts = rs->band_umts;
- error = NULL;
rs->mode = g_key_file_get_integer(rs->settings, SETTINGS_GROUP,
"TechnologyPreference", &error);
@@ -913,6 +921,11 @@
"TechnologyPreference", rs->mode);
}
+ if (error) {
+ g_error_free(error);
+ error = NULL;
+ }
+
DBG("TechnologyPreference: %d", rs->mode);
DBG("GsmBand: %d", rs->band_gsm);
DBG("UmtsBand: %d", rs->band_umts);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/src/storage.h
^
|
@@ -28,6 +28,11 @@
#include <fcntl.h>
#include <sys/types.h>
+/* STORAGEDIR may need to be redefined in unit tests */
+#ifndef STORAGEDIR
+# define STORAGEDIR DEFAULT_STORAGEDIR
+#endif
+
int create_dirs(const char *filename, const mode_t mode);
ssize_t read_file(unsigned char *buffer, size_t len,
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/src/ussd.c
^
|
@@ -515,6 +515,20 @@
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.");
DBG("USSD is: status: %d, %s", status, str);
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/unit/coverage
^
|
@@ -0,0 +1,58 @@
+#!/bin/bash
+#
+# Script to generate unit test coverage report, requires lcov:
+#
+# http://ltp.sourceforge.net/coverage/lcov.php
+#
+
+# Tests with coverage enabled:
+TESTS="\
+ test-common \
+ test-util \
+ test-idmap \
+ test-simutil \
+ test-stkutil \
+ test-sms \
+ test-cdmasms \
+ test-sms-root \
+ test-caif \
+ test-provision \
+ test-sailfish_manager \
+ test-sailfish_sim_info"
+
+pushd `dirname $0` > /dev/null
+TEST_DIR="$PWD"
+pushd .. > /dev/null
+BASE_DIR="$PWD"
+popd > /dev/null
+popd > /dev/null
+
+FULL_COV="$TEST_DIR/full.gcov"
+PLUGINS_COV="$TEST_DIR/plugins.gcov"
+SRC_COV="$TEST_DIR/src.gcov"
+OUT="$TEST_DIR/html"
+
+# Clean everything up
+find "$BASE_DIR" -name "*.gcda" -exec rm {} \;
+rm -f "$FULL_COV" "$PLUGINS_COV" "$SRC_COV"
+rm -fr "$OUT"
+
+# Run the tests
+for t in $TESTS ; do
+ pushd "$TEST_DIR" > /dev/null
+ "$TEST_DIR/$t"
+ RC=$?
+ popd > /dev/null
+ [ $RC = 0 ] || exit 1
+done
+
+# LCOV 1.10 has branch coverage disabled per default
+LCOV_OPT="--rc lcov_branch_coverage=1"
+GENHTML_OPT="--branch-coverage"
+
+lcov $LCOV_OPT -c -d "$BASE_DIR" -o "$FULL_COV" || exit 1
+lcov $LCOV_OPT -e "$FULL_COV" "$BASE_DIR/plugins/*" -o "$PLUGINS_COV" || exit 1
+lcov $LCOV_OPT -e "$FULL_COV" "$BASE_DIR/src/*" -o "$SRC_COV" || exit 1
+genhtml $GENHTML_OPT -t ofono "$PLUGINS_COV" "$SRC_COV" --output-directory "$OUT" || exit 1
+
+echo Coverage report: $OUT/index.html
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/unit/fake_sailfish_watch.c
^
|
@@ -0,0 +1,326 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 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.
+ */
+
+#include "fake_sailfish_watch.h"
+
+#include <gutil_misc.h>
+#include <gutil_log.h>
+
+#include "ofono.h"
+
+typedef GObjectClass SailfishWatchClass;
+typedef struct sailfish_watch SailfishWatch;
+
+struct sailfish_watch_priv {
+ char *path;
+ char *iccid;
+ char *imsi;
+ char *spn;
+ int queued_signals;
+};
+
+#define SIGNAL_MODEM_CHANGED_NAME "sailfish-watch-modem-changed"
+#define SIGNAL_ONLINE_CHANGED_NAME "sailfish-watch-online-changed"
+#define SIGNAL_SIM_CHANGED_NAME "sailfish-watch-sim-changed"
+#define SIGNAL_SIM_STATE_CHANGED_NAME "sailfish-watch-sim-state-changed"
+#define SIGNAL_ICCID_CHANGED_NAME "sailfish-watch-iccid-changed"
+#define SIGNAL_IMSI_CHANGED_NAME "sailfish-watch-imsi-changed"
+#define SIGNAL_SPN_CHANGED_NAME "sailfish-watch-spn-changed"
+#define SIGNAL_NETREG_CHANGED_NAME "sailfish-watch-netreg-changed"
+
+static guint sailfish_watch_signals[WATCH_SIGNAL_COUNT] = { 0 };
+static GHashTable* sailfish_watch_table = NULL;
+
+G_DEFINE_TYPE(SailfishWatch, sailfish_watch, G_TYPE_OBJECT)
+#define SAILFISH_WATCH_TYPE (sailfish_watch_get_type())
+#define SAILFISH_WATCH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
+ SAILFISH_WATCH_TYPE, SailfishWatch))
+
+#define NEW_SIGNAL(klass,name) \
+ sailfish_watch_signals[WATCH_SIGNAL_##name##_CHANGED] = \
+ g_signal_new(SIGNAL_##name##_CHANGED_NAME, \
+ G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
+ 0, NULL, NULL, NULL, G_TYPE_NONE, 0)
+
+#define DBG_(obj,fmt,args...) DBG("%s " fmt, (obj)->path+1, ##args)
+
+static inline int sailfish_watch_signal_bit(enum sailfish_watch_signal id)
+{
+ return (1 << id);
+}
+
+static inline void sailfish_watch_signal_emit(struct sailfish_watch *self,
+ enum sailfish_watch_signal id)
+{
+ self->priv->queued_signals &= ~sailfish_watch_signal_bit(id);
+ g_signal_emit(self, sailfish_watch_signals[id], 0);
+}
+
+void fake_sailfish_watch_signal_queue(struct sailfish_watch *self,
+ enum sailfish_watch_signal id)
+{
+ self->priv->queued_signals |= sailfish_watch_signal_bit(id);
+}
+
+void fake_sailfish_watch_emit_queued_signals(struct sailfish_watch *self)
+{
+ struct sailfish_watch_priv *priv = self->priv;
+ int i;
+
+ for (i = 0; priv->queued_signals && i < WATCH_SIGNAL_COUNT; i++) {
+ if (priv->queued_signals & sailfish_watch_signal_bit(i)) {
+ sailfish_watch_signal_emit(self, i);
+ }
+ }
+}
+
+void fake_sailfish_watch_set_ofono_iccid(struct sailfish_watch *self,
+ const char *iccid)
+{
+ struct sailfish_watch_priv *priv = self->priv;
+
+ if (g_strcmp0(priv->iccid, iccid)) {
+ g_free(priv->iccid);
+ self->iccid = priv->iccid = g_strdup(iccid);
+ fake_sailfish_watch_signal_queue(self,
+ WATCH_SIGNAL_ICCID_CHANGED);
+ }
+}
+
+void fake_sailfish_watch_set_ofono_imsi(struct sailfish_watch *self,
+ const char *imsi)
+{
+ struct sailfish_watch_priv *priv = self->priv;
+
+ if (g_strcmp0(priv->imsi, imsi)) {
+ g_free(priv->imsi);
+ self->imsi = priv->imsi = g_strdup(imsi);
+ fake_sailfish_watch_signal_queue(self,
+ WATCH_SIGNAL_IMSI_CHANGED);
+ }
+}
+
+void fake_sailfish_watch_set_ofono_spn(struct sailfish_watch *self,
+ const char *spn)
+{
+ struct sailfish_watch_priv *priv = self->priv;
+
+ if (g_strcmp0(priv->spn, spn)) {
+ g_free(priv->spn);
+ self->spn = priv->spn = g_strdup(spn);
+ fake_sailfish_watch_signal_queue(self,
+ WATCH_SIGNAL_SPN_CHANGED);
+ }
+}
+
+void fake_sailfish_watch_set_ofono_sim(struct sailfish_watch *self,
+ struct ofono_sim *sim)
+{
+ if (self->sim != sim) {
+ self->sim = sim;
+ fake_sailfish_watch_signal_queue(self,
+ WATCH_SIGNAL_SIM_CHANGED);
+ if (!sim) {
+ fake_sailfish_watch_set_ofono_iccid(self, NULL);
+ fake_sailfish_watch_set_ofono_imsi(self, NULL);
+ fake_sailfish_watch_set_ofono_spn(self, NULL);
+ }
+ }
+}
+
+void fake_sailfish_watch_set_ofono_netreg(struct sailfish_watch *self,
+ struct ofono_netreg *netreg)
+{
+ if (self->netreg != netreg) {
+ self->netreg = netreg;
+ fake_sailfish_watch_signal_queue(self,
+ WATCH_SIGNAL_NETREG_CHANGED);
+ }
+}
+
+static void sailfish_watch_initialize(struct sailfish_watch *self,
+ const char *path)
+{
+ struct sailfish_watch_priv *priv = self->priv;
+
+ self->path = priv->path = g_strdup(path);
+}
+
+static void sailfish_watch_destroyed(gpointer key, GObject* obj)
+{
+ GASSERT(sailfish_watch_table);
+ DBG("%s", (char*)key);
+ if (sailfish_watch_table) {
+ GASSERT(g_hash_table_lookup(sailfish_watch_table, key) == obj);
+ g_hash_table_remove(sailfish_watch_table, key);
+ if (g_hash_table_size(sailfish_watch_table) == 0) {
+ g_hash_table_unref(sailfish_watch_table);
+ sailfish_watch_table = NULL;
+ }
+ }
+}
+
+struct sailfish_watch *sailfish_watch_new(const char *path)
+{
+ struct sailfish_watch *watch = NULL;
+
+ if (path) {
+ if (sailfish_watch_table) {
+ watch = sailfish_watch_ref(g_hash_table_lookup(
+ sailfish_watch_table, path));
+ }
+ if (!watch) {
+ char* key = g_strdup(path);
+
+ watch = g_object_new(SAILFISH_WATCH_TYPE, NULL);
+ sailfish_watch_initialize(watch, path);
+ if (!sailfish_watch_table) {
+ /* Create the table on demand */
+ sailfish_watch_table =
+ g_hash_table_new_full(g_str_hash,
+ g_str_equal, g_free, NULL);
+ }
+ g_hash_table_replace(sailfish_watch_table, key, watch);
+ g_object_weak_ref(G_OBJECT(watch),
+ sailfish_watch_destroyed, key);
+ DBG_(watch, "created");
+ }
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/unit/fake_sailfish_watch.h
^
|
@@ -0,0 +1,55 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 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.
+ */
+
+#ifndef SAILFISH_FAKE_WATCH_H
+#define SAILFISH_FAKE_WATCH_H
+
+#include "sailfish_watch.h"
+
+enum sailfish_watch_signal {
+ WATCH_SIGNAL_MODEM_CHANGED,
+ WATCH_SIGNAL_ONLINE_CHANGED,
+ WATCH_SIGNAL_SIM_CHANGED,
+ WATCH_SIGNAL_SIM_STATE_CHANGED,
+ WATCH_SIGNAL_ICCID_CHANGED,
+ WATCH_SIGNAL_IMSI_CHANGED,
+ WATCH_SIGNAL_SPN_CHANGED,
+ WATCH_SIGNAL_NETREG_CHANGED,
+ WATCH_SIGNAL_COUNT
+};
+
+void fake_sailfish_watch_signal_queue(struct sailfish_watch *watch,
+ enum sailfish_watch_signal id);
+void fake_sailfish_watch_emit_queued_signals(struct sailfish_watch *watch);
+void fake_sailfish_watch_set_ofono_sim(struct sailfish_watch *watch,
+ struct ofono_sim *sim);
+void fake_sailfish_watch_set_ofono_iccid(struct sailfish_watch *watch,
+ const char *iccid);
+void fake_sailfish_watch_set_ofono_imsi(struct sailfish_watch *watch,
+ const char *imsi);
+void fake_sailfish_watch_set_ofono_spn(struct sailfish_watch *watch,
+ const char *spn);
+void fake_sailfish_watch_set_ofono_netreg(struct sailfish_watch *watch,
+ struct ofono_netreg *netreg);
+
+#endif /* FAKE_SAILFISH_WATCH_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/unit/test-provision.c
^
|
@@ -1,8 +1,7 @@
/*
- *
* oFono - Open Source Telephony
*
- * Copyright (C) 2014 Jolla. All rights reserved.
+ * Copyright (C) 2014-2017 Jolla. All rights reserved.
*
* 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
@@ -12,11 +11,6 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
*/
#ifdef HAVE_CONFIG_H
@@ -24,76 +18,1106 @@
#endif
#include <glib.h>
-struct ofono_modem;
-#include <gprs-provision.h>
+#include <gio/gio.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include "ofono.h"
#include "plugins/mbpi.h"
#include "plugins/provision.h"
+#include <string.h>
-void get_and_print_settings(const char *mcc, const char *mnc,
- const char *spn)
-{
- struct ofono_gprs_provision_data *settings;
+#define TEST_SUITE "/provision/"
+
+extern struct ofono_plugin_desc __ofono_builtin_provision;
+
+struct provision_test_case {
+ const char *name;
+ const char *xml;
+ const char *mcc;
+ const char *mnc;
+ const char *spn;
+ const struct ofono_gprs_provision_data *settings;
int count;
- int i;
- provision_get_settings(mcc, mnc, spn, &settings, &count);
- g_print("Found %d contexts for (%s/%s/%s):\n", count, mcc, mnc, spn);
- for (i = 0; i < count; i++){
- struct ofono_gprs_provision_data ap = settings[i];
- g_print(" Name: %s\n", ap.name);
- g_print(" APN: %s\n", ap.apn);
- g_print(" Type: %s\n", mbpi_ap_type(ap.type));
- if (ap.username)
- g_print(" Username: %s\n", ap.username);
- if (ap.password)
- g_print(" Password: %s\n", ap.password);
- if (ap.message_proxy)
- g_print(" MMS proxy: %s\n", ap.message_proxy);
- if (ap.message_center)
- g_print(" MMS center: %s\n", ap.message_center);
- g_print("----------\n");
+};
+
+static GFile *test_write_tmp_file(const char* text, const char *suffix)
+{
+ char *tmpl = g_strconcat("provisionXXXXXX", suffix, NULL);
+ GFileIOStream *io = NULL;
+ GFile *file = g_file_new_tmp(tmpl, &io, NULL);
+ GOutputStream *out = g_io_stream_get_output_stream(G_IO_STREAM(io));
+ gsize len = strlen(text), nout;
+
+ g_assert(file);
+ g_assert(g_output_stream_write_all(out, text, len, &nout, NULL, NULL));
+ g_output_stream_close(out, NULL, NULL);
+ g_object_unref(io);
+ g_free(tmpl);
+
+ if (g_test_verbose()) {
+ char *path = g_file_get_path(file);
+
+ g_print("Created %s\n", path);
+ g_free(path);
}
+
+ return file;
+}
+
+static void test_provision(gconstpointer test_data)
+{
+ const struct provision_test_case *test = test_data;
+ struct ofono_gprs_provision_data *settings = NULL;
+ int i, count = 0;
+ GFile *file;
+ char *path;
+
+ if (test->xml) {
+ file = test_write_tmp_file(test->xml, ".xml");
+ path = g_file_get_path(file);
+ } else {
+ /*
+ * Create and delete a temporary file to end up
+ * with the path pointing to a non-existent file.
+ */
+ GFileIOStream *io = NULL;
+ file = g_file_new_tmp("provisionXXXXXX.xml", &io, NULL);
+ path = g_file_get_path(file);
+ g_file_delete(file, NULL, NULL);
+ g_object_unref(io);
+ g_object_unref(file);
+ file = NULL;
+ }
+
+ mbpi_database = path;
+ g_assert(__ofono_builtin_provision.init() == 0);
+
+ if (test->settings) {
+ g_assert(__ofono_gprs_provision_get_settings(test->mcc,
+ test->mnc, test->spn, &settings, &count));
+ g_assert(count == test->count);
+ for (i = 0; i < count; i++) {
+ const struct ofono_gprs_provision_data *actual =
+ settings + i;
+ const struct ofono_gprs_provision_data *expected =
+ test->settings + i;
+
+ g_assert(actual->type == expected->type);
+ g_assert(actual->proto == expected->proto);
+ g_assert(!g_strcmp0(actual->provider_name,
+ expected->provider_name));
+ g_assert(!g_strcmp0(actual->name, expected->name));
+ g_assert(actual->provider_primary ==
+ expected->provider_primary);
+ g_assert(!g_strcmp0(actual->apn, expected->apn));
+ g_assert(!g_strcmp0(actual->username,
+ expected->username));
+ g_assert(!g_strcmp0(actual->password,
+ expected->password));
+ g_assert(actual->auth_method == expected->auth_method);
+ g_assert(!g_strcmp0(actual->message_proxy,
+ expected->message_proxy));
+ g_assert(!g_strcmp0(actual->message_center,
+ expected->message_center));
+ }
+ } else {
+ g_assert(!__ofono_gprs_provision_get_settings(test->mcc,
+ test->mnc, test->spn, &settings, &count));
+ }
+
+ __ofono_gprs_provision_free_settings(settings, count);
+ __ofono_builtin_provision.exit();
+ if (file) {
+ g_file_delete(file, NULL, NULL);
+ g_object_unref(file);
+ }
+ g_free(path);
+}
+
+static void test_no_driver()
+{
+ struct ofono_gprs_provision_data *settings = NULL;
+ int count = 0;
+
+ g_assert(!__ofono_gprs_provision_get_settings("000", "01", NULL,
+ &settings, &count));
}
-static void test_get_settings(void)
+static void test_no_mcc_mnc()
{
- /* not in database */
- get_and_print_settings("999", "999", NULL);
+ struct ofono_gprs_provision_data *settings = NULL;
+ int count = 0;
- /* partial and case-insensitive matching */
- get_and_print_settings("244", "91", "sonera");
- get_and_print_settings("244", "91", "sONErA");
- get_and_print_settings("244", "91", "sone");
- get_and_print_settings("244", "91", "nera");
-
- /* related to Sonera/Finland network */
- get_and_print_settings("244", "91", NULL);
- get_and_print_settings("244", "91", "sonera");
- get_and_print_settings("244", "91", "aina");
-
- /* related to DNA/Finland network */
- get_and_print_settings("244", "03", NULL);
- get_and_print_settings("244", "03", "dna");
- get_and_print_settings("244", "03", "aina");
- get_and_print_settings("244", "04", NULL);
- get_and_print_settings("244", "04", "dna");
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/unit/test-sailfish_manager.c
^
|
@@ -0,0 +1,1377 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 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.
+ */
+
+#include <sailfish_manager.h>
+#include "sailfish_sim_info.h"
+#include "sailfish_manager_dbus.h"
+#include "fake_sailfish_watch.h"
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include "ofono.h"
+
+#include <gutil_log.h>
+#include <gutil_strv.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#define TEST_TIMEOUT_SEC (20)
+#define TEST_IDLE_WAIT_COUNT (10) /* Should be > SF_INIT_IDLE_COUNT */
+#define TEST_PATH "/test_0"
+#define TEST_PATH_1 "/test_1"
+#define TEST_ICCID "1111111111111111111"
+#define TEST_ICCID_1 "1111111111111111112"
+#define TEST_IMEI "222222222222222"
+#define TEST_IMEI_1 "222222222222223"
+#define TEST_IMEISV "33"
+#define TEST_IMSI "244120000000000"
+#define TEST_IMSI_1 "244120000000001"
+#define TEST_MCC "244"
+#define TEST_MNC "12"
+#define TEST_SPN "Test"
+#define TEST_ERROR_KEY "Error"
+#define TEST_SLOT_ERROR_KEY "SlotError"
+
+extern struct ofono_plugin_desc __ofono_builtin_sailfish_manager;
+static GMainLoop *test_loop = NULL;
+static guint test_timeout_id = 0;
+
+/* Fake ofono_modem */
+
+struct ofono_modem {
+ int unused;
+};
+
+/* Fake ofono_sim */
+
+struct ofono_sim {
+ const char *mcc;
+ const char *mnc;
+ enum ofono_sim_state state;
+};
+
+enum ofono_sim_state ofono_sim_get_state(struct ofono_sim *sim)
+{
+ return sim ? sim->state : OFONO_SIM_STATE_NOT_PRESENT;
+}
+
+const char *ofono_sim_get_mcc(struct ofono_sim *sim)
+{
+ return sim ? sim->mcc : NULL;
+}
+
+const char *ofono_sim_get_mnc(struct ofono_sim *sim)
+{
+ return sim ? sim->mnc : NULL;
+}
+
+/* Fake ofono_netreg */
+
+struct ofono_netreg {
+ const char *mcc;
+ const char *mnc;
+ const char *name;
+ int status;
+};
+
+int ofono_netreg_get_status(struct ofono_netreg *netreg)
+{
+ return netreg ? netreg->status : -1;
+}
+
+const char *ofono_netreg_get_mcc(struct ofono_netreg *netreg)
+{
+ return netreg ? netreg->mcc : NULL;
+}
+
+const char *ofono_netreg_get_mnc(struct ofono_netreg *netreg)
+{
+ return netreg ? netreg->mnc : NULL;
+}
+
+const char *ofono_netreg_get_name(struct ofono_netreg *netreg)
+{
+ return netreg ? netreg->name : NULL;
+}
+
+unsigned int __ofono_netreg_add_status_watch(struct ofono_netreg *netreg,
+ ofono_netreg_status_notify_cb_t notify,
+ void *data, ofono_destroy_func destroy)
+{
+ return 1;
+}
+
+gboolean __ofono_netreg_remove_status_watch(struct ofono_netreg *netreg,
+ unsigned int id)
+{
+ return TRUE;
+}
+
+/* Fake sailfish_manager_dbus */
+
+static struct sailfish_manager_dbus {
+ struct sailfish_manager *m;
+ struct sailfish_manager_dbus_cb cb;
+ enum sailfish_manager_dbus_block block;
+ void (*fn_block_changed)(struct sailfish_manager_dbus *d);
+ int signals;
+} fake_sailfish_manager_dbus;
+
+struct sailfish_manager_dbus *sailfish_manager_dbus_new
+ (struct sailfish_manager *m,
+ const struct sailfish_manager_dbus_cb *cb)
+{
+ memset(&fake_sailfish_manager_dbus, 0,
+ sizeof(fake_sailfish_manager_dbus));
+ fake_sailfish_manager_dbus.m = m;
+ fake_sailfish_manager_dbus.cb = *cb;
+ return &fake_sailfish_manager_dbus;
+}
+
+void sailfish_manager_dbus_free(struct sailfish_manager_dbus *d)
+{
+ g_assert(d == &fake_sailfish_manager_dbus);
+ g_assert(fake_sailfish_manager_dbus.m);
+ memset(&fake_sailfish_manager_dbus, 0,
+ sizeof(fake_sailfish_manager_dbus));
+}
+
+void sailfish_manager_dbus_set_block(struct sailfish_manager_dbus *d,
+ enum sailfish_manager_dbus_block b)
+{
+ if (d->block != b) {
+ DBG("0x%02x", (int)b);
+ d->block = b;
+ if (d->fn_block_changed) {
+ d->fn_block_changed(d);
+ }
+ }
+}
+void sailfish_manager_dbus_signal(struct sailfish_manager_dbus *d,
+ enum sailfish_manager_dbus_signal m)
+{
+ d->signals |= m;
+}
+
+void sailfish_manager_dbus_signal_sim(struct sailfish_manager_dbus *d,
+ int index, gboolean present) {}
+void sailfish_manager_dbus_signal_error(struct sailfish_manager_dbus *d,
+ const char *id, const char *message) {}
+void sailfish_manager_dbus_signal_modem_error(struct sailfish_manager_dbus *d,
+ int index, const char *id, const char *msg) {}
+
+/* Fake sailfish_sim_info_dbus */
+
+struct sailfish_sim_info_dbus {
+ int unused;
+};
+
+struct sailfish_sim_info_dbus *sailfish_sim_info_dbus_new
+ (struct sailfish_sim_info *info)
+{
+ static struct sailfish_sim_info_dbus fake_sailfish_sim_info_dbus;
+ return &fake_sailfish_sim_info_dbus;
+}
+
+void sailfish_sim_info_dbus_free(struct sailfish_sim_info_dbus *dbus) {}
+
+/* Code shared by all tests */
+
+typedef struct sailfish_slot_impl {
+ struct sailfish_slot *handle;
+ enum sailfish_data_role data_role;
+ int enabled_changed;
+} test_slot;
+
+typedef struct sailfish_slot_manager_impl {
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.19+git25.tar.bz2/ofono/unit/test-sailfish_sim_info.c
^
|
@@ -0,0 +1,442 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 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.
+ */
+
+#include "sailfish_sim_info.h"
+#include "fake_sailfish_watch.h"
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include "ofono.h"
+#include "common.h"
+
+#include <gutil_log.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#define TEST_PATH "/test"
+#define TEST_ICCID "1111111111111111111"
+#define TEST_IMSI "244120000000000"
+#define TEST_MCC "244"
+#define TEST_MNC "12"
+#define TEST_DEFAULT_SPN TEST_MCC TEST_MNC
+#define TEST_SPN "Test"
+
+#define ICCID_MAP STORAGEDIR "/iccidmap"
+#define SIM_CACHE STORAGEDIR "/" TEST_IMSI "/cache"
+
+enum sim_info_signals {
+ SIM_INFO_SIGNAL_ICCID_CHANGED,
+ SIM_INFO_SIGNAL_IMSI_CHANGED,
+ SIM_INFO_SIGNAL_SPN_CHANGED,
+ SIM_INFO_SIGNAL_COUNT
+};
+
+/* Fake ofono_sim */
+
+struct ofono_sim {
+ const char *mcc;
+ const char *mnc;
+ const char *spn;
+ enum ofono_sim_state state;
+};
+
+enum ofono_sim_state ofono_sim_get_state(struct ofono_sim *sim)
+{
+ return sim ? sim->state : OFONO_SIM_STATE_NOT_PRESENT;
+}
+
+const char *ofono_sim_get_mcc(struct ofono_sim *sim)
+{
+ return sim ? sim->mcc : NULL;
+}
+
+const char *ofono_sim_get_mnc(struct ofono_sim *sim)
+{
+ return sim ? sim->mnc : NULL;
+}
+
+/* Fake ofono_netreg */
+
+struct ofono_netreg {
+ const char *mcc;
+ const char *mnc;
+ const char *name;
+ int location;
+ int cellid;
+ enum ofono_radio_access_mode technology;
+ enum network_registration_status status;
+ struct ofono_watchlist *status_watches;
+};
+
+int ofono_netreg_get_status(struct ofono_netreg *netreg)
+{
+ return netreg ? netreg->status : -1;
+}
+
+const char *ofono_netreg_get_mcc(struct ofono_netreg *netreg)
+{
+ return netreg ? netreg->mcc : NULL;
+}
+
+const char *ofono_netreg_get_mnc(struct ofono_netreg *netreg)
+{
+ return netreg ? netreg->mnc : NULL;
+}
+
+const char *ofono_netreg_get_name(struct ofono_netreg *netreg)
+{
+ return netreg ? netreg->name : NULL;
+}
+
+unsigned int __ofono_netreg_add_status_watch(struct ofono_netreg *netreg,
+ ofono_netreg_status_notify_cb_t notify,
+ void *data, ofono_destroy_func destroy)
+{
+ struct ofono_watchlist_item *item =
+ g_new0(struct ofono_watchlist_item, 1);
+
+ DBG("%p", netreg);
+ g_assert(netreg);
+ g_assert(notify);
+ item->notify = notify;
+ item->destroy = destroy;
+ item->notify_data = data;
+ return __ofono_watchlist_add_item(netreg->status_watches, item);
+}
+
+gboolean __ofono_netreg_remove_status_watch(struct ofono_netreg *netreg,
+ unsigned int id)
+{
+ return __ofono_watchlist_remove_item(netreg->status_watches, id);
+}
+
+/* Utilities */
+
+static int rmdir_r(const char *path)
+{
+ DIR *d = opendir(path);
+
+ if (d) {
+ const struct dirent *p;
+ int r = 0;
+
+ while (!r && (p = readdir(d))) {
+ char *buf;
+ struct stat st;
+
+ if (!strcmp(p->d_name, ".") ||
+ !strcmp(p->d_name, "..")) {
+ continue;
+ }
+
+ buf = g_strdup_printf("%s/%s", path, p->d_name);
+ if (!stat(buf, &st)) {
+ r = S_ISDIR(st.st_mode) ? rmdir_r(buf) :
+ unlink(buf);
+ }
+ g_free(buf);
+ }
+ closedir(d);
+ return r ? r : rmdir(path);
+ } else {
+ return -1;
+ }
+}
+
+static void netreg_notify_status_watches(struct ofono_netreg *netreg)
+{
+ GSList *l;
+ const char *mcc = netreg->mcc;
+ const char *mnc = netreg->mnc;
+
+ for (l = netreg->status_watches->items; l; l = l->next) {
+ struct ofono_watchlist_item *item = l->data;
+ ofono_netreg_status_notify_cb_t notify = item->notify;
+
+ notify(netreg->status, netreg->location, netreg->cellid,
+ netreg->technology, mcc, mnc, item->notify_data);
+ }
+}
+
+
+/* Test cases */
+
+static void test_basic(void)
+{
+ struct sailfish_sim_info *si;
+
+ /* NULL tolerance */
+ g_assert(!sailfish_sim_info_new(NULL));
+ g_assert(!sailfish_sim_info_ref(NULL));
+ sailfish_sim_info_unref(NULL);
+ sailfish_sim_info_invalidate(NULL);
+ g_assert(!sailfish_sim_info_add_iccid_changed_handler(NULL,NULL,NULL));
+ g_assert(!sailfish_sim_info_add_imsi_changed_handler(NULL,NULL,NULL));
+ g_assert(!sailfish_sim_info_add_spn_changed_handler(NULL,NULL,NULL));
+ sailfish_sim_info_remove_handler(NULL, 0);
+ sailfish_sim_info_remove_handlers(NULL, NULL, 0);
+
+ /* Very basic things (mostly to improve code coverage) */
+ si = sailfish_sim_info_new("/test");
+ g_assert(si);
+ sailfish_sim_info_invalidate(si);
+ g_assert(!sailfish_sim_info_add_iccid_changed_handler(si,NULL,NULL));
+ g_assert(!sailfish_sim_info_add_imsi_changed_handler(si,NULL,NULL));
+ g_assert(!sailfish_sim_info_add_spn_changed_handler(si,NULL,NULL));
+ sailfish_sim_info_remove_handler(si, 0);
|