[-]
[+]
|
Added |
_service:tar_git:ofono.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:ofono.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -1,6 +1,6 @@
<services>
<service name="tar_git">
- <param name="url">https://github.com/Driim/ofono</param>
+ <param name="url">https://github.com/DeadSquirrel01/ofono.git</param>
<param name="branch">master</param>
<param name="revision">HEAD</param>
<param name="token"/>
|
[-]
[+]
|
Deleted |
_service:tar_git:ofono-1.22+master.20180329160942.2d81d8d9.tar.bz2/.gitignore
^
|
@@ -1,61 +0,0 @@
-*.o
-*.lo
-*.la
-.deps
-.libs
-.dirstamp
-Makefile
-Makefile.in
-aclocal.m4
-config.guess
-config.h
-config.h.in
-config.log
-config.status
-config.sub
-configure
-depcomp
-compile
-install-sh
-libtool
-ltmain.sh
-missing
-stamp-h1
-autom4te.cache
-test-driver
-test-suite.log
-
-ofono.pc
-include/ofono
-include/version.h
-src/builtin.h
-src/ofonod
-src/ofono.service
-dundee/dundee
-dundee/dundee.service
-
-unit/test-common
-unit/test-util
-unit/test-idmap
-unit/test-sms
-unit/test-sms-root
-unit/test-simutil
-unit/test-mux
-unit/test-caif
-unit/test-stkutil
-unit/test-cdmasms
-unit/test-*.log
-unit/test-*.trs
-
-tools/huawei-audio
-tools/auto-enable
-tools/get-location
-tools/lookup-apn
-tools/lookup-provider-name
-tools/tty-redirector
-tools/qmi
-tools/stktest
-
-gatchat/gsmdial
-gatchat/test-server
-gatchat/test-qcdm
|
[-]
[+]
|
Deleted |
_service:tar_git:ofono-1.22+master.20180329160942.2d81d8d9.tar.bz2/.mailmap
^
|
@@ -1,7 +0,0 @@
-Luiz Augusto von Dentz <luiz.dentz-von@nokia.com> <luiz.dentz-von@nokia.com>
-Zhenhua Zhang <zhenhua.zhang@intel.com> <zhenhua.zhang@intel.com>
-Pekka Pessi <pekka.pessi@nokia.com> <Pekka.Pessi@nokia.com>
-Pekka Pessi <pekka.pessi@nokia.com> <ppessi@hamsa.research.nokia.com>
-Lasse Kunnasluoto <lasse.kunnasluoto@tieto.com> <Lasse.Kunnasluoto@tieto.com>
-Syam Sidhardhan <s.syam@samsung.com> <syamsidhardh@gmail.com>
-Michael Dietrich <mdt@emdete.de> <mdt@emdete.de>
|
[-]
[+]
|
Deleted |
_service:tar_git:ofono-1.22+master.20180329160942.2d81d8d9.tar.bz2/ofono/include/sailfish_watch.h
^
|
@@ -1,81 +0,0 @@
-/*
- * 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:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:ofono-1.22+master.20180329160942.2d81d8d9.tar.bz2/ofono/plugins/sailfish_manager/sailfish_watch.c
^
|
@@ -1,692 +0,0 @@
-/*
- * oFono - Open Source Telephony
- *
- * Copyright (C) 2017-2018 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_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);
- struct sailfish_watch_priv *priv = self->priv;
-
- GASSERT(priv->spn_watch_id);
- priv->spn_watch_id = 0;
-}
-
-static void sailfish_watch_imsi_update(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);
- sailfish_watch_signal_queue(self, SIGNAL_IMSI_CHANGED);
- /* ofono core crashes if we add spn watch too early */
- if (imsi) {
- ofono_sim_add_spn_watch(self->sim, &priv->spn_watch_id,
|
[-]
[+]
|
Deleted |
_service:tar_git:ofono-1.22+master.20180329160942.2d81d8d9.tar.bz2/ofono/unit/fake_sailfish_watch.c
^
|
@@ -1,326 +0,0 @@
-/*
- * 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");
- }
|
[-]
[+]
|
Deleted |
_service:tar_git:ofono-1.22+master.20180329160942.2d81d8d9.tar.bz2/ofono/unit/fake_sailfish_watch.h
^
|
@@ -1,55 +0,0 @@
-/*
- * 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:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:ofono-1.22+master.20180329160942.2d81d8d9.tar.bz2/ofono/unit/test-sailfish_watch.c
^
|
@@ -1,710 +0,0 @@
-/*
- * oFono - Open Source Telephony
- *
- * Copyright (C) 2018 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 "ofono.h"
-
-#include <gutil_log.h>
-
-static GSList *g_modem_list = NULL;
-static struct ofono_watchlist *g_modemwatches = NULL;
-
-#define TEST_PATH "/test_0"
-#define TEST_PATH_1 "/test_1"
-#define TEST_ICCID "0000000000000000000"
-#define TEST_IMSI "244120000000000"
-#define TEST_SPN "Test"
-
-/* Fake ofono_atom */
-
-struct ofono_atom {
- enum ofono_atom_type type;
- gboolean registered;
- void *data;
- struct ofono_modem *modem;
-};
-
-void *__ofono_atom_get_data(struct ofono_atom *atom)
-{
- return atom->data;
-}
-
-/* Fake ofono_netreg */
-
-struct ofono_netreg {
- struct ofono_atom atom;
-};
-
-/* Fake ofono_sim */
-
-struct ofono_sim {
- struct ofono_atom atom;
- const char *spn;
- const char *spn_dc;
- const char *imsi;
- const char *iccid;
- enum ofono_sim_state state;
- struct ofono_watchlist *spn_watches;
- struct ofono_watchlist *imsi_watches;
- struct ofono_watchlist *iccid_watches;
- struct ofono_watchlist *state_watches;
-};
-
-static unsigned int add_watch_item(struct ofono_watchlist *list,
- void *notify, void *data, ofono_destroy_func destroy)
-{
- struct ofono_watchlist_item *watch =
- g_new0(struct ofono_watchlist_item, 1);
-
- watch->notify = notify;
- watch->destroy = destroy;
- watch->notify_data = data;
- return __ofono_watchlist_add_item(list, watch);
-}
-
-unsigned int ofono_sim_add_iccid_watch(struct ofono_sim *sim,
- ofono_sim_iccid_event_cb_t cb, void *data,
- ofono_destroy_func destroy)
-{
- guint id = add_watch_item(sim->iccid_watches, cb, data, destroy);
-
- if (sim->iccid) {
- cb(sim->iccid, data);
- }
-
- return id;
-}
-
-void ofono_sim_remove_iccid_watch(struct ofono_sim *sim, unsigned int id)
-{
- __ofono_watchlist_remove_item(sim->iccid_watches, id);
-}
-
-static void iccid_watches_cb(gpointer data, gpointer user_data)
-{
- struct ofono_sim *sim = user_data;
- struct ofono_watchlist_item *item = data;
- ofono_sim_iccid_event_cb_t cb = item->notify;
-
- cb(sim->iccid, item->notify_data);
-}
-
-static inline void iccid_watches_notify(struct ofono_sim *sim)
-{
- g_slist_foreach(sim->iccid_watches->items, iccid_watches_cb, sim);
-}
-
-unsigned int ofono_sim_add_imsi_watch(struct ofono_sim *sim,
- ofono_sim_imsi_event_cb_t cb, void *data,
- ofono_destroy_func destroy)
-{
- guint id = add_watch_item(sim->imsi_watches, cb, data, destroy);
-
- if (sim->imsi) {
- cb(sim->imsi, data);
- }
-
- return id;
-}
-
-void ofono_sim_remove_imsi_watch(struct ofono_sim *sim, unsigned int id)
-{
- __ofono_watchlist_remove_item(sim->imsi_watches, id);
-}
-
-static void imsi_watches_cb(gpointer data, gpointer user_data)
-{
- struct ofono_sim *sim = user_data;
- struct ofono_watchlist_item *item = data;
- ofono_sim_imsi_event_cb_t cb = item->notify;
-
- cb(sim->imsi, item->notify_data);
-}
-
-static inline void imsi_watches_notify(struct ofono_sim *sim)
-{
- g_slist_foreach(sim->imsi_watches->items, imsi_watches_cb, sim);
-}
-
-ofono_bool_t ofono_sim_add_spn_watch(struct ofono_sim *sim, unsigned int *id,
- ofono_sim_spn_cb_t cb, void *data, ofono_destroy_func destroy)
-{
- *id = add_watch_item(sim->spn_watches, cb, data, destroy);
- if (sim->spn) {
- cb(sim->spn, sim->spn_dc, data);
- }
- return TRUE;
-}
-
-ofono_bool_t ofono_sim_remove_spn_watch(struct ofono_sim *sim, unsigned int *id)
-{
- if (__ofono_watchlist_remove_item(sim->spn_watches, *id)) {
- *id = 0;
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-static void spn_watches_cb(gpointer data, gpointer user_data)
-{
- struct ofono_sim *sim = user_data;
- struct ofono_watchlist_item *item = data;
- ofono_sim_spn_cb_t notify = item->notify;
-
- notify(sim->spn, sim->spn_dc, item->notify_data);
-}
-
-static inline void spn_watches_notify(struct ofono_sim *sim)
-{
- g_slist_foreach(sim->spn_watches->items, spn_watches_cb, sim);
-}
-
-unsigned int ofono_sim_add_state_watch(struct ofono_sim *sim,
- ofono_sim_state_event_cb_t notify,
- void *data, ofono_destroy_func destroy)
-{
- return add_watch_item(sim->state_watches, notify, data, destroy);
-}
-
-void ofono_sim_remove_state_watch(struct ofono_sim *sim, unsigned int id)
-{
- __ofono_watchlist_remove_item(sim->state_watches, id);
-}
-
-static void state_watches_cb(gpointer data, gpointer user_data)
-{
- struct ofono_sim *sim = user_data;
- struct ofono_watchlist_item *item = data;
- ofono_sim_state_event_cb_t notify = item->notify;
-
- notify(sim->state, item->notify_data);
-}
-
-static void state_watches_notify(struct ofono_sim *sim)
-{
- g_slist_foreach(sim->state_watches->items, state_watches_cb, sim);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/.gitignore
^
|
@@ -32,6 +32,8 @@
dundee/dundee
dundee/dundee.service
+test-driver
+test-suite.log
unit/test-common
unit/test-util
unit/test-idmap
@@ -42,18 +44,25 @@
unit/test-caif
unit/test-stkutil
unit/test-cdmasms
+unit/test-dbus-access
+unit/test-dbus-queue
+unit/test-gprs-filter
+unit/test-ril_config
unit/test-ril_util
+unit/test-ril-transport
unit/test-rilmodem-cb
unit/test-rilmodem-cs
unit/test-rilmodem-gprs
unit/test-rilmodem-sms
+unit/test-sailfish_access
unit/test-sailfish_cell_info
unit/test-sailfish_cell_info_dbus
unit/test-sailfish_manager
unit/test-sailfish_sim_info
unit/test-sailfish_sim_info_dbus
-unit/test-sailfish_watch
+unit/test-watch
unit/test-sms-filter
+unit/test-voicecall-filter
unit/test-*.log
unit/test-*.trs
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/Makefile.am
^
|
@@ -23,16 +23,18 @@
include/cdma-provision.h include/handsfree.h \
include/sim-mnclength.h \
include/handsfree-audio.h include/siri.h \
- include/sms-filter.h \
+ include/sms-filter.h include/gprs-filter.h \
+ include/voicecall-filter.h include/dbus-access.h \
+ include/ril-constants.h include/ril-transport.h \
include/netmon.h include/lte.h \
- include/storage.h \
+ include/storage.h include/watch.h \
gdbus/gdbus.h
nodist_pkginclude_HEADERS = include/version.h
if SAILFISH_MANAGER
nodist_pkginclude_HEADERS += include/sailfish_cell_info.h \
- include/sailfish_manager.h include/sailfish_watch.h
+ include/sailfish_manager.h
endif
local_headers = $(foreach file,$(pkginclude_HEADERS) \
@@ -129,8 +131,13 @@
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
+ plugins/sailfish_manager/sailfish_sim_info_dbus.c
+endif
+
+
+if SAILFISH_ACCESS
+builtin_modules += sailfish_access
+builtin_sources += plugins/sailfish_access.c
endif
if RILMODEM
@@ -736,8 +743,10 @@
src/cdma-provision.c src/handsfree.c \
src/handsfree-audio.c src/bluetooth.h \
src/sim-mnclength.c src/voicecallagent.c \
- src/sms-filter.c src/dbus-queue.c \
- src/hfp.h src/siri.c \
+ src/sms-filter.c src/gprs-filter.c \
+ src/dbus-queue.c src/dbus-access.c \
+ src/voicecall-filter.c src/ril-transport.c \
+ src/hfp.h src/siri.c src/watchlist.c \
src/netmon.c src/lte.c \
src/netmonagent.c src/netmonagent.h
@@ -749,7 +758,8 @@
BUILT_SOURCES = $(local_headers) src/builtin.h
-CLEANFILES = $(BUILT_SOURCES) $(rules_DATA)
+CLEANFILES = $(BUILT_SOURCES) $(rules_DATA) \
+ $(shell find . -name "*.gcda") $(shell find . -name "*.gcno")
plugindir = $(pkglibdir)/plugins
@@ -919,8 +929,7 @@
unit_tests = unit/test-common unit/test-util unit/test-idmap \
unit/test-simutil unit/test-stkutil \
- unit/test-sms unit/test-cdmasms \
- unit/test-provision unit/test-sms-filter
+ unit/test-sms unit/test-cdmasms
if SAILFISH_MANAGER
@@ -946,9 +955,9 @@
unit_tests += unit/test-sailfish_cell_info_dbus
unit_test_sailfish_sim_info_SOURCES = unit/test-sailfish_sim_info.c \
- unit/fake_sailfish_watch.c \
+ unit/fake_watch.c \
plugins/sailfish_manager/sailfish_sim_info.c \
- src/storage.c src/watch.c src/log.c
+ src/storage.c src/watchlist.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
@@ -956,11 +965,11 @@
unit_tests += unit/test-sailfish_sim_info
unit_test_sailfish_sim_info_dbus_SOURCES = unit/test-sailfish_sim_info_dbus.c \
- unit/test-dbus.c unit/fake_sailfish_watch.c \
+ unit/test-dbus.c unit/fake_watch.c \
plugins/sailfish_manager/sailfish_sim_info.c \
plugins/sailfish_manager/sailfish_sim_info_dbus.c \
gdbus/object.c \
- src/dbus.c src/storage.c src/watch.c src/log.c
+ src/dbus.c src/storage.c src/watchlist.c src/log.c
unit_test_sailfish_sim_info_dbus_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS) \
@DBUS_GLIB_CFLAGS@ -DSTORAGEDIR='"/tmp/ofono"' \
-Iplugins/sailfish_manager
@@ -969,7 +978,7 @@
unit_tests += unit/test-sailfish_sim_info_dbus
unit_test_sailfish_manager_SOURCES = unit/test-sailfish_manager.c \
- unit/fake_sailfish_watch.c \
+ unit/fake_watch.c \
plugins/sailfish_manager/sailfish_manager.c \
plugins/sailfish_manager/sailfish_cell_info.c \
plugins/sailfish_manager/sailfish_sim_info.c \
@@ -980,20 +989,42 @@
unit_objects += $(unit_test_sailfish_manager_OBJECTS)
unit_tests += unit/test-sailfish_manager
-unit_test_sailfish_watch_SOURCES = unit/test-sailfish_watch.c \
- plugins/sailfish_manager/sailfish_watch.c \
- src/log.c src/watch.c
-unit_test_sailfish_watch_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
+unit_test_watch_SOURCES = unit/test-watch.c src/watch.c \
+ src/log.c src/watchlist.c
+unit_test_watch_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
-DSTORAGEDIR='"/tmp/ofono"' -Iplugins/sailfish_manager
-unit_test_sailfish_watch_LDADD = @GLIB_LIBS@ -ldl
-unit_objects += $(unit_test_sailfish_watch_OBJECTS)
-unit_tests += unit/test-sailfish_watch
+unit_test_watch_LDADD = @GLIB_LIBS@ -ldl
+unit_objects += $(unit_test_watch_OBJECTS)
+unit_tests += unit/test-watch
endif
+if SAILFISH_ACCESS
+unit_test_sailfish_access_SOURCES = unit/test-sailfish_access.c \
+ plugins/sailfish_access.c src/dbus-access.c src/log.c
+unit_test_sailfish_access_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT)
+unit_test_sailfish_access_LDADD = @GLIB_LIBS@ -ldl
+unit_objects += $(unit_test_sailfish_access_OBJECTS)
+unit_tests += unit/test-sailfish_access
+endif
+
+unit_test_dbus_access_SOURCES = unit/test-dbus-access.c src/dbus-access.c \
+ src/log.c
+unit_test_dbus_access_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT)
+unit_test_dbus_access_LDADD = @GLIB_LIBS@ -ldl
+unit_objects += $(unit_test_dbus_access_OBJECTS)
+unit_tests += unit/test-dbus-access
+
if RILMODEM
if SAILFISH_RILMODEM
+unit_test_ril_config_SOURCES = unit/test-ril_config.c drivers/ril/ril_util.c \
+ drivers/ril/ril_config.c src/log.c
+unit_test_ril_config_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
+unit_test_ril_config_LDADD = @GLIB_LIBS@ -ldl
+unit_objects += $(unit_test_ril_config_OBJECTS)
+unit_tests += unit/test-ril_config
+
unit_test_ril_util_SOURCES = unit/test-ril_util.c drivers/ril/ril_util.c \
src/log.c
unit_test_ril_util_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
@@ -1070,6 +1101,14 @@
unit_test_caif_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_caif_OBJECTS)
+unit_test_dbus_queue_SOURCES = unit/test-dbus-queue.c unit/test-dbus.c \
+ src/dbus-queue.c gdbus/object.c \
+ src/dbus.c src/log.c
+unit_test_dbus_queue_CFLAGS = @DBUS_GLIB_CFLAGS@ $(COVERAGE_OPT) $(AM_CFLAGS)
+unit_test_dbus_queue_LDADD = @DBUS_GLIB_LIBS@ @GLIB_LIBS@ -ldl
+unit_objects += $(unit_test_dbus_queue_OBJECTS)
+unit_tests += unit/test-dbus-queue
+
unit_test_provision_SOURCES = unit/test-provision.c \
plugins/provision.h plugins/mbpi.c \
plugins/sailfish_provision.c \
@@ -1077,12 +1116,36 @@
unit_test_provision_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_provision_LDADD = @GLIB_LIBS@ -ldl
unit_objects += $(unit_test_provision_OBJECTS)
+unit_tests += unit/test-provision
+
+unit_test_ril_transport_SOURCES = unit/test-ril-transport.c \
+ src/ril-transport.c src/log.c
+unit_test_ril_transport_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
+unit_test_ril_transport_LDADD = @GLIB_LIBS@ -ldl
+unit_objects += $(unit_test_ril_transport_OBJECTS)
+unit_tests += unit/test-ril-transport
unit_test_sms_filter_SOURCES = unit/test-sms-filter.c \
src/sms-filter.c src/log.c
unit_test_sms_filter_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_sms_filter_LDADD = @GLIB_LIBS@ -ldl
unit_objects += $(unit_test_sms_filter_OBJECTS)
+unit_tests += unit/test-sms-filter
+
+unit_test_gprs_filter_SOURCES = unit/test-gprs-filter.c \
+ src/gprs-filter.c src/log.c
+unit_test_gprs_filter_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
+unit_test_gprs_filter_LDADD = @GLIB_LIBS@ -ldl
+unit_objects += $(unit_test_gprs_filter_OBJECTS)
+unit_tests += unit/test-gprs-filter
+
+unit_test_voicecall_filter_SOURCES = unit/test-voicecall-filter.c \
+ src/voicecall-filter.c src/log.c \
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/configure.ac
^
|
@@ -184,10 +184,10 @@
AM_CONDITIONAL(SAILFISH_RILMODEM, test "${enable_sailfish_rilmodem}" != "no")
if (test "${enable_sailfish_rilmodem}" = "yes"); then
- PKG_CHECK_MODULES(GRILIO, libgrilio >= 1.0.21, dummy=yes,
- AC_MSG_ERROR(libgrilio >= 1.0.21 is required))
- PKG_CHECK_MODULES(GLIBUTIL, libglibutil >= 1.0.23, dummy=yes,
- AC_MSG_ERROR(libglibutil >= 1.0.23 is required))
+ PKG_CHECK_MODULES(GRILIO, libgrilio >= 1.0.25, dummy=yes,
+ AC_MSG_ERROR(libgrilio >= 1.0.25 is required))
+ PKG_CHECK_MODULES(GLIBUTIL, libglibutil >= 1.0.30, dummy=yes,
+ AC_MSG_ERROR(libglibutil >= 1.0.30 is required))
PKG_CHECK_MODULES(LIBMCE, libmce-glib >= 1.0.5, dummy=yes,
AC_MSG_ERROR(libmce-glib >= 1.0.5 is required))
CFLAGS="$CFLAGS $GRILIO_CFLAGS $LIBMCE_CFLAGS"
@@ -312,6 +312,19 @@
need_glibutil=yes
fi
+AC_ARG_ENABLE(sailfish-access, AC_HELP_STRING([--enable-sailfish-access],
+ [enable Sailfish OS access plugin]),
+ [enable_sailfish_access=${enableval}],
+ [enable_sailfish_access="no"])
+
+AM_CONDITIONAL(SAILFISH_ACCESS, test "${enable_sailfish_access}" != "no")
+if (test "${enable_sailfish_access}" == "yes"); then
+ PKG_CHECK_MODULES(DBUSACCESS, libdbusaccess, dummy=yes,
+ AC_MSG_ERROR(libdbusaccess is required))
+ CFLAGS="$CFLAGS $DBUSACCESS_CFLAGS"
+ LIBS="$LIBS $DBUSACCESS_LIBS"
+fi
+
AC_ARG_ENABLE(sailfish-debuglog, AC_HELP_STRING([--enable-sailfish-debuglog],
[enable Sailfish OS debug log plugin]),
[enable_sailfish_debuglog=${enableval}],
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_call_barring.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2017 Jolla Ltd.
+ * Copyright (C) 2015-2018 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,6 +14,7 @@
*/
#include "ril_plugin.h"
+#include "ril_sim_card.h"
#include "ril_util.h"
#include "ril_log.h"
@@ -26,11 +27,11 @@
* ril.h does not state that string count must be given, but that is
* still expected by the modem
*/
-#define RIL_QUERY_STRING_COUNT 4
#define RIL_SET_STRING_COUNT 5
#define RIL_SET_PW_STRING_COUNT 3
struct ril_call_barring {
+ struct ril_sim_card *card;
GRilIoQueue *q;
guint timer_id;
};
@@ -106,7 +107,7 @@
{
struct ril_call_barring *bd = ofono_call_barring_get_data(b);
char cls_textual[RIL_MAX_SERVICE_LENGTH];
- GRilIoRequest *req = grilio_request_new();
+ GRilIoRequest *req;
DBG("lock: %s, services to query: %d", lock, cls);
@@ -123,15 +124,9 @@
/*
* See 3GPP 27.007 7.4 for parameter descriptions.
- * According to ril.h password should be empty string "" when not
- * needed, but in reality we only need to give string length as 0
*/
- grilio_request_append_int32(req, RIL_QUERY_STRING_COUNT);
- grilio_request_append_utf8(req, lock); /* Facility code */
- grilio_request_append_int32(req, 0); /* Password length */
- grilio_request_append_utf8(req, cls_textual);
- grilio_request_append_utf8(req, NULL); /* AID (not yet supported) */
-
+ req = grilio_request_array_utf8_new(4, lock, "", cls_textual,
+ ril_sim_card_app_aid(bd->card));
ril_call_barring_submit_request(bd, req,
RIL_REQUEST_QUERY_FACILITY_LOCK,
ril_call_barring_query_cb, cb, data);
@@ -182,7 +177,7 @@
RIL_FACILITY_UNLOCK);
grilio_request_append_utf8(req, passwd);
grilio_request_append_utf8(req, cls_textual);
- grilio_request_append_utf8(req, NULL); /* AID (not yet supported) */
+ grilio_request_append_utf8(req, ril_sim_card_app_aid(bd->card));
ril_call_barring_submit_request(bd, req,
RIL_REQUEST_SET_FACILITY_LOCK,
@@ -243,6 +238,7 @@
struct ril_call_barring *bd = g_new0(struct ril_call_barring, 1);
DBG("");
+ bd->card = ril_sim_card_ref(modem->sim_card);
bd->q = grilio_queue_new(ril_modem_io(modem));
bd->timer_id = g_idle_add(ril_call_barring_register, b);
ofono_call_barring_set_data(b, bd);
@@ -260,6 +256,7 @@
g_source_remove(bd->timer_id);
}
+ ril_sim_card_unref(bd->card);
grilio_queue_cancel_all(bd->q, FALSE);
grilio_queue_unref(bd->q);
g_free(bd);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_cell_info.c
^
|
@@ -23,6 +23,7 @@
#include <grilio_request.h>
#include <grilio_parser.h>
+#include <gutil_idlepool.h>
#include <gutil_misc.h>
#define DISPLAY_ON_UPDATE_RATE (1000) /* 1 sec */
@@ -75,6 +76,20 @@
ril_cell_free(cell);
}
+static const char *ril_cell_info_int_format(int value, const char *format)
+{
+ if (value == SAILFISH_CELL_INVALID_VALUE) {
+ return "";
+ } else {
+ static GUtilIdlePool *ril_cell_info_pool = NULL;
+ GUtilIdlePool *pool = gutil_idle_pool_get(&ril_cell_info_pool);
+ char *str = g_strdup_printf(format, value);
+
+ gutil_idle_pool_add(pool, str, g_free);
+ return str;
+ }
+}
+
static gboolean ril_cell_info_list_identical(GSList *l1, GSList *l2)
{
while (l1 && l2) {
@@ -123,11 +138,17 @@
grilio_parser_get_int32(rilp, &gsm->bitErrorRate) &&
(version < 12 || /* RIL_GSM_SignalStrength_v12 part */
grilio_parser_get_int32(rilp, &gsm->timingAdvance))) {
- DBG("[gsm] reg=%d,mcc=%d,mnc=%d,lac=%d,cid=%d,arfcn=%d,"
- "bsic=%d,strength=%d,err=%d,t=%d", registered,
- gsm->mcc, gsm->mnc, gsm->lac, gsm->cid, gsm->arfcn,
- gsm->bsic, gsm->signalStrength, gsm->bitErrorRate,
- gsm->timingAdvance);
+ DBG("[gsm] reg=%d%s%s%s%s%s%s%s%s%s", registered,
+ ril_cell_info_int_format(gsm->mcc, ",mcc=%d"),
+ ril_cell_info_int_format(gsm->mnc, ",mnc=%d"),
+ ril_cell_info_int_format(gsm->lac, ",lac=%d"),
+ ril_cell_info_int_format(gsm->cid, ",cid=%d"),
+ ril_cell_info_int_format(gsm->arfcn, ",arfcn=%d"),
+ ril_cell_info_int_format(gsm->bsic, ",bsic=%d"),
+ ril_cell_info_int_format(gsm->signalStrength,
+ ",strength=%d"),
+ ril_cell_info_int_format(gsm->bitErrorRate, ",err=%d"),
+ ril_cell_info_int_format(gsm->timingAdvance, ",t=%d"));
cell->type = SAILFISH_CELL_TYPE_GSM;
cell->registered = registered;
return cell;
@@ -155,10 +176,16 @@
grilio_parser_get_int32(rilp, &wcdma->uarfcn)) &&
grilio_parser_get_int32(rilp, &wcdma->signalStrength) &&
grilio_parser_get_int32(rilp, &wcdma->bitErrorRate)) {
- DBG("[wcdma] reg=%d,mcc=%d,mnc=%d,lac=%d,cid=%d,psc=%d,"
- "strength=%d,err=%d", registered, wcdma->mcc,
- wcdma->mnc, wcdma->lac, wcdma->cid, wcdma->psc,
- wcdma->signalStrength, wcdma->bitErrorRate);
+ DBG("[wcdma] reg=%d%s%s%s%s%s%s%s", registered,
+ ril_cell_info_int_format(wcdma->mcc, ",mcc=%d"),
+ ril_cell_info_int_format(wcdma->mnc, ",mnc=%d"),
+ ril_cell_info_int_format(wcdma->lac, ",lac=%d"),
+ ril_cell_info_int_format(wcdma->cid, ",cid=%d"),
+ ril_cell_info_int_format(wcdma->psc, ",psc=%d"),
+ ril_cell_info_int_format(wcdma->signalStrength,
+ ",strength=%d"),
+ ril_cell_info_int_format(wcdma->bitErrorRate,
+ ",err=%d"));
cell->type = SAILFISH_CELL_TYPE_WCDMA;
cell->registered = registered;
return cell;
@@ -190,11 +217,19 @@
grilio_parser_get_int32(rilp, <e->rssnr) &&
grilio_parser_get_int32(rilp, <e->cqi) &&
grilio_parser_get_int32(rilp, <e->timingAdvance)) {
- DBG("[lte] reg=%d,mcc=%d,mnc=%d,ci=%d,pci=%d,tac=%d,"
- "strength=%d,rsrp=%d,rsrq=%d,rssnr=%d,cqi=%d,"
- "t=0x%x", registered, lte->mcc, lte->mnc, lte->ci,
- lte->pci, lte->tac, lte->signalStrength, lte->rsrp,
- lte->rsrq, lte->rssnr, lte->cqi, lte->timingAdvance);
+ DBG("[lte] reg=%d%s%s%s%s%s%s%s%s%s%s%s", registered,
+ ril_cell_info_int_format(lte->mcc, ",mcc=%d"),
+ ril_cell_info_int_format(lte->mnc, ",mnc=%d"),
+ ril_cell_info_int_format(lte->ci, ",ci=%d"),
+ ril_cell_info_int_format(lte->pci, ",pci=%d"),
+ ril_cell_info_int_format(lte->tac, ",tac=%d"),
+ ril_cell_info_int_format(lte->signalStrength,
+ ",strength=%d"),
+ ril_cell_info_int_format(lte->rsrp, ",rsrp=%d"),
+ ril_cell_info_int_format(lte->rsrq, ",rsrq=%d"),
+ ril_cell_info_int_format(lte->rssnr, ",rssnr=%d"),
+ ril_cell_info_int_format(lte->cqi, ",cqi=%d"),
+ ril_cell_info_int_format(lte->timingAdvance, ",t=%d"));
cell->type = SAILFISH_CELL_TYPE_LTE;
cell->registered = registered;
return cell;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_config.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2017 Jolla Ltd.
+ * Copyright (C) 2015-2018 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
@@ -19,6 +19,11 @@
#include <gutil_intarray.h>
#include <gutil_ints.h>
+#include <gutil_misc.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
/* Utilities for parsing ril_subscription.conf */
@@ -186,14 +191,23 @@
char *value = ril_config_get_string(file, group, key);
if (value) {
- char **values = g_strsplit(value, ",", -1);
- char **ptr = values;
GUtilIntArray *array = gutil_int_array_new();
+ char **values, **ptr;
+
+ /*
+ * Some people are thinking that # is a comment
+ * anywhere on the line, not just at the beginning
+ */
+ char *comment = strchr(value, '#');
+
+ if (comment) *comment = 0;
+ values = g_strsplit(value, ",", -1);
+ ptr = values;
while (*ptr) {
int val;
- if (ril_parse_int(*ptr++, 0, &val)) {
+ if (gutil_parse_int(*ptr++, 0, &val)) {
gutil_int_array_append(array, val);
}
}
@@ -223,6 +237,337 @@
return NULL;
}
+/**
+ * The ril_config_merge_files() function does the following:
+ *
+ * 1. Loads the specified key file (say, "/etc/foo.conf")
+ * 2. Scans the subdirectory named after the file (e.g. "/etc/foo.d/")
+ * for the files with the same suffix as the main file (e.g. "*.conf")
+ * 3. Sorts the files from the subdirectory (alphabetically)
+ * 4. Merges the contents of the additional files with the main file
+ * according to their sort order.
+ *
+ * When the entries are merged, keys and groups overwrite the exising
+ * ones by default. Keys can be suffixed with special characters to
+ * remove or modify the existing entries instead:
+ *
+ * ':' Sets the (default) value if the key is missing
+ * '+' Appends values to the string list
+ * '?' Appends only new (non-existent) values to the string list
+ * '-' Removes the values from the string list
+ *
+ * Both keys and groups can be prefixed with '!' to remove the entire key
+ * or group.
+ *
+ * For example if we merge these two files:
+ *
+ * /etc/foo.conf:
+ *
+ * [foo]
+ * a=1
+ * b=2,3
+ * c=4
+ * d=5
+ * [bar]
+ * e=5
+ *
+ * /etc/foo.d/bar.conf:
+ *
+ * [foo]
+ * a+=2
+ * b-=2
+ * c=5
+ * !d
+ * [!bar]
+ *
+ * we end up with this:
+ *
+ * [foo]
+ * a=1
+ * b=2,3
+ * c=5
+ *
+ * Not that the list separator is assumed to be ',' (rather than default ';').
+ * The keyfile passed to ril_config_merge_files() should use the same list
+ * separator, because the default values are copied from the config files
+ * as is.
+ */
+
+static gint ril_config_sort_files(gconstpointer a, gconstpointer b)
+{
+ /* The comparison function for g_ptr_array_sort() doesn't take
+ * the pointers from the array as arguments, it takes pointers
+ * to the pointers in the array. */
+ return strcmp(*(char**)a, *(char**)b);
+}
+
+static char **ril_config_collect_files(const char *path, const char *suffix)
+{
+ /* Returns sorted list of regular files in the directory,
+ * optionally having the specified suffix (e.g. ".conf").
+ * Returns NULL if nothing appropriate has been found. */
+ char **files = NULL;
+ DIR *d = opendir(path);
+
+ if (d) {
+ GPtrArray *list = g_ptr_array_new();
+ const struct dirent *p;
+
+ while ((p = readdir(d)) != NULL) {
+ /* No need to even stat . and .. */
+ if (strcmp(p->d_name, ".") &&
+ strcmp(p->d_name, "..") && (!suffix ||
+ g_str_has_suffix(p->d_name, suffix))) {
+ struct stat st;
+ char *buf = g_strconcat(path, "/", p->d_name,
+ NULL);
+
+ if (!stat(buf, &st) && S_ISREG(st.st_mode)) {
+ g_ptr_array_add(list, buf);
+ } else {
+ g_free(buf);
+ }
+ }
+ }
+
+ if (list->len > 0) {
+ g_ptr_array_sort(list, ril_config_sort_files);
+ g_ptr_array_add(list, NULL);
+ files = (char**)g_ptr_array_free(list, FALSE);
+ } else {
+ g_ptr_array_free(list, TRUE);
+ }
+
+ closedir(d);
+ }
+ return files;
+}
+
+static int ril_config_list_find(char **list, gsize len, const char *value)
+{
+ guint i;
+
+ for (i = 0; i < len; i++) {
+ if (!strcmp(list[i], value)) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+static void ril_config_list_append(GKeyFile *conf, GKeyFile *k,
+ const char *group, const char *key,
+ char **values, gsize n, gboolean unique)
+{
+ /* Note: will steal strings from values */
+ if (n > 0) {
+ int i;
+ gsize len = 0;
+ gchar **list = g_key_file_get_string_list(conf, group, key,
+ &len, NULL);
+ GPtrArray *newlist = g_ptr_array_new_full(0, g_free);
+
+ for (i = 0; i < (int)len; i++) {
+ g_ptr_array_add(newlist, list[i]);
+ }
+
+ for (i = 0; i < (int)n; i++) {
+ char *val = values[i];
+
+ if (!unique || ril_config_list_find((char**)
+ newlist->pdata, newlist->len, val) < 0) {
+ /* Move the string to the new list */
+ g_ptr_array_add(newlist, val);
+ memmove(values + i, values + i + 1,
+ sizeof(char*) * (n - i));
+ i--;
+ n--;
+ }
+ }
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_config.h
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2017 Jolla Ltd.
+ * Copyright (C) 2015-2018 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,6 +22,8 @@
#define RILCONF_SETTINGS_GROUP "Settings"
+void ril_config_merge_files(GKeyFile *conf, const char *file);
+
char *ril_config_get_string(GKeyFile *file, const char *group,
const char *key);
char **ril_config_get_strings(GKeyFile *file, const char *group,
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_constants.h
^
|
@@ -1,10 +1,6 @@
/*
- * RIL constants adopted from AOSP's header:
- *
- * /hardware/ril/reference_ril/ril.h
- *
* Copyright (C) 2013 Canonical Ltd.
- * Copyright (C) 2013-2017 Jolla Ltd.
+ * Copyright (C) 2013-2018 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
@@ -19,80 +15,9 @@
#ifndef __RIL_CONSTANTS_H
#define __RIL_CONSTANTS_H 1
-#define RIL_MAX_UUID_LENGTH 64
+#include <ofono/ril-constants.h>
-/* Error Codes */
-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 {
- RIL_CALL_ACTIVE = 0,
- RIL_CALL_HOLDING = 1,
- RIL_CALL_DIALING = 2,
- RIL_CALL_ALERTING = 3,
- RIL_CALL_INCOMING = 4,
- RIL_CALL_WAITING = 5
-};
+#define RIL_MAX_UUID_LENGTH 64
/* Radio state */
enum ril_radio_state {
@@ -267,30 +192,30 @@
};
enum ril_data_call_fail_cause {
- PDP_FAIL_NONE = 0,
- PDP_FAIL_OPERATOR_BARRED = 0x08,
- PDP_FAIL_INSUFFICIENT_RESOURCES = 0x1A,
- PDP_FAIL_MISSING_UKNOWN_APN = 0x1B,
- PDP_FAIL_UNKNOWN_PDP_ADDRESS_TYPE = 0x1C,
- PDP_FAIL_USER_AUTHENTICATION = 0x1D,
- PDP_FAIL_ACTIVATION_REJECT_GGSN = 0x1E,
- PDP_FAIL_ACTIVATION_REJECT_UNSPECIFIED = 0x1F,
- PDP_FAIL_SERVICE_OPTION_NOT_SUPPORTED = 0x20,
- PDP_FAIL_SERVICE_OPTION_NOT_SUBSCRIBED = 0x21,
- PDP_FAIL_SERVICE_OPTION_OUT_OF_ORDER = 0x22,
- PDP_FAIL_NSAPI_IN_USE = 0x23,
- PDP_FAIL_REGULAR_DEACTIVATION = 0x24,
- PDP_FAIL_ONLY_IPV4_ALLOWED = 0x32,
- PDP_FAIL_ONLY_IPV6_ALLOWED = 0x33,
- PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED = 0x34,
- PDP_FAIL_PROTOCOL_ERRORS = 0x6F,
- PDP_FAIL_VOICE_REGISTRATION_FAIL = -1,
- PDP_FAIL_DATA_REGISTRATION_FAIL = -2,
- PDP_FAIL_SIGNAL_LOST = -3,
- PDP_FAIL_PREF_RADIO_TECH_CHANGED = -4,
- PDP_FAIL_RADIO_POWER_OFF = -5,
- PDP_FAIL_TETHERED_CALL_ACTIVE = -6,
- PDP_FAIL_ERROR_UNSPECIFIED = 0xffff
+ PDP_FAIL_NONE = 0,
+ PDP_FAIL_OPERATOR_BARRED = 0x08,
+ PDP_FAIL_INSUFFICIENT_RESOURCES = 0x1A,
+ PDP_FAIL_MISSING_UKNOWN_APN = 0x1B,
+ PDP_FAIL_UNKNOWN_PDP_ADDRESS_TYPE = 0x1C,
+ PDP_FAIL_USER_AUTHENTICATION = 0x1D,
+ PDP_FAIL_ACTIVATION_REJECT_GGSN = 0x1E,
+ PDP_FAIL_ACTIVATION_REJECT_UNSPECIFIED = 0x1F,
+ PDP_FAIL_SERVICE_OPTION_NOT_SUPPORTED = 0x20,
+ PDP_FAIL_SERVICE_OPTION_NOT_SUBSCRIBED = 0x21,
+ PDP_FAIL_SERVICE_OPTION_OUT_OF_ORDER = 0x22,
+ PDP_FAIL_NSAPI_IN_USE = 0x23,
+ PDP_FAIL_REGULAR_DEACTIVATION = 0x24,
+ PDP_FAIL_ONLY_IPV4_ALLOWED = 0x32,
+ PDP_FAIL_ONLY_IPV6_ALLOWED = 0x33,
+ PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED = 0x34,
+ PDP_FAIL_PROTOCOL_ERRORS = 0x6F,
+ PDP_FAIL_VOICE_REGISTRATION_FAIL = -1,
+ PDP_FAIL_DATA_REGISTRATION_FAIL = -2,
+ PDP_FAIL_SIGNAL_LOST = -3,
+ PDP_FAIL_PREF_RADIO_TECH_CHANGED = -4,
+ PDP_FAIL_RADIO_POWER_OFF = -5,
+ PDP_FAIL_TETHERED_CALL_ACTIVE = -6,
+ PDP_FAIL_ERROR_UNSPECIFIED = 0xffff
};
/* RIL_REQUEST_DEACTIVATE_DATA_CALL parameter */
@@ -395,191 +320,13 @@
RIL_CELL_INFO_TYPE_TD_SCDMA = 5
};
-/* RIL Request Messages, ofono -> rild */
-#define RIL_REQUEST_GET_SIM_STATUS 1
-#define RIL_REQUEST_ENTER_SIM_PIN 2
-#define RIL_REQUEST_ENTER_SIM_PUK 3
-#define RIL_REQUEST_ENTER_SIM_PIN2 4
-#define RIL_REQUEST_ENTER_SIM_PUK2 5
-#define RIL_REQUEST_CHANGE_SIM_PIN 6
-#define RIL_REQUEST_CHANGE_SIM_PIN2 7
-#define RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION 8
-#define RIL_REQUEST_GET_CURRENT_CALLS 9
-#define RIL_REQUEST_DIAL 10
-#define RIL_REQUEST_GET_IMSI 11
-#define RIL_REQUEST_HANGUP 12
-#define RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND 13
-#define RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND 14
-#define RIL_REQUEST_SWITCH_HOLDING_AND_ACTIVE 15
-#define RIL_REQUEST_CONFERENCE 16
-#define RIL_REQUEST_UDUB 17
-#define RIL_REQUEST_LAST_CALL_FAIL_CAUSE 18
-#define RIL_REQUEST_SIGNAL_STRENGTH 19
-#define RIL_REQUEST_VOICE_REGISTRATION_STATE 20
-#define RIL_REQUEST_DATA_REGISTRATION_STATE 21
-#define RIL_REQUEST_OPERATOR 22
-#define RIL_REQUEST_RADIO_POWER 23
-#define RIL_REQUEST_DTMF 24
-#define RIL_REQUEST_SEND_SMS 25
-#define RIL_REQUEST_SEND_SMS_EXPECT_MORE 26
-#define RIL_REQUEST_SETUP_DATA_CALL 27
-#define RIL_REQUEST_SIM_IO 28
-#define RIL_REQUEST_SEND_USSD 29
-#define RIL_REQUEST_CANCEL_USSD 30
-#define RIL_REQUEST_GET_CLIR 31
-#define RIL_REQUEST_SET_CLIR 32
-#define RIL_REQUEST_QUERY_CALL_FORWARD_STATUS 33
-#define RIL_REQUEST_SET_CALL_FORWARD 34
-#define RIL_REQUEST_QUERY_CALL_WAITING 35
-#define RIL_REQUEST_SET_CALL_WAITING 36
-#define RIL_REQUEST_SMS_ACKNOWLEDGE 37
-#define RIL_REQUEST_GET_IMEI 38
-#define RIL_REQUEST_GET_IMEISV 39
-#define RIL_REQUEST_ANSWER 40
-#define RIL_REQUEST_DEACTIVATE_DATA_CALL 41
-#define RIL_REQUEST_QUERY_FACILITY_LOCK 42
-#define RIL_REQUEST_SET_FACILITY_LOCK 43
-#define RIL_REQUEST_CHANGE_BARRING_PASSWORD 44
-#define RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE 45
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_data.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2016-2017 Jolla Ltd.
+ * Copyright (C) 2016-2018 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
@@ -34,6 +34,9 @@
#define PROTO_IPV6_STR "IPV6"
#define PROTO_IPV4V6_STR "IPV4V6"
+/* Yes, it does sometimes take minutes in roaming */
+#define SETUP_DATA_CALL_TIMEOUT (300*1000) /* ms */
+
enum ril_data_priv_flags {
RIL_DATA_FLAG_NONE = 0x00,
RIL_DATA_FLAG_ALLOWED = 0x01,
@@ -76,6 +79,12 @@
typedef GObjectClass RilDataClass;
typedef struct ril_data RilData;
+enum ril_data_io_event_id {
+ IO_EVENT_DATA_CALL_LIST_CHANGED,
+ IO_EVENT_RESTRICTED_STATE_CHANGED,
+ IO_EVENT_COUNT
+};
+
enum ril_data_settings_event_id {
SETTINGS_EVENT_IMSI_CHANGED,
SETTINGS_EVENT_PREF_MODE,
@@ -94,9 +103,11 @@
struct ril_radio *radio;
struct ril_network *network;
struct ril_data_manager *dm;
- enum ril_data_priv_flags flags;
struct ril_vendor_hook *vendor_hook;
+ enum ril_data_priv_flags flags;
+ enum ril_restricted_state restricted_state;
+
struct ril_data_request *req_queue;
struct ril_data_request *pending_req;
@@ -104,8 +115,9 @@
guint slot;
char *log_prefix;
guint query_id;
- gulong io_event_id;
+ gulong io_event_id[IO_EVENT_COUNT];
gulong settings_event_id[SETTINGS_EVENT_COUNT];
+ GHashTable* grab;
};
enum ril_data_signal {
@@ -177,7 +189,7 @@
static void ril_data_manager_check_data(struct ril_data_manager *dm);
static void ril_data_manager_check_network_mode(struct ril_data_manager *dm);
-
+static void ril_data_call_deact_cid(struct ril_data *data, int cid);
static void ril_data_power_update(struct ril_data *self);
static void ril_data_signal_emit(struct ril_data *self, enum ril_data_signal id)
{
@@ -360,7 +372,8 @@
/* Try the default parser */
ril_data_call_destroy(call);
memset(call, 0, sizeof(*call));
- parsed = ril_data_call_parse_default(call, version, ©);
+ *parser = copy;
+ parsed = ril_data_call_parse_default(call, version, parser);
}
if (parsed) {
@@ -386,7 +399,7 @@
guint len, struct ril_vendor_hook *hook,
enum ril_data_call_format format)
{
- guint32 version, n;
+ guint32 version, n, i;
GRilIoParser rilp;
grilio_parser_init(&rilp, data, len);
@@ -403,22 +416,14 @@
list->version = format;
}
- if (n > 0) {
- guint i, clen = grilio_parser_bytes_remaining(&rilp)/n;
-
- for (i = 0; i < n; i++) {
- GRilIoParser callp;
- struct ril_data_call *call;
-
- grilio_parser_get_data(&rilp, &callp, clen);
- call = ril_data_call_parse(hook, list->version,
- &callp);
- if (call) {
- list->num++;
- list->calls = g_slist_insert_sorted
- (list->calls, call,
- ril_data_call_compare);
- }
+ for (i = 0; i < n && !grilio_parser_at_end(&rilp); i++) {
+ struct ril_data_call *call = ril_data_call_parse(hook,
+ list->version, &rilp);
+
+ if (call) {
+ list->num++;
+ list->calls = g_slist_insert_sorted(list->calls,
+ call, ril_data_call_compare);
}
}
@@ -544,6 +549,10 @@
static void ril_data_set_calls(struct ril_data *self,
struct ril_data_call_list *list)
{
+ struct ril_data_priv *priv = self->priv;
+ GHashTableIter it;
+ gpointer key;
+
if (!ril_data_call_list_equal(self->data_calls, list)) {
DBG("data calls changed");
ril_data_call_list_free(self->data_calls);
@@ -552,6 +561,63 @@
} else {
ril_data_call_list_free(list);
}
+
+ /* Clean up the grab table */
+ g_hash_table_iter_init(&it, priv->grab);
+ while (g_hash_table_iter_next(&it, &key, NULL)) {
+ const int cid = GPOINTER_TO_INT(key);
+
+ if (!ril_data_call_find(self->data_calls, cid)) {
+ g_hash_table_iter_remove(&it);
+ }
+ }
+
+ if (self->data_calls) {
+ GSList *l;
+
+ /* Disconnect stray calls (one at a time) */
+ for (l = self->data_calls->calls; l; l = l->next) {
+ struct ril_data_call *dc = l->data;
+
+ key = GINT_TO_POINTER(dc->cid);
+ if (!g_hash_table_contains(priv->grab, key)) {
+ DBG_(self, "stray call %u", dc->cid);
+ ril_data_call_deact_cid(self, dc->cid);
+ break;
+ }
+ }
+ }
+}
+
+static void ril_data_check_allowed(struct ril_data *self, gboolean was_allowed)
+{
+ if (ril_data_allowed(self) != was_allowed) {
+ ril_data_signal_emit(self, SIGNAL_ALLOW_CHANGED);
+ }
+}
+
+static void ril_data_restricted_state_changed_cb(GRilIoChannel *io, guint event,
+ const void *data, guint len, void *user_data)
+{
+ struct ril_data *self = RIL_DATA(user_data);
+ GRilIoParser rilp;
+ guint32 count, state;
+
+ GASSERT(event == RIL_UNSOL_RESTRICTED_STATE_CHANGED);
+ grilio_parser_init(&rilp, data, len);
+ if (grilio_parser_get_uint32(&rilp, &count) && count == 1 &&
+ grilio_parser_get_uint32(&rilp, &state) &&
+ grilio_parser_at_end(&rilp)) {
+ struct ril_data_priv *priv = self->priv;
+
+ if (priv->restricted_state != state) {
+ const gboolean was_allowed = ril_data_allowed(self);
+
+ DBG_(self, "restricted state 0x%02x", state);
+ priv->restricted_state = state;
+ ril_data_check_allowed(self, was_allowed);
+ }
+ }
}
static void ril_data_call_list_changed_cb(GRilIoChannel *io, guint event,
@@ -915,6 +981,7 @@
}
GASSERT(!req->pending_id);
+ grilio_request_set_timeout(ioreq, SETUP_DATA_CALL_TIMEOUT);
req->pending_id = grilio_queue_send_request_full(priv->q, ioreq,
RIL_REQUEST_SETUP_DATA_CALL, ril_data_call_setup_cb,
NULL, setup);
@@ -1051,6 +1118,11 @@
return req;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_data.h
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2016-2017 Jolla Ltd.
+ * Copyright (C) 2016-2018 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,8 +17,11 @@
#define RIL_DATA_H
#include "ril_types.h"
+
#include <ofono/gprs-context.h>
+#include <glib-object.h>
+
enum ril_data_call_active {
RIL_DATA_CALL_INACTIVE = 0,
RIL_DATA_CALL_LINK_DOWN = 1,
@@ -120,6 +123,9 @@
void ril_data_request_detach(struct ril_data_request *req);
void ril_data_request_cancel(struct ril_data_request *req);
+gboolean ril_data_call_grab(struct ril_data *data, int cid, void *cookie);
+void ril_data_call_release(struct ril_data *data, int cid, void *cookie);
+
void ril_data_call_free(struct ril_data_call *call);
struct ril_data_call *ril_data_call_dup(const struct ril_data_call *call);
struct ril_data_call *ril_data_call_find(struct ril_data_call_list *list,
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_ecclist.h
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2016 Jolla Ltd.
+ * Copyright (C) 2016-2018 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,6 +18,8 @@
#include "ril_types.h"
+#include <glib-object.h>
+
struct ril_ecclist_priv;
struct ril_ecclist {
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_gprs_context.c
^
|
@@ -88,6 +88,7 @@
static void ril_gprs_context_free_active_call(struct ril_gprs_context *gcd)
{
if (gcd->active_call) {
+ ril_data_call_release(gcd->data, gcd->active_call->cid, gcd);
ril_data_call_free(gcd->active_call);
gcd->active_call = NULL;
}
@@ -111,6 +112,7 @@
gcd->mtu_watch = mtu_watch_new(MAX_MTU);
}
mtu_watch_set_ifname(gcd->mtu_watch, call->ifname);
+ ril_data_call_grab(gcd->data, call->cid, gcd);
} else {
ril_gprs_context_free_active_call(gcd);
}
@@ -396,6 +398,8 @@
if (ril_status != RIL_E_SUCCESS) {
ofono_error("GPRS context: Reply failure: %s",
ril_error_to_string(ril_status));
+ } else if (!call) {
+ ofono_error("Unexpected data call failure");
} else if (call->status != PDP_FAIL_NONE) {
ofono_error("Unexpected data call status %d", call->status);
error.type = OFONO_ERROR_TYPE_CMS;
@@ -478,24 +482,23 @@
* invoked and gcd->deactivate.req will be NULL.
*/
if (gcd->deactivate.req) {
- struct ofono_error error;
ofono_gprs_context_cb_t cb = gcd->deactivate.cb;
gpointer cb_data = gcd->deactivate.data;
if (ril_status == RIL_E_SUCCESS) {
GASSERT(gcd->active_call);
- ril_error_init_ok(&error);
ofono_info("Deactivated data call");
} else {
- ril_error_init_failure(&error);
ofono_error("Deactivate failure: %s",
ril_error_to_string(ril_status));
}
memset(&gcd->deactivate, 0, sizeof(gcd->deactivate));
if (cb) {
+ struct ofono_error error;
+
ril_gprs_context_free_active_call(gcd);
- cb(&error, cb_data);
+ cb(ril_error_ok(&error), cb_data);
return;
}
}
@@ -509,7 +512,7 @@
{
struct ril_gprs_context *gcd = ril_gprs_context_get_data(gc);
- GASSERT(gcd->active_call && gcd->active_ctx_cid == id);
+ GASSERT(gcd->active_ctx_cid == id);
ofono_info("Deactivating context: %u", id);
if (gcd->active_call && gcd->active_ctx_cid == id) {
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_modem.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2018 Jolla Ltd.
+ * Copyright (C) 2015-2019 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
@@ -25,7 +25,7 @@
#include "ofono.h"
-#include "sailfish_watch.h"
+#include <ofono/watch.h>
#define MAX_PDP_CONTEXTS (2)
#define ONLINE_TIMEOUT_SECS (15) /* 20 sec is hardcoded in ofono core */
@@ -52,7 +52,7 @@
struct ril_modem_data {
struct ril_modem modem;
- struct sailfish_watch *watch;
+ struct ofono_watch *watch;
GRilIoQueue *q;
char *log_prefix;
char *imeisv;
@@ -234,7 +234,7 @@
ril_modem_update_online_state(md);
}
-static void ril_modem_imsi_cb(struct sailfish_watch *watch, void *data)
+static void ril_modem_imsi_cb(struct ofono_watch *watch, void *data)
{
struct ril_modem_data *md = data;
@@ -374,8 +374,8 @@
ril_radio_unref(modem->radio);
ril_sim_settings_unref(modem->sim_settings);
- sailfish_watch_remove_handler(md->watch, md->imsi_event_id);
- sailfish_watch_unref(md->watch);
+ ofono_watch_remove_handler(md->watch, md->imsi_event_id);
+ ofono_watch_unref(md->watch);
if (md->online_check_id) {
g_source_remove(md->online_check_id);
@@ -443,10 +443,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);
+ md->watch = ofono_watch_new(path);
md->imsi_event_id =
- sailfish_watch_add_imsi_changed_handler(md->watch,
+ ofono_watch_add_imsi_changed_handler(md->watch,
ril_modem_imsi_cb, md);
md->set_online.md = md;
@@ -454,8 +454,10 @@
ofono_modem_set_data(ofono, md);
err = ofono_modem_register(ofono);
if (!err) {
- ril_radio_power_cycle(modem->radio);
GASSERT(io->connected);
+ if (config->radio_power_cycle) {
+ ril_radio_power_cycle(modem->radio);
+ }
/*
* ofono_modem_reset sets Powered to TRUE without
@@ -468,11 +470,12 @@
/*
* With some RIL implementations, querying available
* band modes causes some magic Android properties to
- * appear. Otherwise this request is pretty harmless
- * and useless.
+ * appear.
*/
- grilio_queue_send_request(md->q, NULL,
- RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
+ if (config->query_available_band_mode) {
+ grilio_queue_send_request(md->q, NULL,
+ RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
+ }
ril_modem_update_radio_settings(md);
return modem;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_netreg.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2016 Jolla Ltd.
+ * Copyright (C) 2015-2019 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
@@ -21,6 +21,9 @@
#include "common.h"
#include "simutil.h"
+#define REGISTRATION_TIMEOUT (100*1000) /* ms */
+#define REGISTRATION_MAX_RETRIES (2)
+
enum ril_netreg_events {
NETREG_RIL_EVENT_NITZ_TIME_RECEIVED,
NETREG_RIL_EVENT_SIGNAL_STRENGTH,
@@ -36,6 +39,7 @@
struct ril_netreg {
GRilIoChannel *io;
GRilIoQueue *q;
+ gboolean network_selection_manual_0;
struct ofono_netreg *netreg;
struct ril_network *network;
char *log_prefix;
@@ -61,6 +65,8 @@
#define ril_netreg_cbd_free g_free
+#define DBG_(nd,fmt,args...) DBG("%s" fmt, (nd)->log_prefix, ##args)
+
static inline struct ril_netreg *ril_netreg_get_data(struct ofono_netreg *ofono)
{
return ofono ? ofono_netreg_get_data(ofono) : NULL;
@@ -109,7 +115,7 @@
struct ril_netreg *nd = user_data;
const struct ril_registration_state *reg = &nd->network->voice;
- DBG("%s", nd->log_prefix);
+ DBG_(nd, "");
GASSERT(nd->notify_id);
nd->notify_id = 0;
ofono_netreg_status_notify(nd->netreg,
@@ -124,9 +130,9 @@
/* Coalesce multiple notifications into one */
if (nd->notify_id) {
- DBG("%snotification aready queued", nd->log_prefix);
+ DBG_(nd, "notification aready queued");
} else {
- DBG("%squeuing notification", nd->log_prefix);
+ DBG_(nd, "queuing notification");
nd->notify_id = g_idle_add(ril_netreg_status_notify_cb, nd);
}
}
@@ -138,7 +144,7 @@
const struct ril_registration_state *reg = &nd->network->voice;
struct ofono_error error;
- DBG("%s", nd->log_prefix);
+ DBG_(nd, "");
cb(ril_error_ok(&error),
ril_netreg_check_status(nd, reg->status),
reg->lac, reg->ci, reg->access_tech, data);
@@ -151,7 +157,7 @@
ofono_netreg_operator_cb_t cb = cbd->cb.operator;
struct ofono_error error;
- DBG("%s", nd->log_prefix);
+ DBG_(nd, "");
GASSERT(nd->current_operator_id);
nd->current_operator_id = 0;
@@ -294,12 +300,16 @@
ofono_netreg_register_cb_t cb, void *data)
{
struct ril_netreg *nd = ril_netreg_get_data(netreg);
+ GRilIoRequest *req = grilio_request_new();
ofono_info("nw select automatic");
- grilio_queue_send_request_full(nd->q, NULL,
+ grilio_request_set_timeout(req, REGISTRATION_TIMEOUT);
+ grilio_request_set_retry(req, 0, REGISTRATION_MAX_RETRIES);
+ grilio_queue_send_request_full(nd->q, req,
RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC,
ril_netreg_register_cb, ril_netreg_cbd_free,
ril_netreg_cbd_new(nd, cb, data));
+ grilio_request_unref(req);
}
static void ril_netreg_register_manual(struct ofono_netreg *netreg,
@@ -308,9 +318,12 @@
{
struct ril_netreg *nd = ril_netreg_get_data(netreg);
GRilIoRequest *req = grilio_request_new();
+ const char *suffix = nd->network_selection_manual_0 ? "+0" : "";
- ofono_info("nw select manual: %s%s", mcc, mnc);
- grilio_request_append_format(req, "%s%s+0", mcc, mnc);
+ ofono_info("nw select manual: %s%s%s", mcc, mnc, suffix);
+ grilio_request_append_format(req, "%s%s%s", mcc, mnc, suffix);
+ grilio_request_set_timeout(req, REGISTRATION_TIMEOUT);
+ grilio_request_set_retry(req, 0, REGISTRATION_MAX_RETRIES);
grilio_queue_send_request_full(nd->q, req,
RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
ril_netreg_register_cb, ril_netreg_cbd_free,
@@ -318,14 +331,24 @@
grilio_request_unref(req);
}
+static int ril_netreg_dbm_to_percentage(int dbm)
+{
+ const int min_dbm = -100; /* very weak signal, 0.0000000001 mW */
+ const int max_dbm = -60; /* strong signal, 0.000001 mW */
+
+ return (dbm <= min_dbm) ? 1 :
+ (dbm >= max_dbm) ? 100 :
+ (100 * (dbm - min_dbm) / (max_dbm - min_dbm));
+}
+
static int ril_netreg_get_signal_strength(const void *data, guint len)
{
GRilIoParser rilp;
int gw_signal = 0, cdma_dbm = 0, evdo_dbm = 0, lte_signal = 0;
+ int rsrp = 0, tdscdma_dbm = 0;
grilio_parser_init(&rilp, data, len);
- /* RIL_SignalStrength_v6 */
/* GW_SignalStrength */
grilio_parser_get_int32(&rilp, &gw_signal);
grilio_parser_get_int32(&rilp, NULL); /* bitErrorRate */
@@ -341,23 +364,57 @@
/* LTE_SignalStrength */
grilio_parser_get_int32(&rilp, <e_signal);
- grilio_parser_get_int32(&rilp, NULL); /* rsrp */
- grilio_parser_get_int32(&rilp, NULL); /* rsrq */
- grilio_parser_get_int32(&rilp, NULL); /* rssnr */
- grilio_parser_get_int32(&rilp, NULL); /* cqi */
+ grilio_parser_get_int32(&rilp, &rsrp);
- DBG("gw: %d, cdma: %d, evdo: %d, lte: %d", gw_signal, cdma_dbm,
- evdo_dbm, lte_signal);
+ /* Skip the rest of LTE_SignalStrength_v8 */
+ if (grilio_parser_get_int32(&rilp, NULL) && /* rsrq */
+ grilio_parser_get_int32(&rilp, NULL) && /* rssnr */
+ grilio_parser_get_int32(&rilp, NULL) && /* cqi */
+ grilio_parser_get_int32(&rilp, NULL)) { /* timingAdvance */
+
+ /* TD_SCDMA_SignalStrength */
+ grilio_parser_get_int32(&rilp, &tdscdma_dbm); /* rscp */
+ }
+
+ if (rsrp == INT_MAX) {
+ DBG("gw: %d, cdma: %d, evdo: %d, lte: %d, tdscdma: %d",
+ gw_signal, cdma_dbm, evdo_dbm,
+ lte_signal, tdscdma_dbm);
+ } else {
+ DBG("gw: %d, cdma: %d, evdo: %d, lte: %d rsrp: %d, tdscdma: %d",
+ gw_signal, cdma_dbm, evdo_dbm,
+ lte_signal, rsrp, tdscdma_dbm);
+ }
/* Return the first valid one */
- if (gw_signal != 99 && gw_signal != -1) {
+
+ /* Some RILs (namely, from MediaTek) report 0 here AND a valid LTE
+ * RSRP value. If we've got zero, don't report it just yet. */
+ if (gw_signal >= 1 && gw_signal <= 31) {
+ /* Valid values are (0-31, 99) as defined in TS 27.007 */
return (gw_signal * 100) / 31;
}
- if (lte_signal != 99 && lte_signal != -1) {
+ /* Valid values are (0-31, 99) as defined in TS 27.007 */
+ if (lte_signal >= 0 && lte_signal <= 31) {
return (lte_signal * 100) / 31;
}
+ /* RSCP range: 25 to 120 dBm as defined in 3GPP TS 25.123 */
+ if (tdscdma_dbm >= 25 && tdscdma_dbm <= 120) {
+ return ril_netreg_dbm_to_percentage(-tdscdma_dbm);
+ }
+
+ /* RSRP range: 44 to 140 dBm as defined in 3GPP TS 36.133 */
+ if (lte_signal == 99 && rsrp >= 44 && rsrp <= 140) {
+ return ril_netreg_dbm_to_percentage(-rsrp);
+ }
+
+ /* If we've got zero strength and no valid RSRP, then so be it */
+ if (gw_signal == 0) {
+ return 0;
+ }
+
/* In case of dbm, return the value directly */
if (cdma_dbm != -1) {
return MIN(cdma_dbm, 100);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_network.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2018 Jolla Ltd.
+ * Copyright (C) 2015-2019 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
@@ -47,6 +47,12 @@
RADIO_EVENT_COUNT
};
+enum ril_network_sim_events {
+ SIM_EVENT_STATUS_CHANGED,
+ SIM_EVENT_IO_ACTIVE_CHANGED,
+ SIM_EVENT_COUNT
+};
+
enum ril_network_unsol_event {
UNSOL_EVENT_NETWORK_STATE,
UNSOL_EVENT_RADIO_CAPABILITY,
@@ -57,8 +63,11 @@
GRilIoChannel *io;
GRilIoQueue *q;
struct ril_radio *radio;
- struct ril_sim_card *sim_card;
+ struct ril_sim_card *simcard;
int rat;
+ enum ril_pref_net_type lte_network_mode;
+ enum ril_pref_net_type umts_network_mode;
+ int network_mode_timeout;
char *log_prefix;
guint operator_poll_id;
guint voice_poll_id;
@@ -68,8 +77,8 @@
gulong set_rat_id;
gulong unsol_event_id[UNSOL_EVENT_COUNT];
gulong settings_event_id;
- gulong sim_status_event_id;
gulong radio_event_id[RADIO_EVENT_COUNT];
+ gulong simcard_event_id[SIM_EVENT_COUNT];
struct ofono_network_operator operator;
gboolean assert_rat;
};
@@ -111,7 +120,8 @@
G_STATIC_ASSERT(OFONO_RADIO_ACCESS_MODE_LTE > OFONO_RADIO_ACCESS_MODE_UMTS);
static void ril_network_query_pref_mode(struct ril_network *self);
-static void ril_network_set_pref_mode(struct ril_network *self, int rat);
+static void ril_network_check_pref_mode(struct ril_network *self,
+ gboolean immediate);
static void ril_network_emit(struct ril_network *self,
enum ril_network_signal sig)
@@ -208,11 +218,11 @@
reg->max_calls = 2;
}
- if (!ril_parse_int(slac, 16, ®->lac)) {
+ if (!gutil_parse_int(slac, 16, ®->lac)) {
reg->lac = -1;
}
- if (!ril_parse_int(sci, 16, ®->ci)) {
+ if (!gutil_parse_int(sci, 16, ®->ci)) {
reg->ci = -1;
}
@@ -444,17 +454,20 @@
static int ril_network_mode_to_rat(struct ril_network *self,
enum ofono_radio_access_mode mode)
{
+ struct ril_sim_settings *settings = self->settings;
+ struct ril_network_priv *priv = self->priv;
+
switch (mode) {
case OFONO_RADIO_ACCESS_MODE_ANY:
case OFONO_RADIO_ACCESS_MODE_LTE:
- if (self->settings->techs & OFONO_RADIO_ACCESS_MODE_LTE) {
- return PREF_NET_TYPE_LTE_GSM_WCDMA;
+ if (settings->techs & OFONO_RADIO_ACCESS_MODE_LTE) {
+ return priv->lte_network_mode;
}
/* no break */
default:
case OFONO_RADIO_ACCESS_MODE_UMTS:
- if (self->settings->techs & OFONO_RADIO_ACCESS_MODE_UMTS) {
- return PREF_NET_TYPE_GSM_WCDMA_AUTO;
+ if (settings->techs & OFONO_RADIO_ACCESS_MODE_UMTS) {
+ return priv->umts_network_mode;
}
/* no break */
case OFONO_RADIO_ACCESS_MODE_GSM:
@@ -497,37 +510,28 @@
{
struct ril_network_priv *priv = self->priv;
- return priv->radio->online && ril_sim_card_ready(priv->sim_card);
+ /*
+ * With some modems an attempt to set rat significantly slows
+ * down SIM I/O, let's avoid that.
+ */
+ return priv->radio->online && ril_sim_card_ready(priv->simcard) &&
+ !priv->simcard->sim_io_active &&
+ !priv->timer[TIMER_SET_RAT_HOLDOFF] ;
}
static gboolean ril_network_set_rat_holdoff_cb(gpointer user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
struct ril_network_priv *priv = self->priv;
- const int rat = ril_network_pref_mode_expected(self);
- DBG_(self, "rat mode %d, expected %d", priv->rat, rat);
GASSERT(priv->timer[TIMER_SET_RAT_HOLDOFF]);
priv->timer[TIMER_SET_RAT_HOLDOFF] = 0;
- /*
- * Don't retry the request if modem is offline or SIM card isn't
- * ready, to avoid spamming system log with error messages. Radio
- * and SIM card state change callbacks will schedule a new check
- * when it's appropriate.
- */
- if (priv->rat != rat || priv->assert_rat) {
- if (ril_network_can_set_pref_mode(self)) {
- ril_network_set_pref_mode(self, rat);
- } else {
- DBG_(self, "giving up");
- }
- }
-
+ ril_network_check_pref_mode(self, FALSE);
return G_SOURCE_REMOVE;
}
-static void ril_network_set_pref_mode_cb(GRilIoChannel *io, int status,
+static void ril_network_set_rat_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
@@ -542,33 +546,53 @@
ril_network_query_pref_mode(self);
}
-static void ril_network_set_pref_mode(struct ril_network *self, int rat)
+static void ril_network_set_rat(struct ril_network *self, int rat)
{
struct ril_network_priv *priv = self->priv;
- GRilIoRequest *req = grilio_request_sized_new(8);
- DBG_(self, "setting rat mode %d", rat);
- grilio_request_append_int32(req, 1); /* Number of params */
- grilio_request_append_int32(req, rat);
-
- grilio_queue_cancel_request(priv->q, priv->set_rat_id, FALSE);
- priv->set_rat_id = grilio_queue_send_request_full(priv->q, req,
- RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE,
- ril_network_set_pref_mode_cb, NULL, self);
- grilio_request_unref(req);
+ if (!priv->set_rat_id && priv->radio->online &&
+ ril_sim_card_ready(priv->simcard) &&
+ /*
+ * With some modems an attempt to set rat significantly
+ * slows down SIM I/O, let's avoid that.
+ */
+ !priv->simcard->sim_io_active &&
+ !priv->timer[TIMER_SET_RAT_HOLDOFF]) {
+ GRilIoRequest *req = grilio_request_sized_new(8);
+
+ DBG_(self, "setting rat mode %d", rat);
+ grilio_request_append_int32(req, 1); /* count */
+ grilio_request_append_int32(req, rat);
+
+ grilio_request_set_timeout(req, priv->network_mode_timeout);
+ priv->set_rat_id = grilio_queue_send_request_full(priv->q, req,
+ RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE,
+ ril_network_set_rat_cb, NULL, self);
+ grilio_request_unref(req);
+
+ /* We have submitted the request, clear the assertion flag */
+ priv->assert_rat = FALSE;
+
+ /* And don't do it too often */
+ priv->timer[TIMER_SET_RAT_HOLDOFF] =
+ g_timeout_add_seconds(SET_PREF_MODE_HOLDOFF_SEC,
+ ril_network_set_rat_holdoff_cb, self);
+ } else {
+ DBG_(self, "need to set rat mode %d", rat);
+ }
+}
- /* We have submitted the request, clear the assertion flag */
- priv->assert_rat = FALSE;
+static void ril_network_set_pref_mode(struct ril_network *self, int rat)
+{
+ struct ril_network_priv *priv = self->priv;
- /* Don't do it too often */
- GASSERT(!priv->timer[TIMER_SET_RAT_HOLDOFF]);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_network.h
^
|
@@ -18,6 +18,8 @@
#include "ril_types.h"
+#include <glib-object.h>
+
struct ofono_network_operator;
struct ril_registration_state {
@@ -46,7 +48,8 @@
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_sim_settings *settings,
+ const struct ril_slot_config *ril_slot_config);
struct ril_network *ril_network_ref(struct ril_network *net);
void ril_network_unref(struct ril_network *net);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_plugin.c
^
|
@@ -1,8 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2018 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2019 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,11 +26,14 @@
#include "ril_vendor.h"
#include "ril_log.h"
-#include <sailfish_manager.h>
-#include <sailfish_watch.h>
+#include <ofono/sailfish_manager.h>
+#include <ofono/watch.h>
+
+#include <grilio_transport.h>
#include <gutil_ints.h>
#include <gutil_macros.h>
+#include <gutil_misc.h>
#include <mce_display.h>
#include <mce_log.h>
@@ -48,6 +50,7 @@
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
#include <ofono/storage.h>
+#include <ofono/ril-transport.h>
#define OFONO_RADIO_ACCESS_MODE_ALL (OFONO_RADIO_ACCESS_MODE_GSM |\
OFONO_RADIO_ACCESS_MODE_UMTS |\
@@ -63,6 +66,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_LTE_MODE PREF_NET_TYPE_LTE_GSM_WCDMA
+#define RILMODEM_DEFAULT_UMTS_MODE PREF_NET_TYPE_GSM_WCDMA_AUTO
+#define RILMODEM_DEFAULT_NETWORK_MODE_TIMEOUT (20*1000) /* ms */
#define RILMODEM_DEFAULT_ENABLE_VOICECALL TRUE
#define RILMODEM_DEFAULT_ENABLE_CBS TRUE
#define RILMODEM_DEFAULT_SLOT 0xffffffff
@@ -75,7 +81,18 @@
#define RILMODEM_DEFAULT_DATA_CALL_RETRY_LIMIT 4
#define RILMODEM_DEFAULT_DATA_CALL_RETRY_DELAY 200 /* ms */
#define RILMODEM_DEFAULT_EMPTY_PIN_QUERY TRUE /* optimistic */
+#define RILMODEM_DEFAULT_QUERY_AVAILABLE_BAND_MODE TRUE /* Qualcomm */
#define RILMODEM_DEFAULT_LEGACY_IMEI_QUERY FALSE
+#define RILMODEM_DEFAULT_RADIO_POWER_CYCLE TRUE
+#define RILMODEM_DEFAULT_CONFIRM_RADIO_POWER_ON TRUE
+#define RILMODEM_DEFAULT_NETWORK_SELECTION_MANUAL_0 TRUE
+#define RILMODEM_DEFAULT_SLOT_FLAGS SAILFISH_SLOT_NO_FLAGS
+
+/* RIL socket transport name and parameters */
+#define RIL_TRANSPORT_MODEM "modem"
+#define RIL_TRANSPORT_SOCKET "socket"
+#define RIL_TRANSPORT_SOCKET_PATH "path"
+#define RIL_TRANSPORT_SOCKET_SUB "sub"
/*
* The convention is that the keys which can only appear in the [Settings]
@@ -83,38 +100,46 @@
* modem section (OR in the [Settings] if they apply to all modems) start
* with lower case.
*/
-#define RILCONF_SETTINGS_EMPTY "EmptyConfig"
-#define RILCONF_SETTINGS_IDENTITY "Identity"
-#define RILCONF_SETTINGS_3GHANDOVER "3GLTEHandover"
-#define RILCONF_SETTINGS_SET_RADIO_CAP "SetRadioCapability"
-
-#define RILCONF_DEV_PREFIX "ril_"
-#define RILCONF_PATH_PREFIX "/" RILCONF_DEV_PREFIX
-#define RILCONF_NAME "name"
-#define RILCONF_SOCKET "socket"
-#define RILCONF_SLOT "slot"
-#define RILCONF_SUB "sub"
-#define RILCONF_START_TIMEOUT "startTimeout"
-#define RILCONF_TIMEOUT "timeout"
-#define RILCONF_4G "enable4G" /* Deprecated */
-#define RILCONF_ENABLE_VOICECALL "enableVoicecall"
-#define RILCONF_ENABLE_CBS "enableCellBroadcast"
-#define RILCONF_TECHNOLOGIES "technologies"
-#define RILCONF_UICC_WORKAROUND "uiccWorkaround"
-#define RILCONF_ECCLIST_FILE "ecclistFile"
-#define RILCONF_ALLOW_DATA_REQ "allowDataReq"
-#define RILCONF_EMPTY_PIN_QUERY "emptyPinQuery"
-#define RILCONF_DATA_CALL_FORMAT "dataCallFormat"
-#define RILCONF_VENDOR_DRIVER "vendorDriver"
-#define RILCONF_DATA_CALL_RETRY_LIMIT "dataCallRetryLimit"
-#define RILCONF_DATA_CALL_RETRY_DELAY "dataCallRetryDelay"
-#define RILCONF_LOCAL_HANGUP_REASONS "localHangupReasons"
-#define RILCONF_REMOTE_HANGUP_REASONS "remoteHangupReasons"
-#define RILCONF_DEFAULT_LEGACY_IMEI_QUERY "legacyImeiQuery"
+#define RILCONF_SETTINGS_EMPTY "EmptyConfig"
+#define RILCONF_SETTINGS_IDENTITY "Identity"
+#define RILCONF_SETTINGS_3GHANDOVER "3GLTEHandover"
+#define RILCONF_SETTINGS_SET_RADIO_CAP "SetRadioCapability"
+
+#define RILCONF_MODEM_PREFIX "ril_"
+#define RILCONF_PATH_PREFIX "/" RILCONF_MODEM_PREFIX
+#define RILCONF_TRANSPORT "transport"
+#define RILCONF_NAME "name"
+#define RILCONF_SOCKET "socket"
+#define RILCONF_SLOT "slot"
+#define RILCONF_SUB "sub"
+#define RILCONF_START_TIMEOUT "startTimeout"
+#define RILCONF_TIMEOUT "timeout"
+#define RILCONF_4G "enable4G" /* Deprecated */
+#define RILCONF_ENABLE_VOICECALL "enableVoicecall"
+#define RILCONF_ENABLE_CBS "enableCellBroadcast"
+#define RILCONF_TECHNOLOGIES "technologies"
+#define RILCONF_LTE_MODE "lteNetworkMode"
+#define RILCONF_UMTS_MODE "umtsNetworkMode"
+#define RILCONF_NETWORK_MODE_TIMEOUT "networkModeTimeout"
+#define RILCONF_UICC_WORKAROUND "uiccWorkaround"
+#define RILCONF_ECCLIST_FILE "ecclistFile"
+#define RILCONF_ALLOW_DATA_REQ "allowDataReq"
+#define RILCONF_EMPTY_PIN_QUERY "emptyPinQuery"
+#define RILCONF_DATA_CALL_FORMAT "dataCallFormat"
+#define RILCONF_VENDOR_DRIVER "vendorDriver"
+#define RILCONF_DATA_CALL_RETRY_LIMIT "dataCallRetryLimit"
+#define RILCONF_DATA_CALL_RETRY_DELAY "dataCallRetryDelay"
+#define RILCONF_LOCAL_HANGUP_REASONS "localHangupReasons"
+#define RILCONF_REMOTE_HANGUP_REASONS "remoteHangupReasons"
+#define RILCONF_LEGACY_IMEI_QUERY "legacyImeiQuery"
+#define RILCONF_RADIO_POWER_CYCLE "radioPowerCycle"
+#define RILCONF_CONFIRM_RADIO_POWER_ON "confirmRadioPowerOn"
+#define RILCONF_SINGLE_DATA_CONTEXT "singleDataContext"
+#define RILCONF_NETWORK_SELECTION_MANUAL_0 "networkSelectionManual0"
/* Modem error ids */
-#define RIL_ERROR_ID_RILD_RESTART "rild-restart"
-#define RIL_ERROR_ID_CAPS_SWITCH_ABORTED "ril-caps-switch-aborted"
+#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,
@@ -167,14 +192,14 @@
ril_plugin* plugin;
struct sailfish_slot *handle;
struct sailfish_cell_info *cell_info;
- struct sailfish_watch *watch;
+ struct ofono_watch *watch;
gulong watch_event_id[WATCH_EVENT_COUNT];
char *path;
char *imei;
char *imeisv;
char *name;
- char *sockpath;
- char *sub;
+ char *transport_name;
+ GHashTable *transport_params;
char *ecclist_file;
int timeout; /* RIL timeout, in milliseconds */
int index;
@@ -192,6 +217,7 @@
struct ril_vendor_hook *vendor_hook;
struct ril_data *data;
gboolean legacy_imei_query;
+ enum sailfish_slot_flags slot_flags;
guint start_timeout;
guint start_timeout_id;
MceDisplay *display;
@@ -963,10 +989,12 @@
slot->radio = ril_radio_new(slot->io);
GASSERT(!slot->io_event_id[IO_EVENT_RADIO_STATE_CHANGED]);
- slot->io_event_id[IO_EVENT_RADIO_STATE_CHANGED] =
- grilio_channel_add_unsol_event_handler(slot->io,
+ if (slot->config.confirm_radio_power_on) {
+ slot->io_event_id[IO_EVENT_RADIO_STATE_CHANGED] =
+ grilio_channel_add_unsol_event_handler(slot->io,
ril_plugin_radio_state_changed,
RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, slot);
+ }
GASSERT(!slot->sim_card);
slot->sim_card = ril_sim_card_new(slot->io, slot->config.slot,
@@ -980,7 +1008,8 @@
GASSERT(!slot->network);
slot->network = ril_network_new(slot->path, slot->io, log_prefix,
- slot->radio, slot->sim_card, slot->sim_settings);
+ slot->radio, slot->sim_card, slot->sim_settings,
+ &slot->config);
GASSERT(!slot->vendor_hook);
slot->vendor_hook = ril_vendor_create_hook(slot->vendor, slot->io,
@@ -1017,9 +1046,10 @@
slot->start_timeout_id = 0;
/* Register this slot with the sailfish manager plugin */
- slot->handle = sailfish_manager_slot_add(plugin->handle, slot,
+ slot->handle = sailfish_manager_slot_add2(plugin->handle, slot,
slot->path, slot->config.techs, slot->imei,
- slot->imeisv, ril_plugin_sim_state(slot));
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_radio.c
^
|
@@ -71,14 +71,16 @@
#define RIL_RADIO_TYPE (ril_radio_get_type())
#define RIL_RADIO(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj,RIL_RADIO_TYPE,RilRadio))
+#define DBG_(self,fmt,args...) DBG("%s" fmt, (self)->priv->log_prefix, ##args)
+
static void ril_radio_submit_power_request(struct ril_radio *self, gboolean on);
static inline gboolean ril_radio_power_should_be_on(struct ril_radio *self)
{
struct ril_radio_priv *priv = self->priv;
- return self->online && !priv->power_cycle &&
- g_hash_table_size(priv->req_table) > 0;
+ return (self->online || g_hash_table_size(priv->req_table) > 0) &&
+ !priv->power_cycle;
}
static inline gboolean ril_radio_state_off(enum ril_radio_state radio_state)
@@ -102,7 +104,7 @@
struct ril_radio *self = RIL_RADIO(user_data);
struct ril_radio_priv *priv = self->priv;
- DBG("%s", priv->log_prefix);
+ DBG_(self, "");
GASSERT(priv->retry_id);
priv->retry_id = 0;
ril_radio_submit_power_request(self,
@@ -116,7 +118,7 @@
struct ril_radio_priv *priv = self->priv;
if (priv->retry_id) {
- DBG("%sretry cancelled", priv->log_prefix);
+ DBG_(self, "retry cancelled");
g_source_remove(priv->retry_id);
priv->retry_id = 0;
}
@@ -129,8 +131,8 @@
if (!priv->pending_id) {
gboolean should_be_on = ril_radio_power_should_be_on(self);
- if (ril_radio_state_on(self->priv->last_known_state) ==
- should_be_on) {
+ if (ril_radio_state_on(priv->last_known_state) ==
+ should_be_on) {
/* All is good, cancel pending retry if there is one */
ril_radio_cancel_retry(self);
} else if (priv->state_changed_while_request_pending) {
@@ -138,7 +140,7 @@
ril_radio_submit_power_request(self, should_be_on);
} else if (!priv->retry_id) {
/* There has been no reaction so far, wait a bit */
- DBG("%sretry scheduled", priv->log_prefix);
+ DBG_(self, "retry scheduled");
priv->retry_id = g_timeout_add_seconds(POWER_RETRY_SECS,
ril_radio_power_request_retry_cb, self);
}
@@ -147,28 +149,20 @@
/* Don't update public state while something is pending */
if (!priv->pending_id && !priv->retry_id &&
self->state != priv->last_known_state) {
- DBG("%s%s -> %s", priv->log_prefix,
- ril_radio_state_to_string(self->state),
+ DBG_(self, "%s -> %s", ril_radio_state_to_string(self->state),
ril_radio_state_to_string(priv->last_known_state));
self->state = priv->last_known_state;
ril_radio_emit_signal(self, SIGNAL_STATE_CHANGED);
}
}
-static void ril_radio_power_request_cb(GRilIoChannel *channel, int ril_status,
- const void *data, guint len, void *user_data)
+static void ril_radio_power_request_done(struct ril_radio *self)
{
- struct ril_radio *self = RIL_RADIO(user_data);
struct ril_radio_priv *priv = self->priv;
GASSERT(priv->pending_id);
priv->pending_id = 0;
- if (ril_status != RIL_E_SUCCESS) {
- ofono_error("Power request failed: %s",
- ril_error_to_string(ril_status));
- }
-
if (priv->next_state_valid) {
ril_radio_submit_power_request(self, priv->next_state);
} else {
@@ -176,6 +170,19 @@
}
}
+static void ril_radio_power_request_cb(GRilIoChannel *channel, int ril_status,
+ const void *data, guint len, void *user_data)
+{
+ struct ril_radio *self = RIL_RADIO(user_data);
+
+ if (ril_status != RIL_E_SUCCESS) {
+ ofono_error("Power request failed: %s",
+ ril_error_to_string(ril_status));
+ }
+
+ ril_radio_power_request_done(self);
+}
+
static void ril_radio_submit_power_request(struct ril_radio *self, gboolean on)
{
/*
@@ -214,13 +221,18 @@
/* Wait for the pending request to complete */
priv->next_state_valid = TRUE;
priv->next_state = on;
- DBG("%s%s (queued)", priv->log_prefix, on_off);
+ DBG_(self, "%s (queued)", on_off);
} else {
- DBG("%s%s (ignored)", priv->log_prefix, on_off);
+ DBG_(self, "%s (ignored)", on_off);
}
} else {
- DBG("%s%s", priv->log_prefix, on_off);
- ril_radio_submit_power_request(self, on);
+ if (ril_radio_state_on(priv->last_known_state) == on) {
+ DBG_(self, "%s (already)", on_off);
+ ril_radio_check_state(self);
+ } else {
+ DBG_(self, "%s", on_off);
+ ril_radio_submit_power_request(self, on);
+ }
}
}
@@ -237,12 +249,12 @@
struct ril_radio_priv *priv = self->priv;
if (ril_radio_state_off(priv->last_known_state)) {
- DBG("%spower is already off", priv->log_prefix);
+ DBG_(self, "power is already off");
GASSERT(!priv->power_cycle);
} else if (priv->power_cycle) {
- DBG("%salready in progress", priv->log_prefix);
+ DBG_(self, "already in progress");
} else {
- DBG("%sinitiated", priv->log_prefix);
+ DBG_(self, "initiated");
priv->power_cycle = TRUE;
if (!priv->pending_id) {
ril_radio_submit_power_request(self, FALSE);
@@ -259,7 +271,7 @@
if (!g_hash_table_contains(priv->req_table, tag)) {
gboolean was_on = ril_radio_power_should_be_on(self);
- DBG("%s%p", priv->log_prefix, tag);
+ DBG_(self, "%p", tag);
g_hash_table_insert(priv->req_table, tag, tag);
if (!was_on && ril_radio_power_should_be_on(self)) {
ril_radio_power_request(self, TRUE, FALSE);
@@ -274,7 +286,7 @@
struct ril_radio_priv *priv = self->priv;
if (g_hash_table_remove(priv->req_table, tag)) {
- DBG("%s%p", priv->log_prefix, tag);
+ DBG_(self, "%p", tag);
if (!ril_radio_power_should_be_on(self)) {
/* The last one turns the lights off */
ril_radio_power_request(self, FALSE, FALSE);
@@ -346,20 +358,41 @@
if (radio_state != RADIO_STATE_UNAVAILABLE) {
struct ril_radio_priv *priv = self->priv;
- DBG("%s%s", priv->log_prefix,
- ril_radio_state_to_string(radio_state));
+ DBG_(self, "%s", ril_radio_state_to_string(radio_state));
GASSERT(!priv->pending_id || !priv->retry_id);
if (priv->power_cycle && ril_radio_state_off(radio_state)) {
- DBG("%sswitched off for power cycle", priv->log_prefix);
+ DBG_(self, "switched off for power cycle");
priv->power_cycle = FALSE;
}
+ priv->last_known_state = radio_state;
+
if (priv->pending_id) {
- priv->state_changed_while_request_pending++;
+ if (ril_radio_state_on(radio_state) ==
+ ril_radio_power_should_be_on(self)) {
+ DBG_(self, "dropping pending request");
+ /*
+ * All right, the modem has switched to the
+ * desired state, drop the request.
+ */
+ grilio_queue_cancel_request(priv->q,
+ priv->pending_id, FALSE);
+
+ /*
+ * This will zero pending_id and call
+ * ril_radio_check_state() if necesary:
+ */
+ ril_radio_power_request_done(self);
+
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_radio.h
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2017 Jolla Ltd.
+ * Copyright (C) 2015-2018 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,6 +18,8 @@
#include "ril_types.h"
+#include <glib-object.h>
+
struct ril_radio {
GObject object;
struct ril_radio_priv *priv;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_radio_caps.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2017 Jolla Ltd.
+ * Copyright (C) 2017-2018 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
@@ -71,6 +71,7 @@
gulong max_pref_mode_event_id;
gulong radio_event_id;
int tx_id;
+ int tx_pending;
struct ril_data *data;
struct ril_radio *radio;
struct ril_network *network;
@@ -85,7 +86,6 @@
GObject object;
GPtrArray *caps_list;
guint check_id;
- int tx_pending;
int tx_id;
int tx_phase_index;
gboolean tx_failed;
@@ -453,7 +453,7 @@
struct ril_radio_caps *self =
g_slice_new0(struct ril_radio_caps);
- self->ref_count = 1;
+ g_atomic_int_set(&self->ref_count, 1);
self->slot = config->slot;
self->log_prefix = (log_prefix && log_prefix[0]) ?
g_strconcat(log_prefix, " ", NULL) : g_strdup("");
@@ -471,13 +471,16 @@
self->simcard_event_id[SIM_EVENT_STATE_CHANGED] =
ril_sim_card_add_state_changed_handler(sim,
ril_radio_caps_simcard_event, self);
+ self->simcard_event_id[SIM_EVENT_IO_ACTIVE_CHANGED] =
+ ril_sim_card_add_sim_io_active_changed_handler(sim,
+ ril_radio_caps_simcard_event, self);
self->network = ril_network_ref(net);
self->settings_event_id[SETTINGS_EVENT_PREF_MODE] =
ril_sim_settings_add_pref_mode_changed_handler(
settings, ril_radio_caps_settings_event, self);
self->settings_event_id[SETTINGS_EVENT_IMSI] =
- ril_sim_settings_add_pref_mode_changed_handler(
+ ril_sim_settings_add_imsi_changed_handler(
settings, ril_radio_caps_settings_event, self);
self->max_pref_mode_event_id =
@@ -560,6 +563,24 @@
}
}
+static gboolean ril_radio_caps_manager_tx_pending
+ (struct ril_radio_caps_manager *self)
+{
+ guint i;
+ const GPtrArray *list = self->caps_list;
+
+ for (i = 0; i < list->len; i++) {
+ const struct ril_radio_caps *caps = list->pdata[i];
+
+ /* Ignore the modems not associated with this transaction */
+ if (caps->tx_id == self->tx_id && caps->tx_pending > 0) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
/**
* Checks that all radio caps have been initialized (i.e. all the initial
* GET_RADIO_CAPABILITY requests have completed) and there's no transaction
@@ -568,7 +589,7 @@
static gboolean ril_radio_caps_manager_can_check
(struct ril_radio_caps_manager *self)
{
- if (self->caps_list && !self->tx_pending) {
+ if (self->caps_list && !ril_radio_caps_manager_tx_pending(self)) {
const GPtrArray *list = self->caps_list;
const struct ril_radio_caps *prev_caps = NULL;
gboolean all_modes_equal = TRUE;
@@ -753,6 +774,10 @@
phase->send_new_cap ? &caps->new_cap :
&caps->old_cap;
+ /* Count it */
+ caps->tx_pending++;
+ DBG_(caps, "tx_pending=%d", caps->tx_pending);
+
/* Encode and send the request */
grilio_request_append_int32(req,
RIL_RADIO_CAPABILITY_VERSION);
@@ -766,9 +791,6 @@
RIL_REQUEST_SET_RADIO_CAPABILITY,
handler, NULL, caps);
grilio_request_unref(req);
-
- /* Count it */
- self->tx_pending++;
}
}
}
@@ -791,7 +813,6 @@
{
ril_radio_caps_manager_foreach(self,
ril_radio_caps_manager_next_transaction_cb);
- self->tx_pending = 0;
self->tx_failed = FALSE;
self->tx_phase_index = -1;
self->tx_id++;
@@ -829,8 +850,10 @@
struct ril_radio_caps *caps = user_data;
struct ril_radio_caps_manager *self = caps->mgr;
- GASSERT(self->tx_pending > 0);
- if (!(--self->tx_pending)) {
+ GASSERT(caps->tx_pending > 0);
+ caps->tx_pending--;
+ DBG_(caps, "tx_pending=%d", caps->tx_pending);
+ if (!ril_radio_caps_manager_tx_pending(self)) {
DBG("transaction aborted");
ril_radio_caps_manager_transaction_done(self);
}
@@ -875,7 +898,7 @@
struct ril_radio_caps_manager *self = caps->mgr;
gboolean ok = FALSE;
- GASSERT(self->tx_pending > 0);
+ GASSERT(caps->tx_pending > 0);
if (ril_status == RIL_E_SUCCESS) {
struct ril_radio_capability cap;
if (ril_radio_caps_parse(caps->log_prefix, data, len, &cap) &&
@@ -892,7 +915,9 @@
}
}
- if (!(--self->tx_pending)) {
+ caps->tx_pending--;
+ DBG_(caps, "tx_pending=%d", caps->tx_pending);
+ if (!ril_radio_caps_manager_tx_pending(self)) {
if (self->tx_failed) {
ril_radio_caps_manager_abort_transaction(self);
} else {
@@ -907,7 +932,7 @@
/* Note: -1 > 2 if 2 is unsigned (which turns -1 into 4294967295) */
const int max_index = G_N_ELEMENTS(ril_radio_caps_tx_phase) - 1;
- GASSERT(!self->tx_pending);
+ GASSERT(!ril_radio_caps_manager_tx_pending(self));
if (self->tx_phase_index >= max_index) {
DBG("transaction %d is done", self->tx_id);
ril_radio_caps_manager_transaction_done(self);
@@ -924,14 +949,16 @@
static void ril_radio_caps_manager_data_off_done(GRilIoChannel *io,
int status, const void *req_data, guint len, void *user_data)
{
- struct ril_radio_caps_manager *self = RADIO_CAPS_MANAGER(user_data);
+ struct ril_radio_caps *caps = user_data;
+ struct ril_radio_caps_manager *self = caps->mgr;
- DBG("%d", self->tx_pending);
- GASSERT(self->tx_pending > 0);
+ GASSERT(caps->tx_pending > 0);
if (status != GRILIO_STATUS_OK) {
self->tx_failed = TRUE;
}
- if (!(--self->tx_pending)) {
+ caps->tx_pending--;
+ DBG_(caps, "tx_pending=%d", caps->tx_pending);
+ if (!ril_radio_caps_manager_tx_pending(self)) {
if (self->tx_failed) {
DBG("failed to start the transaction");
ril_data_manager_assert_data_on(self->data_manager);
@@ -951,13 +978,13 @@
{
GRilIoRequest *req = ril_request_allow_data_new(FALSE);
- self->tx_pending++;
- DBG_(caps, "disallowing data");
+ caps->tx_pending++;
+ DBG_(caps, "tx_pending=%d", caps->tx_pending);
grilio_request_set_timeout(req, DATA_OFF_TIMEOUT_MS);
grilio_queue_send_request_full(caps->q, req,
RIL_REQUEST_ALLOW_DATA,
ril_radio_caps_manager_data_off_done,
- NULL, self);
+ NULL, caps);
grilio_request_unref(req);
}
@@ -967,14 +994,16 @@
struct ril_radio_caps *caps = user_data;
struct ril_radio_caps_manager *self = caps->mgr;
- GASSERT(self->tx_pending > 0);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_sim.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2018 Jolla Ltd.
+ * Copyright (C) 2015-2019 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,7 +18,8 @@
#include "ril_util.h"
#include "ril_log.h"
-#include "sailfish_watch.h"
+#include <ofono/watch.h>
+
#include "simutil.h"
#include "util.h"
#include "ofono.h"
@@ -69,6 +70,11 @@
SIM_CARD_EVENT_COUNT
};
+enum ril_sim_io_event {
+ IO_EVENT_SIM_REFRESH,
+ IO_EVENT_COUNT
+};
+
struct ril_sim {
GRilIoChannel *io;
GRilIoQueue *q;
@@ -81,12 +87,13 @@
gboolean inserted;
guint idle_id; /* Used by register and SIM reset callbacks */
gulong card_event_id[SIM_CARD_EVENT_COUNT];
+ gulong io_event_id[IO_EVENT_COUNT];
guint query_pin_retries_id;
const char *log_prefix;
char *allocated_log_prefix;
- struct sailfish_watch *watch;
+ struct ofono_watch *watch;
gulong sim_state_watch_id;
/* query_passwd_state context */
@@ -102,8 +109,9 @@
guint data_len;
};
-struct ril_sim_cbd {
+struct ril_sim_cbd_io {
struct ril_sim *sd;
+ struct ril_sim_card *card;
union _ofono_sim_cb {
ofono_sim_file_info_cb_t file_info;
ofono_sim_read_cb_t read;
@@ -173,24 +181,43 @@
#define DBG_(sd,fmt,args...) DBG("%s" fmt, (sd)->log_prefix, ##args)
-#define ril_sim_cbd_free g_free
-
static inline struct ril_sim *ril_sim_get_data(struct ofono_sim *sim)
{
return ofono_sim_get_data(sim);
}
-static struct ril_sim_cbd *ril_sim_cbd_new(struct ril_sim *sd, void *cb,
+static struct ril_sim_cbd_io *ril_sim_cbd_io_new(struct ril_sim *sd, void *cb,
void *data)
{
- struct ril_sim_cbd *cbd = g_new0(struct ril_sim_cbd, 1);
+ struct ril_sim_cbd_io *cbd = g_new0(struct ril_sim_cbd_io, 1);
cbd->sd = sd;
cbd->cb.ptr = cb;
cbd->data = data;
+ cbd->card = ril_sim_card_ref(sd->card);
return cbd;
}
+static void ril_sim_cbd_io_free(void *data)
+{
+
+ struct ril_sim_cbd_io *cbd = data;
+
+ ril_sim_card_sim_io_finished(cbd->card, cbd->req_id);
+ ril_sim_card_unref(cbd->card);
+ g_free(cbd);
+}
+
+static void ril_sim_cbd_io_start(struct ril_sim_cbd_io *cbd, GRilIoRequest* req,
+ guint code, GRilIoChannelResponseFunc cb)
+{
+ struct ril_sim *sd = cbd->sd;
+
+ cbd->req_id = grilio_queue_send_request_full(sd->q, req, code,
+ cb, ril_sim_cbd_io_free, cbd);
+ ril_sim_card_sim_io_started(cbd->card, cbd->req_id);
+}
+
static void ril_sim_pin_cbd_state_event_count_cb(struct ril_sim_card *sc,
void *user_data)
{
@@ -249,11 +276,6 @@
}
}
-static const char *ril_sim_app_id(struct ril_sim *sd)
-{
- return sd->card->app ? sd->card->app->aid : NULL;
-}
-
int ril_sim_app_type(struct ofono_sim *sim)
{
struct ril_sim *sd = ril_sim_get_data(sim);
@@ -423,14 +445,13 @@
static void ril_sim_file_info_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
- struct ril_sim_cbd *cbd = user_data;
+ struct ril_sim_cbd_io *cbd = user_data;
ofono_sim_file_info_cb_t cb = cbd->cb.file_info;
struct ril_sim *sd = cbd->sd;
struct ril_sim_io_response *res = NULL;
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);
@@ -474,12 +495,13 @@
static void ril_sim_request_io(struct ril_sim *sd, guint cmd, int fileid,
guint p1, guint p2, guint p3, const char *hex_data,
const guchar *path, guint path_len,
- GRilIoChannelResponseFunc cb, struct ril_sim_cbd *cbd)
+ GRilIoChannelResponseFunc cb, struct ril_sim_cbd_io *cbd)
{
GRilIoRequest *req = grilio_request_new();
DBG_(sd, "cmd=0x%.2X,efid=0x%.4X,%d,%d,%d,%s,pin2=(null),aid=%s",
- cmd, fileid, p1, p2, p3, hex_data, ril_sim_app_id(sd));
+ cmd, fileid, p1, p2, p3, hex_data,
+ ril_sim_card_app_aid(sd->card));
grilio_request_append_int32(req, cmd);
grilio_request_append_int32(req, fileid);
@@ -489,13 +511,11 @@
grilio_request_append_int32(req, p3); /* P3 */
grilio_request_append_utf8(req, hex_data); /* data; only for writes */
grilio_request_append_utf8(req, NULL); /* pin2; only for writes */
- grilio_request_append_utf8(req, ril_sim_app_id(sd));
+ grilio_request_append_utf8(req, ril_sim_card_app_aid(sd->card));
grilio_request_set_blocking(req, TRUE);
grilio_request_set_timeout(req, SIM_IO_TIMEOUT_SECS * 1000);
- 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);
+ ril_sim_cbd_io_start(cbd, req, RIL_REQUEST_SIM_IO, cb);
grilio_request_unref(req);
}
@@ -505,19 +525,19 @@
{
struct ril_sim *sd = ril_sim_get_data(sim);
ril_sim_request_io(sd, CMD_GET_RESPONSE, fileid, 0, 0, 15, NULL,
- path, len, ril_sim_file_info_cb, ril_sim_cbd_new(sd, cb, data));
+ path, len, ril_sim_file_info_cb,
+ ril_sim_cbd_io_new(sd, cb, data));
}
static void ril_sim_read_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
- struct ril_sim_cbd *cbd = user_data;
+ struct ril_sim_cbd_io *cbd = user_data;
ofono_sim_read_cb_t cb = cbd->cb.read;
struct ril_sim_io_response *res;
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) {
@@ -536,7 +556,7 @@
{
struct ril_sim *sd = ril_sim_get_data(sim);
ril_sim_request_io(sd, cmd, fileid, p1, p2, p3, NULL, path, path_len,
- ril_sim_read_cb, ril_sim_cbd_new(sd, cb, data));
+ ril_sim_read_cb, ril_sim_cbd_io_new(sd, cb, data));
}
static void ril_sim_ofono_read_file_transparent(struct ofono_sim *sim,
@@ -566,13 +586,12 @@
static void ril_sim_write_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_sim_card.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2017 Jolla Ltd.
+ * Copyright (C) 2015-2018 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,6 +24,17 @@
#include <gutil_misc.h>
+/*
+ * First we wait for USIM app to get activated by itself. If that
+ * doesn't happen within UICC_SUBSCRIPTION_START_MS we poke the SIM
+ * with SET_UICC_SUBSCRIPTION request, resubmitting it if it times out.
+ * If nothing happens within UICC_SUBSCRIPTION_TIMEOUT_MS we give up.
+ *
+ * Submitting SET_UICC_SUBSCRIPTION request when rild doesn't expect
+ * it sometimes breaks pretty much everything. Unfortunately, there no
+ * reliable way to find out when rild expects it and when it doesn't :/
+ */
+#define UICC_SUBSCRIPTION_START_MS (5000)
#define UICC_SUBSCRIPTION_TIMEOUT_MS (30000)
/* SIM I/O idle timeout is measured in the number of idle loops.
@@ -48,6 +59,7 @@
int flags;
guint status_req_id;
guint sub_req_id;
+ guint sub_start_timer;
gulong event_id[EVENT_COUNT];
guint sim_io_idle_id;
guint sim_io_idle_count;
@@ -157,10 +169,55 @@
}
}
+static void ril_sim_card_tx_start(struct ril_sim_card *self)
+{
+ struct ril_sim_card_priv *priv = self->priv;
+ GRILIO_TRANSACTION_STATE tx_state =
+ grilio_queue_transaction_state(priv->q);
+
+ if (tx_state == GRILIO_TRANSACTION_NONE) {
+ tx_state = grilio_queue_transaction_start(priv->q);
+ DBG("status tx for slot %u %s", self->slot,
+ (tx_state == GRILIO_TRANSACTION_STARTED) ?
+ "started" : "starting");
+ }
+}
+
+static void ril_sim_card_tx_check(struct ril_sim_card *self)
+{
+ struct ril_sim_card_priv *priv = self->priv;
+
+ if (grilio_queue_transaction_state(priv->q) !=
+ GRILIO_TRANSACTION_NONE) {
+ const struct ril_sim_card_status *status = self->status;
+
+ if (status && status->card_state == RIL_CARDSTATE_PRESENT) {
+ /* Transaction (if there is any) is finished when
+ * both GET_SIM_STATUS and SET_UICC_SUBSCRIPTION
+ * complete or get dropped */
+ if (!priv->status_req_id && !priv->sub_req_id &&
+ status->gsm_umts_index >= 0 &&
+ status->gsm_umts_index < status->num_apps) {
+ DBG("status tx for slot %u finished",
+ self->slot);
+ grilio_queue_transaction_finish(priv->q);
+ }
+ } else {
+ DBG("status tx for slot %u cancelled", self->slot);
+ grilio_queue_transaction_finish(priv->q);
+ }
+ }
+}
+
static void ril_sim_card_subscription_done(struct ril_sim_card *self)
{
struct ril_sim_card_priv *priv = self->priv;
+ if (priv->sub_start_timer) {
+ /* Don't need this timer anymore */
+ g_source_remove(priv->sub_start_timer);
+ priv->sub_start_timer = 0;
+ }
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
@@ -168,7 +225,7 @@
grilio_channel_drop_request(priv->io, priv->sub_req_id);
priv->sub_req_id = 0;
}
- grilio_queue_transaction_finish(priv->q);
+ ril_sim_card_tx_check(self);
}
static void ril_sim_card_subscribe_cb(GRilIoChannel* io, int status,
@@ -184,19 +241,18 @@
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)
+static void ril_sim_card_subscribe(struct ril_sim_card *self, int app_index)
{
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_action);
+ DBG("%u,%d,%u", self->slot, app_index, sub_id);
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_action);
+ grilio_request_append_int32(req, RIL_UICC_SUBSCRIPTION_ACTIVATE);
grilio_request_set_retry(req, 0, -1);
grilio_request_set_timeout(req, UICC_SUBSCRIPTION_TIMEOUT_MS);
@@ -213,7 +269,7 @@
/* Don't allow any requests other that GET_SIM_STATUS until
* we are done with the subscription */
- grilio_queue_transaction_start(priv->q);
+ ril_sim_card_tx_start(self);
priv->sub_req_id = grilio_queue_send_request_full(priv->q,
req, code, ril_sim_card_subscribe_cb, NULL, self);
grilio_request_unref(req);
@@ -250,9 +306,8 @@
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,
- RIL_UICC_SUBSCRIPTION_ACTIVATE);
+ if (app_index >= 0 && !self->priv->sub_start_timer) {
+ ril_sim_card_subscribe(self, app_index);
}
}
} else {
@@ -273,6 +328,18 @@
}
}
+static gboolean ril_sim_card_sub_start_timeout(gpointer user_data)
+{
+ struct ril_sim_card *self = RIL_SIMCARD(user_data);
+ struct ril_sim_card_priv *priv = self->priv;
+
+ DBG("%u", self->slot);
+ GASSERT(priv->sub_start_timer);
+ priv->sub_start_timer = 0;
+ ril_sim_card_update_app(self);
+ return G_SOURCE_REMOVE;
+}
+
static void ril_sim_card_update_status(struct ril_sim_card *self,
struct ril_sim_card_status *status)
{
@@ -282,6 +349,23 @@
struct ril_sim_card_status *old_status = self->status;
self->status = status;
+ if (diff & RIL_SIMCARD_STATE_CHANGED &&
+ status->card_state == RIL_CARDSTATE_PRESENT) {
+ struct ril_sim_card_priv *priv = self->priv;
+
+ /*
+ * SIM card has just appeared, give it some time to
+ * activate the USIM app
+ */
+ if (priv->sub_start_timer) {
+ g_source_remove(priv->sub_start_timer);
+ }
+ DBG("started subscription timeout for slot %u",
+ self->slot);
+ priv->sub_start_timer =
+ g_timeout_add(UICC_SUBSCRIPTION_START_MS,
+ ril_sim_card_sub_start_timeout, self);
+ }
ril_sim_card_update_app(self);
g_signal_emit(self, ril_sim_card_signals
[SIGNAL_STATUS_RECEIVED], 0);
@@ -297,6 +381,7 @@
}
ril_sim_card_status_free(old_status);
} else {
+ ril_sim_card_update_app(self);
ril_sim_card_status_free(status);
g_signal_emit(self, ril_sim_card_signals
[SIGNAL_STATUS_RECEIVED], 0);
@@ -430,6 +515,24 @@
ril_sim_card_update_status(self, status);
}
}
+
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_sim_card.h
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2017 Jolla Ltd.
+ * Copyright (C) 2015-2018 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,6 +18,8 @@
#include "ril_types.h"
+#include <glib-object.h>
+
struct ril_sim_card_app {
enum ril_app_type app_type;
enum ril_app_state app_state;
@@ -56,6 +58,7 @@
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_reset(struct ril_sim_card *sc);
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);
@@ -74,9 +77,13 @@
void ril_sim_card_remove_handlers(struct ril_sim_card *sc, gulong *ids, int n);
/* Inline wrappers */
-static inline enum ril_app_type
-ril_sim_card_app_type(struct ril_sim_card *sc)
+static inline enum ril_app_type ril_sim_card_app_type(struct ril_sim_card *sc)
{ return (sc && sc->app) ? sc->app->app_type : RIL_APPTYPE_UNKNOWN; }
+static inline const char *ril_sim_card_app_aid(struct ril_sim_card *sc)
+ { return (sc && sc->app) ? sc->app->aid : NULL; }
+
+#define ril_sim_card_remove_all_handlers(net, ids) \
+ ril_sim_card_remove_handlers(net, ids, G_N_ELEMENTS(ids))
#endif /* RIL_SIM_CARD_H */
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_sim_settings.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2016-2017 Jolla Ltd.
+ * Copyright (C) 2016-2019 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,7 @@
#include "ril_sim_settings.h"
#include "ril_log.h"
-#include "sailfish_watch.h"
+#include <ofono/watch.h>
#include <gutil_misc.h>
@@ -30,14 +30,14 @@
typedef GObjectClass RilSimSettingsClass;
typedef struct ril_sim_settings RilSimSettings;
-enum sailfish_watch_events {
+enum ofono_watch_events {
WATCH_EVENT_IMSI,
WATCH_EVENT_COUNT
};
struct ril_sim_settings_priv {
gulong watch_event_id[WATCH_EVENT_COUNT];
- struct sailfish_watch *watch;
+ struct ofono_watch *watch;
char *imsi;
};
@@ -81,7 +81,7 @@
}
}
-static void ril_sim_settings_imsi_changed(struct sailfish_watch *watch,
+static void ril_sim_settings_imsi_changed(struct ofono_watch *watch,
void *user_data)
{
struct ril_sim_settings *self = RIL_SIM_SETTINGS(user_data);
@@ -106,9 +106,9 @@
priv = self->priv;
self->techs = techs;
self->pref_mode = RIL_PREF_MODE_DEFAULT(self);
- priv->watch = sailfish_watch_new(path);
+ priv->watch = ofono_watch_new(path);
priv->watch_event_id[WATCH_EVENT_IMSI] =
- sailfish_watch_add_imsi_changed_handler(priv->watch,
+ ofono_watch_add_imsi_changed_handler(priv->watch,
ril_sim_settings_imsi_changed, self);
self->imsi = priv->imsi = g_strdup(priv->watch->imsi);
}
@@ -173,8 +173,8 @@
struct ril_sim_settings *self = RIL_SIM_SETTINGS(object);
struct ril_sim_settings_priv *priv = self->priv;
- sailfish_watch_remove_all_handlers(priv->watch, priv->watch_event_id);
- sailfish_watch_unref(priv->watch);
+ ofono_watch_remove_all_handlers(priv->watch, priv->watch_event_id);
+ ofono_watch_unref(priv->watch);
g_free(priv->imsi);
G_OBJECT_CLASS(ril_sim_settings_parent_class)->finalize(object);
}
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_sim_settings.h
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2016-2017 Jolla Ltd.
+ * Copyright (C) 2016-2018 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,6 +18,8 @@
#include "ril_types.h"
+#include <glib-object.h>
+
struct ril_sim_settings_priv;
struct ril_sim_settings {
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_subscription.conf
^
|
@@ -209,3 +209,51 @@
# Default is false (use RIL_REQUEST_DEVICE_IDENTITY)
#
#legacyImeiQuery=false
+
+# Some devices don't support LTE RAT mode PREF_NET_TYPE_LTE_GSM_WCDMA.
+# This option allows to set a custom LTE mode.
+#
+# The default is 9 (PREF_NET_TYPE_LTE_GSM_WCDMA)
+#
+#lteNetworkMode=9
+
+# Timeout for RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, in milliseconds.
+#
+# The default is 20000 (20 seconds)
+#
+#networkModeTimeout=20000
+
+# Cycle radio power at startup.
+#
+# The default is true (cycle the power)
+#
+#radioPowerCycle=true
+
+# With some RILs it seems to be necessary to kick (RIL_REQUEST_RADIO_POWER)
+# the modems with power on after one of the modems has been powered off.
+# Otherwise bad things may happen (like the modem never registering
+# on the network).
+#
+# On the other hand, with some RILs it's causing some trouble (like this
+# extra RIL_REQUEST_RADIO_POWER getting stuck indefinitely).
+#
+# The default is true for historical reasons
+#
+#confirmRadioPowerOn=true
+
+# Normally we should be able to have two simultaneously active data
+# contexts - one for mobile data and one for MMS. Some devices however
+# require that mobile data is disconnected before we can send or receive
+# MMS. In other words, activation of the second data context fails.
+#
+# The default is false (more than one context is supported)
+#
+#singleDataContext=false
+
+# Configures whether +0 is added to MCCMNC string passed to
+# RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL. Some Qualcomm RILs
+# require it, some MediaTek RILs don't like it.
+#
+# The default is true
+#
+#networkSelectionManual0=true
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_types.h
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2018 Jolla Ltd.
+ * Copyright (C) 2015-2019 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
@@ -51,9 +51,16 @@
struct ril_slot_config {
guint slot;
enum ofono_radio_access_mode techs;
+ enum ril_pref_net_type lte_network_mode;
+ enum ril_pref_net_type umts_network_mode;
+ int network_mode_timeout;
+ gboolean query_available_band_mode;
gboolean empty_pin_query;
+ gboolean radio_power_cycle;
+ gboolean confirm_radio_power_on;
gboolean enable_voicecall;
gboolean enable_cbs;
+ gboolean network_selection_manual_0;
GUtilInts *local_hangup_reasons;
GUtilInts *remote_hangup_reasons;
};
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_ussd.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2017 Jolla Ltd.
+ * Copyright (C) 2015-2018 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
@@ -20,6 +20,8 @@
#include "smsutil.h"
#include "util.h"
+#define USSD_CANCEL_TIMEOUT_SEC (20)
+
struct ril_ussd {
struct ofono_ussd *ussd;
GRilIoChannel *io;
@@ -114,11 +116,14 @@
ofono_ussd_cb_t cb, void *data)
{
struct ril_ussd *ud = ril_ussd_get_data(ussd);
+ GRilIoRequest *req = grilio_request_new();
ofono_info("send ussd cancel");
- grilio_queue_send_request_full(ud->q, NULL, RIL_REQUEST_CANCEL_USSD,
+ grilio_request_set_timeout(req, USSD_CANCEL_TIMEOUT_SEC * 1000);
+ grilio_queue_send_request_full(ud->q, req, RIL_REQUEST_CANCEL_USSD,
ril_ussd_cancel_cb, ril_ussd_cbd_free,
ril_ussd_cbd_new(cb, data));
+ grilio_request_unref(req);
}
static void ril_ussd_notify(GRilIoChannel *io, guint code,
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_util.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2017 Jolla Ltd.
+ * Copyright (C) 2015-2018 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,10 +18,10 @@
#include <grilio_channel.h>
+#include <gutil_misc.h>
+
#include <sys/socket.h>
#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
#include "common.h"
#include "netreg.h"
@@ -326,7 +326,7 @@
{
int access_tech = -1;
int tech = -1;
- if (ril_parse_int(stech, 0, &tech)) {
+ if (gutil_parse_int(stech, 0, &tech)) {
switch (tech) {
case RADIO_TECH_GPRS:
case RADIO_TECH_GSM:
@@ -411,26 +411,6 @@
return FALSE;
}
-gboolean ril_parse_int(const char *str, int base, int *value)
-{
- gboolean ok = FALSE;
-
- if (str && str[0]) {
- char *str2 = g_strstrip(g_strdup(str));
- char *end = str2;
- long l;
-
- errno = 0;
- l = strtol(str2, &end, base);
- ok = !*end && errno != ERANGE && l >= INT_MIN && l <= INT_MAX;
- if (ok && value) {
- *value = (int)l;
- }
- g_free(str2);
- }
- return ok;
-}
-
/*
* Local Variables:
* mode: C
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_util.h
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2017 Jolla Ltd.
+ * Copyright (C) 2015-2018 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
@@ -26,7 +26,6 @@
const char *ril_radio_state_to_string(int radio_state);
int ril_parse_tech(const char *stech, int *ril_tech);
gboolean ril_parse_mcc_mnc(const char *str, struct ofono_network_operator *op);
-gboolean ril_parse_int(const char *str, int base, int *value);
#define ril_error_init_ok(err) \
((err)->error = 0, (err)->type = OFONO_ERROR_TYPE_NO_ERROR)
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_vendor.c
^
|
@@ -40,9 +40,11 @@
}
struct ril_vendor_hook *ril_vendor_hook_init(struct ril_vendor_hook *self,
- const struct ril_vendor_hook_proc *proc)
+ const struct ril_vendor_hook_proc *proc,
+ ril_vendor_hook_free_proc free)
{
self->proc = proc;
+ self->free = free;
g_atomic_int_set(&self->ref_count, 1);
return self;
}
@@ -58,13 +60,8 @@
static void ril_vendor_hook_free(struct ril_vendor_hook *self)
{
- const struct ril_vendor_hook_proc *proc = self->proc;
-
- while (!proc->free && proc->base) {
- proc = proc->base;
- }
- if (proc->free) {
- proc->free(self);
+ if (self->free) {
+ self->free(self);
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_vendor.h
^
|
@@ -22,6 +22,7 @@
gboolean empty_pin_query;
gboolean legacy_imei_query;
gboolean enable_cbs;
+ gboolean query_available_band_mode;
};
struct ril_vendor_driver {
@@ -37,7 +38,6 @@
struct ril_vendor_hook_proc {
const struct ril_vendor_hook_proc *base;
- void (*free)(struct ril_vendor_hook *hook);
const char *(*request_to_string)(struct ril_vendor_hook *hook,
guint request);
const char *(*event_to_string)(struct ril_vendor_hook *hook,
@@ -51,8 +51,10 @@
GRilIoParser *rilp);
};
+typedef void (*ril_vendor_hook_free_proc)(struct ril_vendor_hook *hook);
struct ril_vendor_hook {
const struct ril_vendor_hook_proc *proc;
+ ril_vendor_hook_free_proc free;
gint ref_count;
};
@@ -64,7 +66,8 @@
struct ril_vendor_defaults *defaults);
struct ril_vendor_hook *ril_vendor_hook_init(struct ril_vendor_hook *hook,
- const struct ril_vendor_hook_proc *proc);
+ const struct ril_vendor_hook_proc *proc,
+ ril_vendor_hook_free_proc free);
struct ril_vendor_hook *ril_vendor_hook_ref(struct ril_vendor_hook *hook);
void ril_vendor_hook_unref(struct ril_vendor_hook *hook);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_vendor_mtk.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2016-2018 Jolla Ltd.
+ * Copyright (C) 2016-2019 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
@@ -19,16 +19,17 @@
#include "ril_data.h"
#include "ril_log.h"
-#include "sailfish_watch.h"
-
#include <grilio_channel.h>
#include <grilio_parser.h>
#include <grilio_request.h>
#include <grilio_queue.h>
#include <gutil_macros.h>
+#include <gutil_misc.h>
-#include "ofono.h"
+#include <ofono/watch.h>
+#include <ofono/modem.h>
+#include <ofono/gprs.h>
#define SET_INITIAL_ATTACH_APN_TIMEOUT (20*1000)
@@ -56,7 +57,7 @@
GRilIoQueue *q;
GRilIoChannel *io;
struct ril_network *network;
- struct sailfish_watch *watch;
+ struct ofono_watch *watch;
guint set_initial_attach_apn_id;
gboolean initial_attach_apn_ok;
gulong network_event_id[NETWORK_EVENT_COUNT];
@@ -72,30 +73,43 @@
const struct ril_vendor_hook_proc *proc;
};
+/* Hook with auto-detection */
+struct ril_vendor_hook_mtk_auto {
+ struct ril_vendor_hook_mtk mtk;
+ const struct ril_vendor_mtk_driver_data *type;
+ gulong detect_id;
+};
+
/* MTK specific RIL messages (actual codes differ from model to model!) */
struct ril_mtk_msg {
gboolean attach_apn_has_roaming_protocol;
guint request_resume_registration;
+ guint request_set_call_indication;
+
+ /* See ril_vendor_mtk_auto_detect_event */
+#define unsol_msgs unsol_ps_network_state_changed
+#define MTK_UNSOL_MSGS (4)
+
guint unsol_ps_network_state_changed;
guint unsol_registration_suspended;
guint unsol_incoming_call_indication;
guint unsol_set_attach_apn;
};
-/* Fly FS522 Cirrus 14 */
-static const struct ril_mtk_msg mtk_msg_mt6737 = {
+static const struct ril_mtk_msg msg_mtk1 = {
.attach_apn_has_roaming_protocol = TRUE,
.request_resume_registration = 2050,
+ .request_set_call_indication = 2065,
.unsol_ps_network_state_changed = 3012,
.unsol_registration_suspended = 3021,
.unsol_incoming_call_indication = 3037,
.unsol_set_attach_apn = 3065
};
-/* MT8735 Tablet */
-static const struct ril_mtk_msg mtk_msg_mt8735 = {
+static const struct ril_mtk_msg msg_mtk2 = {
.attach_apn_has_roaming_protocol = FALSE,
.request_resume_registration = 2065,
+ .request_set_call_indication = 2086,
.unsol_ps_network_state_changed = 3015,
.unsol_registration_suspended = 3024,
.unsol_incoming_call_indication = 3042,
@@ -108,6 +122,12 @@
return G_CAST(hook, struct ril_vendor_hook_mtk, hook);
}
+static inline struct ril_vendor_hook_mtk_auto *ril_vendor_hook_mtk_auto_cast
+ (struct ril_vendor_hook *hook)
+{
+ return G_CAST(hook, struct ril_vendor_hook_mtk_auto, mtk.hook);
+}
+
static const char *ril_vendor_mtk_request_to_string
(struct ril_vendor_hook *hook, guint request)
{
@@ -116,17 +136,16 @@
if (request == msg->request_resume_registration) {
return "MTK_RESUME_REGISTRATION";
+ } else if (request == msg->request_set_call_indication) {
+ return "MTK_SET_CALL_INDICATION";
} else {
return NULL;
}
}
-static const char *ril_vendor_mtk_event_to_string(struct ril_vendor_hook *hook,
+static const char *ril_vendor_mtk_unsol_msg_name(const struct ril_mtk_msg *msg,
guint event)
{
- struct ril_vendor_hook_mtk *self = ril_vendor_hook_mtk_cast(hook);
- const struct ril_mtk_msg *msg = self->msg;
-
if (event == msg->unsol_ps_network_state_changed) {
return "MTK_PS_NETWORK_STATE_CHANGED";
} else if (event == msg->unsol_registration_suspended) {
@@ -140,6 +159,14 @@
}
}
+static const char *ril_vendor_mtk_event_to_string(struct ril_vendor_hook *hook,
+ guint event)
+{
+ struct ril_vendor_hook_mtk *self = ril_vendor_hook_mtk_cast(hook);
+
+ return ril_vendor_mtk_unsol_msg_name(self->msg, event);
+}
+
static void ril_vendor_mtk_registration_suspended(GRilIoChannel *io, guint id,
const void *data, guint len, void *user_data)
{
@@ -152,7 +179,7 @@
grilio_parser_init(&rilp, data, len);
if (grilio_parser_get_int32(&rilp, NULL) &&
grilio_parser_get_int32(&rilp, &session_id)) {
- GRilIoRequest* req = grilio_request_new();
+ GRilIoRequest *req = grilio_request_new();
DBG("slot=%u,session_id=%d", self->slot, session_id);
grilio_request_append_int32(req, 1);
grilio_request_append_int32(req, session_id);
@@ -208,7 +235,7 @@
grilio_request_append_utf8(req, ""); /* operatorNumeric */
grilio_request_append_int32(req, FALSE); /* canHandleIms */
- grilio_request_append_int32(req, 0); /* Some sort of count */
+ grilio_request_append_int32(req, -1); /* dualApnPlmnList */
return req;
}
@@ -216,17 +243,12 @@
static const struct ofono_gprs_primary_context *ril_vendor_mtk_internet_context
(struct ril_vendor_hook_mtk *self)
{
- struct sailfish_watch *watch = self->watch;
+ struct ofono_watch *watch = self->watch;
if (watch->imsi) {
- struct ofono_atom * atom = __ofono_modem_find_atom(watch->modem,
- OFONO_ATOM_TYPE_GPRS);
-
- if (atom) {
- return __ofono_gprs_context_settings_by_type
- (__ofono_atom_get_data(atom),
+ return ofono_gprs_context_settings_by_type
+ (ofono_modem_get_gprs(watch->modem),
OFONO_GPRS_CONTEXT_TYPE_INTERNET);
- }
}
return NULL;
@@ -281,7 +303,7 @@
}
}
-static void ril_vendor_mtk_watch_imsi_changed(struct sailfish_watch *watch,
+static void ril_vendor_mtk_watch_imsi_changed(struct ofono_watch *watch,
void *user_data)
{
struct ril_vendor_hook_mtk *self = user_data;
@@ -319,15 +341,58 @@
ril_network_query_registration_state(self->network);
}
-static void ril_vendor_mtk_call_state_changed(GRilIoChannel *io,
- guint id, const void *data, guint len, void *user_data)
+static void ril_vendor_mtk_incoming_call_indication(GRilIoChannel *io, guint id,
+ const void *data, guint len, void *user_data)
{
- /* Ignore the payload, let ril_voicecall.c do its normal stuff */
- grilio_channel_inject_unsol_event(io,
- RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0);
+ struct ril_vendor_hook_mtk *self = user_data;
+ const struct ril_mtk_msg *msg = self->msg;
+ GRilIoRequest* req = NULL;
+
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/drivers/ril/ril_voicecall.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
- * Copyright (C) 2015-2017 Jolla Ltd.
+ * Copyright (C) 2015-2018 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
@@ -151,6 +151,10 @@
grilio_parser_get_int32(&rilp, NULL); /* als */
grilio_parser_get_int32(&rilp, &call->type); /* isVoice */
+ grilio_parser_get_int32(&rilp, NULL);
+ grilio_parser_get_int32(&rilp, NULL);
+ grilio_parser_get_int32(&rilp, NULL);
+ grilio_parser_get_utf8(&rilp);
grilio_parser_get_int32(&rilp, NULL); /* isVoicePrivacy */
number = grilio_parser_get_utf8(&rilp);
if (number) {
@@ -591,39 +595,75 @@
grilio_request_unref(ioreq);
}
-static void ril_voicecall_hangup_all(struct ofono_voicecall *vc,
+static void ril_voicecall_hangup(struct ofono_voicecall *vc,
+ gboolean (*filter)(struct ofono_call *call),
ofono_voicecall_cb_t cb, void *data)
{
struct ril_voicecall *vd = ril_voicecall_get_data(vc);
+ struct ril_voicecall_request_data *req = NULL;
+ GSList *l;
- if (vd->calls) {
- GSList *l;
- struct ril_voicecall_request_data *req =
- ril_voicecall_request_data_new(vc, cb, data);
+ /*
+ * Here the idea is that we submit (potentially) multiple
+ * hangup requests to RIL and invoke the callback after
+ * the last request has completed (pending call count
+ * becomes zero).
+ */
+ for (l = vd->calls; l; l = l->next) {
+ struct ofono_call *call = l->data;
- /*
- * Here the idea is that we submit (potentially) multiple
- * hangup requests to RIL and invoke the callback after
- * the last request has completed (pending call count
- * becomes zero).
- */
- for (l = vd->calls; l; l = l->next) {
- struct ofono_call *call = l->data;
+ if (!filter || filter(call)) {
+ if (!req) {
+ req = ril_voicecall_request_data_new(vc, cb,
+ data);
+ }
/* Send request to RIL */
DBG("Hanging up call with id %d", call->id);
ril_voicecall_submit_hangup_req(vc, call->id, req);
+ } else {
+ DBG("Skipping call with id %d", call->id);
}
+ }
- /* Release our reference */
+ if (req) {
+ /* Release our reference (if any) */
ril_voicecall_request_data_unref(req);
} else {
- /* No calls */
+ /* No requests were submitted */
struct ofono_error error;
cb(ril_error_ok(&error), data);
}
}
+static gboolean ril_voicecall_hangup_active_filter(struct ofono_call *call)
+{
+ switch (call->status) {
+ case CALL_STATUS_ACTIVE:
+ case CALL_STATUS_DIALING:
+ case CALL_STATUS_ALERTING:
+ case CALL_STATUS_INCOMING:
+ return TRUE;
+ case CALL_STATUS_HELD:
+ case CALL_STATUS_WAITING:
+ case CALL_STATUS_DISCONNECTED:
+ break;
+ }
+ return FALSE;
+}
+
+static void ril_voicecall_hangup_active(struct ofono_voicecall *vc,
+ ofono_voicecall_cb_t cb, void *data)
+{
+ ril_voicecall_hangup(vc, ril_voicecall_hangup_active_filter, cb, data);
+}
+
+static void ril_voicecall_hangup_all(struct ofono_voicecall *vc,
+ ofono_voicecall_cb_t cb, void *data)
+{
+ ril_voicecall_hangup(vc, NULL, cb, data);
+}
+
static void ril_voicecall_release_specific(struct ofono_voicecall *vc,
int id, ofono_voicecall_cb_t cb, void *data)
{
@@ -687,9 +727,7 @@
{
/* Send request to RIL */
DBG("Answering current call");
- GRilIoRequest *req = grilio_request_array_int32_new(2, 1, 0);
- ril_voicecall_request(RIL_REQUEST_ANSWER, vc, req, cb, data);
- grilio_request_unref(req);
+ ril_voicecall_request(RIL_REQUEST_ANSWER, vc, NULL, cb, data);
}
static void ril_voicecall_send_dtmf_cb(GRilIoChannel *io, int status,
@@ -817,8 +855,7 @@
ofono_voicecall_cb_t cb, void *data)
{
DBG("");
- ril_voicecall_request(RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND,
- vc, NULL, cb, data);
+ ril_voicecall_request(RIL_REQUEST_UDUB, vc, NULL, cb, data);
}
static void ril_voicecall_enable_supp_svc(struct ril_voicecall *vd)
@@ -952,6 +989,7 @@
.remove = ril_voicecall_remove,
.dial = ril_voicecall_dial,
.answer = ril_voicecall_answer,
+ .hangup_active = ril_voicecall_hangup_active,
.hangup_all = ril_voicecall_hangup_all,
.release_specific = ril_voicecall_release_specific,
.send_tones = ril_voicecall_send_dtmf,
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/examples/emulator.c
^
|
@@ -54,7 +54,7 @@
unsigned int len = sizeof(saddr);
int fd;
struct ofono_emulator *em;
- struct ofono_modem *modem;
+ GList *i;
if (cond != G_IO_IN)
return FALSE;
@@ -63,15 +63,16 @@
if (fd == -1)
return FALSE;
- /* Pick the first powered modem */
- modem = modems->data;
- DBG("Picked modem %p for emulator", modem);
+ DBG("Using all modems for emulator.");
- em = ofono_emulator_create(modem, GPOINTER_TO_INT(user));
- if (em == NULL)
- close(fd);
- else
+ em = ofono_emulator_create(GPOINTER_TO_INT(user));
+
+ if (em) {
+ for (i = modems; i; i = i->next)
+ ofono_emulator_add_modem(em, i->data);
ofono_emulator_register(em, fd);
+ } else
+ close(fd);
return TRUE;
}
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/include/dbus-access.h
^
|
@@ -0,0 +1,158 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2019 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 __OFONO_DBUS_ACCESS_H
+#define __OFONO_DBUS_ACCESS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ofono/types.h>
+
+enum ofono_dbus_access {
+ OFONO_DBUS_ACCESS_DENY, /* Deny access */
+ OFONO_DBUS_ACCESS_ALLOW, /* Allow access */
+ OFONO_DBUS_ACCESS_DONT_CARE, /* No decision */
+};
+
+enum ofono_dbus_access_intf {
+ OFONO_DBUS_ACCESS_INTF_MESSAGE, /* org.ofono.Message */
+ OFONO_DBUS_ACCESS_INTF_MESSAGEMGR, /* org.ofono.MessageManager */
+ OFONO_DBUS_ACCESS_INTF_VOICECALL, /* org.ofono.VoiceCall */
+ OFONO_DBUS_ACCESS_INTF_VOICECALLMGR, /* org.ofono.VoiceCallManager */
+ OFONO_DBUS_ACCESS_INTF_CONNCTX, /* org.ofono.ConnectionContext */
+ OFONO_DBUS_ACCESS_INTF_CONNMGR, /* org.ofono.ConnectionManager */
+ OFONO_DBUS_ACCESS_INTF_SIMMGR, /* org.ofono.SimManager */
+ OFONO_DBUS_ACCESS_INTF_MODEM, /* org.ofono.Modem */
+ OFONO_DBUS_ACCESS_INTF_RADIOSETTINGS, /* org.ofono.RadioSettings */
+ OFONO_DBUS_ACCESS_INTF_COUNT
+};
+
+/* OFONO_DBUS_ACCESS_INTF_MESSAGE */
+enum ofono_dbus_access_message_method {
+ OFONO_DBUS_ACCESS_MESSAGE_CANCEL,
+ OFONO_DBUS_ACCESS_MESSAGE_METHOD_COUNT
+};
+
+/* OFONO_DBUS_ACCESS_INTF_MESSAGEMGR */
+enum ofono_dbus_access_messagemgr_method {
+ OFONO_DBUS_ACCESS_MESSAGEMGR_SEND_MESSAGE,
+ OFONO_DBUS_ACCESS_MESSAGEMGR_METHOD_COUNT
+};
+
+/* OFONO_DBUS_ACCESS_INTF_VOICECALL */
+enum ofono_dbus_access_voicecall_method {
+ OFONO_DBUS_ACCESS_VOICECALL_DEFLECT,
+ OFONO_DBUS_ACCESS_VOICECALL_HANGUP,
+ OFONO_DBUS_ACCESS_VOICECALL_ANSWER,
+ OFONO_DBUS_ACCESS_VOICECALL_METHOD_COUNT
+};
+
+/* OFONO_DBUS_ACCESS_INTF_VOICECALLMGR */
+enum ofono_dbus_access_voicecallmgr_method {
+ OFONO_DBUS_ACCESS_VOICECALLMGR_DIAL,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_TRANSFER,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_SWAP_CALLS,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_RELEASE_AND_ANSWER,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_RELEASE_AND_SWAP,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_HOLD_AND_ANSWER,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_HANGUP_ALL,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_CREATE_MULTIPARTY,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_HANGUP_MULTIPARTY,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_SEND_TONES,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_REGISTER_VOICECALL_AGENT,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_UNREGISTER_VOICECALL_AGENT,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_METHOD_COUNT
+};
+
+/* OFONO_DBUS_ACCESS_INTF_CONNCTX */
+enum ofono_dbus_access_connctx_method {
+ OFONO_DBUS_ACCESS_CONNCTX_SET_PROPERTY,
+ OFONO_DBUS_ACCESS_CONNCTX_PROVISION_CONTEXT,
+ OFONO_DBUS_ACCESS_CONNCTX_METHOD_COUNT
+};
+
+/* OFONO_DBUS_ACCESS_INTF_CONNMGR */
+enum ofono_dbus_access_connmgr_method {
+ OFONO_DBUS_ACCESS_CONNMGR_SET_PROPERTY,
+ OFONO_DBUS_ACCESS_CONNMGR_DEACTIVATE_ALL,
+ OFONO_DBUS_ACCESS_CONNMGR_RESET_CONTEXTS,
+ OFONO_DBUS_ACCESS_CONNMGR_METHOD_COUNT
+};
+
+/* OFONO_DBUS_ACCESS_INTF_SIMMGR */
+enum ofono_dbus_access_simmgr_method {
+ OFONO_DBUS_ACCESS_SIMMGR_SET_PROPERTY,
+ OFONO_DBUS_ACCESS_SIMMGR_CHANGE_PIN,
+ OFONO_DBUS_ACCESS_SIMMGR_ENTER_PIN,
+ OFONO_DBUS_ACCESS_SIMMGR_RESET_PIN,
+ OFONO_DBUS_ACCESS_SIMMGR_LOCK_PIN,
+ OFONO_DBUS_ACCESS_SIMMGR_UNLOCK_PIN,
+ OFONO_DBUS_ACCESS_SIMMGR_METHOD_COUNT
+};
+
+/* OFONO_DBUS_ACCESS_INTF_MODEM */
+enum ofono_dbus_access_modem_method {
+ OFONO_DBUS_ACCESS_MODEM_SET_PROPERTY,
+ OFONO_DBUS_ACCESS_MODEM_METHOD_COUNT
+};
+
+/* OFONO_DBUS_ACCESS_INTF_RADIOSETTINGS */
+enum ofono_dbus_access_radiosettings_method {
+ OFONO_DBUS_ACCESS_RADIOSETTINGS_SET_PROPERTY,
+ OFONO_DBUS_ACCESS_RADIOSETTINGS_METHOD_COUNT
+};
+
+#define OFONO_DBUS_ACCESS_PRIORITY_LOW (-100)
+#define OFONO_DBUS_ACCESS_PRIORITY_DEFAULT (0)
+#define OFONO_DBUS_ACCESS_PRIORITY_HIGH (100)
+
+struct ofono_dbus_access_plugin {
+ const char *name;
+ int priority;
+ enum ofono_dbus_access (*method_access)(const char *sender,
+ enum ofono_dbus_access_intf intf,
+ int method, const char *arg);
+
+ void (*_reserved[10])(void);
+
+ /* api_level will remain zero (and ignored) until we run out of
+ * the above placeholders. */
+ int api_level;
+};
+
+int ofono_dbus_access_plugin_register
+ (const struct ofono_dbus_access_plugin *plugin);
+void ofono_dbus_access_plugin_unregister
+ (const struct ofono_dbus_access_plugin *plugin);
+
+const char *ofono_dbus_access_intf_name(enum ofono_dbus_access_intf intf);
+const char *ofono_dbus_access_method_name(enum ofono_dbus_access_intf intf,
+ int method);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_DBUS_ACCESS_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/include/emulator.h
^
|
@@ -68,8 +68,9 @@
struct ofono_emulator_request *req,
void *data);
-struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
- enum ofono_emulator_type type);
+struct ofono_emulator *ofono_emulator_create(enum ofono_emulator_type type);
+void ofono_emulator_add_modem(struct ofono_emulator *em,
+ struct ofono_modem *modem);
void ofono_emulator_register(struct ofono_emulator *em, int fd);
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/include/gprs-filter.h
^
|
@@ -0,0 +1,84 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2018 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 __OFONO_GPRS_FILTER_H
+#define __OFONO_GPRS_FILTER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ofono/types.h>
+
+struct ofono_gprs;
+struct ofono_gprs_context;
+struct ofono_gprs_primary_context;
+
+/* If ctx is NULL then activation gets cancelled */
+typedef void (*ofono_gprs_filter_activate_cb_t)
+ (const struct ofono_gprs_primary_context *ctx, void *data);
+typedef void (*ofono_gprs_filter_check_cb_t)(ofono_bool_t allow, void *data);
+
+#define OFONO_GPRS_FILTER_PRIORITY_LOW (-100)
+#define OFONO_GPRS_FILTER_PRIORITY_DEFAULT (0)
+#define OFONO_GPRS_FILTER_PRIORITY_HIGH (100)
+
+/*
+ * The api_version field makes it possible to keep using old plugins
+ * even if struct ofono_gprs_filter gets extended with new callbacks.
+ */
+
+#define OFONO_GPRS_FILTER_API_VERSION (1)
+
+/*
+ * The filter callbacks either invoke the completion callback directly
+ * or return the id of the cancellable asynchronous operation (but never
+ * both). If non-zero value is returned, the completion callback has to
+ * be invoked later on a fresh stack. Once the asynchronous filtering
+ * operation is cancelled, the associated completion callback must not
+ * be invoked.
+ *
+ * Please avoid making blocking D-Bus calls from the filter callbacks.
+ */
+struct ofono_gprs_filter {
+ const char *name;
+ int api_version; /* OFONO_GPRS_FILTER_API_VERSION */
+ int priority;
+ void (*cancel)(unsigned int id);
+ unsigned int (*filter_activate)(struct ofono_gprs_context *gc,
+ const struct ofono_gprs_primary_context *ctx,
+ ofono_gprs_filter_activate_cb_t cb,
+ void *data);
+ /* API version 1 */
+ unsigned int (*filter_check)(struct ofono_gprs *gprs,
+ ofono_gprs_filter_check_cb_t cb, void *data);
+};
+
+int ofono_gprs_filter_register(const struct ofono_gprs_filter *filter);
+void ofono_gprs_filter_unregister(const struct ofono_gprs_filter *filter);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_GPRS_FILTER_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/include/gprs.h
^
|
@@ -26,10 +26,9 @@
extern "C" {
#endif
-#include <ofono/types.h>
+#include <ofono/gprs-context.h>
struct ofono_gprs;
-struct ofono_gprs_context;
typedef void (*ofono_gprs_status_cb_t)(const struct ofono_error *error,
int status, void *data);
@@ -83,6 +82,11 @@
void ofono_gprs_cid_activated(struct ofono_gprs *gprs, unsigned int cid,
const char *apn);
+void ofono_gprs_attached_update(struct ofono_gprs *gprs);
+
+const struct ofono_gprs_primary_context *ofono_gprs_context_settings_by_type
+ (struct ofono_gprs *gprs, enum ofono_gprs_context_type type);
+
#ifdef __cplusplus
}
#endif
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/include/modem.h
^
|
@@ -29,7 +29,9 @@
#include <ofono/types.h>
struct ofono_modem;
+struct ofono_gprs;
struct ofono_sim;
+struct ofono_voicecall;
enum ofono_modem_type {
OFONO_MODEM_TYPE_HARDWARE = 0,
@@ -82,6 +84,8 @@
const char *ofono_modem_get_path(struct ofono_modem *modem);
struct ofono_sim *ofono_modem_get_sim(struct ofono_modem *modem);
+struct ofono_gprs *ofono_modem_get_gprs(struct ofono_modem *modem);
+struct ofono_voicecall *ofono_modem_get_voicecall(struct ofono_modem *modem);
void ofono_modem_set_data(struct ofono_modem *modem, void *data);
void *ofono_modem_get_data(struct ofono_modem *modem);
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/include/ril-constants.h
^
|
@@ -0,0 +1,284 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2018 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 __OFONO_RIL_CONSTANTS_H
+#define __OFONO_RIL_CONSTANTS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Error Codes */
+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
+};
+
+/* RIL Request Messages, ofono -> rild */
+#define RIL_REQUEST_GET_SIM_STATUS 1
+#define RIL_REQUEST_ENTER_SIM_PIN 2
+#define RIL_REQUEST_ENTER_SIM_PUK 3
+#define RIL_REQUEST_ENTER_SIM_PIN2 4
+#define RIL_REQUEST_ENTER_SIM_PUK2 5
+#define RIL_REQUEST_CHANGE_SIM_PIN 6
+#define RIL_REQUEST_CHANGE_SIM_PIN2 7
+#define RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION 8
+#define RIL_REQUEST_GET_CURRENT_CALLS 9
+#define RIL_REQUEST_DIAL 10
+#define RIL_REQUEST_GET_IMSI 11
+#define RIL_REQUEST_HANGUP 12
+#define RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND 13
+#define RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND 14
+#define RIL_REQUEST_SWITCH_HOLDING_AND_ACTIVE 15
+#define RIL_REQUEST_CONFERENCE 16
+#define RIL_REQUEST_UDUB 17
+#define RIL_REQUEST_LAST_CALL_FAIL_CAUSE 18
+#define RIL_REQUEST_SIGNAL_STRENGTH 19
+#define RIL_REQUEST_VOICE_REGISTRATION_STATE 20
+#define RIL_REQUEST_DATA_REGISTRATION_STATE 21
+#define RIL_REQUEST_OPERATOR 22
+#define RIL_REQUEST_RADIO_POWER 23
+#define RIL_REQUEST_DTMF 24
+#define RIL_REQUEST_SEND_SMS 25
+#define RIL_REQUEST_SEND_SMS_EXPECT_MORE 26
+#define RIL_REQUEST_SETUP_DATA_CALL 27
+#define RIL_REQUEST_SIM_IO 28
+#define RIL_REQUEST_SEND_USSD 29
+#define RIL_REQUEST_CANCEL_USSD 30
+#define RIL_REQUEST_GET_CLIR 31
+#define RIL_REQUEST_SET_CLIR 32
+#define RIL_REQUEST_QUERY_CALL_FORWARD_STATUS 33
+#define RIL_REQUEST_SET_CALL_FORWARD 34
+#define RIL_REQUEST_QUERY_CALL_WAITING 35
+#define RIL_REQUEST_SET_CALL_WAITING 36
+#define RIL_REQUEST_SMS_ACKNOWLEDGE 37
+#define RIL_REQUEST_GET_IMEI 38
+#define RIL_REQUEST_GET_IMEISV 39
+#define RIL_REQUEST_ANSWER 40
+#define RIL_REQUEST_DEACTIVATE_DATA_CALL 41
+#define RIL_REQUEST_QUERY_FACILITY_LOCK 42
+#define RIL_REQUEST_SET_FACILITY_LOCK 43
+#define RIL_REQUEST_CHANGE_BARRING_PASSWORD 44
+#define RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE 45
+#define RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC 46
+#define RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL 47
+#define RIL_REQUEST_QUERY_AVAILABLE_NETWORKS 48
+#define RIL_REQUEST_DTMF_START 49
+#define RIL_REQUEST_DTMF_STOP 50
+#define RIL_REQUEST_BASEBAND_VERSION 51
+#define RIL_REQUEST_SEPARATE_CONNECTION 52
+#define RIL_REQUEST_SET_MUTE 53
+#define RIL_REQUEST_GET_MUTE 54
+#define RIL_REQUEST_QUERY_CLIP 55
+#define RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE 56
+#define RIL_REQUEST_DATA_CALL_LIST 57
+#define RIL_REQUEST_RESET_RADIO 58
+#define RIL_REQUEST_OEM_HOOK_RAW 59
+#define RIL_REQUEST_OEM_HOOK_STRINGS 60
+#define RIL_REQUEST_SCREEN_STATE 61
+#define RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION 62
+#define RIL_REQUEST_WRITE_SMS_TO_SIM 63
+#define RIL_REQUEST_DELETE_SMS_ON_SIM 64
+#define RIL_REQUEST_SET_BAND_MODE 65
+#define RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE 66
+#define RIL_REQUEST_STK_GET_PROFILE 67
+#define RIL_REQUEST_STK_SET_PROFILE 68
+#define RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND 69
+#define RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE 70
+#define RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM 71
+#define RIL_REQUEST_EXPLICIT_CALL_TRANSFER 72
+#define RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE 73
+#define RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE 74
+#define RIL_REQUEST_GET_NEIGHBORING_CELL_IDS 75
+#define RIL_REQUEST_SET_LOCATION_UPDATES 76
+#define RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE 77
+#define RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE 78
+#define RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE 79
+#define RIL_REQUEST_SET_TTY_MODE 80
+#define RIL_REQUEST_QUERY_TTY_MODE 81
+#define RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE 82
+#define RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE 83
+#define RIL_REQUEST_CDMA_FLASH 84
+#define RIL_REQUEST_CDMA_BURST_DTMF 85
+#define RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY 86
+#define RIL_REQUEST_CDMA_SEND_SMS 87
+#define RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE 88
+#define RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG 89
+#define RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG 90
+#define RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION 91
+#define RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG 92
+#define RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG 93
+#define RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION 94
+#define RIL_REQUEST_CDMA_SUBSCRIPTION 95
+#define RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM 96
+#define RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM 97
+#define RIL_REQUEST_DEVICE_IDENTITY 98
+#define RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE 99
+#define RIL_REQUEST_GET_SMSC_ADDRESS 100
+#define RIL_REQUEST_SET_SMSC_ADDRESS 101
+#define RIL_REQUEST_REPORT_SMS_MEMORY_STATUS 102
+#define RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING 103
+#define RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE 104
+#define RIL_REQUEST_ISIM_AUTHENTICATION 105
+#define RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU 106
+#define RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS 107
+#define RIL_REQUEST_VOICE_RADIO_TECH 108
+#define RIL_REQUEST_GET_CELL_INFO_LIST 109
+#define RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE 110
+#define RIL_REQUEST_SET_INITIAL_ATTACH_APN 111
+#define RIL_REQUEST_IMS_REGISTRATION_STATE 112
+#define RIL_REQUEST_IMS_SEND_SMS 113
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/include/ril-transport.h
^
|
@@ -0,0 +1,64 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2018 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 __OFONO_RIL_TRANSPORT_H
+#define __OFONO_RIL_TRANSPORT_H
+
+#include <ofono/types.h>
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct grilio_transport;
+
+/*
+ * The api_version field makes it possible to keep using old plugins
+ * even if struct ofono_ril_transport gets extended with new callbacks.
+ */
+
+#define OFONO_RIL_TRANSPORT_API_VERSION (0)
+
+/*
+ * The connect callback takes a (char*) -> (char*) hashtable containing
+ * transport-specific connection parameters. The caller receives a reference
+ * i.e. it has to unref the returned object.
+ */
+struct ofono_ril_transport {
+ const char *name;
+ int api_version; /* OFONO_RIL_TRANSPORT_API_VERSION */
+ struct grilio_transport *(*connect)(GHashTable *params);
+};
+
+int ofono_ril_transport_register(const struct ofono_ril_transport *t);
+void ofono_ril_transport_unregister(const struct ofono_ril_transport *t);
+
+struct grilio_transport *ofono_ril_transport_connect(const char *name,
+ GHashTable *params);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_RIL_TRANSPORT_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/include/sailfish_manager.h
^
|
@@ -35,6 +35,18 @@
typedef void (*sailfish_slot_manager_impl_cb_t)
(struct sailfish_slot_manager_impl *impl, void *user_data);
+enum sailfish_slot_flags {
+ SAILFISH_SLOT_NO_FLAGS = 0,
+ /* Normally we should be able to have two simultaneously active
+ * data contexts - one for mobile data and one for MMS. The flag
+ * below says that for whatever reason it's impossible and mobile
+ * data has to be disconnected before we can send or receive MMS.
+ * On such devices it may not be a good idea to automatically
+ * download MMS because that would kill active mobile data
+ * connections. */
+ SAILFISH_SLOT_SINGLE_CONTEXT = 0x01
+};
+
typedef struct sailfish_slot {
const char *path;
const char *imei;
@@ -81,6 +93,12 @@
const char *path, enum ofono_radio_access_mode techs,
const char *imei, const char *imeisv,
enum sailfish_sim_state sim_state);
+struct sailfish_slot *sailfish_manager_slot_add2
+ (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,
+ enum sailfish_slot_flags flags);
void sailfish_manager_imei_obtained(struct sailfish_slot *s, const char *imei);
void sailfish_manager_imeisv_obtained(struct sailfish_slot *s,
const char *imeisv);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/include/types.h
^
|
@@ -56,6 +56,7 @@
OFONO_ERROR_TYPE_CEER,
OFONO_ERROR_TYPE_SIM,
OFONO_ERROR_TYPE_FAILURE,
+ OFONO_ERROR_TYPE_ERRNO
};
enum ofono_disconnect_reason {
@@ -70,16 +71,6 @@
int error;
};
-#define OFONO_EINVAL(error) do { \
- error->type = OFONO_ERROR_TYPE_FAILURE; \
- error->error = -EINVAL; \
-} while (0)
-
-#define OFONO_NO_ERROR(error) do { \
- error->type = OFONO_ERROR_TYPE_NO_ERROR; \
- error->error = 0; \
-} while (0)
-
#define OFONO_MAX_PHONE_NUMBER_LENGTH 80
#define OFONO_MAX_CALLER_NAME_LENGTH 80
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/include/voicecall-filter.h
^
|
@@ -0,0 +1,128 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2018 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 __OFONO_VOICECALL_FILTER_H
+#define __OFONO_VOICECALL_FILTER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ofono/voicecall.h>
+
+/* 27.007 Section 7.6 */
+enum ofono_clip_validity {
+ OFONO_CLIP_VALIDITY_VALID = 0,
+ OFONO_CLIP_VALIDITY_WITHHELD,
+ OFONO_CLIP_VALIDITY_NOT_AVAILABLE
+};
+
+/* 27.007 Section 7.18 */
+enum ofono_call_status {
+ OFONO_CALL_STATUS_ACTIVE = 0,
+ OFONO_CALL_STATUS_HELD,
+ OFONO_CALL_STATUS_DIALING,
+ OFONO_CALL_STATUS_ALERTING,
+ OFONO_CALL_STATUS_INCOMING,
+ OFONO_CALL_STATUS_WAITING,
+ OFONO_CALL_STATUS_DISCONNECTED
+};
+
+/* 27.007 Section 7.18 */
+enum ofono_call_direction {
+ OFONO_CALL_DIRECTION_MOBILE_ORIGINATED = 0,
+ OFONO_CALL_DIRECTION_MOBILE_TERMINATED
+};
+
+/* 27.007 Section 7.30 */
+enum ofono_cnap_validity {
+ OFONO_CNAP_VALIDITY_VALID = 0,
+ OFONO_CNAP_VALIDITY_WITHHELD,
+ OFONO_CNAP_VALIDITY_NOT_AVAILABLE
+};
+
+enum ofono_voicecall_filter_dial_result {
+ OFONO_VOICECALL_FILTER_DIAL_CONTINUE, /* Run the next filter */
+ OFONO_VOICECALL_FILTER_DIAL_BLOCK /* Don't dial*/
+};
+
+enum ofono_voicecall_filter_incoming_result {
+ OFONO_VOICECALL_FILTER_INCOMING_CONTINUE, /* Run the next filter */
+ OFONO_VOICECALL_FILTER_INCOMING_HANGUP, /* Hangup incoming call */
+ OFONO_VOICECALL_FILTER_INCOMING_IGNORE /* Ignore incoming call */
+};
+
+typedef void (*ofono_voicecall_filter_dial_cb_t)
+ (enum ofono_voicecall_filter_dial_result result,
+ void *data);
+
+typedef void (*ofono_voicecall_filter_incoming_cb_t)
+ (enum ofono_voicecall_filter_incoming_result result,
+ void *data);
+
+#define OFONO_VOICECALL_FILTER_PRIORITY_LOW (-100)
+#define OFONO_VOICECALL_FILTER_PRIORITY_DEFAULT (0)
+#define OFONO_VOICECALL_FILTER_PRIORITY_HIGH (100)
+
+/*
+ * The api_version field makes it possible to keep using old plugins
+ * even if struct ofono_voicecall_filter gets extended with new callbacks.
+ */
+
+#define OFONO_VOICECALL_FILTER_API_VERSION (0)
+
+/*
+ * The filter callbacks either invoke the completion callback directly
+ * or return the id of the cancellable asynchronous operation (but never
+ * both). If non-zero value is returned, the completion callback has to
+ * be invoked later on a fresh stack. Once the asynchronous filtering
+ * operation is cancelled, the associated completion callback must not
+ * be invoked.
+ *
+ * Please avoid making blocking D-Bus calls from the filter callbacks.
+ */
+struct ofono_voicecall_filter {
+ const char *name;
+ int api_version; /* OFONO_VOICECALL_FILTER_API_VERSION */
+ int priority;
+ void (*filter_cancel)(unsigned int id);
+ unsigned int (*filter_dial)(struct ofono_voicecall *vc,
+ const struct ofono_phone_number *number,
+ enum ofono_clir_option clir,
+ ofono_voicecall_filter_dial_cb_t cb,
+ void *data);
+ unsigned int (*filter_incoming)(struct ofono_voicecall *vc,
+ const struct ofono_call *call,
+ ofono_voicecall_filter_incoming_cb_t cb,
+ void *data);
+};
+
+void ofono_voicecall_filter_notify(struct ofono_voicecall *vc);
+int ofono_voicecall_filter_register(const struct ofono_voicecall_filter *f);
+void ofono_voicecall_filter_unregister(const struct ofono_voicecall_filter *f);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_VOICECALL_FILTER_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/include/voicecall.h
^
|
@@ -153,6 +153,8 @@
*/
void ofono_voicecall_mpty_hint(struct ofono_voicecall *vc, unsigned int ids);
+struct ofono_modem *ofono_voicecall_get_modem(struct ofono_voicecall *vc);
+
int ofono_voicecall_driver_register(const struct ofono_voicecall_driver *d);
void ofono_voicecall_driver_unregister(const struct ofono_voicecall_driver *d);
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/include/watch.h
^
|
@@ -0,0 +1,113 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2017-2019 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 OFONO_WATCH_H
+#define OFONO_WATCH_H
+
+#include <ofono/gprs-context.h>
+
+struct ofono_modem;
+struct ofono_sim;
+struct ofono_netreg;
+
+enum ofono_netreg_status {
+ OFONO_NETREG_STATUS_NONE = -1,
+ OFONO_NETREG_STATUS_NOT_REGISTERED = 0,
+ OFONO_NETREG_STATUS_REGISTERED = 1,
+ OFONO_NETREG_STATUS_SEARCHING = 2,
+ OFONO_NETREG_STATUS_DENIED = 3,
+ OFONO_NETREG_STATUS_UNKNOWN = 4,
+ OFONO_NETREG_STATUS_ROAMING = 5
+};
+
+/* This object watches ofono modem and various other things */
+struct ofono_watch {
+ const char *path;
+ /* Modem */
+ struct ofono_modem *modem;
+ ofono_bool_t 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;
+ /* Since mer/1.21+git47 */
+ enum ofono_netreg_status reg_status;
+ const char *reg_mcc;
+ const char *reg_mnc;
+ const char *reg_name;
+ /* OFONO_ATOM_TYPE_GPRS */
+ struct ofono_gprs *gprs;
+};
+
+typedef void (*ofono_watch_cb_t)(struct ofono_watch *w, void *user_data);
+typedef void (*ofono_watch_gprs_settings_cb_t)(struct ofono_watch *watch,
+ enum ofono_gprs_context_type type,
+ const struct ofono_gprs_primary_context *settings,
+ void *user_data);
+
+struct ofono_watch *ofono_watch_new(const char *path);
+struct ofono_watch *ofono_watch_ref(struct ofono_watch *w);
+void ofono_watch_unref(struct ofono_watch *w);
+
+unsigned long ofono_watch_add_modem_changed_handler(struct ofono_watch *w,
+ ofono_watch_cb_t cb, void *user_data);
+unsigned long ofono_watch_add_online_changed_handler(struct ofono_watch *w,
+ ofono_watch_cb_t cb, void *user_data);
+unsigned long ofono_watch_add_sim_changed_handler(struct ofono_watch *w,
+ ofono_watch_cb_t cb, void *user_data);
+unsigned long ofono_watch_add_sim_state_changed_handler(struct ofono_watch *w,
+ ofono_watch_cb_t cb, void *user_data);
+unsigned long ofono_watch_add_iccid_changed_handler(struct ofono_watch *w,
+ ofono_watch_cb_t cb, void *user_data);
+unsigned long ofono_watch_add_imsi_changed_handler(struct ofono_watch *w,
+ ofono_watch_cb_t cb, void *user_data);
+unsigned long ofono_watch_add_spn_changed_handler(struct ofono_watch *w,
+ ofono_watch_cb_t cb, void *user_data);
+unsigned long ofono_watch_add_netreg_changed_handler(struct ofono_watch *w,
+ ofono_watch_cb_t cb, void *user_data);
+void ofono_watch_remove_handler(struct ofono_watch *w, unsigned long id);
+void ofono_watch_remove_handlers(struct ofono_watch *w, unsigned long *ids,
+ unsigned int count);
+
+#define ofono_watch_remove_all_handlers(w,ids) \
+ ofono_watch_remove_handlers(w, ids, sizeof(ids)/sizeof((ids)[0]))
+
+/* Since mer/1.21+git47 */
+unsigned long ofono_watch_add_reg_status_changed_handler(struct ofono_watch *w,
+ ofono_watch_cb_t cb, void *user_data);
+unsigned long ofono_watch_add_reg_mcc_changed_handler(struct ofono_watch *w,
+ ofono_watch_cb_t cb, void *user_data);
+unsigned long ofono_watch_add_reg_mnc_changed_handler(struct ofono_watch *w,
+ ofono_watch_cb_t cb, void *user_data);
+unsigned long ofono_watch_add_reg_name_changed_handler(struct ofono_watch *w,
+ ofono_watch_cb_t cb, void *user_data);
+unsigned long ofono_watch_add_gprs_changed_handler(struct ofono_watch *w,
+ ofono_watch_cb_t cb, void *user_data);
+unsigned long ofono_watch_add_gprs_settings_changed_handler
+ (struct ofono_watch *watch, ofono_watch_gprs_settings_cb_t cb,
+ void *user_data);
+
+#endif /* OFONO_WATCH_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/plugins/dun_gw_bluez4.c
^
|
@@ -79,7 +79,7 @@
static void dun_gw_connect_cb(GIOChannel *io, GError *err, gpointer user_data)
{
struct ofono_emulator *em = user_data;
- struct ofono_modem *modem;
+ GList *i;
int fd;
DBG("");
@@ -90,16 +90,17 @@
return;
}
- /* Pick the first powered modem */
- modem = modems->data;
- DBG("Picked modem %p for emulator", modem);
+ DBG("Using all modems for emulator");
- em = ofono_emulator_create(modem, OFONO_EMULATOR_TYPE_DUN);
+ em = ofono_emulator_create(OFONO_EMULATOR_TYPE_DUN);
if (em == NULL) {
g_io_channel_shutdown(io, TRUE, NULL);
return;
}
+ for (i = modems; i; i = i->next)
+ ofono_emulator_add_modem(em, i->data);
+
fd = g_io_channel_unix_get_fd(io);
g_io_channel_set_close_on_unref(io, FALSE);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/plugins/dun_gw_bluez5.c
^
|
@@ -56,7 +56,7 @@
const char *device;
int fd;
struct ofono_emulator *em;
- struct ofono_modem *modem;
+ GList *i;
DBG("Profile handler NewConnection");
@@ -80,7 +80,6 @@
DBG("%s", device);
- /* Pick the first powered modem */
if (modems == NULL) {
close(fd);
return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
@@ -88,10 +87,9 @@
"No GPRS capable modem");
}
- modem = modems->data;
- DBG("Picked modem %p for emulator", modem);
+ DBG("Using all modems for emulator.");
- em = ofono_emulator_create(modem, OFONO_EMULATOR_TYPE_DUN);
+ em = ofono_emulator_create(OFONO_EMULATOR_TYPE_DUN);
if (em == NULL) {
close(fd);
return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
@@ -99,6 +97,9 @@
"Not enough resources");
}
+ for (i = modems; i; i = i->next)
+ ofono_emulator_add_modem(em, i->data);
+
ofono_emulator_register(em, fd);
return dbus_message_new_method_return(msg);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/plugins/hfp_ag_bluez4.c
^
|
@@ -91,6 +91,7 @@
struct ofono_modem *modem;
struct ofono_emulator *em;
int fd;
+ GList *i;
DBG("");
@@ -99,17 +100,18 @@
return;
}
- /* Pick the first voicecall capable modem */
- modem = modems->data;
- if (modem == NULL)
+ if (modems == NULL)
return;
- DBG("Picked modem %p for emulator", modem);
+ DBG("Using all modems for emulator");
- em = ofono_emulator_create(modem, OFONO_EMULATOR_TYPE_HFP);
+ em = ofono_emulator_create(OFONO_EMULATOR_TYPE_HFP);
if (em == NULL)
return;
+ for (i = modems; i; i = i->next)
+ ofono_emulator_add_modem(em, i->data);
+
fd = g_io_channel_unix_get_fd(io);
g_io_channel_set_close_on_unref(io, FALSE);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/plugins/hfp_ag_bluez5.c
^
|
@@ -47,19 +47,18 @@
#include "bluez5.h"
#include "bluetooth.h"
-#ifndef DBUS_TYPE_UNIX_FD
-#define DBUS_TYPE_UNIX_FD -1
-#endif
-
#define HFP_AG_EXT_PROFILE_PATH "/bluetooth/profile/hfp_ag"
#define BT_ADDR_SIZE 18
#define HFP_AG_DRIVER "hfp-ag-driver"
+static gboolean hfp_ag_enabled;
+static guint service_watch_id;
static guint modemwatch_id;
static GList *modems;
static GHashTable *sim_hash = NULL;
static GHashTable *connection_hash;
+static struct ofono_emulator *emulator = NULL;
static int hfp_card_probe(struct ofono_handsfree_card *card,
unsigned int vendor, void *data)
@@ -72,6 +71,8 @@
static void hfp_card_remove(struct ofono_handsfree_card *card)
{
DBG("");
+
+ emulator = NULL;
}
static void codec_negotiation_done_cb(int err, void *data)
@@ -172,9 +173,9 @@
struct sockaddr_rc saddr;
socklen_t optlen;
struct ofono_emulator *em;
- struct ofono_modem *modem;
char local[BT_ADDR_SIZE], remote[BT_ADDR_SIZE];
struct ofono_handsfree_card *card;
+ GList *i;
int err;
DBG("Profile handler NewConnection");
@@ -202,7 +203,6 @@
goto invalid;
}
- /* Pick the first voicecall capable modem */
if (modems == NULL) {
close(fd);
return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
@@ -210,9 +210,7 @@
"No voice call capable modem");
}
- modem = modems->data;
-
- DBG("Picked modem %p for emulator", modem);
+ DBG("Using all modems for emulator.");
memset(&saddr, 0, sizeof(saddr));
optlen = sizeof(saddr);
@@ -240,7 +238,7 @@
bt_ba2str(&saddr.rc_bdaddr, remote);
- em = ofono_emulator_create(modem, OFONO_EMULATOR_TYPE_HFP);
+ em = ofono_emulator_create(OFONO_EMULATOR_TYPE_HFP);
if (em == NULL) {
close(fd);
return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
@@ -248,6 +246,10 @@
"Not enough resources");
}
+ for (i = modems; i; i = i->next)
+ ofono_emulator_add_modem(em, i->data);
+
+ emulator = em;
ofono_emulator_register(em, fd);
fd_dup = dup(fd);
@@ -367,6 +369,9 @@
modems = g_list_append(modems, modem);
+ if (emulator)
+ ofono_emulator_add_modem(emulator, modem);
+
if (modems->next != NULL)
return;
@@ -459,29 +464,27 @@
modem_watch(modem, TRUE, user);
}
-static int hfp_ag_init(void)
+static void hfp_ag_enable(DBusConnection *conn)
{
- DBusConnection *conn = ofono_dbus_get_connection();
int err;
- if (DBUS_TYPE_UNIX_FD < 0)
- return -EBADF;
-
/* Registers External Profile handler */
- if (!g_dbus_register_interface(conn, HFP_AG_EXT_PROFILE_PATH,
- BLUEZ_PROFILE_INTERFACE,
- profile_methods, NULL,
- NULL, NULL, NULL)) {
+ if (!g_dbus_register_interface(conn,
+ HFP_AG_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE,
+ profile_methods,
+ NULL, NULL, NULL, NULL)) {
ofono_error("Register Profile interface failed: %s",
- HFP_AG_EXT_PROFILE_PATH);
- return -EIO;
+ HFP_AG_EXT_PROFILE_PATH);
+ return;
}
err = ofono_handsfree_card_driver_register(&hfp_ag_driver);
if (err < 0) {
g_dbus_unregister_interface(conn, HFP_AG_EXT_PROFILE_PATH,
- BLUEZ_PROFILE_INTERFACE);
- return err;
+ BLUEZ_PROFILE_INTERFACE);
+ ofono_error("Failed to register driver: %d", err);
+ return;
}
sim_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
@@ -490,30 +493,78 @@
__ofono_modem_foreach(call_modemwatch, NULL);
connection_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, connection_destroy);
+ g_free, connection_destroy);
ofono_handsfree_audio_ref();
- return 0;
+ hfp_ag_enabled = TRUE;
}
-static void hfp_ag_exit(void)
+static void hfp_ag_disable(DBusConnection *conn)
+{
+ if (modemwatch_id) {
+ __ofono_modemwatch_remove(modemwatch_id);
+ modemwatch_id = 0;
+ }
+
+ if (connection_hash) {
+ g_hash_table_destroy(connection_hash);
+ connection_hash = NULL;
+ }
+
+ g_list_free(modems);
+ modems = NULL;
+
+ if (sim_hash) {
+ g_hash_table_foreach_remove(sim_hash, sim_watch_remove, NULL);
+ g_hash_table_destroy(sim_hash);
+ sim_hash = NULL;
+ }
+
+ if (hfp_ag_enabled) {
+ g_dbus_unregister_interface(conn, HFP_AG_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE);
+ ofono_handsfree_card_driver_unregister(&hfp_ag_driver);
+ ofono_handsfree_audio_unref();
+ }
+
+ hfp_ag_enabled = FALSE;
+}
+
+static void bluez_connect_cb(DBusConnection *connection, void *user_data)
+{
+ hfp_ag_enable(connection);
+}
+
+static void bluez_disconnect_cb(DBusConnection *connection, void *user_data)
+{
+ hfp_ag_disable(connection);
+}
+
+static int hfp_ag_init(void)
{
DBusConnection *conn = ofono_dbus_get_connection();
- __ofono_modemwatch_remove(modemwatch_id);
- g_dbus_unregister_interface(conn, HFP_AG_EXT_PROFILE_PATH,
- BLUEZ_PROFILE_INTERFACE);
+ hfp_ag_enable(conn);
- ofono_handsfree_card_driver_unregister(&hfp_ag_driver);
+ service_watch_id = g_dbus_add_service_watch(conn, "org.bluez",
+ bluez_connect_cb,
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/plugins/push-notification.c
^
|
@@ -96,7 +96,7 @@
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
- if (!__ofono_dbus_valid_object_path(agent_path))
+ if (!dbus_validate_path(agent_path, NULL))
return __ofono_error_invalid_format(msg);
pn->agent = sms_agent_new(AGENT_INTERFACE,
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/plugins/sailfish_access.c
^
|
@@ -0,0 +1,257 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2019 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 OFONO_API_SUBJECT_TO_CHANGE
+
+#include <ofono/dbus-access.h>
+#include <ofono/plugin.h>
+#include <ofono/log.h>
+
+#include <dbusaccess_policy.h>
+#include <dbusaccess_peer.h>
+
+struct sailfish_access_intf {
+ const char *name;
+};
+
+struct sailfish_access_intf_policy {
+ const char* intf;
+ int n_methods;
+ DAPolicy* policy[1];
+};
+
+#define OFONO_BUS DA_BUS_SYSTEM
+
+#define COMMON_GROUP "Common"
+#define DEFAULT_POLICY "DefaultAccess"
+#define DEFAULT_INTF_POLICY "*"
+
+/* File name is external for unit testing */
+const char *sailfish_access_config_file = "/etc/ofono/dbusaccess.conf";
+static GHashTable* access_table = NULL;
+static const char *default_access_policy = DA_POLICY_VERSION "; "
+ "* = deny; "
+ "group(sailfish-radio) | group(privileged) = allow";
+
+/*
+ * Configuration is loaded from /etc/ofono/dbusaccess.conf
+ * If configuration is missing, default access rules are used.
+ * Syntax goes like this:
+ *
+ * [Common]
+ * DefaultAccess = <default rules for all controlled interfaces/methods>
+ *
+ * [InterfaceX]
+ * * = <default access rules for all methods in this interface>
+ * MethodY = <access rule for this method>
+ */
+
+static void sailfish_access_policy_free(gpointer user_data)
+{
+ da_policy_unref((DAPolicy*)user_data);
+}
+
+static void sailfish_access_load_config_intf(GKeyFile *config,
+ enum ofono_dbus_access_intf intf, DAPolicy* default_policy)
+{
+ struct sailfish_access_intf_policy *intf_policy;
+ const char *group = ofono_dbus_access_intf_name(intf);
+ const char *method;
+ DAPolicy *default_intf_policy = NULL;
+ char *default_intf_policy_spec = g_key_file_get_string(config, group,
+ DEFAULT_INTF_POLICY, NULL);
+ GPtrArray *policies = g_ptr_array_new_with_free_func
+ (sailfish_access_policy_free);
+ int i = 0;
+
+ /* Parse the default policy for this interface */
+ if (default_intf_policy_spec) {
+ default_intf_policy = da_policy_new(default_intf_policy_spec);
+ if (default_intf_policy) {
+ default_policy = default_intf_policy;
+ } else {
+ ofono_warn("Failed to parse default %s rule \"%s\"",
+ group, default_intf_policy_spec);
+ }
+ g_free(default_intf_policy_spec);
+ }
+
+ /* Parse individual policies for each method */
+ while ((method = ofono_dbus_access_method_name(intf, i++)) != NULL) {
+ DAPolicy* policy;
+ char *spec = g_key_file_get_string(config, group, method, NULL);
+
+ if (spec) {
+ policy = da_policy_new(spec);
+ if (!policy) {
+ ofono_warn("Failed to parse %s.%s rule \"%s\"",
+ group, method, spec);
+ policy = da_policy_ref(default_policy);
+ }
+ } else {
+ policy = da_policy_ref(default_policy);
+ }
+ g_ptr_array_add(policies, policy);
+ g_free(spec);
+ }
+
+ /* Allocate storage for interface policy information */
+ intf_policy = g_malloc0(
+ G_STRUCT_OFFSET(struct sailfish_access_intf_policy, policy) +
+ sizeof(DAPolicy*) * policies->len);
+ intf_policy->intf = group;
+ intf_policy->n_methods = policies->len;
+
+ for (i = 0; i < intf_policy->n_methods; i++) {
+ intf_policy->policy[i] = da_policy_ref(policies->pdata[i]);
+ }
+
+ da_policy_unref(default_intf_policy);
+ g_hash_table_insert(access_table, GINT_TO_POINTER(intf), intf_policy);
+ g_ptr_array_free(policies, TRUE);
+}
+
+static void sailfish_access_load_config()
+{
+ GKeyFile *config = g_key_file_new();
+ char *default_policy_spec;
+ DAPolicy* default_policy;
+ int i;
+
+ /*
+ * Try to load config file, in case of error just make sure
+ * that it config is empty.
+ */
+ if (g_file_test(sailfish_access_config_file, G_FILE_TEST_EXISTS)) {
+ if (g_key_file_load_from_file(config,
+ sailfish_access_config_file,
+ G_KEY_FILE_NONE, NULL)) {
+ DBG("Loading D-Bus access rules from %s",
+ sailfish_access_config_file);
+ } else {
+ g_key_file_unref(config);
+ config = g_key_file_new();
+ }
+ }
+
+ default_policy_spec = g_key_file_get_string(config, COMMON_GROUP,
+ DEFAULT_POLICY, NULL);
+ default_policy = da_policy_new(default_policy_spec);
+
+ if (!default_policy) {
+ default_policy = da_policy_new(default_access_policy);
+ if (!default_policy) {
+ ofono_warn("Failed to parse default D-Bus policy "
+ "\"%s\" (missing group?)",
+ default_access_policy);
+ }
+ }
+
+ for (i = 0; i < OFONO_DBUS_ACCESS_INTF_COUNT; i++) {
+ sailfish_access_load_config_intf(config, i, default_policy);
+ }
+
+ da_policy_unref(default_policy);
+ g_free(default_policy_spec);
+ g_key_file_unref(config);
+}
+
+static void sailfish_access_intf_free(gpointer user_data)
+{
+ struct sailfish_access_intf_policy* intf = user_data;
+ int i;
+
+ for (i = 0; i < intf->n_methods; i++) {
+ da_policy_unref(intf->policy[i]);
+ }
+ g_free(intf);
+}
+
+static enum ofono_dbus_access sailfish_access_method_access(const char *sender,
+ enum ofono_dbus_access_intf intf,
+ int method, const char *arg)
+{
+ struct sailfish_access_intf_policy *intf_policy = g_hash_table_lookup
+ (access_table, GINT_TO_POINTER(intf));
+
+ if (intf_policy && method >= 0 && method < intf_policy->n_methods) {
+ DAPeer *peer = da_peer_get(OFONO_BUS, sender);
+
+ if (peer) {
+ switch (da_policy_check(intf_policy->policy[method],
+ &peer->cred, 0, arg, DA_ACCESS_ALLOW)) {
+ case DA_ACCESS_ALLOW:
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/plugins/sailfish_manager/sailfish_manager.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony
*
- * Copyright (C) 2017-2018 Jolla Ltd.
+ * Copyright (C) 2017-2019 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,6 +22,8 @@
#include <gutil_macros.h>
#include <string.h>
+#include <ofono/watch.h>
+
#include "src/ofono.h"
#include "src/storage.h"
@@ -31,12 +33,11 @@
#include "sailfish_manager_dbus.h"
#include "sailfish_cell_info_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 {
+enum ofono_watch_events {
WATCH_EVENT_MODEM,
WATCH_EVENT_ONLINE,
WATCH_EVENT_IMSI,
@@ -83,12 +84,13 @@
struct sailfish_slot_priv *next;
struct sailfish_slot_manager *manager;
struct sailfish_slot_impl *impl;
- struct sailfish_watch *watch;
+ struct ofono_watch *watch;
struct sailfish_sim_info *siminfo;
struct sailfish_sim_info_dbus *siminfo_dbus;
struct sailfish_cell_info *cellinfo;
struct sailfish_cell_info_dbus *cellinfo_dbus;
enum sailfish_sim_state sim_state;
+ enum sailfish_slot_flags flags;
gulong watch_event_id[WATCH_EVENT_COUNT];
char *imei;
char *imeisv;
@@ -230,7 +232,7 @@
}
}
-static void sailfish_manager_slot_modem_changed(struct sailfish_watch *w,
+static void sailfish_manager_slot_modem_changed(struct ofono_watch *w,
void *user_data)
{
struct sailfish_slot_priv *s = user_data;
@@ -241,7 +243,7 @@
sailfish_manager_update_ready(p);
}
-static void sailfish_manager_slot_imsi_changed(struct sailfish_watch *w,
+static void sailfish_manager_slot_imsi_changed(struct ofono_watch *w,
void *user_data)
{
struct sailfish_slot_priv *slot = user_data;
@@ -321,6 +323,17 @@
const char *imei, const char *imeisv,
enum sailfish_sim_state sim_state)
{
+ return sailfish_manager_slot_add2(m, impl, path, techs, imei, imeisv,
+ sim_state, SAILFISH_SLOT_NO_FLAGS);
+}
+
+struct sailfish_slot *sailfish_manager_slot_add2
+ (struct sailfish_slot_manager *m, struct sailfish_slot_impl *impl,
+ const char *path, enum ofono_radio_access_mode techs,
+ const char *imei, const char *imeisv,
+ enum sailfish_sim_state sim_state,
+ enum sailfish_slot_flags flags)
+{
/* Only accept these calls when we are starting! We have been
* assuming all along that the number of slots is known right
* from startup. Perhaps it wasn't a super bright idea because
@@ -339,7 +352,8 @@
s->impl = impl;
s->manager = m;
s->sim_state = sim_state;
- s->watch = sailfish_watch_new(path);
+ s->flags = flags;
+ s->watch = ofono_watch_new(path);
s->siminfo = sailfish_sim_info_new(path);
s->siminfo_dbus = sailfish_sim_info_dbus_new(s->siminfo);
s->pub.path = s->watch->path;
@@ -389,13 +403,13 @@
/* Register for events */
s->watch_event_id[WATCH_EVENT_MODEM] =
- sailfish_watch_add_modem_changed_handler(s->watch,
+ ofono_watch_add_modem_changed_handler(s->watch,
sailfish_manager_slot_modem_changed, s);
s->watch_event_id[WATCH_EVENT_ONLINE] =
- sailfish_watch_add_online_changed_handler(s->watch,
+ ofono_watch_add_online_changed_handler(s->watch,
sailfish_manager_slot_modem_changed, s);
s->watch_event_id[WATCH_EVENT_IMSI] =
- sailfish_watch_add_imsi_changed_handler(s->watch,
+ ofono_watch_add_imsi_changed_handler(s->watch,
sailfish_manager_slot_imsi_changed, s);
return &s->pub;
@@ -426,8 +440,8 @@
sailfish_sim_info_dbus_free(s->siminfo_dbus);
sailfish_cell_info_dbus_free(s->cellinfo_dbus);
sailfish_cell_info_unref(s->cellinfo);
- sailfish_watch_remove_all_handlers(s->watch, s->watch_event_id);
- sailfish_watch_unref(s->watch);
+ ofono_watch_remove_all_handlers(s->watch, s->watch_event_id);
+ ofono_watch_unref(s->watch);
g_free(s->imei);
g_free(s->imeisv);
s->next = NULL;
@@ -649,10 +663,12 @@
mms_slot = sailfish_manager_find_slot_imsi(p, p->mms_imsi);
}
- if (mms_slot && mms_slot != slot) {
+ if (mms_slot && (mms_slot != slot ||
+ (slot->flags & SAILFISH_SLOT_SINGLE_CONTEXT))) {
/*
- * Reset default data SIM if another SIM is
- * temporarily selected for MMS.
+ * Reset default data SIM if
+ * a) another SIM is temporarily selected for MMS; or
+ * b) this slot can't have more than one context active.
*/
slot = NULL;
}
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/plugins/sailfish_manager/sailfish_sim_info.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony
*
- * Copyright (C) 2017-2018 Jolla Ltd.
+ * Copyright (C) 2017-2019 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,8 +17,9 @@
#include <config.h>
#endif
+#include <ofono/watch.h>
+
#include "sailfish_sim_info.h"
-#include "sailfish_watch.h"
#include <gutil_misc.h>
#include <gutil_log.h>
@@ -42,7 +43,7 @@
typedef GObjectClass SailfishSimInfoClass;
typedef struct sailfish_sim_info SailfishSimInfo;
-enum sailfish_watch_events {
+enum ofono_watch_events {
WATCH_EVENT_SIM,
WATCH_EVENT_SIM_STATE,
WATCH_EVENT_ICCID,
@@ -53,7 +54,7 @@
};
struct sailfish_sim_info_priv {
- struct sailfish_watch *watch;
+ struct ofono_watch *watch;
struct ofono_netreg *netreg;
char *iccid;
char *imsi;
@@ -251,7 +252,7 @@
static void sailfish_sim_info_update_spn(struct sailfish_sim_info *self)
{
- struct sailfish_watch *watch = self->priv->watch;
+ struct ofono_watch *watch = self->priv->watch;
if (watch->spn && watch->spn[0]) {
sailfish_sim_info_set_spn(self, watch->spn);
@@ -431,7 +432,7 @@
}
}
-static void sailfish_sim_info_iccid_watch_cb(struct sailfish_watch *watch,
+static void sailfish_sim_info_iccid_watch_cb(struct ofono_watch *watch,
void *data)
{
struct sailfish_sim_info *self = SAILFISH_SIMINFO(data);
@@ -441,7 +442,7 @@
sailfish_sim_info_emit_queued_signals(self);
}
-static void sailfish_sim_info_imsi_watch_cb(struct sailfish_watch *watch,
+static void sailfish_sim_info_imsi_watch_cb(struct ofono_watch *watch,
void *data)
{
struct sailfish_sim_info *self = SAILFISH_SIMINFO(data);
@@ -450,7 +451,7 @@
sailfish_sim_info_emit_queued_signals(self);
}
-static void sailfish_sim_info_spn_watch_cb(struct sailfish_watch *watch,
+static void sailfish_sim_info_spn_watch_cb(struct ofono_watch *watch,
void *data)
{
struct sailfish_sim_info *self = SAILFISH_SIMINFO(data);
@@ -503,7 +504,7 @@
}
}
-static void sailfish_sim_info_netreg_changed(struct sailfish_watch *watch,
+static void sailfish_sim_info_netreg_changed(struct ofono_watch *watch,
void *data)
{
struct sailfish_sim_info *self = SAILFISH_SIMINFO(data);
@@ -517,7 +518,7 @@
struct sailfish_sim_info *self = NULL;
if (path) {
- struct sailfish_watch *watch = sailfish_watch_new(path);
+ struct ofono_watch *watch = ofono_watch_new(path);
struct sailfish_sim_info_priv *priv;
self = g_object_new(SAILFISH_SIMINFO_TYPE, NULL);
@@ -525,16 +526,16 @@
priv->watch = watch;
self->path = watch->path;
priv->watch_event_id[WATCH_EVENT_ICCID] =
- sailfish_watch_add_iccid_changed_handler(watch,
+ ofono_watch_add_iccid_changed_handler(watch,
sailfish_sim_info_iccid_watch_cb, self);
priv->watch_event_id[WATCH_EVENT_IMSI] =
- sailfish_watch_add_imsi_changed_handler(watch,
+ ofono_watch_add_imsi_changed_handler(watch,
sailfish_sim_info_imsi_watch_cb, self);
priv->watch_event_id[WATCH_EVENT_SPN] =
- sailfish_watch_add_spn_changed_handler(watch,
+ ofono_watch_add_spn_changed_handler(watch,
sailfish_sim_info_spn_watch_cb, self);
priv->watch_event_id[WATCH_EVENT_NETREG] =
- sailfish_watch_add_netreg_changed_handler(watch,
+ ofono_watch_add_netreg_changed_handler(watch,
sailfish_sim_info_netreg_changed, self);
sailfish_sim_info_set_iccid(self, watch->iccid);
sailfish_sim_info_set_netreg(self, watch->netreg);
@@ -610,8 +611,8 @@
struct sailfish_sim_info *self = SAILFISH_SIMINFO(object);
struct sailfish_sim_info_priv *priv = self->priv;
- sailfish_watch_remove_all_handlers(priv->watch, priv->watch_event_id);
- sailfish_watch_unref(priv->watch);
+ ofono_watch_remove_all_handlers(priv->watch, priv->watch_event_id);
+ ofono_watch_unref(priv->watch);
g_free(priv->iccid);
g_free(priv->imsi);
g_free(priv->sim_spn);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/plugins/sailfish_manager/sailfish_sim_info_dbus.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony
*
- * Copyright (C) 2017 Jolla Ltd.
+ * Copyright (C) 2017-2019 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,9 +14,9 @@
*/
#include "sailfish_sim_info.h"
-#include "sailfish_watch.h"
#include <ofono/dbus.h>
+#include <ofono/watch.h>
#include <gdbus.h>
@@ -36,7 +36,7 @@
struct sailfish_sim_info_dbus {
struct sailfish_sim_info *info;
- struct sailfish_watch *watch;
+ struct ofono_watch *watch;
DBusConnection *conn;
gulong watch_event_id[WATCH_EVENT_COUNT];
gulong info_event_id[SIM_INFO_EVENT_COUNT];
@@ -165,7 +165,7 @@
{ }
};
-static void sailfish_sim_info_dbus_modem_cb(struct sailfish_watch *watch,
+static void sailfish_sim_info_dbus_modem_cb(struct ofono_watch *watch,
void *data)
{
if (watch->modem) {
@@ -214,7 +214,7 @@
DBG("%s", info->path);
dbus->info = sailfish_sim_info_ref(info);
- dbus->watch = sailfish_watch_new(info->path);
+ dbus->watch = ofono_watch_new(info->path);
dbus->conn = dbus_connection_ref(ofono_dbus_get_connection());
/* Register D-Bus interface */
@@ -229,7 +229,7 @@
}
dbus->watch_event_id[WATCH_EVENT_MODEM] =
- sailfish_watch_add_modem_changed_handler(dbus->watch,
+ ofono_watch_add_modem_changed_handler(dbus->watch,
sailfish_sim_info_dbus_modem_cb, dbus);
dbus->info_event_id[SIM_INFO_EVENT_ICCID] =
sailfish_sim_info_add_iccid_changed_handler(info,
@@ -275,9 +275,9 @@
}
dbus_connection_unref(dbus->conn);
- sailfish_watch_remove_all_handlers(dbus->watch,
+ ofono_watch_remove_all_handlers(dbus->watch,
dbus->watch_event_id);
- sailfish_watch_unref(dbus->watch);
+ ofono_watch_unref(dbus->watch);
sailfish_sim_info_remove_all_handlers(dbus->info,
dbus->info_event_id);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/plugins/smart-messaging.c
^
|
@@ -119,7 +119,7 @@
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
- if (!__ofono_dbus_valid_object_path(agent_path))
+ if (!dbus_validate_path(agent_path, NULL))
return __ofono_error_invalid_format(msg);
sm->agent = sms_agent_new(AGENT_INTERFACE,
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/plugins/udevng.c
^
|
@@ -1124,7 +1124,6 @@
const char *mdm = NULL, *net = NULL;
GSList *list;
- DBG("%s %s\n", __DATE__, __TIME__);
DBG("%s %s %s %s %s %s\n", modem->syspath, modem->devname,
modem->driver, modem->vendor, modem->model, modem->sysattr);
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/dbus-access.c
^
|
@@ -0,0 +1,252 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2019 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 "ofono.h"
+
+#include <errno.h>
+#include <string.h>
+
+static GSList *dbus_access_plugins = NULL;
+
+const char *ofono_dbus_access_intf_name(enum ofono_dbus_access_intf intf)
+{
+ switch (intf) {
+ case OFONO_DBUS_ACCESS_INTF_MESSAGE:
+ return OFONO_MESSAGE_INTERFACE;
+ case OFONO_DBUS_ACCESS_INTF_MESSAGEMGR:
+ return OFONO_MESSAGE_MANAGER_INTERFACE;
+ case OFONO_DBUS_ACCESS_INTF_VOICECALL:
+ return OFONO_VOICECALL_INTERFACE;
+ case OFONO_DBUS_ACCESS_INTF_VOICECALLMGR:
+ return OFONO_VOICECALL_MANAGER_INTERFACE;
+ case OFONO_DBUS_ACCESS_INTF_CONNCTX:
+ return OFONO_CONNECTION_CONTEXT_INTERFACE;
+ case OFONO_DBUS_ACCESS_INTF_CONNMGR:
+ return OFONO_CONNECTION_MANAGER_INTERFACE;
+ case OFONO_DBUS_ACCESS_INTF_SIMMGR:
+ return OFONO_SIM_MANAGER_INTERFACE;
+ case OFONO_DBUS_ACCESS_INTF_MODEM:
+ return OFONO_MODEM_INTERFACE;
+ case OFONO_DBUS_ACCESS_INTF_RADIOSETTINGS:
+ return OFONO_RADIO_SETTINGS_INTERFACE;
+ case OFONO_DBUS_ACCESS_INTF_COUNT:
+ break;
+ }
+ return NULL;
+}
+
+const char *ofono_dbus_access_method_name(enum ofono_dbus_access_intf intf,
+ int method)
+{
+ switch (intf) {
+ case OFONO_DBUS_ACCESS_INTF_MESSAGE:
+ switch ((enum ofono_dbus_access_message_method)method) {
+ case OFONO_DBUS_ACCESS_MESSAGE_CANCEL:
+ return "Cancel";
+ case OFONO_DBUS_ACCESS_MESSAGE_METHOD_COUNT:
+ break;
+ }
+ break;
+ case OFONO_DBUS_ACCESS_INTF_MESSAGEMGR:
+ switch ((enum ofono_dbus_access_messagemgr_method)method) {
+ case OFONO_DBUS_ACCESS_MESSAGEMGR_SEND_MESSAGE:
+ return "SendMessage";
+ case OFONO_DBUS_ACCESS_MESSAGEMGR_METHOD_COUNT:
+ break;
+ }
+ break;
+ case OFONO_DBUS_ACCESS_INTF_VOICECALL:
+ switch ((enum ofono_dbus_access_voicecall_method)method) {
+ case OFONO_DBUS_ACCESS_VOICECALL_DEFLECT:
+ return "Deflect";
+ case OFONO_DBUS_ACCESS_VOICECALL_HANGUP:
+ return "Hangup";
+ case OFONO_DBUS_ACCESS_VOICECALL_ANSWER:
+ return "Answer";
+ case OFONO_DBUS_ACCESS_VOICECALL_METHOD_COUNT:
+ break;
+ }
+ break;
+ case OFONO_DBUS_ACCESS_INTF_VOICECALLMGR:
+ switch ((enum ofono_dbus_access_voicecallmgr_method)method) {
+ case OFONO_DBUS_ACCESS_VOICECALLMGR_DIAL:
+ return "Dial";
+ case OFONO_DBUS_ACCESS_VOICECALLMGR_TRANSFER:
+ return "Transfer";
+ case OFONO_DBUS_ACCESS_VOICECALLMGR_SWAP_CALLS:
+ return "SwapCalls";
+ case OFONO_DBUS_ACCESS_VOICECALLMGR_RELEASE_AND_ANSWER:
+ return "ReleaseAndAnswer";
+ case OFONO_DBUS_ACCESS_VOICECALLMGR_RELEASE_AND_SWAP:
+ return "ReleaseAndSwap";
+ case OFONO_DBUS_ACCESS_VOICECALLMGR_HOLD_AND_ANSWER:
+ return "HoldAndAnswer";
+ case OFONO_DBUS_ACCESS_VOICECALLMGR_HANGUP_ALL:
+ return "HangupAll";
+ case OFONO_DBUS_ACCESS_VOICECALLMGR_CREATE_MULTIPARTY:
+ return "CreateMultiparty";
+ case OFONO_DBUS_ACCESS_VOICECALLMGR_HANGUP_MULTIPARTY:
+ return "HangupMultiparty";
+ case OFONO_DBUS_ACCESS_VOICECALLMGR_SEND_TONES:
+ return "SendTones";
+ case OFONO_DBUS_ACCESS_VOICECALLMGR_REGISTER_VOICECALL_AGENT:
+ return "RegisterVoicecallAgent";
+ case OFONO_DBUS_ACCESS_VOICECALLMGR_UNREGISTER_VOICECALL_AGENT:
+ return "UnregisterVoicecallAgent";
+ case OFONO_DBUS_ACCESS_VOICECALLMGR_METHOD_COUNT:
+ break;
+ }
+ break;
+ case OFONO_DBUS_ACCESS_INTF_CONNCTX:
+ switch ((enum ofono_dbus_access_connctx_method)method) {
+ case OFONO_DBUS_ACCESS_CONNCTX_SET_PROPERTY:
+ return "SetProperty";
+ case OFONO_DBUS_ACCESS_CONNCTX_PROVISION_CONTEXT:
+ return "ProvisionContext";
+ case OFONO_DBUS_ACCESS_CONNCTX_METHOD_COUNT:
+ break;
+ }
+ break;
+ case OFONO_DBUS_ACCESS_INTF_CONNMGR:
+ switch ((enum ofono_dbus_access_connmgr_method)method) {
+ case OFONO_DBUS_ACCESS_CONNMGR_SET_PROPERTY:
+ return "SetProperty";
+ case OFONO_DBUS_ACCESS_CONNMGR_DEACTIVATE_ALL:
+ return "DeactivateAll";
+ case OFONO_DBUS_ACCESS_CONNMGR_RESET_CONTEXTS:
+ return "ResetContexts";
+ case OFONO_DBUS_ACCESS_CONNMGR_METHOD_COUNT:
+ break;
+ }
+ break;
+ case OFONO_DBUS_ACCESS_INTF_SIMMGR:
+ switch ((enum ofono_dbus_access_simmgr_method)method) {
+ case OFONO_DBUS_ACCESS_SIMMGR_SET_PROPERTY:
+ return "SetProperty";
+ case OFONO_DBUS_ACCESS_SIMMGR_CHANGE_PIN:
+ return "ChangePin";
+ case OFONO_DBUS_ACCESS_SIMMGR_ENTER_PIN:
+ return "EnterPin";
+ case OFONO_DBUS_ACCESS_SIMMGR_RESET_PIN:
+ return "ResetPin";
+ case OFONO_DBUS_ACCESS_SIMMGR_LOCK_PIN:
+ return "LockPin";
+ case OFONO_DBUS_ACCESS_SIMMGR_UNLOCK_PIN:
+ return "UnlockPin";
+ case OFONO_DBUS_ACCESS_SIMMGR_METHOD_COUNT:
+ break;
+ }
+ break;
+ case OFONO_DBUS_ACCESS_INTF_MODEM:
+ switch ((enum ofono_dbus_access_modem_method)method) {
+ case OFONO_DBUS_ACCESS_MODEM_SET_PROPERTY:
+ return "SetProperty";
+ case OFONO_DBUS_ACCESS_MODEM_METHOD_COUNT:
+ break;
+ }
+ break;
+ case OFONO_DBUS_ACCESS_INTF_RADIOSETTINGS:
+ switch ((enum ofono_dbus_access_radiosettings_method)method) {
+ case OFONO_DBUS_ACCESS_RADIOSETTINGS_SET_PROPERTY:
+ return "SetProperty";
+ case OFONO_DBUS_ACCESS_RADIOSETTINGS_METHOD_COUNT:
+ break;
+ }
+ break;
+ case OFONO_DBUS_ACCESS_INTF_COUNT:
+ break;
+ }
+ return NULL;
+}
+
+gboolean __ofono_dbus_access_method_allowed(const char *sender,
+ enum ofono_dbus_access_intf intf,
+ int method, const char *arg)
+{
+ GSList *l = dbus_access_plugins;
+
+ while (l) {
+ GSList *next = l->next;
+ const struct ofono_dbus_access_plugin *plugin = l->data;
+
+ switch (plugin->method_access(sender, intf, method, arg)) {
+ case OFONO_DBUS_ACCESS_DENY:
+ return FALSE;
+ case OFONO_DBUS_ACCESS_ALLOW:
+ return TRUE;
+ case OFONO_DBUS_ACCESS_DONT_CARE:
+ break;
+ }
+
+ l = next;
+ }
+
+ return TRUE;
+}
+
+/**
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/dbus-queue.c
^
|
@@ -56,7 +56,7 @@
(struct ofono_dbus_queue_request *req,
ofono_dbus_cb_t fn, void *param)
{
- DBusMessage *reply = fn(req->msg, param);
+ DBusMessage *reply = fn ? fn(req->msg, param) : NULL;
if (!reply)
reply = __ofono_error_failed(req->msg);
@@ -129,11 +129,13 @@
if (!q || !q->requests) {
/* This should never happen */
- dbus_message_unref(reply);
+ if (reply) {
+ dbus_message_unref(reply);
+ }
return;
}
- /* De-queue the request */
+ /* De-queue one request */
done = q->requests;
next = done->next;
q->requests = next;
@@ -148,8 +150,19 @@
__ofono_dbus_queue_req_free(done);
/* Submit the next request if there is any */
- if (next) {
- next->fn(next->msg, next->data);
+ while (next && reply) {
+ reply = next->fn(next->msg, next->data);
+ if (reply) {
+ /* The request has completed synchronously */
+ done = next;
+ next = done->next;
+ q->requests = next;
+ done->next = NULL;
+
+ /* Send the reply */
+ __ofono_dbus_pending_reply(&done->msg, reply);
+ __ofono_dbus_queue_req_free(done);
+ }
}
}
@@ -190,7 +203,8 @@
ofono_dbus_reply_cb_t fn)
{
__ofono_dbus_queue_reply_all_fn_param(q,
- __ofono_dbus_queue_reply_all_wrapper, fn);
+ __ofono_dbus_queue_reply_all_wrapper,
+ fn ? fn : __ofono_error_failed);
}
void __ofono_dbus_queue_reply_all_fn_param(struct ofono_dbus_queue *q,
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/dbus.c
^
|
@@ -24,6 +24,7 @@
#endif
#include <glib.h>
+#include <errno.h>
#include <gdbus.h>
#include "ofono.h"
@@ -37,7 +38,7 @@
DBusMessage *(*ofono_error_func)(DBusMessage *);
};
-struct error_mapping_entry cme_errors_mapping[] = {
+static const struct error_mapping_entry cme_errors_mapping[] = {
{ 3, __ofono_error_not_allowed },
{ 4, __ofono_error_not_supported },
{ 16, __ofono_error_incorrect_password },
@@ -45,6 +46,16 @@
{ 31, __ofono_error_timed_out },
{ 32, __ofono_error_access_denied },
{ 50, __ofono_error_invalid_args },
+ { }
+};
+
+static const struct error_mapping_entry errno_errors_mapping[] = {
+ { EACCES, __ofono_error_access_denied },
+ { EOPNOTSUPP, __ofono_error_not_supported },
+ { ENOSYS, __ofono_error_not_implemented },
+ { ETIMEDOUT, __ofono_error_timed_out },
+ { EINPROGRESS, __ofono_error_busy },
+ { }
};
static void append_variant(DBusMessageIter *iter,
@@ -419,26 +430,31 @@
" network");
}
+static DBusMessage *__ofono_map_error(const struct error_mapping_entry *map,
+ int error, DBusMessage *msg)
+{
+ const struct error_mapping_entry *e;
+
+ for (e = map; e->ofono_error_func; e++)
+ if (e->error == error)
+ return e->ofono_error_func(msg);
+
+ return __ofono_error_failed(msg);
+}
+
DBusMessage *__ofono_error_from_error(const struct ofono_error *error,
DBusMessage *msg)
{
- struct error_mapping_entry *e;
- int maxentries;
- int i;
-
switch (error->type) {
case OFONO_ERROR_TYPE_CME:
- e = cme_errors_mapping;
- maxentries = sizeof(cme_errors_mapping) /
- sizeof(struct error_mapping_entry);
- for (i = 0; i < maxentries; i++)
- if (e[i].error == error->error)
- return e[i].ofono_error_func(msg);
- break;
+ return __ofono_map_error(cme_errors_mapping, error->error, msg);
case OFONO_ERROR_TYPE_CMS:
return __ofono_error_failed(msg);
case OFONO_ERROR_TYPE_CEER:
return __ofono_error_failed(msg);
+ case OFONO_ERROR_TYPE_ERRNO:
+ return __ofono_map_error(errno_errors_mapping,
+ ABS(error->error), msg);
default:
return __ofono_error_failed(msg);
}
@@ -456,50 +472,6 @@
*msg = NULL;
}
-gboolean __ofono_dbus_valid_object_path(const char *path)
-{
- unsigned int i;
- char c = '\0';
-
- if (path == NULL)
- return FALSE;
-
- if (path[0] == '\0')
- return FALSE;
-
- if (path[0] && !path[1] && path[0] == '/')
- return TRUE;
-
- if (path[0] != '/')
- return FALSE;
-
- for (i = 0; path[i]; i++) {
- if (path[i] == '/' && c == '/')
- return FALSE;
-
- c = path[i];
-
- if (path[i] >= 'a' && path[i] <= 'z')
- continue;
-
- if (path[i] >= 'A' && path[i] <= 'Z')
- continue;
-
- if (path[i] >= '0' && path[i] <= '9')
- continue;
-
- if (path[i] == '_' || path[i] == '/')
- continue;
-
- return FALSE;
- }
-
- if (path[i-1] == '/')
- return FALSE;
-
- return TRUE;
-}
-
DBusConnection *ofono_dbus_get_connection(void)
{
return g_connection;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/emulator.c
^
|
@@ -51,7 +51,9 @@
};
struct ofono_emulator {
- struct ofono_atom *atom;
+ GList *atoms;
+ GList *registered_atoms;
+ gboolean emulator_registered;
enum ofono_emulator_type type;
GAtServer *server;
GAtPPP *ppp;
@@ -355,10 +357,17 @@
static struct ofono_call *find_call_with_status(struct ofono_emulator *em,
int status)
{
- struct ofono_modem *modem = __ofono_atom_get_modem(em->atom);
- struct ofono_voicecall *vc;
+ struct ofono_modem *modem;
+ struct ofono_voicecall *vc = NULL;
+ GList *i;
+
+ for (i = em->atoms; i; i = i->next) {
+ modem = __ofono_atom_get_modem(i->data);
+ if ((vc = __ofono_atom_find(OFONO_ATOM_TYPE_VOICECALL, modem)))
+ break;
+ }
+
- vc = __ofono_atom_find(OFONO_ATOM_TYPE_VOICECALL, modem);
if (vc == NULL)
return NULL;
@@ -1153,7 +1162,20 @@
struct ofono_emulator *em = __ofono_atom_get_data(atom);
GSList *l;
- DBG("%p", em);
+ DBG("%p (atom %p)", em, atom);
+
+ em->registered_atoms = g_list_remove(em->registered_atoms, atom);
+ if (em->registered_atoms)
+ return;
+
+ if (!em->emulator_registered) {
+ DBG("emulator already unregistered");
+ return;
+ }
+
+ em->emulator_registered = FALSE;
+
+ DBG("%p no more atoms registered", em);
if (em->callsetup_source) {
g_source_remove(em->callsetup_source);
@@ -1185,12 +1207,27 @@
em->card = NULL;
}
+static void emulator_register_atom(struct ofono_emulator *em, struct ofono_atom *atom)
+{
+ if (!g_list_find(em->registered_atoms, atom)) {
+ em->registered_atoms = g_list_append(em->registered_atoms, atom);
+ DBG("%p", atom);
+ __ofono_atom_register(atom, emulator_unregister);
+ }
+}
+
void ofono_emulator_register(struct ofono_emulator *em, int fd)
{
GIOChannel *io;
+ GList *i;
DBG("%p, %d", em, fd);
+ if (em->emulator_registered) {
+ DBG("emulator already registered");
+ return;
+ }
+
if (fd < 0)
return;
@@ -1240,7 +1277,8 @@
g_at_server_register(em->server, "+BCS", bcs_cb, em, NULL);
}
- __ofono_atom_register(em->atom, emulator_unregister);
+ for (i = em->atoms; i; i = i->next)
+ emulator_register_atom(em, i->data);
switch (em->type) {
case OFONO_EMULATOR_TYPE_DUN:
@@ -1254,31 +1292,41 @@
default:
break;
}
+
+ em->emulator_registered = TRUE;
+}
+
+static void emulator_free(struct ofono_emulator *em)
+{
+ g_assert(!em->atoms);
+
+ DBG("free emulator %p", em);
+ if (em->registered_atoms)
+ g_list_free(em->registered_atoms);
+ g_free(em);
}
static void emulator_remove(struct ofono_atom *atom)
{
struct ofono_emulator *em = __ofono_atom_get_data(atom);
- DBG("atom: %p", atom);
+ DBG("remove atom %p", atom);
+ em->atoms = g_list_remove(em->atoms, atom);
- g_free(em);
+ if (!em->atoms)
+ emulator_free(em);
}
-struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
- enum ofono_emulator_type type)
+struct ofono_emulator *ofono_emulator_create(enum ofono_emulator_type type)
{
struct ofono_emulator *em;
- enum ofono_atom_type atom_t;
- DBG("modem: %p, type: %d", modem, type);
-
- if (type == OFONO_EMULATOR_TYPE_DUN)
- atom_t = OFONO_ATOM_TYPE_EMULATOR_DUN;
- else if (type == OFONO_EMULATOR_TYPE_HFP)
- atom_t = OFONO_ATOM_TYPE_EMULATOR_HFP;
- else
+ if (type != OFONO_EMULATOR_TYPE_DUN && type != OFONO_EMULATOR_TYPE_HFP) {
+ DBG("unsupported emulator type %d", type);
return NULL;
+ }
+
+ DBG("create emulator of type %d", type);
em = g_try_new0(struct ofono_emulator, 1);
@@ -1296,15 +1344,59 @@
em->events_mode = 3; /* default mode is forwarding events */
em->cmee_mode = 0; /* CME ERROR disabled by default */
- em->atom = __ofono_modem_add_atom_offline(modem, atom_t,
- emulator_remove, em);
-
return em;
}
+void ofono_emulator_add_modem(struct ofono_emulator *em,
+ struct ofono_modem *modem)
+{
+ struct ofono_atom *atom;
+ enum ofono_atom_type atom_t;
+
+ if (em->type == OFONO_EMULATOR_TYPE_DUN)
+ atom_t = OFONO_ATOM_TYPE_EMULATOR_DUN;
+ else
+ atom_t = OFONO_ATOM_TYPE_EMULATOR_HFP;
+
+ if ((atom = __ofono_modem_find_atom(modem, atom_t))) {
+ if (g_list_find(em->atoms, atom)) {
+ DBG("modem %p already added", modem);
+ goto register_atom;
+ }
+ }
+
+ DBG("%p", modem);
+
+ atom = __ofono_modem_add_atom_offline(modem, atom_t,
+ emulator_remove, em);
+ em->atoms = g_list_append(em->atoms, atom);
+
+register_atom:
+ if (em->emulator_registered)
+ emulator_register_atom(em, atom);
+}
+
void ofono_emulator_remove(struct ofono_emulator *em)
{
- __ofono_atom_free(em->atom);
+ GList *remove_list;
+ GList *i;
+
+ DBG("");
+
+ /* If emulator has atoms we make a copy of the atom list here,
+ * as the list is modified when the atoms are being destroyed.
+ * When last atom is gone struct ofono_emulator is freed as
+ * well (in emulator_remove()). */
+ if (em->atoms) {
+ remove_list = g_list_copy(em->atoms);
+ for (i = remove_list; i; i = i->next) {
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/gnss.c
^
|
@@ -135,7 +135,7 @@
&agent_path, DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
- if (!__ofono_dbus_valid_object_path(agent_path))
+ if (!dbus_validate_path(agent_path, NULL))
return __ofono_error_invalid_format(msg);
gnss->posr_agent = gnss_agent_new(agent_path,
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/gprs-filter.c
^
|
@@ -0,0 +1,548 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2018-2019 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 "ofono.h"
+
+#include <errno.h>
+#include <string.h>
+
+struct gprs_filter_request;
+struct gprs_filter_request_fn {
+ const char *name;
+ gboolean (*can_process)(const struct ofono_gprs_filter *filter);
+ guint (*process)(const struct ofono_gprs_filter *filter,
+ struct gprs_filter_request *req);
+ void (*complete)(struct gprs_filter_request *req, gboolean allow);
+ void (*free)(struct gprs_filter_request *req);
+};
+
+struct gprs_filter_request {
+ int refcount;
+ struct gprs_filter_chain *chain;
+ struct ofono_gprs_context *gc;
+ const struct gprs_filter_request_fn *fn;
+ GSList *filter_link;
+ guint pending_id;
+ guint next_id;
+ ofono_destroy_func destroy;
+ void* user_data;
+};
+
+struct gprs_filter_request_activate {
+ struct gprs_filter_request req;
+ struct ofono_gprs_primary_context ctx;
+ gprs_filter_activate_cb_t cb;
+};
+
+struct gprs_filter_request_check {
+ struct gprs_filter_request req;
+ ofono_gprs_filter_check_cb_t cb;
+};
+
+struct gprs_filter_chain {
+ struct ofono_gprs *gprs;
+ GSList *req_list;
+};
+
+static GSList *gprs_filter_list = NULL;
+
+static void gprs_filter_request_init(struct gprs_filter_request *req,
+ const struct gprs_filter_request_fn *fn,
+ struct gprs_filter_chain *chain, struct ofono_gprs_context *gc,
+ ofono_destroy_func destroy, void *user_data)
+{
+ req->chain = chain;
+ req->fn = fn;
+ req->gc = gc;
+ req->filter_link = gprs_filter_list;
+ req->destroy = destroy;
+ req->user_data = user_data;
+
+ /*
+ * The list holds an implicit reference to the message. The reference
+ * is released by gprs_filter_request_free when the message is removed
+ * from the list.
+ */
+ req->refcount = 1;
+ chain->req_list = g_slist_append(chain->req_list, req);
+}
+
+static void gprs_filter_request_cancel(struct gprs_filter_request *req)
+{
+ if (req->pending_id) {
+ const struct ofono_gprs_filter *f = req->filter_link->data;
+
+ /*
+ * If the filter returns id of the pending operation,
+ * then it must provide the cancel callback
+ */
+ f->cancel(req->pending_id);
+ req->pending_id = 0;
+ }
+ if (req->next_id) {
+ g_source_remove(req->next_id);
+ req->next_id = 0;
+ }
+}
+
+static void gprs_filter_request_dispose(struct gprs_filter_request *req)
+{
+ /* May be invoked several times per request */
+ if (req->destroy) {
+ ofono_destroy_func destroy = req->destroy;
+
+ req->destroy = NULL;
+ destroy(req->user_data);
+ }
+}
+
+static void gprs_filter_request_free(struct gprs_filter_request *req)
+{
+ gprs_filter_request_dispose(req);
+ req->fn->free(req);
+}
+
+#define gprs_filter_request_ref(req) ((void)((req)->refcount++))
+
+static int gprs_filter_request_unref(struct gprs_filter_request *req)
+{
+ const int refcount = --(req->refcount);
+
+ if (!refcount) {
+ gprs_filter_request_free(req);
+ }
+ return refcount;
+}
+
+static void gprs_filter_request_free1(gpointer data)
+{
+ struct gprs_filter_request *req = data;
+
+ /*
+ * This is a g_slist_free_full() callback for use by
+ * __ofono_gprs_filter_chain_free(), meaning that the
+ * chain is no more. Zero the pointer to it in case if
+ * this is not the last reference.
+ */
+ req->chain = NULL;
+ gprs_filter_request_unref(req);
+}
+
+static void gprs_filter_request_dequeue(struct gprs_filter_request *req)
+{
+ struct gprs_filter_chain *chain = req->chain;
+ GSList *l;
+
+ /*
+ * Single-linked list is not particularly good at searching
+ * and removing the elements but since it should be pretty
+ * short (typically just one request), it's not worth optimization.
+ */
+ if (chain && (l = g_slist_find(chain->req_list, req)) != NULL) {
+ gprs_filter_request_free1(l->data);
+ chain->req_list = g_slist_delete_link(chain->req_list, l);
+ }
+}
+
+static void gprs_filter_request_complete(struct gprs_filter_request *req,
+ gboolean allow)
+{
+ gprs_filter_request_ref(req);
+ req->fn->complete(req, allow);
+ gprs_filter_request_dispose(req);
+ gprs_filter_request_dequeue(req);
+ gprs_filter_request_unref(req);
+}
+
+static void gprs_filter_request_process(struct gprs_filter_request *req)
+{
+ GSList *l = req->filter_link;
+ const struct ofono_gprs_filter *f = l->data;
+ const struct gprs_filter_request_fn *fn = req->fn;
+
+ while (f && !fn->can_process(f)) {
+ l = l->next;
+ f = l ? l->data : NULL;
+ }
+
+ gprs_filter_request_ref(req);
+ if (f) {
+ req->filter_link = l;
+ req->pending_id = fn->process(f, req);
+ } else {
+ gprs_filter_request_complete(req, TRUE);
+ }
+ gprs_filter_request_unref(req);
+}
+
+static void gprs_filter_request_next(struct gprs_filter_request *req,
+ GSourceFunc fn)
+{
+ req->pending_id = 0;
+ req->next_id = g_idle_add(fn, req);
+}
+
+static gboolean gprs_filter_request_continue_cb(gpointer data)
+{
+ struct gprs_filter_request *req = data;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/gprs.c
^
|
@@ -46,6 +46,7 @@
#include "idmap.h"
#include "simutil.h"
#include "util.h"
+#include "watch_p.h"
#define GPRS_FLAG_ATTACHING 0x1
#define GPRS_FLAG_RECHECK 0x2
@@ -85,6 +86,7 @@
void *driver_data;
struct ofono_atom *atom;
unsigned int spn_watch;
+ struct gprs_filter_chain *filters;
};
struct ipv4_settings {
@@ -136,7 +138,13 @@
struct ofono_gprs *gprs;
};
-static void gprs_attached_update(struct ofono_gprs *gprs);
+/*
+ * In Sailfish OS fork gprs_attached_update() is exported to plugins
+ * as ofono_gprs_attached_update(). Exported functions must start
+ * with ofono_ prefix.
+ */
+#define gprs_attached_update(gprs) ofono_gprs_attached_update(gprs)
+
static void gprs_netreg_update(struct ofono_gprs *gprs);
static void gprs_deactivate_next(struct ofono_gprs *gprs);
static void write_context_settings(struct ofono_gprs *gprs,
@@ -368,6 +376,9 @@
if (ctx == NULL || ctx->gprs == NULL || ctx->context_driver == NULL)
return;
+ __ofono_gprs_filter_chain_cancel(ctx->gprs->filters,
+ ctx->context_driver);
+
gprs_cid_release(ctx->gprs, ctx->context.cid);
ctx->context.cid = 0;
ctx->context_driver->inuse = FALSE;
@@ -905,6 +916,13 @@
name, DBUS_TYPE_STRING, &value);
}
+static void pri_settings_changed(struct pri_context *ctx)
+{
+ const char *path = __ofono_atom_get_path(ctx->gprs->atom);
+
+ __ofono_watch_gprs_settings_changed(path, ctx->type, &ctx->context);
+}
+
static void pri_reset_context_properties(struct pri_context *ctx,
const struct ofono_gprs_provision_data *ap)
{
@@ -971,6 +989,10 @@
write_context_settings(gprs, ctx);
storage_sync(gprs->imsi, SETTINGS_STORE, gprs->settings);
}
+
+ if (changed) {
+ pri_settings_changed(ctx);
+ }
}
static gboolean ap_valid(const struct ofono_gprs_provision_data *ap)
@@ -1024,6 +1046,13 @@
return FALSE;
}
+static gboolean connctx_allow(DBusMessage *msg,
+ enum ofono_dbus_access_connctx_method method, const char *arg)
+{
+ return __ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
+ OFONO_DBUS_ACCESS_INTF_CONNCTX, method, arg);
+}
+
static DBusMessage *pri_provision_context(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -1036,6 +1065,10 @@
DBusMessage *reply = NULL;
int i, count = 0;
+ if (!connctx_allow(msg, OFONO_DBUS_ACCESS_CONNCTX_PROVISION_CONTEXT,
+ NULL))
+ return __ofono_error_access_denied(msg);
+
if (sim == NULL)
return __ofono_error_failed(msg);
@@ -1047,16 +1080,17 @@
for (i = 0; i < count; i++) {
const struct ofono_gprs_provision_data *ap = settings + i;
if (ap->type == ctx->type && ap_valid(ap)) {
- if ((!ctx->active &&
- !ctx->pending && !ctx->gprs->pending) ||
- !pri_deactivation_required(ctx, ap)) {
+ if (ctx->pending || ctx->gprs->pending) {
+ /* Context is being messed with */
+ reply = __ofono_error_busy(msg);
+ } else if (ctx->active &&
+ pri_deactivation_required(ctx, ap)) {
+ /* Context needs to be deactivated first */
+ reply = __ofono_error_busy(msg);
+ } else {
/* Re-provision the context */
pri_reset_context_properties(ctx, ap);
reply = dbus_message_new_method_return(msg);
- } else {
- /* Context should be inactive */
- if (ctx->gprs->pending || ctx->pending)
- reply = __ofono_error_busy(msg);
}
break;
}
@@ -1151,8 +1185,6 @@
DBusConnection *conn = ofono_dbus_get_connection();
dbus_bool_t value;
- DBG("%p", ctx);
-
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
DBG("Activating context failed with error: %s",
telephony_error_to_str(error));
@@ -1163,6 +1195,8 @@
return;
}
+ DBG("%p", ctx);
+
ctx->active = TRUE;
__ofono_dbus_pending_reply(&ctx->pending,
dbus_message_new_method_return(ctx->pending));
@@ -1198,6 +1232,8 @@
return;
}
+ DBG("%p", ctx);
+
__ofono_dbus_pending_reply(&ctx->pending,
dbus_message_new_method_return(ctx->pending));
@@ -1310,6 +1346,7 @@
"AccessPointName",
DBUS_TYPE_STRING, &apn);
+ pri_settings_changed(ctx);
return NULL;
}
@@ -1340,6 +1377,7 @@
"Username",
DBUS_TYPE_STRING, &username);
+ pri_settings_changed(ctx);
return NULL;
}
@@ -1370,6 +1408,7 @@
"Password",
DBUS_TYPE_STRING, &password);
+ pri_settings_changed(ctx);
return NULL;
}
@@ -1398,6 +1437,7 @@
OFONO_CONNECTION_CONTEXT_INTERFACE,
"Type", DBUS_TYPE_STRING, &type);
+ pri_settings_changed(ctx);
return NULL;
}
@@ -1427,6 +1467,7 @@
OFONO_CONNECTION_CONTEXT_INTERFACE,
"Protocol", DBUS_TYPE_STRING, &str);
+ pri_settings_changed(ctx);
return NULL;
}
@@ -1543,9 +1584,55 @@
"AuthenticationMethod",
DBUS_TYPE_STRING, &str);
+ pri_settings_changed(ctx);
return NULL;
}
+struct pri_request_data {
+ struct pri_context *pri;
+ DBusMessage *msg;
+};
+
+static struct pri_request_data *pri_request_new(struct pri_context *pri)
+{
+ struct pri_request_data *data = g_new0(struct pri_request_data, 1);
+
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/handsfree-audio.c
^
|
@@ -912,6 +912,7 @@
if (agent) {
agent_release(agent);
agent_free(agent);
+ agent = NULL;
}
__ofono_handsfree_audio_manager_cleanup();
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/message.c
^
|
@@ -83,6 +83,11 @@
struct message *m = data;
int res;
+ if (!__ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
+ OFONO_DBUS_ACCESS_INTF_MESSAGE,
+ OFONO_DBUS_ACCESS_MESSAGE_CANCEL, NULL))
+ return __ofono_error_access_denied(msg);
+
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/modem.c
^
|
@@ -190,6 +190,16 @@
return __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem);
}
+struct ofono_gprs *ofono_modem_get_gprs(struct ofono_modem *modem)
+{
+ return __ofono_atom_find(OFONO_ATOM_TYPE_GPRS, modem);
+}
+
+struct ofono_voicecall *ofono_modem_get_voicecall(struct ofono_modem *modem)
+{
+ return __ofono_atom_find(OFONO_ATOM_TYPE_VOICECALL, modem);
+}
+
struct ofono_atom *__ofono_modem_add_atom(struct ofono_modem *modem,
enum ofono_atom_type type,
void (*destruct)(struct ofono_atom *),
@@ -1085,6 +1095,11 @@
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
return __ofono_error_invalid_args(msg);
+ if (!__ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
+ OFONO_DBUS_ACCESS_INTF_MODEM,
+ OFONO_DBUS_ACCESS_MODEM_SET_PROPERTY, name))
+ return __ofono_error_access_denied(msg);
+
if (powering_down == TRUE)
return __ofono_error_failed(msg);
@@ -1882,7 +1897,7 @@
else
snprintf(path, sizeof(path), "/%s", name);
- if (__ofono_dbus_valid_object_path(path) == FALSE)
+ if (!dbus_validate_path(path, NULL))
return NULL;
modem = g_try_new0(struct ofono_modem, 1);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/netmon.c
^
|
@@ -353,7 +353,7 @@
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
- if (!__ofono_dbus_valid_object_path(agent_path))
+ if (!dbus_validate_path(agent_path, NULL))
return __ofono_error_invalid_format(msg);
if (!period)
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/network.c
^
|
@@ -1527,9 +1527,8 @@
}
if (netreg->mode != NETWORK_REGISTRATION_MODE_MANUAL &&
- (status == NETWORK_REGISTRATION_STATUS_NOT_REGISTERED ||
- status == NETWORK_REGISTRATION_STATUS_DENIED ||
- status == NETWORK_REGISTRATION_STATUS_UNKNOWN)) {
+ status != NETWORK_REGISTRATION_STATUS_REGISTERED &&
+ status != NETWORK_REGISTRATION_STATUS_ROAMING) {
if (netreg->driver->register_auto != NULL)
netreg->driver->register_auto(netreg, init_register,
netreg);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/ofono.h
^
|
@@ -77,8 +77,6 @@
void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply);
-gboolean __ofono_dbus_valid_object_path(const char *path);
-
struct ofono_watchlist_item {
unsigned int id;
void *notify;
@@ -277,10 +275,6 @@
gboolean __ofono_gprs_get_roaming_allowed(struct ofono_gprs *gprs);
#include <ofono/gprs-context.h>
-
-const struct ofono_gprs_primary_context *__ofono_gprs_context_settings_by_type
- (struct ofono_gprs *gprs, enum ofono_gprs_context_type type);
-
#include <ofono/radio-settings.h>
#include <ofono/audio-settings.h>
#include <ofono/ctm.h>
@@ -592,6 +586,57 @@
const struct sms_scts *scts,
sms_dispatch_recv_text_cb_t default_handler);
+#include <ofono/gprs-filter.h>
+
+struct gprs_filter_chain;
+
+typedef void (*gprs_filter_activate_cb_t)
+ (const struct ofono_gprs_primary_context *ctx, void *user_data);
+typedef void (*gprs_filter_check_cb_t)(ofono_bool_t allow, void *user_data);
+struct gprs_filter_chain *__ofono_gprs_filter_chain_new(struct ofono_gprs *gp);
+void __ofono_gprs_filter_chain_free(struct gprs_filter_chain *chain);
+void __ofono_gprs_filter_chain_cancel(struct gprs_filter_chain *chain,
+ struct ofono_gprs_context *gc);
+void __ofono_gprs_filter_chain_activate(struct gprs_filter_chain *chain,
+ struct ofono_gprs_context *gc,
+ const struct ofono_gprs_primary_context *ctx,
+ gprs_filter_activate_cb_t act, ofono_destroy_func destroy,
+ void *user_data);
+void __ofono_gprs_filter_chain_check(struct gprs_filter_chain *chain,
+ gprs_filter_check_cb_t cb, ofono_destroy_func destroy,
+ void *user_data);
+
+#include <ofono/voicecall-filter.h>
+
+struct voicecall_filter_chain;
+
+struct voicecall_filter_chain *__ofono_voicecall_filter_chain_new
+ (struct ofono_voicecall *vc);
+void __ofono_voicecall_filter_chain_cancel(struct voicecall_filter_chain *c,
+ const struct ofono_call *call);
+void __ofono_voicecall_filter_chain_restart(struct voicecall_filter_chain *c,
+ const struct ofono_call *call);
+void __ofono_voicecall_filter_chain_free(struct voicecall_filter_chain *c);
+void __ofono_voicecall_filter_chain_dial(struct voicecall_filter_chain *c,
+ const struct ofono_phone_number *number,
+ enum ofono_clir_option clir,
+ ofono_voicecall_filter_dial_cb_t cb,
+ ofono_destroy_func destroy, void *user_data);
+void __ofono_voicecall_filter_chain_dial_check(struct voicecall_filter_chain *c,
+ const struct ofono_call *call,
+ ofono_voicecall_filter_dial_cb_t cb,
+ ofono_destroy_func destroy, void *user_data);
+void __ofono_voicecall_filter_chain_incoming(struct voicecall_filter_chain *c,
+ const struct ofono_call *call,
+ ofono_voicecall_filter_incoming_cb_t cb,
+ ofono_destroy_func destroy, void *user_data);
+
+#include <ofono/dbus-access.h>
+
+gboolean __ofono_dbus_access_method_allowed(const char *sender,
+ enum ofono_dbus_access_intf iface,
+ int method, const char *arg);
+
#include <ofono/sim-mnclength.h>
int __ofono_sim_mnclength_get_mnclength(const char *imsi);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/phonebook.c
^
|
@@ -428,7 +428,6 @@
g_slist_foreach(phonebook->merge_list, print_merged_entry,
phonebook->vcards);
g_slist_free_full(phonebook->merge_list, destroy_merged_entry);
- g_slist_free(phonebook->merge_list);
phonebook->merge_list = NULL;
phonebook->storage_index++;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/plugin.c
^
|
@@ -211,17 +211,26 @@
DBG("");
+ /*
+ * Terminate the plugins but don't unload the libraries yet.
+ * Plugins may reference data structures allocated by each other.
+ */
for (list = plugins; list; list = list->next) {
struct ofono_plugin *plugin = list->data;
if (plugin->active == TRUE && plugin->desc->exit)
plugin->desc->exit();
+ }
+
+ /* Second pass - unload the libraries */
+ for (list = plugins; list; list = list->next) {
+ struct ofono_plugin *plugin = list->data;
if (plugin->handle)
dlclose(plugin->handle);
-
- g_free(plugin);
}
- g_slist_free(plugins);
+ /* Finally, free the memory */
+ g_slist_free_full(plugins, g_free);
+ plugins = NULL;
}
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/radio-settings.c
^
|
@@ -552,6 +552,11 @@
dbus_message_iter_get_basic(&iter, &property);
dbus_message_iter_next(&iter);
+ if (!__ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
+ OFONO_DBUS_ACCESS_INTF_RADIOSETTINGS,
+ OFONO_DBUS_ACCESS_RADIOSETTINGS_SET_PROPERTY, property))
+ return __ofono_error_access_denied(msg);
+
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
return __ofono_error_invalid_args(msg);
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/ril-transport.c
^
|
@@ -0,0 +1,78 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2018 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 <ofono/ril-transport.h>
+#include <ofono/log.h>
+
+#include <string.h>
+#include <errno.h>
+
+static GSList *ril_transports = NULL;
+
+struct grilio_transport *ofono_ril_transport_connect(const char *name,
+ GHashTable *params)
+{
+ if (name) {
+ GSList *l;
+
+ for (l = ril_transports; l; l = l->next) {
+ const struct ofono_ril_transport *t = l->data;
+
+ if (!strcmp(name, t->name)) {
+ return t->connect ? t->connect(params) : NULL;
+ }
+ }
+ ofono_error("Unknown RIL transport: %s", name);
+ }
+ return NULL;
+}
+
+int ofono_ril_transport_register(const struct ofono_ril_transport *t)
+{
+ if (!t || !t->name) {
+ return -EINVAL;
+ } else {
+ GSList *l;
+
+ for (l = ril_transports; l; l = l->next) {
+ const struct ofono_ril_transport *t1 = l->data;
+
+ if (!strcmp(t->name, t1->name)) {
+ DBG("%s already registered", t->name);
+ return -EALREADY;
+ }
+ }
+
+ DBG("%s", t->name);
+ ril_transports = g_slist_append(ril_transports, (void*)t);
+ return 0;
+ }
+}
+
+void ofono_ril_transport_unregister(const struct ofono_ril_transport *t)
+{
+ if (t && t->name) {
+ DBG("%s", t->name);
+ ril_transports = g_slist_remove(ril_transports, t);
+ }
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/sim.c
^
|
@@ -646,6 +646,13 @@
return TRUE;
}
+static gboolean sim_allow(DBusMessage *msg,
+ enum ofono_dbus_access_simmgr_method method, const char *arg)
+{
+ return __ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
+ OFONO_DBUS_ACCESS_INTF_SIMMGR, method, arg);
+}
+
static DBusMessage *sim_set_property(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -663,6 +670,9 @@
dbus_message_iter_get_basic(&iter, &name);
+ if (!sim_allow(msg, OFONO_DBUS_ACCESS_SIMMGR_SET_PROPERTY, name))
+ return __ofono_error_access_denied(msg);
+
if (!strcmp(name, "SubscriberNumbers")) {
gboolean set_ok = FALSE;
struct ofono_phone_number *own;
@@ -826,6 +836,9 @@
{
struct ofono_sim *sim = data;
+ if (!sim_allow(msg, OFONO_DBUS_ACCESS_SIMMGR_LOCK_PIN, NULL))
+ return __ofono_error_access_denied(msg);
+
return sim_lock_or_unlock(sim, 1, conn, msg);
}
@@ -834,6 +847,9 @@
{
struct ofono_sim *sim = data;
+ if (!sim_allow(msg, OFONO_DBUS_ACCESS_SIMMGR_UNLOCK_PIN, NULL))
+ return __ofono_error_access_denied(msg);
+
return sim_lock_or_unlock(sim, 0, conn, msg);
}
@@ -865,6 +881,9 @@
const char *old;
const char *new;
+ if (!sim_allow(msg, OFONO_DBUS_ACCESS_SIMMGR_CHANGE_PIN, NULL))
+ return __ofono_error_access_denied(msg);
+
if (sim->driver->change_passwd == NULL)
return __ofono_error_not_implemented(msg);
@@ -921,6 +940,9 @@
enum ofono_sim_password_type type;
const char *pin;
+ if (!sim_allow(msg, OFONO_DBUS_ACCESS_SIMMGR_ENTER_PIN, NULL))
+ return __ofono_error_access_denied(msg);
+
if (sim->driver->send_passwd == NULL)
return __ofono_error_not_implemented(msg);
@@ -1156,6 +1178,9 @@
const char *puk;
const char *pin;
+ if (!sim_allow(msg, OFONO_DBUS_ACCESS_SIMMGR_RESET_PIN, NULL))
+ return __ofono_error_access_denied(msg);
+
if (sim->driver->reset_passwd == NULL)
return __ofono_error_not_implemented(msg);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/sms.c
^
|
@@ -1033,6 +1033,11 @@
struct sms_message_data *message;
struct sms_address addr;
+ if (!__ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
+ OFONO_DBUS_ACCESS_INTF_MESSAGEMGR,
+ OFONO_DBUS_ACCESS_MESSAGEMGR_SEND_MESSAGE, NULL))
+ return __ofono_error_access_denied(msg);
+
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &to,
DBUS_TYPE_STRING, &text,
DBUS_TYPE_INVALID))
@@ -2145,7 +2150,7 @@
g_queue_push_tail(sms->txq, entry);
if (sms->registered && g_queue_get_length(sms->txq) == 1)
- sms->tx_source = g_timeout_add(0, tx_next, sms);
+ sms->tx_source = g_timeout_add(100, tx_next, sms);
if (uuid)
memcpy(uuid, &entry->uuid, sizeof(*uuid));
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/stk.c
^
|
@@ -722,7 +722,7 @@
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
- if (!__ofono_dbus_valid_object_path(agent_path))
+ if (!dbus_validate_path(agent_path, NULL))
return __ofono_error_invalid_format(msg);
stk->default_agent = stk_agent_new(agent_path,
@@ -839,7 +839,7 @@
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
- if (!__ofono_dbus_valid_object_path(agent_path))
+ if (!dbus_validate_path(agent_path, NULL))
return __ofono_error_invalid_format(msg);
for (i = 0; i < selection && menu->items[i].text; i++);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/ussd.c
^
|
@@ -417,13 +417,18 @@
}
if (status == OFONO_USSD_STATUS_TERMINATED) {
- ussd_change_state(ussd, USSD_STATE_IDLE);
+ if (ussd->state == USSD_STATE_ACTIVE && data && data_len > 0) {
+ /* Interpret that as a Notify */
+ status = OFONO_USSD_STATUS_NOTIFY;
+ } else {
+ ussd_change_state(ussd, USSD_STATE_IDLE);
- if (ussd->pending == NULL)
- return;
+ if (ussd->pending == NULL)
+ return;
- reply = __ofono_error_network_terminated(ussd->pending);
- goto out;
+ reply = __ofono_error_network_terminated(ussd->pending);
+ goto out;
+ }
}
if (status == OFONO_USSD_STATUS_NOT_SUPPORTED) {
@@ -808,6 +813,22 @@
DBusConnection *conn = ofono_dbus_get_connection();
struct ofono_modem *modem = __ofono_atom_get_modem(atom);
const char *path = __ofono_atom_get_path(atom);
+ DBusMessage *reply;
+
+ if (ussd->pending) {
+ reply = __ofono_error_canceled(ussd->pending);
+ __ofono_dbus_pending_reply(&ussd->pending, reply);
+ }
+
+ if (ussd->cancel) {
+ reply = dbus_message_new_method_return(ussd->cancel);
+ __ofono_dbus_pending_reply(&ussd->cancel, reply);
+ }
+
+ if (ussd->req)
+ ussd_request_finish(ussd, -ECANCELED, 0, NULL, 0);
+
+ ussd_change_state(ussd, USSD_STATE_IDLE);
g_slist_free_full(ussd->ss_control_list, ssc_entry_destroy);
ussd->ss_control_list = NULL;
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/voicecall-filter.c
^
|
@@ -0,0 +1,662 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2018-2019 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 "ofono.h"
+#include "common.h"
+
+#include <errno.h>
+#include <string.h>
+
+struct voicecall_filter_request;
+struct voicecall_filter_request_fn {
+ const char *name;
+ gboolean (*can_process)(const struct ofono_voicecall_filter *filter);
+ guint (*process)(const struct ofono_voicecall_filter *filter,
+ struct voicecall_filter_request *req);
+ void (*allow)(struct voicecall_filter_request *req);
+ void (*free)(struct voicecall_filter_request *req);
+};
+
+struct voicecall_filter_request {
+ int refcount;
+ const struct voicecall_filter_request_fn *fn;
+ const struct ofono_call *call;
+ struct voicecall_filter_chain *chain;
+ GSList *filter_link;
+ guint pending_id;
+ guint next_id;
+ ofono_destroy_func destroy;
+ void* user_data;
+};
+
+struct voicecall_filter_request_dial {
+ struct voicecall_filter_request req;
+ const struct ofono_phone_number *number;
+ enum ofono_clir_option clir;
+ ofono_voicecall_filter_dial_cb_t cb;
+};
+
+struct voicecall_filter_request_incoming {
+ struct voicecall_filter_request req;
+ ofono_voicecall_filter_incoming_cb_t cb;
+};
+
+struct voicecall_filter_chain {
+ struct ofono_voicecall *vc;
+ GSList *req_list;
+};
+
+static GSList *voicecall_filters = NULL;
+
+static void voicecall_filter_request_init(struct voicecall_filter_request *req,
+ const struct voicecall_filter_request_fn *fn,
+ struct voicecall_filter_chain *chain, const struct ofono_call *call,
+ ofono_destroy_func destroy, void *user_data)
+{
+ req->fn = fn;
+ req->chain = chain;
+ req->call = call;
+ req->filter_link = voicecall_filters;
+ req->destroy = destroy;
+ req->user_data = user_data;
+
+ /*
+ * The list holds an implicit reference to the message. The reference
+ * is released by voicecall_filter_request_free when the message is
+ * removed from the list.
+ */
+ req->refcount = 1;
+ chain->req_list = g_slist_append(chain->req_list, req);
+}
+
+static void voicecall_filter_request_cancel
+ (struct voicecall_filter_request *req)
+{
+ if (req->pending_id) {
+ const struct ofono_voicecall_filter *f = req->filter_link->data;
+
+ /*
+ * If the filter returns id of the pending operation,
+ * then it must provide the cancel callback
+ */
+ f->filter_cancel(req->pending_id);
+ req->pending_id = 0;
+ }
+ if (req->next_id) {
+ g_source_remove(req->next_id);
+ req->next_id = 0;
+ }
+}
+
+static void voicecall_filter_request_dispose
+ (struct voicecall_filter_request *req)
+{
+ /* May be invoked several times per request */
+ if (req->destroy) {
+ ofono_destroy_func destroy = req->destroy;
+
+ req->destroy = NULL;
+ destroy(req->user_data);
+ }
+}
+
+static void voicecall_filter_request_free(struct voicecall_filter_request *req)
+{
+ voicecall_filter_request_dispose(req);
+ req->fn->free(req);
+}
+
+#define voicecall_filter_request_ref(req) ((void)((req)->refcount++))
+
+static int voicecall_filter_request_unref(struct voicecall_filter_request *req)
+{
+ const int refcount = --(req->refcount);
+
+ if (!refcount) {
+ voicecall_filter_request_free(req);
+ }
+ return refcount;
+}
+
+static void voicecall_filter_request_done(struct voicecall_filter_request *req)
+{
+ /* Zero the pointer to it in case if this is not the last reference. */
+ req->chain = NULL;
+ voicecall_filter_request_unref(req);
+}
+
+static void voicecall_filter_request_dequeue
+ (struct voicecall_filter_request *req)
+{
+ struct voicecall_filter_chain *chain = req->chain;
+ GSList *l;
+
+ /*
+ * Single-linked list is not particularly good at searching
+ * and removing the elements but since it should be pretty
+ * short (typically just one request), it's not worth optimization.
+ */
+ if (chain && (l = g_slist_find(chain->req_list, req)) != NULL) {
+ voicecall_filter_request_done(l->data);
+ chain->req_list = g_slist_delete_link(chain->req_list, l);
+ }
+}
+
+static void voicecall_filter_request_complete
+ (struct voicecall_filter_request *req,
+ void (*complete)(struct voicecall_filter_request *req))
+{
+ voicecall_filter_request_ref(req);
+ complete(req);
+ voicecall_filter_request_dispose(req);
+ voicecall_filter_request_dequeue(req);
+ voicecall_filter_request_unref(req);
+}
+
+static void voicecall_filter_request_process
+ (struct voicecall_filter_request *req)
+{
+ GSList *l = req->filter_link;
+ const struct ofono_voicecall_filter *f = l->data;
+ const struct voicecall_filter_request_fn *fn = req->fn;
+
+ while (f && !fn->can_process(f)) {
+ l = l->next;
+ f = l ? l->data : NULL;
+ }
+
+ voicecall_filter_request_ref(req);
+ if (f) {
+ req->filter_link = l;
+ req->pending_id = fn->process(f, req);
+ } else {
+ voicecall_filter_request_complete(req, fn->allow);
+ }
+ voicecall_filter_request_unref(req);
+}
+
+static void voicecall_filter_request_next(struct voicecall_filter_request *req,
+ GSourceFunc fn)
+{
+ req->pending_id = 0;
+ req->next_id = g_idle_add(fn, req);
+}
+
+static gboolean voicecall_filter_request_continue_cb(gpointer data)
+{
+ struct voicecall_filter_request *req = data;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/voicecall.c
^
|
@@ -78,6 +78,8 @@
struct ofono_emulator *pending_em;
unsigned int pending_id;
struct voicecall_agent *vc_agent;
+ struct voicecall_filter_chain *filters;
+ GSList *incoming_filter_list;
};
struct voicecall {
@@ -118,6 +120,14 @@
int status;
};
+struct dial_filter_req {
+ struct ofono_voicecall *vc;
+ struct ofono_phone_number pn;
+ enum ofono_clir_option clir;
+ ofono_voicecall_cb_t cb;
+ void *data;
+};
+
static const char *default_en_list[] = { "911", "112", NULL };
static const char *default_en_list_no_sim[] = { "119", "118", "999", "110",
"08", "000", NULL };
@@ -344,6 +354,7 @@
for (i = 0; tone_str[i]; i++)
if (!g_ascii_isdigit(tone_str[i]) && tone_str[i] != 'p' &&
tone_str[i] != 'P' && tone_str[i] != '*' &&
+ tone_str[i] != '.' && tone_str[i] != ',' &&
tone_str[i] != '#' && (tone_str[i] < 'A' ||
tone_str[i] > 'D'))
return -EINVAL;
@@ -495,6 +506,13 @@
return reply;
}
+static gboolean voicecall_allow(DBusMessage *msg,
+ enum ofono_dbus_access_voicecall_method method)
+{
+ return __ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
+ OFONO_DBUS_ACCESS_INTF_VOICECALL, method, NULL);
+}
+
static DBusMessage *voicecall_deflect(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -505,6 +523,9 @@
struct ofono_phone_number ph;
const char *number;
+ if (!voicecall_allow(msg, OFONO_DBUS_ACCESS_VOICECALL_DEFLECT))
+ return __ofono_error_access_denied(msg);
+
if (call->status != CALL_STATUS_INCOMING &&
call->status != CALL_STATUS_WAITING)
return __ofono_error_failed(msg);
@@ -540,6 +561,9 @@
gboolean single_call = vc->call_list->next == 0;
struct tone_queue_entry *tone_entry = NULL;
+ if (!voicecall_allow(msg, OFONO_DBUS_ACCESS_VOICECALL_HANGUP))
+ return __ofono_error_access_denied(msg);
+
/* clear any remaining tones */
while ((tone_entry = g_queue_peek_head(vc->toneq)))
tone_request_finish(vc, tone_entry, ENOENT, TRUE);
@@ -640,6 +664,9 @@
struct ofono_voicecall *vc = v->vc;
struct ofono_call *call = v->call;
+ if (!voicecall_allow(msg, OFONO_DBUS_ACCESS_VOICECALL_ANSWER))
+ return __ofono_error_access_denied(msg);
+
if (call->status != CALL_STATUS_INCOMING)
return __ofono_error_failed(msg);
@@ -694,6 +721,9 @@
{
struct voicecall *voicecall = (struct voicecall *)userdata;
+ __ofono_voicecall_filter_chain_cancel(voicecall->vc->filters,
+ voicecall->call);
+
g_free(voicecall->call);
g_free(voicecall->message);
@@ -1496,7 +1526,7 @@
}
- reply = __ofono_error_failed(vc->pending);
+ reply = __ofono_error_from_error(error, vc->pending);
}
__ofono_dbus_pending_reply(&vc->pending, reply);
@@ -1505,6 +1535,168 @@
voicecalls_emit_call_added(vc, v);
}
+static void dummy_callback(const struct ofono_error *error, void *data)
+{
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
+ DBG("command failed with error: %s",
+ telephony_error_to_str(error));
+}
+
+static void filter_hangup(struct voicecall *v)
+{
+ struct ofono_voicecall *vc = v->vc;
+ const struct ofono_call *call = v->call;
+ const struct ofono_voicecall_driver *driver = vc->driver;
+
+ switch (call->status) {
+ case OFONO_CALL_STATUS_WAITING:
+ if (driver->set_udub) {
+ driver->set_udub(vc, dummy_callback, vc);
+ return;
+ } else if (driver->release_specific) {
+ driver->release_specific(vc, call->id,
+ dummy_callback, vc);
+ return;
+ }
+ break;
+ case OFONO_CALL_STATUS_ACTIVE:
+ case OFONO_CALL_STATUS_DIALING:
+ case OFONO_CALL_STATUS_ALERTING:
+ if (driver->hangup_active) {
+ driver->hangup_active(vc, dummy_callback, vc);
+ return;
+ }
+ /* no break */
+ default:
+ if (driver->release_specific) {
+ driver->release_specific(vc, call->id,
+ dummy_callback, vc);
+ return;
+ }
+ break;
+ }
+
+ ofono_warn("Couldn't disconnect %s call %d",
+ call_status_to_string(call->status), call->id);
+}
+
+static void filter_dial_check_cb(enum ofono_voicecall_filter_dial_result result,
+ void *data)
+{
+ struct voicecall *v = data;
+
+ if (result == OFONO_VOICECALL_FILTER_DIAL_CONTINUE) {
+ DBG("No need to release %s call %d",
+ call_status_to_string(v->call->status), v->call->id);
+ } else {
+ DBG("Need to release %s call %d",
+ call_status_to_string(v->call->status), v->call->id);
+ filter_hangup(v);
+ }
+}
+
+static void filter_incoming_check_cb
+ (enum ofono_voicecall_filter_incoming_result result, void *data)
+{
+ struct voicecall *v = data;
+
+ if (result == OFONO_VOICECALL_FILTER_INCOMING_CONTINUE) {
+ DBG("No need to release %s call %d",
+ call_status_to_string(v->call->status), v->call->id);
+ } else {
+ DBG("Need to release %s call %d",
+ call_status_to_string(v->call->status), v->call->id);
+ filter_hangup(v);
+ }
+}
+
+static void filter_incoming_cb(enum ofono_voicecall_filter_incoming_result res,
+ void *data)
+{
+ struct voicecall *v = data;
+ struct ofono_voicecall *vc = v->vc;
+
+ vc->incoming_filter_list = g_slist_remove(vc->incoming_filter_list, v);
+ if (res == OFONO_VOICECALL_FILTER_INCOMING_HANGUP) {
+ if (vc->driver->release_specific) {
+ vc->driver->release_specific(vc, v->call->id,
+ dummy_callback, vc);
+ }
+ voicecall_destroy(v);
+ } else if (res == OFONO_VOICECALL_FILTER_INCOMING_IGNORE) {
+ voicecall_destroy(v);
+ } else if (voicecall_dbus_register(v)) {
+ struct ofono_voicecall *vc = v->vc;
+
+ vc->call_list = g_slist_insert_sorted(vc->call_list, v,
+ call_compare);
+ voicecalls_emit_call_added(vc, v);
+ }
+}
+
+void ofono_voicecall_filter_notify(struct ofono_voicecall *vc)
+{
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/watch.c
^
|
@@ -1,8 +1,7 @@
/*
- *
* oFono - Open Source Telephony
*
- * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
+ * Copyright (C) 2017-2019 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
@@ -10,98 +9,856 @@
*
* 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
+ * 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
-#include <config.h>
-#endif
+#include "watch_p.h"
-#include <glib.h>
#include "ofono.h"
-struct ofono_watchlist *__ofono_watchlist_new(ofono_destroy_func destroy)
+#include <glib-object.h>
+
+typedef GObjectClass OfonoWatchObjectClass;
+typedef struct ofono_watch_object OfonoWatchObject;
+
+struct ofono_watch_object {
+ GObject object;
+ struct ofono_watch pub;
+ char *path;
+ char *iccid;
+ char *imsi;
+ char *spn;
+ char *reg_mcc;
+ char *reg_mnc;
+ char *reg_name;
+ 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;
+ guint gprs_watch_id;
+};
+
+struct ofono_watch_closure {
+ GCClosure cclosure;
+ union ofono_watch_closure_cb {
+ GCallback ptr;
+ ofono_watch_cb_t generic;
+ ofono_watch_gprs_settings_cb_t gprs_settings;
+ } cb;
+ void *user_data;
+};
+
+enum ofono_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_REG_STATUS_CHANGED,
+ SIGNAL_REG_MCC_CHANGED,
+ SIGNAL_REG_MNC_CHANGED,
+ SIGNAL_REG_NAME_CHANGED,
+ SIGNAL_GPRS_CHANGED,
+ SIGNAL_GPRS_SETTINGS_CHANGED,
+ SIGNAL_COUNT
+};
+
+#define SIGNAL_MODEM_CHANGED_NAME "ofono-watch-modem-changed"
+#define SIGNAL_ONLINE_CHANGED_NAME "ofono-watch-online-changed"
+#define SIGNAL_SIM_CHANGED_NAME "ofono-watch-sim-changed"
+#define SIGNAL_SIM_STATE_CHANGED_NAME "ofono-watch-sim-state-changed"
+#define SIGNAL_ICCID_CHANGED_NAME "ofono-watch-iccid-changed"
+#define SIGNAL_IMSI_CHANGED_NAME "ofono-watch-imsi-changed"
+#define SIGNAL_SPN_CHANGED_NAME "ofono-watch-spn-changed"
+#define SIGNAL_NETREG_CHANGED_NAME "ofono-watch-netreg-changed"
+#define SIGNAL_REG_STATUS_CHANGED_NAME "ofono-watch-reg-status-changed"
+#define SIGNAL_REG_MCC_CHANGED_NAME "ofono-watch-reg-mcc-changed"
+#define SIGNAL_REG_MNC_CHANGED_NAME "ofono-watch-reg-mnc-changed"
+#define SIGNAL_REG_NAME_CHANGED_NAME "ofono-watch-reg-name-changed"
+#define SIGNAL_GPRS_CHANGED_NAME "ofono-watch-gprs-changed"
+#define SIGNAL_GPRS_SETTINGS_CHANGED_NAME "ofono-watch-gprs-settings-changed"
+
+static guint ofono_watch_signals[SIGNAL_COUNT] = { 0 };
+static GHashTable *ofono_watch_table = NULL;
+
+G_DEFINE_TYPE(OfonoWatchObject, ofono_watch_object, G_TYPE_OBJECT)
+#define OFONO_WATCH_OBJECT_TYPE (ofono_watch_object_get_type())
+#define OFONO_WATCH_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
+ OFONO_WATCH_OBJECT_TYPE, OfonoWatchObject))
+
+#define NEW_SIGNAL(klass,name) \
+ ofono_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)
+#define ASSERT(expr) ((void)0)
+
+static inline struct ofono_watch_object *ofono_watch_object_cast
+ (struct ofono_watch *watch)
+{
+ return watch ? OFONO_WATCH_OBJECT(G_STRUCT_MEMBER_P(watch,
+ - G_STRUCT_OFFSET(struct ofono_watch_object, pub))) : NULL;
+}
+
+static inline int ofono_watch_signal_bit(enum ofono_watch_signal id)
+{
+ return (1 << id);
+}
+
+static inline void ofono_watch_signal_emit(struct ofono_watch_object *self,
+ enum ofono_watch_signal id)
+{
+ self->queued_signals &= ~ofono_watch_signal_bit(id);
+ g_signal_emit(self, ofono_watch_signals[id], 0);
+}
+
+static inline void ofono_watch_signal_queue(struct ofono_watch_object *self,
+ enum ofono_watch_signal id)
+{
+ self->queued_signals |= ofono_watch_signal_bit(id);
+}
+
+static void ofono_watch_emit_queued_signals(struct ofono_watch_object *self)
+{
+ int i;
+
+ for (i = 0; self->queued_signals && i < SIGNAL_COUNT; i++) {
+ if (self->queued_signals & ofono_watch_signal_bit(i)) {
+ ofono_watch_signal_emit(self, i);
+ }
+ }
+}
+
+static void ofono_watch_iccid_update(struct ofono_watch_object *self,
+ const char *iccid)
+{
+ if (g_strcmp0(self->iccid, iccid)) {
+ g_free(self->iccid);
+ self->pub.iccid = self->iccid = g_strdup(iccid);
+ ofono_watch_signal_queue(self, SIGNAL_ICCID_CHANGED);
+ }
+}
+
+static void ofono_watch_iccid_notify(const char *iccid, void *user_data)
+{
+ struct ofono_watch_object *self = OFONO_WATCH_OBJECT(user_data);
+
+ ofono_watch_iccid_update(self, iccid);
+ ofono_watch_emit_queued_signals(self);
+}
+
+static void ofono_watch_iccid_destroy(void *user_data)
+{
+ struct ofono_watch_object *self = OFONO_WATCH_OBJECT(user_data);
+
+ ASSERT(self->iccid_watch_id);
+ self->iccid_watch_id = 0;
+}
+
+static void ofono_watch_spn_update(struct ofono_watch_object *self,
+ const char *spn)
+{
+ if (g_strcmp0(self->spn, spn)) {
+ g_free(self->spn);
+ self->pub.spn = self->spn = g_strdup(spn);
+ ofono_watch_signal_queue(self, SIGNAL_SPN_CHANGED);
+ }
+}
+
+static void ofono_watch_spn_notify(const char *spn, const char *dc,
+ void *user_data)
+{
+ struct ofono_watch_object *self = OFONO_WATCH_OBJECT(user_data);
+
+ ofono_watch_spn_update(self, spn);
+ ofono_watch_emit_queued_signals(self);
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/watch_p.h
^
|
@@ -0,0 +1,34 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2019 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 OFONO_WATCH_PRIVATE_H
+#define OFONO_WATCH_PRIVATE_H
+
+#include <ofono/watch.h>
+
+void __ofono_watch_netreg_changed(const char *path);
+void __ofono_watch_gprs_settings_changed(const char *path,
+ enum ofono_gprs_context_type type,
+ const struct ofono_gprs_primary_context *settings);
+
+#endif /* OFONO_WATCH_PRIVATE_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/src/watchlist.c
^
|
@@ -0,0 +1,107 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2011 Intel Corporation. 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
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include "ofono.h"
+
+struct ofono_watchlist *__ofono_watchlist_new(ofono_destroy_func destroy)
+{
+ struct ofono_watchlist *watchlist;
+
+ watchlist = g_new0(struct ofono_watchlist, 1);
+ watchlist->destroy = destroy;
+
+ return watchlist;
+}
+
+unsigned int __ofono_watchlist_add_item(struct ofono_watchlist *watchlist,
+ struct ofono_watchlist_item *item)
+{
+ item->id = ++watchlist->next_id;
+
+ if (item->id == 0)
+ item->id = ++watchlist->next_id;
+
+ watchlist->items = g_slist_prepend(watchlist->items, item);
+
+ return item->id;
+}
+
+gboolean __ofono_watchlist_remove_item(struct ofono_watchlist *watchlist,
+ unsigned int id)
+{
+ struct ofono_watchlist_item *item;
+ GSList *p;
+ GSList *c;
+
+ p = NULL;
+ c = watchlist->items;
+
+ while (c) {
+ item = c->data;
+
+ if (item->id != id) {
+ p = c;
+ c = c->next;
+ continue;
+ }
+
+ if (p)
+ p->next = c->next;
+ else
+ watchlist->items = c->next;
+
+ if (item->destroy)
+ item->destroy(item->notify_data);
+
+ if (watchlist->destroy)
+ watchlist->destroy(item);
+ g_slist_free_1(c);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+void __ofono_watchlist_free(struct ofono_watchlist *watchlist)
+{
+ struct ofono_watchlist_item *item;
+ GSList *l;
+
+ for (l = watchlist->items; l; l = l->next) {
+ item = l->data;
+
+ if (item->destroy)
+ item->destroy(item->notify_data);
+
+ if (watchlist->destroy)
+ watchlist->destroy(item);
+ }
+
+ g_slist_free(watchlist->items);
+ watchlist->items = NULL;
+ g_free(watchlist);
+}
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/test/set-ddr
^
|
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
import sys
import dbus
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/test/transfer-call
^
|
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
import sys
import dbus
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/coverage
^
|
@@ -16,15 +16,22 @@
test-cdmasms \
test-sms-root \
test-caif \
+ test-dbus-queue \
+ test-dbus-access \
+ test-gprs-filter \
test-provision \
+ test-watch \
test-ril_util \
+ test-ril_config \
+ test-ril-transport \
test-sms-filter \
+ test-voicecall-filter \
+ test-sailfish_access \
test-sailfish_cell_info \
test-sailfish_cell_info_dbus \
test-sailfish_manager \
test-sailfish_sim_info \
- test-sailfish_sim_info_dbus \
- test-sailfish_watch"
+ test-sailfish_sim_info_dbus"
pushd `dirname $0` > /dev/null
TEST_DIR="$PWD"
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/fake_watch.c
^
|
@@ -0,0 +1,364 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2017-2019 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_watch.h"
+
+#include "ofono.h"
+
+#include <gutil_log.h>
+#include <gutil_macros.h>
+#include <gutil_misc.h>
+
+#include <glib-object.h>
+
+typedef GObjectClass FakeOfonoWatchClass;
+typedef struct fake_ofono_watch FakeOfonoWatch;
+
+struct fake_ofono_watch {
+ GObject object;
+ struct ofono_watch pub;
+ char *path;
+ char *iccid;
+ char *imsi;
+ char *spn;
+ int queued_signals;
+};
+
+struct fake_ofono_watch_closure {
+ GCClosure cclosure;
+ ofono_watch_cb_t cb;
+ void *user_data;
+};
+
+#define SIGNAL_MODEM_CHANGED_NAME "ofono-watch-modem-changed"
+#define SIGNAL_ONLINE_CHANGED_NAME "ofono-watch-online-changed"
+#define SIGNAL_SIM_CHANGED_NAME "ofono-watch-sim-changed"
+#define SIGNAL_SIM_STATE_CHANGED_NAME "ofono-watch-sim-state-changed"
+#define SIGNAL_ICCID_CHANGED_NAME "ofono-watch-iccid-changed"
+#define SIGNAL_IMSI_CHANGED_NAME "ofono-watch-imsi-changed"
+#define SIGNAL_SPN_CHANGED_NAME "ofono-watch-spn-changed"
+#define SIGNAL_NETREG_CHANGED_NAME "ofono-watch-netreg-changed"
+
+static guint fake_ofono_watch_signals[FAKE_WATCH_SIGNAL_COUNT] = { 0 };
+static GHashTable *fake_ofono_watch_table = NULL;
+
+G_DEFINE_TYPE(FakeOfonoWatch, fake_ofono_watch, G_TYPE_OBJECT)
+#define FAKE_OFONO_WATCH_TYPE (fake_ofono_watch_get_type())
+#define FAKE_OFONO_WATCH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
+ FAKE_OFONO_WATCH_TYPE, FakeOfonoWatch))
+
+#define NEW_SIGNAL(klass,name) \
+ fake_ofono_watch_signals[FAKE_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 struct fake_ofono_watch *fake_ofono_watch_cast
+ (struct ofono_watch *watch)
+{
+ return watch ?
+ FAKE_OFONO_WATCH(G_CAST(watch, struct fake_ofono_watch, pub)) :
+ NULL;
+}
+
+static inline int fake_ofono_watch_signal_bit(enum fake_watch_signal id)
+{
+ return (1 << id);
+}
+
+static inline void fake_ofono_watch_signal_emit(struct fake_ofono_watch *self,
+ enum fake_watch_signal id)
+{
+ self->queued_signals &= ~fake_ofono_watch_signal_bit(id);
+ g_signal_emit(self, fake_ofono_watch_signals[id], 0);
+}
+
+void fake_watch_signal_queue(struct ofono_watch *watch,
+ enum fake_watch_signal id)
+{
+ struct fake_ofono_watch *self = fake_ofono_watch_cast(watch);
+
+ self->queued_signals |= fake_ofono_watch_signal_bit(id);
+}
+
+void fake_watch_emit_queued_signals(struct ofono_watch *watch)
+{
+ struct fake_ofono_watch *self = fake_ofono_watch_cast(watch);
+ int i;
+
+ for (i = 0; self->queued_signals && i < FAKE_WATCH_SIGNAL_COUNT; i++) {
+ if (self->queued_signals & fake_ofono_watch_signal_bit(i)) {
+ fake_ofono_watch_signal_emit(self, i);
+ }
+ }
+}
+
+void fake_watch_set_ofono_iccid(struct ofono_watch *watch, const char *iccid)
+{
+ struct fake_ofono_watch *self = fake_ofono_watch_cast(watch);
+
+ if (g_strcmp0(self->iccid, iccid)) {
+ g_free(self->iccid);
+ watch->iccid = self->iccid = g_strdup(iccid);
+ fake_watch_signal_queue(watch, FAKE_WATCH_SIGNAL_ICCID_CHANGED);
+ }
+}
+
+void fake_watch_set_ofono_imsi(struct ofono_watch *watch, const char *imsi)
+{
+ struct fake_ofono_watch *self = fake_ofono_watch_cast(watch);
+
+ if (g_strcmp0(self->imsi, imsi)) {
+ g_free(self->imsi);
+ watch->imsi = self->imsi = g_strdup(imsi);
+ fake_watch_signal_queue(watch, FAKE_WATCH_SIGNAL_IMSI_CHANGED);
+ }
+}
+
+void fake_watch_set_ofono_spn(struct ofono_watch *watch, const char *spn)
+{
+ struct fake_ofono_watch *self = fake_ofono_watch_cast(watch);
+
+ if (g_strcmp0(self->spn, spn)) {
+ g_free(self->spn);
+ watch->spn = self->spn = g_strdup(spn);
+ fake_watch_signal_queue(watch, FAKE_WATCH_SIGNAL_SPN_CHANGED);
+ }
+}
+
+void fake_watch_set_ofono_sim(struct ofono_watch *watch,
+ struct ofono_sim *sim)
+{
+ if (watch->sim != sim) {
+ watch->sim = sim;
+ fake_watch_signal_queue(watch, FAKE_WATCH_SIGNAL_SIM_CHANGED);
+ if (!sim) {
+ fake_watch_set_ofono_iccid(watch, NULL);
+ fake_watch_set_ofono_imsi(watch, NULL);
+ fake_watch_set_ofono_spn(watch, NULL);
+ }
+ }
+}
+
+void fake_watch_set_ofono_netreg(struct ofono_watch *watch,
+ struct ofono_netreg *netreg)
+{
+ if (watch->netreg != netreg) {
+ watch->netreg = netreg;
+ fake_watch_signal_queue(watch,
+ FAKE_WATCH_SIGNAL_NETREG_CHANGED);
+ }
+}
+
+static void fake_ofono_watch_initialize(struct fake_ofono_watch *self,
+ const char *path)
+{
+ self->pub.path = self->path = g_strdup(path);
+}
+
+static void fake_ofono_watch_destroyed(gpointer key, GObject *obj)
+{
+ GASSERT(fake_ofono_watch_table);
+ DBG("%s", (char*)key);
+ if (fake_ofono_watch_table) {
+ GASSERT(g_hash_table_lookup(fake_ofono_watch_table,key) == obj);
+ g_hash_table_remove(fake_ofono_watch_table, key);
+ if (g_hash_table_size(fake_ofono_watch_table) == 0) {
+ g_hash_table_unref(fake_ofono_watch_table);
+ fake_ofono_watch_table = NULL;
+ }
+ }
+}
+
+struct ofono_watch *ofono_watch_new(const char *path)
+{
+ if (path) {
+ struct fake_ofono_watch *self = NULL;
+
+ if (fake_ofono_watch_table) {
+ self = g_hash_table_lookup(fake_ofono_watch_table,
+ path);
+ }
+ if (self) {
+ g_object_ref(self);
+ } else {
+ char *key = g_strdup(path);
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/fake_watch.h
^
|
@@ -0,0 +1,50 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2017-2019 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 FAKE_WATCH_H
+#define FAKE_WATCH_H
+
+#include <ofono/watch.h>
+
+enum fake_watch_signal {
+ FAKE_WATCH_SIGNAL_MODEM_CHANGED,
+ FAKE_WATCH_SIGNAL_ONLINE_CHANGED,
+ FAKE_WATCH_SIGNAL_SIM_CHANGED,
+ FAKE_WATCH_SIGNAL_SIM_STATE_CHANGED,
+ FAKE_WATCH_SIGNAL_ICCID_CHANGED,
+ FAKE_WATCH_SIGNAL_IMSI_CHANGED,
+ FAKE_WATCH_SIGNAL_SPN_CHANGED,
+ FAKE_WATCH_SIGNAL_NETREG_CHANGED,
+ FAKE_WATCH_SIGNAL_COUNT
+};
+
+void fake_watch_signal_queue(struct ofono_watch *w, enum fake_watch_signal id);
+void fake_watch_emit_queued_signals(struct ofono_watch *w);
+void fake_watch_set_ofono_sim(struct ofono_watch *w, struct ofono_sim *sim);
+void fake_watch_set_ofono_iccid(struct ofono_watch *w, const char *iccid);
+void fake_watch_set_ofono_imsi(struct ofono_watch *w, const char *imsi);
+void fake_watch_set_ofono_spn(struct ofono_watch *w, const char *spn);
+void fake_watch_set_ofono_netreg(struct ofono_watch *w,
+ struct ofono_netreg *netreg);
+
+#endif /* FAKE_WATCH_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/test-dbus-access.c
^
|
@@ -0,0 +1,191 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2019 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 "ofono.h"
+
+#include <errno.h>
+
+static enum ofono_dbus_access dontcare_method_access(const char *sender,
+ enum ofono_dbus_access_intf intf, int method, const char *arg)
+{
+ return OFONO_DBUS_ACCESS_DONT_CARE;
+}
+static enum ofono_dbus_access allow_method_access(const char *sender,
+ enum ofono_dbus_access_intf intf, int method, const char *arg)
+{
+ return OFONO_DBUS_ACCESS_ALLOW;
+}
+static enum ofono_dbus_access deny_method_access(const char *sender,
+ enum ofono_dbus_access_intf intf, int method, const char *arg)
+{
+ return OFONO_DBUS_ACCESS_DENY;
+}
+
+struct ofono_dbus_access_plugin access_inval;
+struct ofono_dbus_access_plugin access_dontcare = {
+ .name = "DontCare",
+ .priority = OFONO_DBUS_ACCESS_PRIORITY_LOW,
+ .method_access = dontcare_method_access
+};
+struct ofono_dbus_access_plugin access_allow = {
+ .name = "Allow",
+ .priority = OFONO_DBUS_ACCESS_PRIORITY_DEFAULT,
+ .method_access = allow_method_access
+};
+struct ofono_dbus_access_plugin access_deny = {
+ .name = "Deny",
+ .priority = OFONO_DBUS_ACCESS_PRIORITY_LOW,
+ .method_access = deny_method_access
+};
+
+/*==========================================================================*
+ * Tests
+ *==========================================================================*/
+
+static void test_intf_name()
+{
+ int i;
+
+ /* Valid interface ids must have names */
+ for (i = 0; i < OFONO_DBUS_ACCESS_INTF_COUNT; i++) {
+ g_assert(ofono_dbus_access_intf_name(i));
+ }
+ /* And the invalid ones must have no names */
+ g_assert(!ofono_dbus_access_intf_name(-1));
+ g_assert(!ofono_dbus_access_intf_name(i));
+ /* An no method names too */
+ g_assert(!ofono_dbus_access_method_name(-1, 0));
+ g_assert(!ofono_dbus_access_method_name(i, 0));
+}
+
+struct test_method_name_data {
+ enum ofono_dbus_access_intf intf;
+ int n_methods;
+};
+
+static const struct test_method_name_data method_name_tests[] = {
+ {
+ OFONO_DBUS_ACCESS_INTF_MESSAGE,
+ OFONO_DBUS_ACCESS_MESSAGE_METHOD_COUNT
+ },{
+ OFONO_DBUS_ACCESS_INTF_MESSAGEMGR,
+ OFONO_DBUS_ACCESS_MESSAGEMGR_METHOD_COUNT
+ },{
+ OFONO_DBUS_ACCESS_INTF_VOICECALL,
+ OFONO_DBUS_ACCESS_VOICECALL_METHOD_COUNT
+ },{
+ OFONO_DBUS_ACCESS_INTF_VOICECALLMGR,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_METHOD_COUNT
+ },{
+ OFONO_DBUS_ACCESS_INTF_CONNCTX,
+ OFONO_DBUS_ACCESS_CONNCTX_METHOD_COUNT
+ },{
+ OFONO_DBUS_ACCESS_INTF_CONNMGR,
+ OFONO_DBUS_ACCESS_CONNMGR_METHOD_COUNT
+ },{
+ OFONO_DBUS_ACCESS_INTF_SIMMGR,
+ OFONO_DBUS_ACCESS_SIMMGR_METHOD_COUNT
+ },{
+ OFONO_DBUS_ACCESS_INTF_MODEM,
+ OFONO_DBUS_ACCESS_MODEM_METHOD_COUNT
+ },{
+ OFONO_DBUS_ACCESS_INTF_RADIOSETTINGS,
+ OFONO_DBUS_ACCESS_RADIOSETTINGS_METHOD_COUNT
+ }
+};
+
+static void test_method_name(gconstpointer test_data)
+{
+ const struct test_method_name_data *test = test_data;
+ int i;
+
+ /* Valid method ids must have names */
+ for (i = 0; i < test->n_methods; i++) {
+ g_assert(ofono_dbus_access_method_name(test->intf, i));
+ }
+ /* And the invalid ones must have no names */
+ g_assert(!ofono_dbus_access_method_name(test->intf, -1));
+ g_assert(!ofono_dbus_access_method_name(test->intf, i));
+}
+
+G_STATIC_ASSERT(G_N_ELEMENTS(method_name_tests)==OFONO_DBUS_ACCESS_INTF_COUNT);
+
+static void test_register()
+{
+ g_assert(ofono_dbus_access_plugin_register(NULL) == -EINVAL);
+ g_assert(ofono_dbus_access_plugin_register(&access_inval) == -EINVAL);
+ ofono_dbus_access_plugin_unregister(NULL);
+
+ /* Plugin won't be registered more than once */
+ g_assert(!ofono_dbus_access_plugin_register(&access_deny));
+ g_assert(ofono_dbus_access_plugin_register(&access_deny) == -EALREADY);
+
+ /* Allow has higher priority */
+ g_assert(!ofono_dbus_access_plugin_register(&access_allow));
+ g_assert(__ofono_dbus_access_method_allowed(":1.0", 0, 1, NULL));
+ ofono_dbus_access_plugin_unregister(&access_deny);
+ ofono_dbus_access_plugin_unregister(&access_allow);
+
+ /* Allow has higher priority */
+ g_assert(!ofono_dbus_access_plugin_register(&access_allow));
+ g_assert(!ofono_dbus_access_plugin_register(&access_deny));
+ g_assert(__ofono_dbus_access_method_allowed(":1.0", 0, 1, NULL));
+ ofono_dbus_access_plugin_unregister(&access_deny);
+ ofono_dbus_access_plugin_unregister(&access_allow);
+
+ /* Deny wins here */
+ g_assert(!ofono_dbus_access_plugin_register(&access_dontcare));
+ g_assert(!ofono_dbus_access_plugin_register(&access_deny));
+ g_assert(!__ofono_dbus_access_method_allowed(":1.0", 0, 1, NULL));
+ ofono_dbus_access_plugin_unregister(&access_deny);
+ ofono_dbus_access_plugin_unregister(&access_dontcare);
+
+ /* DontCare will allow everything */
+ g_assert(!ofono_dbus_access_plugin_register(&access_dontcare));
+ g_assert(__ofono_dbus_access_method_allowed(":1.0", 0, 1, NULL));
+ ofono_dbus_access_plugin_unregister(&access_dontcare);
+}
+
+#define TEST_(test) "/dbus-access/" test
+
+int main(int argc, char *argv[])
+{
+ int i;
+
+ g_test_init(&argc, &argv, NULL);
+
+ __ofono_log_init("test-dbus-access", g_test_verbose() ? "*" : NULL,
+ FALSE, FALSE);
+
+ g_test_add_func(TEST_("intf_name"), test_intf_name);
+ for (i = 0; i < G_N_ELEMENTS(method_name_tests); i++) {
+ char* name = g_strdup_printf(TEST_("method_name/%d"), i + 1);
+ const struct test_method_name_data *test =
+ method_name_tests + i;
+
+ g_test_add_data_func(name, test, test_method_name);
+ g_free(name);
+ }
+ g_test_add_func(TEST_("register"), test_register);
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/test-dbus-queue.c
^
|
@@ -0,0 +1,659 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2018 Jolla Ltd. 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
+ * 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 "test-dbus.h"
+
+#include <ofono/dbus.h>
+
+#include "ofono.h"
+#include "dbus-queue.h"
+
+#include <gutil_log.h>
+#include <gutil_macros.h>
+
+#define TEST_TIMEOUT (10) /* seconds */
+#define TEST_DBUS_INTERFACE "test.interface"
+#define TEST_DBUS_METHOD "Test"
+#define TEST_DBUS_PATH "/"
+
+#define TEST_ERROR_CANCELED "org.ofono.Error.Canceled"
+#define TEST_ERROR_FAILED "org.ofono.Error.Failed"
+
+#define GDBUS_TEST_METHOD(fn) GDBUS_ASYNC_METHOD(TEST_DBUS_METHOD, \
+ GDBUS_ARGS( { "arg", "i" }), NULL, fn)
+
+static gboolean test_debug;
+
+/* ==== common ==== */
+
+static gboolean test_timeout(gpointer param)
+{
+ g_assert(!"TIMEOUT");
+ return G_SOURCE_REMOVE;
+}
+
+static guint test_setup_timeout(void)
+{
+ if (test_debug) {
+ return 0;
+ } else {
+ return g_timeout_add_seconds(TEST_TIMEOUT, test_timeout, NULL);
+ }
+}
+
+#define test_register_interface(methods,data) \
+ g_assert(g_dbus_register_interface(ofono_dbus_get_connection(), \
+ TEST_DBUS_PATH, TEST_DBUS_INTERFACE, \
+ methods, NULL, NULL, data, NULL))
+
+static void test_client_call(struct test_dbus_context* dbus, dbus_int32_t arg,
+ DBusPendingCallNotifyFunction fn)
+{
+ DBusPendingCall *call;
+ DBusConnection* conn = dbus->client_connection;
+ DBusMessage *msg = dbus_message_new_method_call(NULL, TEST_DBUS_PATH,
+ TEST_DBUS_INTERFACE, TEST_DBUS_METHOD);
+
+ dbus_message_append_args(msg, DBUS_TYPE_INT32, &arg, DBUS_TYPE_INVALID);
+ g_assert(dbus_connection_send_with_reply(conn, msg, &call,
+ DBUS_TIMEOUT_INFINITE));
+ dbus_pending_call_set_notify(call, fn, dbus, NULL);
+ dbus_message_unref(msg);
+}
+
+static void test_expect_canceled(DBusPendingCall *call, void *unused)
+{
+ DBG("");
+ test_dbus_check_error_reply(call, TEST_ERROR_CANCELED);
+}
+
+static void test_expect_failed(DBusPendingCall *call, void *unused)
+{
+ DBG("");
+ test_dbus_check_error_reply(call, TEST_ERROR_FAILED);
+}
+
+/* ==== basic ==== */
+
+static void test_basic(void)
+{
+ __ofono_dbus_queue_free(__ofono_dbus_queue_new());
+
+ /* These are NULL tolerant: */
+ __ofono_dbus_queue_free(NULL);
+ __ofono_dbus_queue_reply_ok(NULL);
+ __ofono_dbus_queue_reply_failed(NULL);
+ __ofono_dbus_queue_reply_all_ok(NULL);
+ __ofono_dbus_queue_reply_all_failed(NULL);
+ __ofono_dbus_queue_reply_msg(NULL, NULL);
+ g_assert(!__ofono_dbus_queue_pending(NULL));
+ g_assert(!__ofono_dbus_queue_set_pending(NULL, NULL));
+}
+
+/* ==== free ==== */
+
+struct test_free_data {
+ struct test_dbus_context dbus;
+ struct ofono_dbus_queue *queue;
+};
+
+static DBusMessage *test_free_cb(DBusMessage *msg, void *data)
+{
+ DBG("");
+ return NULL;
+}
+
+static void test_free_reply(DBusPendingCall *call, void *dbus)
+{
+ struct test_free_data *test = G_CAST(dbus, struct test_free_data, dbus);
+
+ DBG("");
+ test_dbus_check_error_reply(call, TEST_ERROR_CANCELED);
+ g_main_loop_quit(test->dbus.loop);
+}
+
+static DBusMessage *test_free_handler(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct test_free_data *test = data;
+
+ DBG("");
+
+ /* test_free_cb queues the message */
+ __ofono_dbus_queue_request(test->queue, test_free_cb, msg, test);
+
+ /* And this cancels it: */
+ __ofono_dbus_queue_free(test->queue);
+ test->queue = NULL;
+ return NULL;
+}
+
+static const GDBusMethodTable test_free_methods[] = {
+ { GDBUS_TEST_METHOD(test_free_handler) },
+ { }
+};
+
+static void test_free_start(struct test_dbus_context *dbus)
+{
+ struct test_free_data *test = G_CAST(dbus, struct test_free_data, dbus);
+
+ test_register_interface(test_free_methods, test);
+ test_client_call(dbus, 0, test_free_reply);
+}
+
+static void test_free(void)
+{
+ struct test_free_data test;
+ guint timeout = test_setup_timeout();
+
+ memset(&test, 0, sizeof(test));
+ test_dbus_setup(&test.dbus);
+ test.dbus.start = test_free_start;
+ test.queue = __ofono_dbus_queue_new();
+
+ g_main_loop_run(test.dbus.loop);
+
+ g_assert(!test.queue); /* Freed by test_free_handler */
+ test_dbus_shutdown(&test.dbus);
+ if (timeout) {
+ g_source_remove(timeout);
+ }
+}
+
+/* ==== cancel ==== */
+
+struct test_cancel_data {
+ struct test_dbus_context dbus;
+ struct ofono_dbus_queue *queue;
+};
+
+static gboolean test_cancel_msg(void *data)
+{
+ struct test_cancel_data *test = data;
+
+ /* This is will cancel the message: */
+ __ofono_dbus_queue_reply_msg(test->queue, NULL);
+ return G_SOURCE_REMOVE;
+}
+
+static DBusMessage *test_cancel_cb(DBusMessage *msg, void *data)
+{
+ DBG("");
+ g_idle_add(test_cancel_msg, data);
+ return NULL;
+}
+
+static void test_cancel_reply(DBusPendingCall *call, void *dbus)
+{
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/test-dbus.c
^
|
@@ -235,13 +235,11 @@
return value;
}
-void test_dbus_expect_empty_reply(DBusPendingCall *call, void *data)
+void test_dbus_check_empty_reply(DBusPendingCall *call, void *unused)
{
- struct test_dbus_context *test = data;
DBusMessage *reply = dbus_pending_call_steal_reply(call);
DBusMessageIter it;
- DBG("");
g_assert(dbus_message_get_type(reply) ==
DBUS_MESSAGE_TYPE_METHOD_RETURN);
@@ -250,9 +248,29 @@
dbus_message_unref(reply);
dbus_pending_call_unref(call);
+}
+
+void test_dbus_expect_empty_reply(DBusPendingCall *call, void *data)
+{
+ struct test_dbus_context *test = data;
+
+ DBG("");
+ test_dbus_check_empty_reply(call, data);
test_dbus_loop_quit_later(test->loop);
}
+void test_dbus_check_error_reply(DBusPendingCall *call, const char *error)
+{
+ DBusMessage *msg = dbus_pending_call_steal_reply(call);
+ const char *name;
+
+ g_assert(dbus_message_get_type(msg) == DBUS_MESSAGE_TYPE_ERROR);
+ name = dbus_message_get_error_name(msg);
+ g_assert(!g_strcmp0(name, error));
+ dbus_message_unref(msg);
+ dbus_pending_call_unref(call);
+}
+
void test_dbus_check_string_reply(DBusPendingCall *call, const char *str)
{
DBusMessage *reply = dbus_pending_call_steal_reply(call);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/test-dbus.h
^
|
@@ -39,7 +39,9 @@
const char *test_dbus_get_string(DBusMessageIter *it);
const char *test_dbus_get_object_path(DBusMessageIter *it);
+void test_dbus_check_error_reply(DBusPendingCall *call, const char *error);
void test_dbus_check_string_reply(DBusPendingCall *call, const char *str);
+void test_dbus_check_empty_reply(DBusPendingCall *call, void *unused);
void test_dbus_expect_empty_reply(DBusPendingCall *call, void *data);
DBusMessage *test_dbus_find_signal(struct test_dbus_context *test,
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/test-gprs-filter.c
^
|
@@ -0,0 +1,1133 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2018 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 "ofono.h"
+
+#include <gutil_macros.h>
+#include <gutil_log.h>
+
+#include <errno.h>
+
+#define TEST_TIMEOUT_SEC (20)
+
+static gboolean test_debug = FALSE;
+static GMainLoop *test_loop = NULL;
+static int test_filter_cancel_count;
+static int test_filter_activate_count;
+static int test_filter_check_count;
+
+struct test_later_data {
+ ofono_gprs_filter_activate_cb_t cb;
+ struct ofono_gprs_primary_context* ctx;
+ void *user_data;
+};
+
+struct test_check_later_data {
+ ofono_bool_t allow;
+ ofono_gprs_filter_check_cb_t cb;
+ void *user_data;
+};
+
+/* Fake data structures */
+
+struct ofono_gprs_context {
+ struct ofono_gprs_primary_context ctx;
+ struct ofono_gprs *gprs;
+};
+
+struct ofono_gprs {
+ struct gprs_filter_chain *chain;
+};
+
+/* Code shared by all tests */
+
+static gboolean test_timeout_cb(gpointer user_data)
+{
+ g_assert(FALSE);
+ return G_SOURCE_REMOVE;
+}
+
+static gboolean test_quit_cb(gpointer user_data)
+{
+ g_main_loop_quit(test_loop);
+ return G_SOURCE_REMOVE;
+}
+
+static void test_inc(gpointer data)
+{
+ (*(int*)data)++;
+}
+
+static void test_activate_expect_allow
+ (const struct ofono_gprs_primary_context *ctx, void *data)
+{
+ g_assert(ctx);
+ if (data) (*(int*)data)++;
+}
+
+static void test_activate_expect_allow_and_quit
+ (const struct ofono_gprs_primary_context *ctx, void *data)
+{
+ g_assert(ctx);
+ if (data) (*(int*)data)++;
+ g_main_loop_quit(test_loop);
+}
+
+static void test_activate_expect_disallow
+ (const struct ofono_gprs_primary_context *ctx, void *data)
+{
+ g_assert(!ctx);
+ if (data) (*(int*)data)++;
+}
+
+static void test_activate_expect_disallow_and_quit
+ (const struct ofono_gprs_primary_context *ctx, void *data)
+{
+ g_assert(!ctx);
+ if (data) (*(int*)data)++;
+ g_main_loop_quit(test_loop);
+}
+
+static void test_check_expect_allow(ofono_bool_t allow, void *data)
+{
+ g_assert(allow);
+ if (data) (*(int*)data)++;
+}
+
+static void test_check_expect_allow_and_quit(ofono_bool_t allow, void *data)
+{
+ g_assert(allow);
+ if (data) (*(int*)data)++;
+ g_main_loop_quit(test_loop);
+}
+
+static void test_check_expect_disallow_and_quit(ofono_bool_t allow, void *data)
+{
+ g_assert(!allow);
+ if (data) (*(int*)data)++;
+ g_main_loop_quit(test_loop);
+}
+
+static void test_clear_counts()
+{
+ test_filter_cancel_count = 0;
+ test_filter_activate_count = 0;
+ test_filter_check_count = 0;
+}
+
+static void test_common_init()
+{
+ test_clear_counts();
+ test_loop = g_main_loop_new(NULL, FALSE);
+ if (!test_debug) {
+ g_timeout_add_seconds(TEST_TIMEOUT_SEC, test_timeout_cb, NULL);
+ }
+}
+
+static void test_gc_init(struct ofono_gprs *gprs,
+ struct ofono_gprs_context *gc)
+{
+ memset(gc, 0, sizeof(*gc));
+ gc->gprs = gprs;
+}
+
+static void test_gprs_init(struct ofono_gprs *gprs,
+ struct ofono_gprs_context *gc)
+{
+ memset(gprs, 0, sizeof(*gprs));
+ test_gc_init(gprs, gc);
+}
+
+static void test_common_deinit()
+{
+ g_main_loop_unref(test_loop);
+ test_loop = NULL;
+}
+
+static gboolean filter_later_cb(gpointer user_data)
+{
+ struct test_later_data* later = user_data;
+
+ later->cb(later->ctx, later->user_data);
+ return G_SOURCE_REMOVE;
+}
+
+static void filter_free_cb(gpointer user_data)
+{
+ struct test_later_data* later = user_data;
+
+ g_free(later->ctx);
+ g_free(later);
+}
+
+static unsigned int filter_later(ofono_gprs_filter_activate_cb_t cb,
+ const struct ofono_gprs_primary_context *ctx, void *user_data)
+{
+ struct test_later_data* later = g_new0(struct test_later_data, 1);
+
+ later->cb = cb;
+ later->ctx = g_memdup(ctx, sizeof(*ctx));
+ later->user_data = user_data;
+
+ return g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, filter_later_cb,
+ later, filter_free_cb);
+}
+
+static unsigned int filter_activate_cancel(struct ofono_gprs_context *gc,
+ const struct ofono_gprs_primary_context *ctx,
+ ofono_gprs_filter_activate_cb_t cb, void *user_data)
+{
+ test_filter_cancel_count++;
+ cb(NULL, user_data);
+ return 0;
+}
+
+static unsigned int filter_activate_cancel_later(struct ofono_gprs_context *gc,
+ const struct ofono_gprs_primary_context *ctx,
+ ofono_gprs_filter_activate_cb_t cb, void *user_data)
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/test-ril-transport.c
^
|
@@ -0,0 +1,97 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2018 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 "ofono.h"
+#include <ofono/ril-transport.h>
+
+#include <string.h>
+#include <errno.h>
+
+static void test_null(void)
+{
+ struct ofono_ril_transport noname;
+
+ memset(&noname, 0, sizeof(noname));
+ g_assert(ofono_ril_transport_register(NULL) == -EINVAL);
+ g_assert(ofono_ril_transport_register(&noname) == -EINVAL);
+ ofono_ril_transport_unregister(NULL);
+ ofono_ril_transport_unregister(&noname);
+ g_assert(!ofono_ril_transport_connect(NULL, NULL));
+}
+
+static void test_register(void)
+{
+ struct ofono_ril_transport foo;
+ struct ofono_ril_transport bar;
+
+ memset(&foo, 0, sizeof(foo));
+ memset(&bar, 0, sizeof(bar));
+
+ foo.name = "foo";
+ bar.name = "bar";
+ g_assert(ofono_ril_transport_register(&foo) == 0);
+ g_assert(ofono_ril_transport_register(&bar) == 0);
+ g_assert(ofono_ril_transport_register(&bar) == (-EALREADY));
+ g_assert(!ofono_ril_transport_connect(foo.name, NULL));
+ g_assert(!ofono_ril_transport_connect("test", NULL));
+ ofono_ril_transport_unregister(&foo);
+ ofono_ril_transport_unregister(&bar);
+}
+
+static struct grilio_transport *test_connect_cb(GHashTable *params)
+{
+ static int dummy;
+
+ return (void*)&dummy;
+}
+
+static void test_connect(void)
+{
+ static const struct ofono_ril_transport test = {
+ .name = "test",
+ .api_version = OFONO_RIL_TRANSPORT_API_VERSION,
+ .connect = test_connect_cb
+ };
+
+ g_assert(ofono_ril_transport_register(&test) == 0);
+ /* The returned pointer points to a static variable, no need to free */
+ g_assert(ofono_ril_transport_connect(test.name, NULL));
+ ofono_ril_transport_unregister(&test);
+}
+
+#define TEST_(name) "/ril-transport/" name
+
+int main(int argc, char *argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+
+ __ofono_log_init("test-ril_util",
+ g_test_verbose() ? "*" : NULL,
+ FALSE, FALSE);
+
+ g_test_add_func(TEST_("null"), test_null);
+ g_test_add_func(TEST_("register"), test_register);
+ g_test_add_func(TEST_("connect"), test_connect);
+
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/test-ril_config.c
^
|
@@ -0,0 +1,864 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2018 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 "drivers/ril/ril_config.h"
+
+#include <ofono/log.h>
+#include "ofono.h"
+
+#include <gutil_strv.h>
+#include <gutil_ints.h>
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#define TMP_DIR_TEMPLATE "test-ril_config-XXXXXX"
+
+static void test_get_value(const char *conf, void (*test)(GKeyFile *k))
+{
+ char *dir = g_dir_make_tmp(TMP_DIR_TEMPLATE, NULL);
+ char *file = g_strconcat(dir, "/test.conf", NULL);
+ GKeyFile *k = g_key_file_new();
+
+ g_assert(g_file_set_contents(file, conf, -1, NULL));
+ g_assert(g_key_file_load_from_file(k, file, 0, NULL));
+
+ DBG("%s:\n%s", file, conf);
+ test(k);
+
+ remove(file);
+ remove(dir);
+
+ g_key_file_unref(k);
+ g_free(file);
+ g_free(dir);
+}
+
+static gboolean test_keyfile_empty(GKeyFile *k)
+{
+ gsize n = 0;
+ char **groups = g_key_file_get_groups(k, &n);
+
+ g_strfreev(groups);
+ return !n;
+}
+
+static void test_merge_ignore(const char *filename, const char *contents,
+ const char *dirname, const char *filename1, const char *contents1)
+{
+ char *dir = g_dir_make_tmp(TMP_DIR_TEMPLATE, NULL);
+ char *file = g_strconcat(dir, "/", filename, NULL);
+ char *subdir = g_strconcat(dir, "/", dirname, NULL);
+ char *file1 = g_strconcat(subdir, "/", filename1, NULL);
+ GKeyFile *k = g_key_file_new();
+ char *data;
+
+ g_assert(!mkdir(subdir, 0700));
+ g_assert(g_file_set_contents(file, contents, -1, NULL));
+ g_assert(g_file_set_contents(file1, contents1, -1, NULL));
+ DBG("reading %s", file);
+ ril_config_merge_files(k, file);
+ data = g_key_file_to_data(k, NULL, NULL);
+ DBG("\n%s", data);
+ g_assert(!g_strcmp0(data, contents));
+ g_free(data);
+ g_key_file_unref(k);
+
+ remove(file);
+ remove(file1);
+ remove(subdir);
+ remove(dir);
+
+ g_free(file);
+ g_free(file1);
+ g_free(dir);
+ g_free(subdir);
+}
+
+static void test_merge1(const char *conf, const char *conf1, const char *out)
+{
+ char *dir = g_dir_make_tmp(TMP_DIR_TEMPLATE, NULL);
+ char *file = g_strconcat(dir, "/foo.conf", NULL);
+ char *subdir = g_strconcat(dir, "/foo.d", NULL);
+ char *file1 = g_strconcat(subdir, "/bar.conf", NULL);
+ GKeyFile *k = g_key_file_new();
+ char *data;
+
+ g_assert(!mkdir(subdir, 0700));
+ g_assert(g_file_set_contents(file, conf, -1, NULL));
+ g_assert(g_file_set_contents(file1, conf1, -1, NULL));
+
+ DBG("reading %s", file);
+ g_key_file_set_list_separator(k, ',');
+ ril_config_merge_files(k, file);
+ data = g_key_file_to_data(k, NULL, NULL);
+ DBG("\n%s", data);
+ g_assert(!g_strcmp0(data, out));
+ g_free(data);
+ g_key_file_unref(k);
+
+ remove(file);
+ remove(file1);
+ remove(subdir);
+ remove(dir);
+
+ g_free(file);
+ g_free(file1);
+ g_free(dir);
+ g_free(subdir);
+}
+
+/* ==== get_string ==== */
+
+static void test_get_string0_cb(GKeyFile *k)
+{
+ char *value = ril_config_get_string(k, "g", "k");
+ g_assert(!g_strcmp0(value, "v"));
+ g_free(value);
+ g_assert(!ril_config_get_string(k, RILCONF_SETTINGS_GROUP, "k"));
+ g_assert(!ril_config_get_string(k, "foo", "k"));
+}
+
+static void test_get_string0(void)
+{
+ static const char conf [] = "[g]\nk=v\n";
+ test_get_value(conf, test_get_string0_cb);
+}
+
+static void test_get_string1_cb(GKeyFile *k)
+{
+ char *value = ril_config_get_string(k, RILCONF_SETTINGS_GROUP, "k");
+ g_assert(!g_strcmp0(value, "v"));
+ g_free(value);
+ value = ril_config_get_string(k, "g", "k");
+ g_assert(!g_strcmp0(value, "v"));
+ g_free(value);
+}
+
+static void test_get_string1(void)
+{
+ static const char conf [] = "[" RILCONF_SETTINGS_GROUP "]\nk=v\n";
+
+ test_get_value(conf, test_get_string1_cb);
+}
+
+static void test_get_string2_cb(GKeyFile *k)
+{
+ char *value = ril_config_get_string(k, RILCONF_SETTINGS_GROUP, "k");
+ g_assert(!g_strcmp0(value, "v1"));
+ g_free(value);
+ value = ril_config_get_string(k, "g", "k");
+ g_assert(!g_strcmp0(value, "v2"));
+ g_free(value);
+ value = ril_config_get_string(k, "g1", "k");
+ g_assert(!g_strcmp0(value, "v1"));
+ g_free(value);
+}
+
+static void test_get_string2(void)
+{
+ static const char conf [] =
+ "[" RILCONF_SETTINGS_GROUP "]\nk=v1\n\n"
+ "[g]\nk=v2\n";
+
+ test_get_value(conf, test_get_string2_cb);
+}
+
+/* ==== get_strings ==== */
+
+static void test_get_strings0_cb(GKeyFile *k)
+{
+ char **values = ril_config_get_strings(k, "g", "k", ',');
+ g_assert(values);
+ g_assert(gutil_strv_length(values) == 0);
+ g_strfreev(values);
+
+ values = ril_config_get_strings(k, RILCONF_SETTINGS_GROUP, "k", ',');
+ g_assert(values);
+ g_assert(gutil_strv_length(values) == 0);
+ g_strfreev(values);
+}
+
+static void test_get_strings0(void)
+{
+ static const char conf [] = "[" RILCONF_SETTINGS_GROUP "]\nk=\n";
+ test_get_value(conf, test_get_strings0_cb);
+}
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/test-ril_util.c
^
|
@@ -81,27 +81,6 @@
g_assert(!op.tech);
}
-void test_parse_int(void)
-{
- int value;
-
- g_assert(!ril_parse_int(NULL, 0, NULL));
- g_assert(!ril_parse_int("", 0, NULL));
- g_assert(!ril_parse_int("garbage", 0, NULL));
- g_assert(!ril_parse_int("0 trailing garbage", 0, NULL));
- g_assert(ril_parse_int("0", 0, NULL));
- g_assert(ril_parse_int("0", 0, &value));
- g_assert(value == 0);
- g_assert(!ril_parse_int("0x10000000000000000", 0, &value));
- g_assert(!ril_parse_int("-2147483649", 0, &value));
- g_assert(!ril_parse_int("4294967295", 0, &value));
- g_assert(ril_parse_int(" 0x7fffffff ", 0, &value));
- g_assert(value == 0x7fffffff);
- g_assert(ril_parse_int(" 7fffffff ", 16, &value));
- g_assert(value == 0x7fffffff);
- g_assert(!ril_parse_int("0xffffffff", 0, &value));
-}
-
void test_strings(void)
{
g_assert(!g_strcmp0(ril_error_to_string(RIL_E_SUCCESS), "OK"));
@@ -128,7 +107,6 @@
g_test_add_func(TEST_("parse_tech"), test_parse_tech);
g_test_add_func(TEST_("parse_mcc_mnc"), test_parse_mcc_mnc);
- g_test_add_func(TEST_("parse_int"), test_parse_int);
g_test_add_func(TEST_("strings"), test_strings);
return g_test_run();
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/test-sailfish_access.c
^
|
@@ -0,0 +1,302 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2019 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 "ofono.h"
+
+#include <dbusaccess_peer.h>
+#include <dbusaccess_policy.h>
+#include <dbusaccess_system.h>
+
+#include <gutil_idlepool.h>
+#include <gutil_log.h>
+
+#include <errno.h>
+
+static GUtilIdlePool* peer_pool;
+
+extern struct ofono_plugin_desc __ofono_builtin_sailfish_access;
+extern const char *sailfish_access_config_file;
+
+#define TMP_DIR_TEMPLATE "test-sailfish_access-XXXXXX"
+
+#define ROOT_SENDER ":1.100"
+#define PRIVILEGED_SENDER ":1.200"
+#define NON_PRIVILEGED_SENDER ":1.300"
+#define INVALID_SENDER ":1.400"
+
+#define NEMO_UID (100000)
+#define NEMO_GID (100000)
+#define PRIVILEGED_GID (996)
+#define SAILFISH_RADIO_GID (997)
+
+/*==========================================================================*
+ * Stubs
+ *==========================================================================*/
+
+DAPeer *da_peer_get(DA_BUS bus, const char *name)
+{
+ if (name && g_strcmp0(name, INVALID_SENDER)) {
+ gsize len = strlen(name);
+ DAPeer *peer = g_malloc0(sizeof(DAPeer) + len + 1);
+ char *buf = (char*)(peer + 1);
+ strcpy(buf, name);
+ peer->name = buf;
+ gutil_idle_pool_add(peer_pool, peer, g_free);
+ if (!strcmp(name, PRIVILEGED_SENDER)) {
+ peer->cred.euid = NEMO_UID;
+ peer->cred.egid = PRIVILEGED_GID;
+ } else if (strcmp(name, ROOT_SENDER)) {
+ peer->cred.euid = NEMO_UID;
+ peer->cred.egid = NEMO_GID;
+ }
+ return peer;
+ } else {
+ return NULL;
+ }
+}
+
+void da_peer_flush(DA_BUS bus, const char *name)
+{
+ gutil_idle_pool_drain(peer_pool);
+}
+
+/*
+ * The build environment doesn't necessarily have these users and groups.
+ * And yet, sailfish access plugin depends on those.
+ */
+
+int da_system_uid(const char *user)
+{
+ if (!g_strcmp0(user, "nemo")) {
+ return NEMO_UID;
+ } else {
+ return -1;
+ }
+}
+
+int da_system_gid(const char *group)
+{
+ if (!g_strcmp0(group, "sailfish-radio")) {
+ return SAILFISH_RADIO_GID;
+ } else if (!g_strcmp0(group, "privileged")) {
+ return PRIVILEGED_GID;
+ } else {
+ return -1;
+ }
+}
+
+/*==========================================================================*
+ * Tests
+ *==========================================================================*/
+
+static void test_register()
+{
+ g_assert(__ofono_builtin_sailfish_access.init() == 0);
+ g_assert(__ofono_builtin_sailfish_access.init() == -EALREADY);
+ __ofono_builtin_sailfish_access.exit();
+ __ofono_builtin_sailfish_access.exit();
+}
+
+static void test_default()
+{
+ const char *default_config_file = sailfish_access_config_file;
+
+ sailfish_access_config_file = "/no such file";
+ g_assert(__ofono_builtin_sailfish_access.init() == 0);
+
+ /* root and privileged are allowed to Dial by default */
+ g_assert(__ofono_dbus_access_method_allowed(ROOT_SENDER,
+ OFONO_DBUS_ACCESS_INTF_VOICECALLMGR,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_DIAL, NULL));
+ g_assert(__ofono_dbus_access_method_allowed(PRIVILEGED_SENDER,
+ OFONO_DBUS_ACCESS_INTF_VOICECALLMGR,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_DIAL, NULL));
+
+ /* Non-privileged and unknown users are not */
+ g_assert(!__ofono_dbus_access_method_allowed(NON_PRIVILEGED_SENDER,
+ OFONO_DBUS_ACCESS_INTF_VOICECALLMGR,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_DIAL, NULL));
+ g_assert(!__ofono_dbus_access_method_allowed(INVALID_SENDER,
+ OFONO_DBUS_ACCESS_INTF_VOICECALLMGR,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_DIAL, NULL));
+
+ /* Unknown interfaces/methods are allowed */
+ g_assert(__ofono_dbus_access_method_allowed(NON_PRIVILEGED_SENDER,
+ OFONO_DBUS_ACCESS_INTF_COUNT, 0, NULL));
+ g_assert(__ofono_dbus_access_method_allowed(NON_PRIVILEGED_SENDER,
+ OFONO_DBUS_ACCESS_INTF_MESSAGE, -1, NULL));
+ g_assert(__ofono_dbus_access_method_allowed(NON_PRIVILEGED_SENDER,
+ OFONO_DBUS_ACCESS_INTF_MESSAGE,
+ OFONO_DBUS_ACCESS_MESSAGE_METHOD_COUNT, NULL));
+
+ __ofono_builtin_sailfish_access.exit();
+
+ /* Restore the defaults */
+ sailfish_access_config_file = default_config_file;
+}
+
+struct test_config_data {
+ gboolean allowed;
+ const char *sender;
+ enum ofono_dbus_access_intf intf;
+ int method;
+ const char *config;
+};
+
+static const struct test_config_data config_tests [] = {
+ {
+ TRUE, NON_PRIVILEGED_SENDER,
+ OFONO_DBUS_ACCESS_INTF_VOICECALL,
+ OFONO_DBUS_ACCESS_VOICECALL_HANGUP,
+ "[org.ofono.VoiceCall]\n"
+ "Hangup = " DA_POLICY_VERSION "; * = allow \n"
+ },{
+ FALSE, NON_PRIVILEGED_SENDER,
+ OFONO_DBUS_ACCESS_INTF_VOICECALL,
+ OFONO_DBUS_ACCESS_VOICECALL_HANGUP,
+ "[org.ofono.VoiceCall]\n"
+ "Hangup = " DA_POLICY_VERSION "; * = allow \n"
+ "=========" /* Invalid key file */
+ },{
+ FALSE, NON_PRIVILEGED_SENDER,
+ OFONO_DBUS_ACCESS_INTF_VOICECALLMGR,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_DIAL,
+ "[Common]\n"
+ "DefaultAccess = " DA_POLICY_VERSION "; * = allow \n"
+ "[org.ofono.VoiceCallManager]\n"
+ "Dial = " DA_POLICY_VERSION "; * = deny\n"
+ "group(privileged) = allow\n"
+ },{
+ TRUE, NON_PRIVILEGED_SENDER,
+ OFONO_DBUS_ACCESS_INTF_VOICECALLMGR,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_TRANSFER,
+ "[Common]\n"
+ "DefaultAccess = " DA_POLICY_VERSION "; * = allow \n"
+ "[org.ofono.VoiceCallManager]\n"
+ "Dial = " DA_POLICY_VERSION "; * = deny; "
+ "group(privileged) = allow \n"
+ },{
+ TRUE, PRIVILEGED_SENDER,
+ OFONO_DBUS_ACCESS_INTF_VOICECALLMGR,
+ OFONO_DBUS_ACCESS_VOICECALLMGR_DIAL,
+ "[Common]\n"
+ "DefaultAccess = " DA_POLICY_VERSION "; * = allow \n"
+ "[org.ofono.VoiceCallManager]\n"
+ "Dial = " DA_POLICY_VERSION "; * = deny; "
+ "group(privileged) = allow \n"
+ },{
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/test-sailfish_manager.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony
*
- * Copyright (C) 2017-2018 Jolla Ltd.
+ * Copyright (C) 2017-2019 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,7 +18,7 @@
#include "sailfish_sim_info.h"
#include "sailfish_manager_dbus.h"
-#include "fake_sailfish_watch.h"
+#include "fake_watch.h"
#define OFONO_API_SUBJECT_TO_CHANGE
#include "ofono.h"
@@ -610,7 +610,7 @@
{
test_slot_manager *sm = user_data;
test_slot *s = sm->slot;
- struct sailfish_watch *w = sailfish_watch_new(TEST_PATH);
+ struct ofono_watch *w = ofono_watch_new(TEST_PATH);
struct sailfish_manager *m = fake_sailfish_manager_dbus.m;
struct ofono_modem modem;
char **slots;
@@ -625,18 +625,18 @@
memset(&modem, 0, sizeof(modem));
w->modem = &modem;
w->online = TRUE;
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_ONLINE_CHANGED);
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_MODEM_CHANGED);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_ONLINE_CHANGED);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_MODEM_CHANGED);
+ fake_watch_emit_queued_signals(w);
sailfish_manager_set_cell_info(s->handle, NULL);
sailfish_manager_set_cell_info(s->handle, &fake_sailfish_cell_info);
w->modem = NULL;
w->online = FALSE;
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_ONLINE_CHANGED);
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_MODEM_CHANGED);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_ONLINE_CHANGED);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_MODEM_CHANGED);
+ fake_watch_emit_queued_signals(w);
sailfish_manager_set_cell_info(s->handle, NULL);
g_assert(!fake_sailfish_cell_info_ref_count);
@@ -708,7 +708,7 @@
fake_sailfish_manager_dbus.fn_block_changed =
test_quit_loop_when_unblocked;
- sailfish_watch_unref(w);
+ ofono_watch_unref(w);
return G_SOURCE_REMOVE;
}
@@ -885,7 +885,7 @@
test_slot_manager *sm = user_data;
test_slot *s = sm->slot;
struct sailfish_manager *m = fake_sailfish_manager_dbus.m;
- struct sailfish_watch *w = sailfish_watch_new(TEST_PATH);
+ struct ofono_watch *w = ofono_watch_new(TEST_PATH);
struct ofono_sim sim;
memset(&sim, 0, sizeof(sim));
@@ -899,10 +899,10 @@
g_assert(!m->default_voice_path);
/* Once IMSI is known, default voice modem will point to this slot */
- fake_sailfish_watch_set_ofono_sim(w, &sim);
- fake_sailfish_watch_set_ofono_iccid(w, TEST_ICCID);
- fake_sailfish_watch_set_ofono_imsi(w, TEST_IMSI);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_set_ofono_sim(w, &sim);
+ fake_watch_set_ofono_iccid(w, TEST_ICCID);
+ fake_watch_set_ofono_imsi(w, TEST_IMSI);
+ fake_watch_emit_queued_signals(w);
g_assert(!m->default_voice_imsi);
g_assert(!g_strcmp0(m->default_voice_path, TEST_PATH));
@@ -919,16 +919,16 @@
g_assert(!g_strcmp0(m->default_voice_path, TEST_PATH));
/* Remove the SIM */
- fake_sailfish_watch_set_ofono_iccid(w, NULL);
- fake_sailfish_watch_set_ofono_imsi(w, NULL);
- fake_sailfish_watch_set_ofono_spn(w, NULL);
+ fake_watch_set_ofono_iccid(w, NULL);
+ fake_watch_set_ofono_imsi(w, NULL);
+ fake_watch_set_ofono_spn(w, NULL);
sailfish_manager_set_sim_state(s->handle, SAILFISH_SIM_STATE_ABSENT);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_emit_queued_signals(w);
g_assert(!m->slots[0]->sim_present);
g_assert(!g_strcmp0(m->default_voice_imsi, TEST_IMSI));
g_assert(!m->default_voice_path);
- sailfish_watch_unref(w);
+ ofono_watch_unref(w);
g_main_loop_quit(test_loop);
return G_SOURCE_REMOVE;
}
@@ -977,7 +977,7 @@
test_slot_manager *sm = user_data;
test_slot *s = sm->slot;
struct sailfish_manager *m = fake_sailfish_manager_dbus.m;
- struct sailfish_watch *w = sailfish_watch_new(TEST_PATH);
+ struct ofono_watch *w = ofono_watch_new(TEST_PATH);
struct ofono_modem modem;
struct ofono_sim sim;
@@ -995,10 +995,10 @@
g_assert(!m->default_data_path);
/* Once IMSI is known, default voice modem will point to this slot */
- fake_sailfish_watch_set_ofono_sim(w, &sim);
- fake_sailfish_watch_set_ofono_iccid(w, TEST_ICCID);
- fake_sailfish_watch_set_ofono_imsi(w, TEST_IMSI);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_set_ofono_sim(w, &sim);
+ fake_watch_set_ofono_iccid(w, TEST_ICCID);
+ fake_watch_set_ofono_imsi(w, TEST_IMSI);
+ fake_watch_emit_queued_signals(w);
g_assert(!g_strcmp0(m->default_voice_path, TEST_PATH));
g_assert(!m->default_data_path); /* No default data slot */
@@ -1011,9 +1011,9 @@
/* Set modem online */
w->modem = &modem;
w->online = TRUE;
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_ONLINE_CHANGED);
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_MODEM_CHANGED);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_ONLINE_CHANGED);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_MODEM_CHANGED);
+ fake_watch_emit_queued_signals(w);
/* Now is should point to our slot */
g_assert(!g_strcmp0(m->default_data_path, TEST_PATH));
@@ -1023,19 +1023,19 @@
g_assert(!m->default_data_path);
/* Switch the SIM */
- fake_sailfish_watch_set_ofono_imsi(w, TEST_IMSI_1);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_set_ofono_imsi(w, TEST_IMSI_1);
+ fake_watch_emit_queued_signals(w);
g_assert(!g_strcmp0(m->default_data_path, TEST_PATH));
/* Remove the SIM */
- fake_sailfish_watch_set_ofono_sim(w, NULL);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_set_ofono_sim(w, NULL);
+ fake_watch_emit_queued_signals(w);
sailfish_manager_set_sim_state(s->handle, SAILFISH_SIM_STATE_ABSENT);
g_assert(!m->slots[0]->sim_present);
g_assert(!g_strcmp0(m->default_data_imsi, TEST_IMSI_1));
g_assert(!m->default_data_path);
- sailfish_watch_unref(w);
+ ofono_watch_unref(w);
g_main_loop_quit(test_loop);
return G_SOURCE_REMOVE;
}
@@ -1085,7 +1085,7 @@
test_slot_manager *sm = user_data;
test_slot *s = sm->slot;
struct sailfish_manager *m = fake_sailfish_manager_dbus.m;
- struct sailfish_watch *w = sailfish_watch_new(TEST_PATH);
+ struct ofono_watch *w = ofono_watch_new(TEST_PATH);
struct ofono_modem modem;
struct ofono_sim sim;
@@ -1107,12 +1107,12 @@
/* Make the test slot the default data modem */
w->modem = &modem;
w->online = TRUE;
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_ONLINE_CHANGED);
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_MODEM_CHANGED);
- fake_sailfish_watch_set_ofono_sim(w, &sim);
- fake_sailfish_watch_set_ofono_iccid(w, TEST_ICCID);
- fake_sailfish_watch_set_ofono_imsi(w, TEST_IMSI);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_ONLINE_CHANGED);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_MODEM_CHANGED);
+ fake_watch_set_ofono_sim(w, &sim);
+ fake_watch_set_ofono_iccid(w, TEST_ICCID);
+ fake_watch_set_ofono_imsi(w, TEST_IMSI);
+ fake_watch_emit_queued_signals(w);
/* Data SIM gets automatically selected on a single-SIM phone */
g_assert(!g_strcmp0(m->default_voice_path, TEST_PATH));
@@ -1151,7 +1151,7 @@
g_assert(!m->mms_imsi);
g_assert(!m->mms_path);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/test-sailfish_sim_info.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony
*
- * Copyright (C) 2017-2018 Jolla Ltd.
+ * Copyright (C) 2017-2019 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,7 @@
*/
#include "sailfish_sim_info.h"
-#include "fake_sailfish_watch.h"
+#include "fake_watch.h"
#define OFONO_API_SUBJECT_TO_CHANGE
#include "ofono.h"
@@ -173,17 +173,17 @@
}
}
-static void test_remove_sim(struct ofono_sim* sim, struct sailfish_watch *watch)
+static void test_remove_sim(struct ofono_sim* sim, struct ofono_watch *watch)
{
sim->mcc = NULL;
sim->mnc = NULL;
sim->state = OFONO_SIM_STATE_NOT_PRESENT;
- fake_sailfish_watch_signal_queue(watch, WATCH_SIGNAL_IMSI_CHANGED);
- fake_sailfish_watch_signal_queue(watch, WATCH_SIGNAL_SIM_STATE_CHANGED);
- fake_sailfish_watch_set_ofono_iccid(watch, NULL);
- fake_sailfish_watch_set_ofono_imsi(watch, NULL);
- fake_sailfish_watch_set_ofono_spn(watch, NULL);
- fake_sailfish_watch_emit_queued_signals(watch);
+ fake_watch_signal_queue(watch, FAKE_WATCH_SIGNAL_IMSI_CHANGED);
+ fake_watch_signal_queue(watch, FAKE_WATCH_SIGNAL_SIM_STATE_CHANGED);
+ fake_watch_set_ofono_iccid(watch, NULL);
+ fake_watch_set_ofono_imsi(watch, NULL);
+ fake_watch_set_ofono_spn(watch, NULL);
+ fake_watch_emit_queued_signals(watch);
}
/* Test cases */
@@ -222,7 +222,7 @@
static void test_cache(void)
{
struct sailfish_sim_info *si;
- struct sailfish_watch *w = sailfish_watch_new(TEST_PATH);
+ struct ofono_watch *w = ofono_watch_new(TEST_PATH);
struct ofono_sim sim;
struct stat st;
gulong id[SIM_INFO_SIGNAL_COUNT];
@@ -248,8 +248,8 @@
test_signal_count_cb, count +
SIM_INFO_SIGNAL_SPN_CHANGED);
- fake_sailfish_watch_set_ofono_sim(w, &sim);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_set_ofono_sim(w, &sim);
+ fake_watch_emit_queued_signals(w);
g_assert(!count[SIM_INFO_SIGNAL_ICCID_CHANGED]);
g_assert(!count[SIM_INFO_SIGNAL_IMSI_CHANGED]);
g_assert(!count[SIM_INFO_SIGNAL_SPN_CHANGED]);
@@ -257,8 +257,8 @@
g_assert(!si->imsi);
g_assert(!si->spn);
- fake_sailfish_watch_set_ofono_iccid(w, TEST_ICCID);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_set_ofono_iccid(w, TEST_ICCID);
+ fake_watch_emit_queued_signals(w);
g_assert(!g_strcmp0(si->iccid, TEST_ICCID));
g_assert(count[SIM_INFO_SIGNAL_ICCID_CHANGED] == 1);
g_assert(!count[SIM_INFO_SIGNAL_IMSI_CHANGED]);
@@ -266,8 +266,8 @@
g_assert(stat(ICCID_MAP, &st) < 0);
count[SIM_INFO_SIGNAL_ICCID_CHANGED] = 0;
- fake_sailfish_watch_set_ofono_imsi(w, TEST_IMSI);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_set_ofono_imsi(w, TEST_IMSI);
+ fake_watch_emit_queued_signals(w);
g_assert(!g_strcmp0(si->imsi, TEST_IMSI));
g_assert(!count[SIM_INFO_SIGNAL_ICCID_CHANGED]);
g_assert(!count[SIM_INFO_SIGNAL_SPN_CHANGED]);
@@ -283,9 +283,9 @@
sim.mcc = TEST_MCC;
sim.mnc = TEST_MNC;
sim.state = OFONO_SIM_STATE_READY;
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_IMSI_CHANGED);
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_SIM_STATE_CHANGED);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_IMSI_CHANGED);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_SIM_STATE_CHANGED);
+ fake_watch_emit_queued_signals(w);
g_assert(!g_strcmp0(si->spn, TEST_DEFAULT_SPN));
g_assert(count[SIM_INFO_SIGNAL_SPN_CHANGED] == 1);
count[SIM_INFO_SIGNAL_SPN_CHANGED] = 0;
@@ -301,8 +301,8 @@
memset(count, 0, sizeof(count));
sim.state = OFONO_SIM_STATE_INSERTED;
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_SIM_STATE_CHANGED);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_SIM_STATE_CHANGED);
+ fake_watch_emit_queued_signals(w);
g_assert(!count[SIM_INFO_SIGNAL_ICCID_CHANGED]);
g_assert(!count[SIM_INFO_SIGNAL_IMSI_CHANGED]);
g_assert(!count[SIM_INFO_SIGNAL_SPN_CHANGED]);
@@ -310,9 +310,9 @@
sim.mcc = TEST_MCC;
sim.mnc = TEST_MNC;
sim.state = OFONO_SIM_STATE_READY;
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_SIM_STATE_CHANGED);
- fake_sailfish_watch_set_ofono_iccid(w, TEST_ICCID);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_SIM_STATE_CHANGED);
+ fake_watch_set_ofono_iccid(w, TEST_ICCID);
+ fake_watch_emit_queued_signals(w);
/* IMSI gets loaded from the cache file */
g_assert(!g_strcmp0(si->iccid, TEST_ICCID));
@@ -324,8 +324,8 @@
memset(count, 0, sizeof(count));
/* Replace default SPN with the real one */
- fake_sailfish_watch_set_ofono_spn(w, TEST_SPN);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_set_ofono_spn(w, TEST_SPN);
+ fake_watch_emit_queued_signals(w);
g_assert(!g_strcmp0(si->spn, TEST_SPN));
g_assert(!count[SIM_INFO_SIGNAL_ICCID_CHANGED]);
g_assert(!count[SIM_INFO_SIGNAL_IMSI_CHANGED]);
@@ -336,19 +336,19 @@
g_assert(S_ISREG(st.st_mode));
/* Stray events have no effect */
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_SPN_CHANGED);
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_IMSI_CHANGED);
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_ICCID_CHANGED);
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_SIM_STATE_CHANGED);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_SPN_CHANGED);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_IMSI_CHANGED);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_ICCID_CHANGED);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_SIM_STATE_CHANGED);
+ fake_watch_emit_queued_signals(w);
g_assert(!count[SIM_INFO_SIGNAL_ICCID_CHANGED]);
g_assert(!count[SIM_INFO_SIGNAL_IMSI_CHANGED]);
g_assert(!count[SIM_INFO_SIGNAL_SPN_CHANGED]);
/* Empty SPN and IMSI are ignored too */
- fake_sailfish_watch_set_ofono_imsi(w, "");
- fake_sailfish_watch_set_ofono_spn(w, "");
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_set_ofono_imsi(w, "");
+ fake_watch_set_ofono_spn(w, "");
+ fake_watch_emit_queued_signals(w);
g_assert(!count[SIM_INFO_SIGNAL_ICCID_CHANGED]);
g_assert(!count[SIM_INFO_SIGNAL_IMSI_CHANGED]);
g_assert(!count[SIM_INFO_SIGNAL_SPN_CHANGED]);
@@ -367,10 +367,10 @@
sim.mcc = NULL;
sim.mnc = NULL;
sim.state = OFONO_SIM_STATE_INSERTED;
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_ICCID_CHANGED);
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_SIM_STATE_CHANGED);
- fake_sailfish_watch_set_ofono_iccid(w, TEST_ICCID);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_ICCID_CHANGED);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_SIM_STATE_CHANGED);
+ fake_watch_set_ofono_iccid(w, TEST_ICCID);
+ fake_watch_emit_queued_signals(w);
g_assert(!g_strcmp0(si->iccid, TEST_ICCID));
g_assert(!g_strcmp0(si->imsi, TEST_IMSI));
g_assert(!g_strcmp0(si->spn, TEST_SPN));
@@ -390,8 +390,8 @@
memset(count, 0, sizeof(count));
sim.state = OFONO_SIM_STATE_INSERTED;
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_SIM_STATE_CHANGED);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_SIM_STATE_CHANGED);
+ fake_watch_emit_queued_signals(w);
g_assert(!count[SIM_INFO_SIGNAL_ICCID_CHANGED]);
g_assert(!count[SIM_INFO_SIGNAL_IMSI_CHANGED]);
g_assert(!count[SIM_INFO_SIGNAL_SPN_CHANGED]);
@@ -399,11 +399,11 @@
sim.mcc = TEST_MCC;
sim.mnc = TEST_MNC;
sim.state = OFONO_SIM_STATE_READY;
- fake_sailfish_watch_signal_queue(w, WATCH_SIGNAL_SIM_STATE_CHANGED);
- fake_sailfish_watch_set_ofono_iccid(w, TEST_ICCID_1);
- fake_sailfish_watch_set_ofono_imsi(w, TEST_IMSI_1);
+ fake_watch_signal_queue(w, FAKE_WATCH_SIGNAL_SIM_STATE_CHANGED);
+ fake_watch_set_ofono_iccid(w, TEST_ICCID_1);
+ fake_watch_set_ofono_imsi(w, TEST_IMSI_1);
- fake_sailfish_watch_emit_queued_signals(w);
+ fake_watch_emit_queued_signals(w);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/test-sailfish_sim_info_dbus.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony
*
- * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018-2019 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,7 @@
*/
#include "test-dbus.h"
-#include "fake_sailfish_watch.h"
+#include "fake_watch.h"
#include "sailfish_sim_info.h"
@@ -242,7 +242,7 @@
struct ofono_modem modem;
struct test_dbus_context context;
struct sailfish_sim_info_dbus *dbus;
- struct sailfish_watch *watch;
+ struct ofono_watch *watch;
const char *iccid;
};
@@ -310,14 +310,14 @@
memset(&test, 0, sizeof(test));
test.modem.path = TEST_MODEM_PATH;
test.context.start = test_get_all1_start;
- test.watch = sailfish_watch_new(test.modem.path);
+ test.watch = ofono_watch_new(test.modem.path);
test.watch->modem = &test.modem;
test.iccid = "";
test_dbus_setup(&test.context);
g_main_loop_run(test.context.loop);
- sailfish_watch_unref(test.watch);
+ ofono_watch_unref(test.watch);
sailfish_sim_info_dbus_free(test.dbus);
test_dbus_shutdown(&test.context);
if (timeout) {
@@ -333,18 +333,18 @@
struct test_get_all_data *test =
G_CAST(context, struct test_get_all_data, context);
const char *path = test->modem.path;
- struct sailfish_watch *watch = test->watch;
+ struct ofono_watch *watch = test->watch;
DBG("");
test->dbus = sailfish_sim_info_dbus_new_path(path);
g_assert(test->dbus);
- /* Tell sailfish_watch that we have a modem */
+ /* Tell ofono_watch that we have a modem */
test->watch->modem = &test->modem;
- fake_sailfish_watch_set_ofono_sim(watch, &test->modem.sim);
- fake_sailfish_watch_set_ofono_iccid(watch, test->iccid);
- fake_sailfish_watch_signal_queue(watch, WATCH_SIGNAL_MODEM_CHANGED);
- fake_sailfish_watch_emit_queued_signals(watch);
+ fake_watch_set_ofono_sim(watch, &test->modem.sim);
+ fake_watch_set_ofono_iccid(watch, test->iccid);
+ fake_watch_signal_queue(watch, FAKE_WATCH_SIGNAL_MODEM_CHANGED);
+ fake_watch_emit_queued_signals(watch);
test_submit_get_all_call(test, test_get_all_reply);
}
@@ -358,7 +358,7 @@
memset(&test, 0, sizeof(test));
test.modem.path = TEST_MODEM_PATH;
test.context.start = test_get_all2_start;
- test.watch = sailfish_watch_new(test.modem.path);
+ test.watch = ofono_watch_new(test.modem.path);
test.iccid = TEST_ICCID;
test_dbus_setup(&test.context);
@@ -368,7 +368,7 @@
g_assert(test_dbus_find_signal(&test.context, test.modem.path,
SIM_INFO_DBUS_INTERFACE, SIM_INFO_DBUS_ICCID_CHANGED_SIGNAL));
- sailfish_watch_unref(test.watch);
+ ofono_watch_unref(test.watch);
sailfish_sim_info_dbus_free(test.dbus);
test_dbus_shutdown(&test.context);
if (timeout) {
@@ -448,7 +448,7 @@
struct ofono_modem modem;
struct test_dbus_context context;
struct sailfish_sim_info_dbus *dbus;
- struct sailfish_watch *watch;
+ struct ofono_watch *watch;
const char *iccid;
const char *result;
};
@@ -474,8 +474,8 @@
DBG("");
test->dbus = sailfish_sim_info_dbus_new_path(path);
- fake_sailfish_watch_set_ofono_iccid(test->watch, test->iccid);
- fake_sailfish_watch_emit_queued_signals(test->watch);
+ fake_watch_set_ofono_iccid(test->watch, test->iccid);
+ fake_watch_emit_queued_signals(test->watch);
g_assert(test->dbus);
msg = dbus_message_new_method_call(NULL, test->modem.path,
@@ -497,10 +497,10 @@
test.result = result;
test.modem.path = TEST_MODEM_PATH;
test.context.start = test_get_iccid_start;
- test.watch = sailfish_watch_new(test.modem.path);
+ test.watch = ofono_watch_new(test.modem.path);
test.watch->modem = &test.modem;
- fake_sailfish_watch_set_ofono_iccid(test.watch, init_iccid);
- fake_sailfish_watch_emit_queued_signals(test.watch);
+ fake_watch_set_ofono_iccid(test.watch, init_iccid);
+ fake_watch_emit_queued_signals(test.watch);
test_dbus_setup(&test.context);
g_main_loop_run(test.context.loop);
@@ -509,7 +509,7 @@
g_assert(test_dbus_find_signal(&test.context, test.modem.path,
SIM_INFO_DBUS_INTERFACE, SIM_INFO_DBUS_ICCID_CHANGED_SIGNAL));
- sailfish_watch_unref(test.watch);
+ ofono_watch_unref(test.watch);
sailfish_sim_info_dbus_free(test.dbus);
test_dbus_shutdown(&test.context);
if (timeout) {
@@ -535,7 +535,7 @@
struct ofono_modem modem;
struct test_dbus_context context;
struct sailfish_sim_info_dbus *dbus;
- struct sailfish_watch *watch;
+ struct ofono_watch *watch;
const char *method;
const char *result;
};
@@ -559,16 +559,16 @@
G_CAST(context, struct test_get_string_data, context);
const char *path = test->modem.path;
struct ofono_sim *sim = &test->modem.sim;
- struct sailfish_watch *watch = test->watch;
+ struct ofono_watch *watch = test->watch;
DBG("%s", test->method);
test->dbus = sailfish_sim_info_dbus_new_path(path);
sim->mcc = TEST_MCC;
sim->mnc = TEST_MNC;
sim->state = OFONO_SIM_STATE_READY;
- fake_sailfish_watch_signal_queue(watch, WATCH_SIGNAL_SIM_STATE_CHANGED);
- fake_sailfish_watch_set_ofono_imsi(watch, TEST_IMSI);
- fake_sailfish_watch_emit_queued_signals(watch);
+ fake_watch_signal_queue(watch, FAKE_WATCH_SIGNAL_SIM_STATE_CHANGED);
+ fake_watch_set_ofono_imsi(watch, TEST_IMSI);
+ fake_watch_emit_queued_signals(watch);
g_assert(test->dbus);
msg = dbus_message_new_method_call(NULL, test->modem.path,
@@ -590,11 +590,11 @@
test.result = result;
test.modem.path = TEST_MODEM_PATH;
test.context.start = test_get_string_start;
- test.watch = sailfish_watch_new(test.modem.path);
+ test.watch = ofono_watch_new(test.modem.path);
test.watch->modem = &test.modem;
- fake_sailfish_watch_set_ofono_iccid(test.watch, TEST_ICCID);
- fake_sailfish_watch_set_ofono_sim(test.watch, &test.modem.sim);
- fake_sailfish_watch_emit_queued_signals(test.watch);
+ fake_watch_set_ofono_iccid(test.watch, TEST_ICCID);
+ fake_watch_set_ofono_sim(test.watch, &test.modem.sim);
+ fake_watch_emit_queued_signals(test.watch);
test_dbus_setup(&test.context);
g_main_loop_run(test.context.loop);
@@ -605,7 +605,7 @@
g_assert(test_dbus_find_signal(&test.context, test.modem.path,
SIM_INFO_DBUS_INTERFACE, SIM_INFO_DBUS_SPN_CHANGED_SIGNAL));
- sailfish_watch_unref(test.watch);
+ ofono_watch_unref(test.watch);
sailfish_sim_info_dbus_free(test.dbus);
test_dbus_shutdown(&test.context);
if (timeout) {
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/test-voicecall-filter.c
^
|
@@ -0,0 +1,1210 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2018 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 "ofono.h"
+#include "common.h"
+
+#include <gutil_macros.h>
+#include <gutil_log.h>
+
+#include <errno.h>
+
+#define TEST_TIMEOUT_SEC (20)
+
+static gboolean test_debug = FALSE;
+static GMainLoop *test_loop = NULL;
+static int test_filter_dial_count = 0;
+static int test_filter_incoming_count = 0;
+
+/* Fake data structures */
+
+struct ofono_voicecall {
+ struct voicecall_filter_chain *chain;
+};
+
+/* Code shared by all tests */
+
+static gboolean test_timeout_cb(gpointer user_data)
+{
+ g_assert(FALSE);
+ return G_SOURCE_REMOVE;
+}
+
+static gboolean test_quit_cb(gpointer user_data)
+{
+ g_main_loop_quit(test_loop);
+ return G_SOURCE_REMOVE;
+}
+
+static gboolean test_cancel_cb(void* data)
+{
+ struct voicecall_filter_chain *chain = data;
+
+ DBG("");
+ __ofono_voicecall_filter_chain_cancel(chain, NULL);
+ g_idle_add(test_quit_cb, NULL);
+ return G_SOURCE_REMOVE;
+}
+
+static void test_inc(gpointer data)
+{
+ (*(int*)data)++;
+}
+
+static void test_dial_expect_continue_inc
+ (enum ofono_voicecall_filter_dial_result result, void *data)
+{
+ g_assert(result == OFONO_VOICECALL_FILTER_DIAL_CONTINUE);
+ if (data) (*(int*)data)++;
+}
+
+static void test_dial_expect_continue_and_quit
+ (enum ofono_voicecall_filter_dial_result result, void *data)
+{
+ g_assert(result == OFONO_VOICECALL_FILTER_DIAL_CONTINUE);
+ g_main_loop_quit(test_loop);
+}
+
+static void test_dial_expect_block_and_quit
+ (enum ofono_voicecall_filter_dial_result result, void *data)
+{
+ g_assert(result == OFONO_VOICECALL_FILTER_DIAL_BLOCK);
+ g_main_loop_quit(test_loop);
+}
+
+static void test_dial_unexpected
+ (enum ofono_voicecall_filter_dial_result result, void *data)
+{
+ g_assert(FALSE);
+}
+
+static void test_incoming_expect_continue_inc
+ (enum ofono_voicecall_filter_incoming_result result, void *data)
+{
+ g_assert(result == OFONO_VOICECALL_FILTER_INCOMING_CONTINUE);
+ if (data) (*(int*)data)++;
+}
+
+static void test_incoming_expect_continue_and_quit
+ (enum ofono_voicecall_filter_incoming_result result, void *data)
+{
+ g_assert(result == OFONO_VOICECALL_FILTER_INCOMING_CONTINUE);
+ g_main_loop_quit(test_loop);
+}
+
+static void test_incoming_expect_hangup_and_quit
+ (enum ofono_voicecall_filter_incoming_result result, void *data)
+{
+ g_assert(result == OFONO_VOICECALL_FILTER_INCOMING_HANGUP);
+ g_main_loop_quit(test_loop);
+}
+
+static void test_incoming_expect_ignore_and_quit
+ (enum ofono_voicecall_filter_incoming_result result, void *data)
+{
+ g_assert(result == OFONO_VOICECALL_FILTER_INCOMING_IGNORE);
+ g_main_loop_quit(test_loop);
+}
+
+static void test_incoming_unexpected
+ (enum ofono_voicecall_filter_incoming_result result, void *data)
+{
+ g_assert(FALSE);
+}
+
+static void test_clear_counts()
+{
+ test_filter_dial_count = 0;
+ test_filter_incoming_count = 0;
+}
+
+static void test_common_init()
+{
+ test_clear_counts();
+ test_loop = g_main_loop_new(NULL, FALSE);
+ if (!test_debug) {
+ g_timeout_add_seconds(TEST_TIMEOUT_SEC, test_timeout_cb, NULL);
+ }
+}
+
+static void test_voicecall_init(struct ofono_voicecall *vc)
+{
+ memset(vc, 0, sizeof(*vc));
+}
+
+static void test_common_deinit()
+{
+ g_main_loop_unref(test_loop);
+ test_loop = NULL;
+}
+
+struct filter_dial_later_data {
+ ofono_voicecall_filter_dial_cb_t cb;
+ enum ofono_voicecall_filter_dial_result result;
+ void *user_data;
+};
+
+static gboolean filter_dial_later_cb(gpointer user_data)
+{
+ struct filter_dial_later_data* later = user_data;
+
+ test_filter_dial_count++;
+ later->cb(later->result, later->user_data);
+ return G_SOURCE_REMOVE;
+}
+
+static unsigned int filter_dial_later(ofono_voicecall_filter_dial_cb_t cb,
+ enum ofono_voicecall_filter_dial_result result, void *user_data)
+{
+ struct filter_dial_later_data* later =
+ g_new0(struct filter_dial_later_data, 1);
+
+ later->cb = cb;
+ later->result = result;
+ later->user_data = user_data;
+
+ return g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, filter_dial_later_cb,
+ later, g_free);
+}
+
+static unsigned int filter_dial_continue(struct ofono_voicecall *vc,
+ const struct ofono_phone_number *number, enum ofono_clir_option clir,
+ ofono_voicecall_filter_dial_cb_t cb, void *user_data)
+{
+ test_filter_dial_count++;
+ cb(OFONO_VOICECALL_FILTER_DIAL_CONTINUE, user_data);
+ return 0;
+}
+
+static unsigned int filter_dial_continue_later(struct ofono_voicecall *vc,
+ const struct ofono_phone_number *number, enum ofono_clir_option clir,
+ ofono_voicecall_filter_dial_cb_t cb, void *user_data)
+{
+ return filter_dial_later(cb, OFONO_VOICECALL_FILTER_DIAL_CONTINUE,
+ user_data);
+}
+
+static unsigned int filter_dial_block(struct ofono_voicecall *vc,
|
[-]
[+]
|
Added |
_service:tar_git:ofono-1.55.tar.bz2/ofono/unit/test-watch.c
^
|
@@ -0,0 +1,902 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2018-2019 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 "watch_p.h"
+
+#include "ofono.h"
+
+#include <gutil_log.h>
+
+static GSList *g_modem_list = NULL;
+static struct ofono_watchlist *g_modemwatches = NULL;
+
+#define TEST_PATH "/test_0"
+#define TEST_PATH_1 "/test_1"
+#define TEST_ICCID "0000000000000000000"
+#define TEST_IMSI "244120000000000"
+#define TEST_SPN "Test"
+#define TEST_MCC "244"
+#define TEST_MNC "12"
+#define TEST_NAME "Test"
+
+/* Fake ofono_atom */
+
+struct ofono_atom {
+ enum ofono_atom_type type;
+ gboolean registered;
+ void *data;
+ struct ofono_modem *modem;
+};
+
+void *__ofono_atom_get_data(struct ofono_atom *atom)
+{
+ return atom->data;
+}
+
+/* Fake ofono_gprs */
+
+struct ofono_gprs {
+ struct ofono_atom atom;
+ enum ofono_gprs_context_type type;
+ const struct ofono_gprs_primary_context *settings;
+};
+
+/* Fake ofono_netreg */
+
+struct ofono_netreg {
+ struct ofono_atom atom;
+ enum ofono_netreg_status status;
+ const char *mcc;
+ const char *mnc;
+ const char *name;
+};
+
+int ofono_netreg_get_status(struct ofono_netreg *netreg)
+{
+ return netreg ? netreg->status : OFONO_NETREG_STATUS_NONE;
+}
+
+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;
+}
+
+/* Fake ofono_sim */
+
+struct ofono_sim {
+ struct ofono_atom atom;
+ const char *spn;
+ const char *spn_dc;
+ const char *imsi;
+ const char *iccid;
+ enum ofono_sim_state state;
+ struct ofono_watchlist *spn_watches;
+ struct ofono_watchlist *imsi_watches;
+ struct ofono_watchlist *iccid_watches;
+ struct ofono_watchlist *state_watches;
+};
+
+static unsigned int add_watch_item(struct ofono_watchlist *list,
+ void *notify, void *data, ofono_destroy_func destroy)
+{
+ struct ofono_watchlist_item *watch =
+ g_new0(struct ofono_watchlist_item, 1);
+
+ watch->notify = notify;
+ watch->destroy = destroy;
+ watch->notify_data = data;
+ return __ofono_watchlist_add_item(list, watch);
+}
+
+unsigned int ofono_sim_add_iccid_watch(struct ofono_sim *sim,
+ ofono_sim_iccid_event_cb_t cb, void *data,
+ ofono_destroy_func destroy)
+{
+ guint id = add_watch_item(sim->iccid_watches, cb, data, destroy);
+
+ if (sim->iccid) {
+ cb(sim->iccid, data);
+ }
+
+ return id;
+}
+
+void ofono_sim_remove_iccid_watch(struct ofono_sim *sim, unsigned int id)
+{
+ __ofono_watchlist_remove_item(sim->iccid_watches, id);
+}
+
+static void iccid_watches_cb(gpointer data, gpointer user_data)
+{
+ struct ofono_sim *sim = user_data;
+ struct ofono_watchlist_item *item = data;
+ ofono_sim_iccid_event_cb_t cb = item->notify;
+
+ cb(sim->iccid, item->notify_data);
+}
+
+static inline void iccid_watches_notify(struct ofono_sim *sim)
+{
+ g_slist_foreach(sim->iccid_watches->items, iccid_watches_cb, sim);
+}
+
+unsigned int ofono_sim_add_imsi_watch(struct ofono_sim *sim,
+ ofono_sim_imsi_event_cb_t cb, void *data,
+ ofono_destroy_func destroy)
+{
+ guint id = add_watch_item(sim->imsi_watches, cb, data, destroy);
+
+ if (sim->imsi) {
+ cb(sim->imsi, data);
+ }
+
+ return id;
+}
+
+void ofono_sim_remove_imsi_watch(struct ofono_sim *sim, unsigned int id)
+{
+ __ofono_watchlist_remove_item(sim->imsi_watches, id);
+}
+
+static void imsi_watches_cb(gpointer data, gpointer user_data)
+{
+ struct ofono_sim *sim = user_data;
+ struct ofono_watchlist_item *item = data;
+ ofono_sim_imsi_event_cb_t cb = item->notify;
+
+ cb(sim->imsi, item->notify_data);
+}
+
+static inline void imsi_watches_notify(struct ofono_sim *sim)
+{
+ g_slist_foreach(sim->imsi_watches->items, imsi_watches_cb, sim);
+}
+
+ofono_bool_t ofono_sim_add_spn_watch(struct ofono_sim *sim, unsigned int *id,
+ ofono_sim_spn_cb_t cb, void *data, ofono_destroy_func destroy)
+{
+ *id = add_watch_item(sim->spn_watches, cb, data, destroy);
+ if (sim->spn) {
+ cb(sim->spn, sim->spn_dc, data);
+ }
+ return TRUE;
+}
+
+ofono_bool_t ofono_sim_remove_spn_watch(struct ofono_sim *sim, unsigned int *id)
+{
+ if (__ofono_watchlist_remove_item(sim->spn_watches, *id)) {
+ *id = 0;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+static void spn_watches_cb(gpointer data, gpointer user_data)
+{
+ struct ofono_sim *sim = user_data;
|