mirror of
https://github.com/sailfishos/ofono
synced 2025-12-01 23:21:04 +08:00
Compare commits
2 Commits
mer/1.24+g
...
mer/1.24+g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecf14f5165 | ||
|
|
bc4c860a86 |
12
ofono/.gitignore
vendored
12
ofono/.gitignore
vendored
@@ -42,8 +42,11 @@ unit/test-sms-root
|
||||
unit/test-simutil
|
||||
unit/test-mux
|
||||
unit/test-caif
|
||||
unit/test-cell-info
|
||||
unit/test-cell-info-dbus
|
||||
unit/test-stkutil
|
||||
unit/test-cdmasms
|
||||
unit/test-conf
|
||||
unit/test-dbus-access
|
||||
unit/test-dbus-clients
|
||||
unit/test-dbus-queue
|
||||
@@ -58,13 +61,10 @@ 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-config
|
||||
unit/test-slot-manager
|
||||
unit/test-watch
|
||||
unit/test-sim-info
|
||||
unit/test-sim-info-dbus
|
||||
unit/test-sms-filter
|
||||
unit/test-voicecall-filter
|
||||
unit/test-*.log
|
||||
|
||||
@@ -28,7 +28,9 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \
|
||||
include/ril-constants.h include/ril-transport.h \
|
||||
include/watch.h gdbus/gdbus.h include/dbus-clients.h \
|
||||
include/netmon.h include/lte.h include/ims.h \
|
||||
include/storage.h
|
||||
include/slot.h include/cell-info.h \
|
||||
include/storage.h include/conf.h include/misc.h \
|
||||
include/mtu-limit.h
|
||||
|
||||
nodist_pkginclude_HEADERS = include/version.h
|
||||
|
||||
@@ -119,22 +121,15 @@ builtin_modules += udevng
|
||||
builtin_sources += plugins/udevng.c
|
||||
endif
|
||||
|
||||
if SAILFISH_MANAGER
|
||||
builtin_modules += sailfish_manager
|
||||
builtin_sources += plugins/sailfish_manager/sailfish_cell_info.c \
|
||||
plugins/sailfish_manager/sailfish_cell_info_dbus.c \
|
||||
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
|
||||
endif
|
||||
|
||||
|
||||
if SAILFISH_ACCESS
|
||||
builtin_modules += sailfish_access
|
||||
builtin_sources += plugins/sailfish_access.c
|
||||
endif
|
||||
|
||||
if DATAFILES
|
||||
dist_conf_DATA += drivers/ril/ril_subscription.conf
|
||||
endif
|
||||
|
||||
if RILMODEM
|
||||
if SAILFISH_RILMODEM
|
||||
|
||||
@@ -181,10 +176,6 @@ builtin_sources += drivers/ril/ril_call_barring.c \
|
||||
# Vendor specific extensions
|
||||
builtin_sources += drivers/ril/ril_vendor_mtk.c
|
||||
|
||||
if DATAFILES
|
||||
dist_conf_DATA += drivers/ril/ril_subscription.conf
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
builtin_sources += $(gril_sources)
|
||||
@@ -754,7 +745,6 @@ endif
|
||||
sbin_PROGRAMS = src/ofonod
|
||||
|
||||
src_ofonod_SOURCES = $(builtin_sources) $(gatchat_sources) src/ofono.ver \
|
||||
src/mtu-watch.c \
|
||||
src/main.c src/ofono.h src/log.c src/plugin.c \
|
||||
src/modem.c src/common.h src/common.c \
|
||||
src/manager.c src/dbus.c src/util.h src/util.c \
|
||||
@@ -781,12 +771,15 @@ src_ofonod_SOURCES = $(builtin_sources) $(gatchat_sources) src/ofono.ver \
|
||||
src/handsfree-audio.c src/bluetooth.h \
|
||||
src/sim-mnclength.c src/voicecallagent.c \
|
||||
src/sms-filter.c src/gprs-filter.c \
|
||||
src/dbus-clients.c src/dbus-queue.c \
|
||||
src/dbus-access.c src/config.c \
|
||||
src/dbus-clients.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/ims.c \
|
||||
src/netmonagent.c src/netmonagent.h
|
||||
src/netmonagent.c src/netmonagent.h \
|
||||
src/slot-manager.c src/slot-manager-dbus.c \
|
||||
src/cell-info.c src/cell-info-dbus.c \
|
||||
src/sim-info.c src/sim-info-dbus.c \
|
||||
src/conf.c src/mtu-limit.c
|
||||
|
||||
src_ofonod_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \
|
||||
@GLIB_LIBS@ @DBUS_LIBS@ -ldl
|
||||
@@ -813,8 +806,7 @@ AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ $(builtin_cflags) \
|
||||
|
||||
AM_CPPFLAGS = -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/src \
|
||||
-I$(srcdir)/gdbus -I$(srcdir)/gisi -I$(srcdir)/gatchat \
|
||||
-I$(srcdir)/btio -I$(srcdir)/gril \
|
||||
-I$(srcdir)/plugins/sailfish_manager
|
||||
-I$(srcdir)/btio -I$(srcdir)/gril
|
||||
|
||||
doc_files = doc/overview.txt doc/ofono-paper.txt doc/release-faq.txt \
|
||||
doc/manager-api.txt doc/modem-api.txt doc/network-api.txt \
|
||||
@@ -974,61 +966,50 @@ unit_tests = unit/test-common unit/test-util unit/test-idmap \
|
||||
unit/test-simutil unit/test-stkutil \
|
||||
unit/test-sms unit/test-cdmasms
|
||||
|
||||
if SAILFISH_MANAGER
|
||||
unit_test_cell_info_SOURCES = unit/test-cell-info.c src/cell-info.c src/log.c
|
||||
unit_test_cell_info_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT)
|
||||
unit_test_cell_info_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_cell_info_OBJECTS)
|
||||
unit_tests += unit/test-cell-info
|
||||
|
||||
unit_test_sailfish_cell_info_SOURCES = unit/test-sailfish_cell_info.c \
|
||||
plugins/sailfish_manager/sailfish_cell_info.c
|
||||
unit_test_sailfish_cell_info_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT)
|
||||
unit_test_sailfish_cell_info_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sailfish_cell_info_OBJECTS)
|
||||
unit_tests += unit/test-sailfish_cell_info
|
||||
|
||||
unit_test_sailfish_cell_info_dbus_SOURCES = unit/test-dbus.c \
|
||||
unit/test-sailfish_cell_info_dbus.c \
|
||||
unit/fake_sailfish_cell_info.c \
|
||||
plugins/sailfish_manager/sailfish_cell_info.c \
|
||||
plugins/sailfish_manager/sailfish_cell_info_dbus.c \
|
||||
unit_test_cell_info_dbus_SOURCES = unit/test-dbus.c \
|
||||
unit/test-cell-info-dbus.c unit/fake_cell_info.c \
|
||||
src/cell-info.c src/cell-info-dbus.c \
|
||||
gdbus/object.c src/dbus-clients.c \
|
||||
src/dbus.c src/log.c
|
||||
unit_test_sailfish_cell_info_dbus_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
|
||||
unit_test_cell_info_dbus_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
|
||||
@DBUS_GLIB_CFLAGS@
|
||||
unit_test_sailfish_cell_info_dbus_LDADD = @DBUS_GLIB_LIBS@ @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sailfish_cell_info_dbus_OBJECTS)
|
||||
unit_tests += unit/test-sailfish_cell_info_dbus
|
||||
unit_test_cell_info_dbus_LDADD = @DBUS_GLIB_LIBS@ @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_cell_info_dbus_OBJECTS)
|
||||
unit_tests += unit/test-cell-info-dbus
|
||||
|
||||
unit_test_sailfish_sim_info_SOURCES = unit/test-sailfish_sim_info.c \
|
||||
unit/fake_watch.c \
|
||||
plugins/sailfish_manager/sailfish_sim_info.c \
|
||||
src/storage.c src/watchlist.c src/log.c
|
||||
unit_test_sailfish_sim_info_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS) \
|
||||
unit_test_sim_info_SOURCES = unit/test-sim-info.c unit/fake_watch.c \
|
||||
src/sim-info.c src/storage.c src/watchlist.c src/log.c
|
||||
unit_test_sim_info_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS) \
|
||||
-DSTORAGEDIR='"/tmp/ofono"'
|
||||
unit_test_sailfish_sim_info_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sailfish_sim_info_OBJECTS)
|
||||
unit_tests += unit/test-sailfish_sim_info
|
||||
unit_test_sim_info_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sim_info_OBJECTS)
|
||||
unit_tests += unit/test-sim-info
|
||||
|
||||
unit_test_sailfish_sim_info_dbus_SOURCES = unit/test-sailfish_sim_info_dbus.c \
|
||||
unit_test_sim_info_dbus_SOURCES = unit/test-sim-info-dbus.c \
|
||||
unit/test-dbus.c unit/fake_watch.c \
|
||||
plugins/sailfish_manager/sailfish_sim_info.c \
|
||||
plugins/sailfish_manager/sailfish_sim_info_dbus.c \
|
||||
src/sim-info.c src/sim-info-dbus.c \
|
||||
gdbus/object.c \
|
||||
src/dbus.c src/storage.c src/watchlist.c src/log.c
|
||||
unit_test_sailfish_sim_info_dbus_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS) \
|
||||
unit_test_sim_info_dbus_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS) \
|
||||
@DBUS_GLIB_CFLAGS@ -DSTORAGEDIR='"/tmp/ofono"'
|
||||
unit_test_sailfish_sim_info_dbus_LDADD = @DBUS_GLIB_LIBS@ @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sailfish_sim_info_dbus_OBJECTS)
|
||||
unit_tests += unit/test-sailfish_sim_info_dbus
|
||||
unit_test_sim_info_dbus_LDADD = @DBUS_GLIB_LIBS@ @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sim_info_dbus_OBJECTS)
|
||||
unit_tests += unit/test-sim-info-dbus
|
||||
|
||||
unit_test_sailfish_manager_SOURCES = unit/test-sailfish_manager.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 \
|
||||
unit_test_slot_manager_SOURCES = unit/test-slot-manager.c unit/fake_watch.c \
|
||||
src/slot-manager.c src/cell-info.c src/sim-info.c \
|
||||
src/storage.c src/log.c
|
||||
unit_test_sailfish_manager_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
|
||||
unit_test_slot_manager_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
|
||||
-DSTORAGEDIR='"/tmp/ofono"'
|
||||
unit_test_sailfish_manager_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sailfish_manager_OBJECTS)
|
||||
unit_tests += unit/test-sailfish_manager
|
||||
unit_test_slot_manager_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_slot_manager_OBJECTS)
|
||||
unit_tests += unit/test-slot-manager
|
||||
|
||||
unit_test_watch_SOURCES = unit/test-watch.c src/watch.c \
|
||||
src/log.c src/watchlist.c
|
||||
@@ -1038,15 +1019,6 @@ unit_test_watch_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_watch_OBJECTS)
|
||||
unit_tests += unit/test-watch
|
||||
|
||||
endif
|
||||
|
||||
unit_test_config_SOURCES = unit/test-config.c drivers/ril/ril_util.c \
|
||||
src/config.c src/log.c
|
||||
unit_test_config_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
|
||||
unit_test_config_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_config_OBJECTS)
|
||||
unit_tests += unit/test-config
|
||||
|
||||
if SAILFISH_ACCESS
|
||||
unit_test_sailfish_access_SOURCES = unit/test-sailfish_access.c \
|
||||
plugins/sailfish_access.c src/dbus-access.c src/log.c
|
||||
@@ -1066,8 +1038,15 @@ unit_tests += unit/test-dbus-access
|
||||
if RILMODEM
|
||||
if SAILFISH_RILMODEM
|
||||
|
||||
unit_test_conf_SOURCES = unit/test-conf.c drivers/ril/ril_util.c \
|
||||
src/conf.c src/util.c src/log.c
|
||||
unit_test_conf_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
|
||||
unit_test_conf_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_conf_OBJECTS)
|
||||
unit_tests += unit/test-conf
|
||||
|
||||
unit_test_ril_config_SOURCES = unit/test-ril_config.c drivers/ril/ril_util.c \
|
||||
drivers/ril/ril_config.c src/log.c
|
||||
drivers/ril/ril_config.c src/conf.c src/util.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)
|
||||
@@ -1081,7 +1060,7 @@ unit_objects += $(unit_test_ril_ecclist_OBJECTS)
|
||||
unit_tests += unit/test-ril_ecclist
|
||||
|
||||
unit_test_ril_util_SOURCES = unit/test-ril_util.c drivers/ril/ril_util.c \
|
||||
src/log.c
|
||||
src/util.c src/log.c
|
||||
unit_test_ril_util_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
|
||||
unit_test_ril_util_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_ril_util_OBJECTS)
|
||||
@@ -1089,7 +1068,7 @@ unit_tests += unit/test-ril_util
|
||||
|
||||
unit_test_ril_vendor_SOURCES = unit/test-ril_vendor.c unit/fake_watch.c \
|
||||
drivers/ril/ril_vendor.c drivers/ril/ril_vendor_mtk.c \
|
||||
drivers/ril/ril_util.c src/log.c
|
||||
drivers/ril/ril_util.c src/util.c src/log.c
|
||||
unit_test_ril_vendor_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
|
||||
unit_test_ril_vendor_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_ril_vendor_OBJECTS)
|
||||
|
||||
@@ -183,8 +183,8 @@ AC_ARG_ENABLE(sailfish-rilmodem, AC_HELP_STRING([--enable-sailfish-rilmodem],
|
||||
[enable_sailfish_rilmodem="no"])
|
||||
AM_CONDITIONAL(SAILFISH_RILMODEM, test "${enable_sailfish_rilmodem}" != "no")
|
||||
|
||||
PKG_CHECK_MODULES(GLIBUTIL, libglibutil >= 1.0.35, dummy=yes,
|
||||
AC_MSG_ERROR(libglibutil >= 1.0.35 is required))
|
||||
PKG_CHECK_MODULES(GLIBUTIL, libglibutil >= 1.0.49, dummy=yes,
|
||||
AC_MSG_ERROR(libglibutil >= 1.0.49 is required))
|
||||
CFLAGS="$CFLAGS $GLIBUTIL_CFLAGS"
|
||||
LIBS="$LIBS $GLIBUTIL_LIBS"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -18,8 +18,6 @@
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/* See 3GPP 27.007 7.4 for possible values */
|
||||
#define RIL_MAX_SERVICE_LENGTH 3
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "common.h"
|
||||
#include <ofono/netreg.h>
|
||||
|
||||
struct ril_call_forward {
|
||||
GRilIoQueue *q;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 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,6 @@
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
struct ril_call_settings {
|
||||
GRilIoQueue *q;
|
||||
guint timer_id;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2020 Jolla Ltd.
|
||||
* Copyright (C) 2016-2021 Jolla Ltd.
|
||||
* Copyright (C) 2020 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <grilio_parser.h>
|
||||
|
||||
#include <gutil_idlepool.h>
|
||||
#include <gutil_macros.h>
|
||||
#include <gutil_misc.h>
|
||||
|
||||
#define DEFAULT_UPDATE_RATE_MS (10000) /* 10 sec */
|
||||
@@ -35,7 +36,8 @@ typedef struct ril_cell_info RilCellInfo;
|
||||
|
||||
struct ril_cell_info {
|
||||
GObject object;
|
||||
struct sailfish_cell_info info;
|
||||
struct ofono_cell_info info;
|
||||
struct ofono_cell **cells;
|
||||
GRilIoChannel *io;
|
||||
struct ril_radio *radio;
|
||||
struct ril_sim_card *sim_card;
|
||||
@@ -59,26 +61,18 @@ enum ril_cell_info_signal {
|
||||
|
||||
static guint ril_cell_info_signals[SIGNAL_COUNT] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE(RilCellInfo, ril_cell_info, G_TYPE_OBJECT)
|
||||
#define RIL_CELL_INFO_TYPE (ril_cell_info_get_type())
|
||||
#define RIL_CELL_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
|
||||
RIL_CELL_INFO_TYPE, RilCellInfo))
|
||||
#define PARENT_TYPE G_TYPE_OBJECT
|
||||
#define PARENT_CLASS ril_cell_info_parent_class
|
||||
#define THIS_TYPE (ril_cell_info_get_type())
|
||||
#define THIS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), THIS_TYPE, RilCellInfo))
|
||||
|
||||
G_DEFINE_TYPE(RilCellInfo, ril_cell_info, PARENT_TYPE)
|
||||
|
||||
#define DBG_(self,fmt,args...) DBG("%s" fmt, (self)->log_prefix, ##args)
|
||||
|
||||
static inline void ril_cell_free(struct sailfish_cell *cell)
|
||||
{
|
||||
g_slice_free(struct sailfish_cell, cell);
|
||||
}
|
||||
|
||||
static void ril_cell_free1(gpointer cell)
|
||||
{
|
||||
ril_cell_free(cell);
|
||||
}
|
||||
|
||||
static const char *ril_cell_info_int_format(int value, const char *format)
|
||||
{
|
||||
if (value == SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (value == OFONO_CELL_INVALID_VALUE) {
|
||||
return "";
|
||||
} else {
|
||||
static GUtilIdlePool *ril_cell_info_pool = NULL;
|
||||
@@ -90,41 +84,56 @@ static const char *ril_cell_info_int_format(int value, const char *format)
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean ril_cell_info_list_identical(GSList *l1, GSList *l2)
|
||||
static gint ril_cell_info_list_sort_cb(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
while (l1 && l2) {
|
||||
if (memcmp(l1->data, l2->data, sizeof(struct sailfish_cell))) {
|
||||
return FALSE;
|
||||
}
|
||||
l1 = l1->next;
|
||||
l2 = l2->next;
|
||||
}
|
||||
return !l1 && !l2;
|
||||
return ofono_cell_compare_location(*(struct ofono_cell **)a,
|
||||
*(struct ofono_cell **)b);
|
||||
}
|
||||
|
||||
static void ril_cell_info_update_cells(struct ril_cell_info *self, GSList *l)
|
||||
static gboolean ril_cell_info_list_identical(const ofono_cell_ptr *l1,
|
||||
const ofono_cell_ptr *l2)
|
||||
{
|
||||
if (!ril_cell_info_list_identical(self->info.cells, l)) {
|
||||
g_slist_free_full(self->info.cells, ril_cell_free1);
|
||||
self->info.cells = l;
|
||||
if (l1 && l2) {
|
||||
while (*l1 && *l2) {
|
||||
if (memcmp(*l1, *l2, sizeof(struct ofono_cell))) {
|
||||
return FALSE;
|
||||
}
|
||||
l1++;
|
||||
l2++;
|
||||
}
|
||||
return !*l1 && !*l2;
|
||||
} else {
|
||||
return (!l1 || !*l1) && (!l2 || !*l2);
|
||||
}
|
||||
}
|
||||
|
||||
/* Takes ownership of GPtrArray */
|
||||
static void ril_cell_info_update_cells(RilCellInfo *self, GPtrArray *l)
|
||||
{
|
||||
if (l && !ril_cell_info_list_identical(self->cells,
|
||||
(struct ofono_cell **)l->pdata)) {
|
||||
gutil_ptrv_free((void**)self->cells);
|
||||
self->info.cells = (struct ofono_cell **)
|
||||
g_ptr_array_free(l, FALSE);
|
||||
g_signal_emit(self, ril_cell_info_signals
|
||||
[SIGNAL_CELLS_CHANGED], 0);
|
||||
} else {
|
||||
g_slist_free_full(l, ril_cell_free1);
|
||||
} else if (l) {
|
||||
g_ptr_array_set_free_func(l, g_free);
|
||||
g_ptr_array_free(l, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static struct sailfish_cell *ril_cell_info_parse_cell_gsm(GRilIoParser *rilp,
|
||||
static struct ofono_cell *ril_cell_info_parse_cell_gsm(GRilIoParser *rilp,
|
||||
guint version, gboolean registered)
|
||||
{
|
||||
struct sailfish_cell *cell = g_slice_new0(struct sailfish_cell);
|
||||
struct sailfish_cell_info_gsm *gsm = &cell->info.gsm;
|
||||
struct ofono_cell *cell = g_new0(struct ofono_cell, 1);
|
||||
struct ofono_cell_info_gsm *gsm = &cell->info.gsm;
|
||||
|
||||
/* Optional RIL_CellIdentityGsm_v12 part */
|
||||
gsm->arfcn = SAILFISH_CELL_INVALID_VALUE;
|
||||
gsm->bsic = SAILFISH_CELL_INVALID_VALUE;
|
||||
gsm->arfcn = OFONO_CELL_INVALID_VALUE;
|
||||
gsm->bsic = OFONO_CELL_INVALID_VALUE;
|
||||
/* Optional RIL_GSM_SignalStrength_v12 part */
|
||||
gsm->timingAdvance = SAILFISH_CELL_INVALID_VALUE;
|
||||
gsm->timingAdvance = OFONO_CELL_INVALID_VALUE;
|
||||
/* RIL_CellIdentityGsm */
|
||||
if (grilio_parser_get_int32(rilp, &gsm->mcc) &&
|
||||
grilio_parser_get_int32(rilp, &gsm->mnc) &&
|
||||
@@ -149,24 +158,24 @@ static struct sailfish_cell *ril_cell_info_parse_cell_gsm(GRilIoParser *rilp,
|
||||
",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->type = OFONO_CELL_TYPE_GSM;
|
||||
cell->registered = registered;
|
||||
return cell;
|
||||
}
|
||||
|
||||
ofono_error("failed to parse GSM cell info");
|
||||
ril_cell_free(cell);
|
||||
g_free(cell);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct sailfish_cell *ril_cell_info_parse_cell_wcdma(GRilIoParser *rilp,
|
||||
static struct ofono_cell *ril_cell_info_parse_cell_wcdma(GRilIoParser *rilp,
|
||||
guint version, gboolean registered)
|
||||
{
|
||||
struct sailfish_cell *cell = g_slice_new0(struct sailfish_cell);
|
||||
struct sailfish_cell_info_wcdma *wcdma = &cell->info.wcdma;
|
||||
struct ofono_cell *cell = g_new0(struct ofono_cell, 1);
|
||||
struct ofono_cell_info_wcdma *wcdma = &cell->info.wcdma;
|
||||
|
||||
/* Optional RIL_CellIdentityWcdma_v12 part */
|
||||
wcdma->uarfcn = SAILFISH_CELL_INVALID_VALUE;
|
||||
wcdma->uarfcn = OFONO_CELL_INVALID_VALUE;
|
||||
if (grilio_parser_get_int32(rilp, &wcdma->mcc) &&
|
||||
grilio_parser_get_int32(rilp, &wcdma->mnc) &&
|
||||
grilio_parser_get_int32(rilp, &wcdma->lac) &&
|
||||
@@ -186,24 +195,24 @@ static struct sailfish_cell *ril_cell_info_parse_cell_wcdma(GRilIoParser *rilp,
|
||||
",strength=%d"),
|
||||
ril_cell_info_int_format(wcdma->bitErrorRate,
|
||||
",err=%d"));
|
||||
cell->type = SAILFISH_CELL_TYPE_WCDMA;
|
||||
cell->type = OFONO_CELL_TYPE_WCDMA;
|
||||
cell->registered = registered;
|
||||
return cell;
|
||||
}
|
||||
|
||||
ofono_error("failed to parse WCDMA cell info");
|
||||
ril_cell_free(cell);
|
||||
g_free(cell);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct sailfish_cell *ril_cell_info_parse_cell_lte(GRilIoParser *rilp,
|
||||
static struct ofono_cell *ril_cell_info_parse_cell_lte(GRilIoParser *rilp,
|
||||
guint version, gboolean registered)
|
||||
{
|
||||
struct sailfish_cell *cell = g_slice_new0(struct sailfish_cell);
|
||||
struct sailfish_cell_info_lte *lte = &cell->info.lte;
|
||||
struct ofono_cell *cell = g_new0(struct ofono_cell, 1);
|
||||
struct ofono_cell_info_lte *lte = &cell->info.lte;
|
||||
|
||||
/* Optional RIL_CellIdentityLte_v12 part */
|
||||
lte->earfcn = SAILFISH_CELL_INVALID_VALUE;
|
||||
lte->earfcn = OFONO_CELL_INVALID_VALUE;
|
||||
if (grilio_parser_get_int32(rilp, <e->mcc) &&
|
||||
grilio_parser_get_int32(rilp, <e->mnc) &&
|
||||
grilio_parser_get_int32(rilp, <e->ci) &&
|
||||
@@ -230,18 +239,18 @@ static struct sailfish_cell *ril_cell_info_parse_cell_lte(GRilIoParser *rilp,
|
||||
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->type = OFONO_CELL_TYPE_LTE;
|
||||
cell->registered = registered;
|
||||
return cell;
|
||||
}
|
||||
|
||||
ofono_error("failed to parse LTE cell info");
|
||||
ril_cell_free(cell);
|
||||
g_free(cell);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean ril_cell_info_parse_cell(GRilIoParser *rilp, guint v,
|
||||
struct sailfish_cell **cell_ptr)
|
||||
struct ofono_cell **cell_ptr)
|
||||
{
|
||||
int type, reg;
|
||||
|
||||
@@ -250,7 +259,7 @@ static gboolean ril_cell_info_parse_cell(GRilIoParser *rilp, guint v,
|
||||
/* Skip timestamp */
|
||||
grilio_parser_get_int32_array(rilp, NULL, 3)) {
|
||||
int skip = 0;
|
||||
struct sailfish_cell *cell = NULL;
|
||||
struct ofono_cell *cell = NULL;
|
||||
|
||||
/* Normalize the boolean value */
|
||||
reg = (reg != FALSE);
|
||||
@@ -291,23 +300,25 @@ static gboolean ril_cell_info_parse_cell(GRilIoParser *rilp, guint v,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GSList *ril_cell_info_parse_list(guint v, const void *data, guint len)
|
||||
static GPtrArray *ril_cell_info_parse_list(guint v, const void *data, guint len)
|
||||
{
|
||||
GSList *l = NULL;
|
||||
GPtrArray *l = NULL;
|
||||
GRilIoParser rilp;
|
||||
int i, n;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
if (grilio_parser_get_int32(&rilp, &n) && n > 0) {
|
||||
struct sailfish_cell *c;
|
||||
struct ofono_cell *c;
|
||||
|
||||
l = g_ptr_array_sized_new(n + 1);
|
||||
DBG("%d cell(s):", n);
|
||||
for (i=0; i<n && ril_cell_info_parse_cell(&rilp, v, &c); i++) {
|
||||
if (c) {
|
||||
l = g_slist_insert_sorted(l, c,
|
||||
sailfish_cell_compare_func);
|
||||
g_ptr_array_add(l, c);
|
||||
}
|
||||
}
|
||||
g_ptr_array_sort(l, ril_cell_info_list_sort_cb);
|
||||
g_ptr_array_add(l, NULL);
|
||||
}
|
||||
|
||||
GASSERT(grilio_parser_at_end(&rilp));
|
||||
@@ -317,7 +328,7 @@ static GSList *ril_cell_info_parse_list(guint v, const void *data, guint len)
|
||||
static void ril_cell_info_list_changed_cb(GRilIoChannel *io, guint code,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(user_data);
|
||||
RilCellInfo *self = THIS(user_data);
|
||||
|
||||
DBG_(self, "");
|
||||
ril_cell_info_update_cells(self, ril_cell_info_parse_list
|
||||
@@ -327,7 +338,7 @@ static void ril_cell_info_list_changed_cb(GRilIoChannel *io, guint code,
|
||||
static void ril_cell_info_list_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(user_data);
|
||||
RilCellInfo *self = THIS(user_data);
|
||||
|
||||
DBG_(self, "");
|
||||
GASSERT(self->query_id);
|
||||
@@ -340,17 +351,17 @@ static void ril_cell_info_list_cb(GRilIoChannel *io, int status,
|
||||
static void ril_cell_info_set_rate_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(user_data);
|
||||
RilCellInfo *self = THIS(user_data);
|
||||
|
||||
DBG_(self, "");
|
||||
GASSERT(self->set_rate_id);
|
||||
self->set_rate_id = 0;
|
||||
}
|
||||
|
||||
static gboolean ril_cell_info_retry(GRilIoRequest* request, int ril_status,
|
||||
const void* response_data, guint response_len, void* user_data)
|
||||
static gboolean ril_cell_info_retry(GRilIoRequest *request, int ril_status,
|
||||
const void *response_data, guint response_len, void *user_data)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(user_data);
|
||||
RilCellInfo *self = THIS(user_data);
|
||||
|
||||
switch (ril_status) {
|
||||
case RIL_E_SUCCESS:
|
||||
@@ -361,7 +372,7 @@ static gboolean ril_cell_info_retry(GRilIoRequest* request, int ril_status,
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_cell_info_query(struct ril_cell_info *self)
|
||||
static void ril_cell_info_query(RilCellInfo *self)
|
||||
{
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
@@ -374,7 +385,7 @@ static void ril_cell_info_query(struct ril_cell_info *self)
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_cell_info_set_rate(struct ril_cell_info *self)
|
||||
static void ril_cell_info_set_rate(RilCellInfo *self)
|
||||
{
|
||||
GRilIoRequest *req = grilio_request_array_int32_new(1,
|
||||
(self->update_rate_ms >= 0 && self->enabled) ?
|
||||
@@ -389,7 +400,7 @@ static void ril_cell_info_set_rate(struct ril_cell_info *self)
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_cell_info_refresh(struct ril_cell_info *self)
|
||||
static void ril_cell_info_refresh(RilCellInfo *self)
|
||||
{
|
||||
/* RIL_REQUEST_GET_CELL_INFO_LIST fails without SIM card */
|
||||
if (self->enabled && self->radio->state == RADIO_STATE_ON &&
|
||||
@@ -402,7 +413,7 @@ static void ril_cell_info_refresh(struct ril_cell_info *self)
|
||||
|
||||
static void ril_cell_info_radio_state_cb(struct ril_radio *radio, void *arg)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(arg);
|
||||
RilCellInfo *self = THIS(arg);
|
||||
|
||||
DBG_(self, "%s", ril_radio_state_to_string(radio->state));
|
||||
ril_cell_info_refresh(self);
|
||||
@@ -410,7 +421,7 @@ static void ril_cell_info_radio_state_cb(struct ril_radio *radio, void *arg)
|
||||
|
||||
static void ril_cell_info_sim_status_cb(struct ril_sim_card *sim, void *arg)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(arg);
|
||||
RilCellInfo *self = THIS(arg);
|
||||
|
||||
self->sim_card_ready = ril_sim_card_ready(sim);
|
||||
DBG_(self, "%sready", self->sim_card_ready ? "" : "not ");
|
||||
@@ -420,60 +431,57 @@ static void ril_cell_info_sim_status_cb(struct ril_sim_card *sim, void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
/* sailfish_cell_info interface callbacks */
|
||||
/* ofono_cell_info interface callbacks */
|
||||
|
||||
struct ril_cell_info_closure {
|
||||
typedef struct ril_cell_info_closure {
|
||||
GCClosure cclosure;
|
||||
sailfish_cell_info_cb_t cb;
|
||||
ofono_cell_info_cb_t cb;
|
||||
void *arg;
|
||||
};
|
||||
} RilCellInfoClosure;
|
||||
|
||||
static inline struct ril_cell_info *ril_cell_info_cast
|
||||
(struct sailfish_cell_info *info)
|
||||
static inline RilCellInfo *ril_cell_info_cast(struct ofono_cell_info *info)
|
||||
{
|
||||
return G_CAST(info, struct ril_cell_info, info);
|
||||
return G_CAST(info, RilCellInfo, info);
|
||||
}
|
||||
|
||||
static void ril_cell_info_ref_proc(struct sailfish_cell_info *info)
|
||||
static void ril_cell_info_ref_proc(struct ofono_cell_info *info)
|
||||
{
|
||||
g_object_ref(ril_cell_info_cast(info));
|
||||
}
|
||||
|
||||
static void ril_cell_info_unref_proc(struct sailfish_cell_info *info)
|
||||
static void ril_cell_info_unref_proc(struct ofono_cell_info *info)
|
||||
{
|
||||
g_object_unref(ril_cell_info_cast(info));
|
||||
}
|
||||
|
||||
static void ril_cell_info_cells_changed_cb(struct ril_cell_info *self,
|
||||
struct ril_cell_info_closure *closure)
|
||||
static void ril_cell_info_cells_changed_cb(RilCellInfo *self,
|
||||
RilCellInfoClosure *closure)
|
||||
{
|
||||
closure->cb(&self->info, closure->arg);
|
||||
}
|
||||
|
||||
static gulong ril_cell_info_add_cells_changed_handler_proc
|
||||
(struct sailfish_cell_info *info,
|
||||
sailfish_cell_info_cb_t cb, void *arg)
|
||||
(struct ofono_cell_info *info, ofono_cell_info_cb_t cb, void *arg)
|
||||
{
|
||||
if (cb) {
|
||||
struct ril_cell_info_closure *closure =
|
||||
(struct ril_cell_info_closure *) g_closure_new_simple
|
||||
(sizeof(struct ril_cell_info_closure), NULL);
|
||||
GCClosure* cc = &closure->cclosure;
|
||||
RilCellInfoClosure *closure = (RilCellInfoClosure *)
|
||||
g_closure_new_simple(sizeof(RilCellInfoClosure), NULL);
|
||||
GCClosure *cc = &closure->cclosure;
|
||||
|
||||
cc->closure.data = closure;
|
||||
cc->callback = G_CALLBACK(ril_cell_info_cells_changed_cb);
|
||||
closure->cb = cb;
|
||||
closure->arg = arg;
|
||||
return g_signal_connect_closure_by_id(ril_cell_info_cast(info),
|
||||
ril_cell_info_signals[SIGNAL_CELLS_CHANGED], 0,
|
||||
&cc->closure, FALSE);
|
||||
ril_cell_info_signals[SIGNAL_CELLS_CHANGED], 0,
|
||||
&cc->closure, FALSE);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_cell_info_remove_handler_proc(struct sailfish_cell_info *info,
|
||||
gulong id)
|
||||
static void ril_cell_info_remove_handler_proc(struct ofono_cell_info *info,
|
||||
gulong id)
|
||||
{
|
||||
if (G_LIKELY(id)) {
|
||||
g_signal_handler_disconnect(ril_cell_info_cast(info), id);
|
||||
@@ -481,9 +489,9 @@ static void ril_cell_info_remove_handler_proc(struct sailfish_cell_info *info,
|
||||
}
|
||||
|
||||
static void ril_cell_info_set_update_interval_proc
|
||||
(struct sailfish_cell_info *info, int ms)
|
||||
(struct ofono_cell_info *info, int ms)
|
||||
{
|
||||
struct ril_cell_info *self = ril_cell_info_cast(info);
|
||||
RilCellInfo *self = ril_cell_info_cast(info);
|
||||
|
||||
if (self->update_rate_ms != ms) {
|
||||
self->update_rate_ms = ms;
|
||||
@@ -494,10 +502,10 @@ static void ril_cell_info_set_update_interval_proc
|
||||
}
|
||||
}
|
||||
|
||||
void ril_cell_info_set_enabled_proc(struct sailfish_cell_info *info,
|
||||
gboolean enabled)
|
||||
void ril_cell_info_set_enabled_proc(struct ofono_cell_info *info,
|
||||
gboolean enabled)
|
||||
{
|
||||
struct ril_cell_info *self = ril_cell_info_cast(info);
|
||||
RilCellInfo *self = ril_cell_info_cast(info);
|
||||
|
||||
if (self->enabled != enabled) {
|
||||
self->enabled = enabled;
|
||||
@@ -509,22 +517,12 @@ void ril_cell_info_set_enabled_proc(struct sailfish_cell_info *info,
|
||||
}
|
||||
}
|
||||
|
||||
struct sailfish_cell_info *ril_cell_info_new(GRilIoChannel *io,
|
||||
const char *log_prefix, struct ril_radio *radio,
|
||||
struct ril_sim_card *sim_card)
|
||||
struct ofono_cell_info *ril_cell_info_new(GRilIoChannel *io,
|
||||
const char *log_prefix, struct ril_radio *radio,
|
||||
struct ril_sim_card *sim_card)
|
||||
{
|
||||
static const struct sailfish_cell_info_proc ril_cell_info_proc = {
|
||||
ril_cell_info_ref_proc,
|
||||
ril_cell_info_unref_proc,
|
||||
ril_cell_info_add_cells_changed_handler_proc,
|
||||
ril_cell_info_remove_handler_proc,
|
||||
ril_cell_info_set_update_interval_proc,
|
||||
ril_cell_info_set_enabled_proc
|
||||
};
|
||||
RilCellInfo *self = g_object_new(THIS_TYPE, 0);
|
||||
|
||||
struct ril_cell_info *self = g_object_new(RIL_CELL_INFO_TYPE, 0);
|
||||
|
||||
self->info.proc = &ril_cell_info_proc;
|
||||
self->io = grilio_channel_ref(io);
|
||||
self->radio = ril_radio_ref(radio);
|
||||
self->sim_card = ril_sim_card_ref(sim_card);
|
||||
@@ -550,14 +548,25 @@ struct sailfish_cell_info *ril_cell_info_new(GRilIoChannel *io,
|
||||
return &self->info;
|
||||
}
|
||||
|
||||
static void ril_cell_info_init(struct ril_cell_info *self)
|
||||
static void ril_cell_info_init(RilCellInfo *self)
|
||||
{
|
||||
static const struct ofono_cell_info_proc ril_cell_info_proc = {
|
||||
ril_cell_info_ref_proc,
|
||||
ril_cell_info_unref_proc,
|
||||
ril_cell_info_add_cells_changed_handler_proc,
|
||||
ril_cell_info_remove_handler_proc,
|
||||
ril_cell_info_set_update_interval_proc,
|
||||
ril_cell_info_set_enabled_proc
|
||||
};
|
||||
|
||||
self->update_rate_ms = DEFAULT_UPDATE_RATE_MS;
|
||||
self->info.cells = self->cells = g_new0(struct ofono_cell*, 1);
|
||||
self->info.proc = &ril_cell_info_proc;
|
||||
}
|
||||
|
||||
static void ril_cell_info_dispose(GObject *object)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(object);
|
||||
RilCellInfo *self = THIS(object);
|
||||
|
||||
grilio_channel_remove_handlers(self->io, &self->event_id, 1);
|
||||
if (self->query_id) {
|
||||
@@ -569,23 +578,25 @@ static void ril_cell_info_dispose(GObject *object)
|
||||
FALSE);
|
||||
self->set_rate_id = 0;
|
||||
}
|
||||
ril_radio_remove_handlers(self->radio, &self->radio_state_event_id, 1);
|
||||
/* xxx_remove_handlers() zero the ids */
|
||||
ril_radio_remove_handlers(self->radio,
|
||||
&self->radio_state_event_id, 1);
|
||||
ril_sim_card_remove_handlers(self->sim_card,
|
||||
&self->sim_status_event_id, 1);
|
||||
G_OBJECT_CLASS(ril_cell_info_parent_class)->dispose(object);
|
||||
&self->sim_status_event_id, 1);
|
||||
G_OBJECT_CLASS(PARENT_CLASS)->dispose(object);
|
||||
}
|
||||
|
||||
static void ril_cell_info_finalize(GObject *object)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(object);
|
||||
RilCellInfo *self = THIS(object);
|
||||
|
||||
DBG_(self, "");
|
||||
gutil_ptrv_free((void**)self->cells);
|
||||
g_free(self->log_prefix);
|
||||
grilio_channel_unref(self->io);
|
||||
ril_radio_unref(self->radio);
|
||||
ril_sim_card_unref(self->sim_card);
|
||||
g_slist_free_full(self->info.cells, ril_cell_free1);
|
||||
G_OBJECT_CLASS(ril_cell_info_parent_class)->finalize(object);
|
||||
G_OBJECT_CLASS(PARENT_CLASS)->finalize(object);
|
||||
}
|
||||
|
||||
static void ril_cell_info_class_init(RilCellInfoClass *klass)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2019 Jolla Ltd.
|
||||
* Copyright (C) 2016-2021 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,9 +18,9 @@
|
||||
|
||||
#include "ril_types.h"
|
||||
|
||||
#include <sailfish_cell_info.h>
|
||||
#include <ofono/cell-info.h>
|
||||
|
||||
struct sailfish_cell_info *ril_cell_info_new(GRilIoChannel *io,
|
||||
struct ofono_cell_info *ril_cell_info_new(GRilIoChannel *io,
|
||||
const char *log_prefix, struct ril_radio *radio,
|
||||
struct ril_sim_card *sim_card);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
* Copyright (C) 2019-2020 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -28,234 +28,10 @@
|
||||
|
||||
/* Utilities for parsing ril_subscription.conf */
|
||||
|
||||
char *ril_config_get_string(GKeyFile *file, const char *group, const char *key)
|
||||
{
|
||||
char *val = g_key_file_get_string(file, group, key, NULL);
|
||||
|
||||
if (!val && strcmp(group, RILCONF_SETTINGS_GROUP)) {
|
||||
/* Check the common section */
|
||||
val = g_key_file_get_string(file, RILCONF_SETTINGS_GROUP, key,
|
||||
NULL);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
char **ril_config_get_strings(GKeyFile *file, const char *group,
|
||||
const char *key, char delimiter)
|
||||
{
|
||||
char *str = ril_config_get_string(file, group, key);
|
||||
|
||||
if (str) {
|
||||
char **strv, **p;
|
||||
char delimiter_str[2];
|
||||
|
||||
delimiter_str[0] = delimiter;
|
||||
delimiter_str[1] = 0;
|
||||
strv = g_strsplit(str, delimiter_str, -1);
|
||||
|
||||
/* Strip whitespaces */
|
||||
for (p = strv; *p; p++) {
|
||||
*p = g_strstrip(*p);
|
||||
}
|
||||
|
||||
g_free(str);
|
||||
return strv;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean ril_config_get_integer(GKeyFile *file, const char *group,
|
||||
const char *key, int *out_value)
|
||||
{
|
||||
GError *error = NULL;
|
||||
int value = g_key_file_get_integer(file, group, key, &error);
|
||||
|
||||
if (!error) {
|
||||
if (out_value) {
|
||||
*out_value = value;
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
g_error_free(error);
|
||||
if (strcmp(group, RILCONF_SETTINGS_GROUP)) {
|
||||
/* Check the common section */
|
||||
error = NULL;
|
||||
value = g_key_file_get_integer(file,
|
||||
RILCONF_SETTINGS_GROUP, key, &error);
|
||||
if (!error) {
|
||||
if (out_value) {
|
||||
*out_value = value;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
g_error_free(error);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean ril_config_get_boolean(GKeyFile *file, const char *group,
|
||||
const char *key, gboolean *out_value)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gboolean value = g_key_file_get_boolean(file, group, key, &error);
|
||||
|
||||
if (!error) {
|
||||
if (out_value) {
|
||||
*out_value = value;
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
g_error_free(error);
|
||||
if (strcmp(group, RILCONF_SETTINGS_GROUP)) {
|
||||
/* Check the common section */
|
||||
error = NULL;
|
||||
value = g_key_file_get_boolean(file,
|
||||
RILCONF_SETTINGS_GROUP, key, &error);
|
||||
if (!error) {
|
||||
if (out_value) {
|
||||
*out_value = value;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
g_error_free(error);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean ril_config_get_flag(GKeyFile *file, const char *group,
|
||||
const char *key, int flag, int *flags)
|
||||
{
|
||||
gboolean value;
|
||||
|
||||
if (ril_config_get_boolean(file, group, key, &value)) {
|
||||
if (value) {
|
||||
*flags |= flag;
|
||||
} else {
|
||||
*flags &= ~flag;
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean ril_config_get_enum(GKeyFile *file, const char *group,
|
||||
const char *key, int *result,
|
||||
const char *name, int value, ...)
|
||||
{
|
||||
char *str = ril_config_get_string(file, group, key);
|
||||
|
||||
if (str) {
|
||||
/*
|
||||
* Some people are thinking that # is a comment
|
||||
* anywhere on the line, not just at the beginning
|
||||
*/
|
||||
char *comment = strchr(str, '#');
|
||||
|
||||
if (comment) *comment = 0;
|
||||
g_strstrip(str);
|
||||
if (strcasecmp(str, name)) {
|
||||
va_list args;
|
||||
va_start(args, value);
|
||||
while ((name = va_arg(args, char*)) != NULL) {
|
||||
value = va_arg(args, int);
|
||||
if (!strcasecmp(str, name)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
ofono_error("Invalid %s config value (%s)", key, str);
|
||||
}
|
||||
|
||||
g_free(str);
|
||||
|
||||
if (name) {
|
||||
if (result) {
|
||||
*result = value;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean ril_config_get_mask(GKeyFile *file, const char *group,
|
||||
const char *key, int *result,
|
||||
const char *name, int value, ...)
|
||||
{
|
||||
char *str = ril_config_get_string(file, group, key);
|
||||
gboolean ok = FALSE;
|
||||
|
||||
if (result) {
|
||||
*result = 0;
|
||||
}
|
||||
|
||||
if (str) {
|
||||
/*
|
||||
* Some people are thinking that # is a comment
|
||||
* anywhere on the line, not just at the beginning
|
||||
*/
|
||||
char *comment = strchr(str, '#');
|
||||
char **values, **ptr;
|
||||
|
||||
if (comment) *comment = 0;
|
||||
values = g_strsplit(str, "+", -1);
|
||||
|
||||
for (ok = TRUE, ptr = values; *ptr && ok; ptr++) {
|
||||
const char* found_str = NULL;
|
||||
const char* s = g_strstrip(*ptr);
|
||||
|
||||
if (!strcasecmp(s, name)) {
|
||||
found_str = name;
|
||||
if (result) {
|
||||
*result |= value;
|
||||
}
|
||||
} else {
|
||||
va_list args;
|
||||
const char* known;
|
||||
|
||||
va_start(args, value);
|
||||
while ((known = va_arg(args, char*)) != NULL) {
|
||||
const int bit = va_arg(args, int);
|
||||
|
||||
if (!strcasecmp(s, known)) {
|
||||
found_str = known;
|
||||
if (result) {
|
||||
*result |= bit;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
if (!found_str) {
|
||||
ofono_error("Unknown bit '%s' in %s", s, key);
|
||||
ok = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
g_strfreev(values);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
if (!ok && result) {
|
||||
*result = 0;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
GUtilInts *ril_config_get_ints(GKeyFile *file, const char *group,
|
||||
const char *key)
|
||||
{
|
||||
char *value = ril_config_get_string(file, group, key);
|
||||
char *value = ofono_conf_get_string(file, group, key);
|
||||
|
||||
if (value) {
|
||||
GUtilIntArray *array = gutil_int_array_new();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
* Copyright (C) 2019-2020 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -19,28 +19,10 @@
|
||||
|
||||
#include "ril_types.h"
|
||||
|
||||
/* Utilities for parsing ril_subscription.conf */
|
||||
#include <ofono/conf.h>
|
||||
|
||||
#define RILCONF_SETTINGS_GROUP "Settings"
|
||||
#define RILCONF_SETTINGS_GROUP OFONO_COMMON_SETTINGS_GROUP
|
||||
|
||||
char *ril_config_get_string(GKeyFile *file, const char *group,
|
||||
const char *key);
|
||||
char **ril_config_get_strings(GKeyFile *file, const char *group,
|
||||
const char *key, char delimiter);
|
||||
gboolean ril_config_get_integer(GKeyFile *file, const char *group,
|
||||
const char *key, int *value);
|
||||
gboolean ril_config_get_boolean(GKeyFile *file, const char *group,
|
||||
const char *key, gboolean *value);
|
||||
gboolean ril_config_get_flag(GKeyFile *file, const char *group,
|
||||
const char *key, int flag, int *flags);
|
||||
gboolean ril_config_get_enum(GKeyFile *file, const char *group,
|
||||
const char *key, int *result,
|
||||
const char *name, int value, ...)
|
||||
G_GNUC_NULL_TERMINATED;
|
||||
gboolean ril_config_get_mask(GKeyFile *file, const char *group,
|
||||
const char *key, int *result,
|
||||
const char *name, int value, ...)
|
||||
G_GNUC_NULL_TERMINATED;
|
||||
GUtilInts *ril_config_get_ints(GKeyFile *file, const char *group,
|
||||
const char *key);
|
||||
char *ril_config_ints_to_string(GUtilInts *ints, char separator);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2019 Jolla Ltd.
|
||||
* Copyright (C) 2019-2021 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,8 +16,7 @@
|
||||
#include "ril_connman.h"
|
||||
|
||||
#include <ofono/log.h>
|
||||
|
||||
#include <gdbus.h>
|
||||
#include <ofono/gdbus.h>
|
||||
|
||||
#include <gutil_macros.h>
|
||||
#include <gutil_misc.h>
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
#include <grilio_parser.h>
|
||||
#include <grilio_request.h>
|
||||
|
||||
#include "common.h" /* ACCESS_TECHNOLOGY_EUTRAN */
|
||||
|
||||
/* Yes, it does sometimes take minutes in roaming */
|
||||
#define SETUP_DATA_CALL_TIMEOUT (300*1000) /* ms */
|
||||
|
||||
@@ -898,7 +896,7 @@ static void ril_data_call_setup_cb(GRilIoChannel *io, int ril_status,
|
||||
*/
|
||||
case PDP_FAIL_MULTI_CONN_TO_SAME_PDN_NOT_ALLOWED:
|
||||
if (priv->network->data.access_tech ==
|
||||
ACCESS_TECHNOLOGY_EUTRAN &&
|
||||
OFONO_ACCESS_TECHNOLOGY_EUTRAN &&
|
||||
!priv->downgraded_tech) {
|
||||
DBG("downgrading preferred technology");
|
||||
priv->downgraded_tech = TRUE;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2019 Jolla Ltd.
|
||||
* Copyright (C) 2019-2021 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_devmon.h"
|
||||
|
||||
struct ril_devmon_io *ril_devmon_start_io(struct ril_devmon *devmon,
|
||||
GRilIoChannel *channel, struct sailfish_cell_info *cell_info)
|
||||
GRilIoChannel *channel, struct ofono_cell_info *cell_info)
|
||||
{
|
||||
return devmon ? devmon->start_io(devmon, channel, cell_info) : NULL;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2019-2020 Jolla Ltd.
|
||||
* Copyright (C) 2019-2021 Jolla Ltd.
|
||||
* Copyright (C) 2020 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -17,7 +17,9 @@
|
||||
#ifndef RIL_DEVMON_H
|
||||
#define RIL_DEVMON_H
|
||||
|
||||
#include "ril_cell_info.h"
|
||||
#include "ril_types.h"
|
||||
|
||||
#include <ofono/cell-info.h>
|
||||
|
||||
/*
|
||||
* Separate instance of ril_devmon is created for each modem.
|
||||
@@ -31,7 +33,7 @@ struct ril_devmon_io {
|
||||
struct ril_devmon {
|
||||
void (*free)(struct ril_devmon *devmon);
|
||||
struct ril_devmon_io *(*start_io)(struct ril_devmon *devmon,
|
||||
GRilIoChannel *channel, struct sailfish_cell_info *cell_info);
|
||||
GRilIoChannel *channel, struct ofono_cell_info *cell_info);
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -65,7 +67,7 @@ struct ril_devmon *ril_devmon_combine(struct ril_devmon *devmon[], guint n);
|
||||
|
||||
/* Utilities (NULL tolerant) */
|
||||
struct ril_devmon_io *ril_devmon_start_io(struct ril_devmon *devmon,
|
||||
GRilIoChannel *channel, struct sailfish_cell_info *cell_info);
|
||||
GRilIoChannel *channel, struct ofono_cell_info *cell_info);
|
||||
void ril_devmon_io_free(struct ril_devmon_io *devmon_io);
|
||||
void ril_devmon_free(struct ril_devmon *devmon);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2019 Jolla Ltd.
|
||||
* Copyright (C) 2019-2021 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
|
||||
@@ -31,7 +31,7 @@ static inline DevMon *ril_devmon_auto_cast(struct ril_devmon *pub)
|
||||
}
|
||||
|
||||
static struct ril_devmon_io *ril_devmon_auto_start_io(struct ril_devmon *devmon,
|
||||
GRilIoChannel *io, struct sailfish_cell_info *cell_info)
|
||||
GRilIoChannel *io, struct ofono_cell_info *cell_info)
|
||||
{
|
||||
DevMon *self = ril_devmon_auto_cast(devmon);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2020 Jolla Ltd.
|
||||
* Copyright (C) 2020-2021 Jolla Ltd.
|
||||
* Copyright (C) 2020 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -52,7 +52,7 @@ static void ril_devmon_combine_io_free(struct ril_devmon_io *io)
|
||||
}
|
||||
|
||||
static struct ril_devmon_io *ril_devmon_combine_start_io(struct ril_devmon *dm,
|
||||
GRilIoChannel *chan, struct sailfish_cell_info *ci)
|
||||
GRilIoChannel *chan, struct ofono_cell_info *ci)
|
||||
{
|
||||
guint i;
|
||||
DevMon *self = ril_devmon_combine_cast(dm);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2019 Jolla Ltd.
|
||||
* Copyright (C) 2019-2021 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
|
||||
@@ -72,7 +72,7 @@ typedef struct ril_devmon_ds {
|
||||
typedef struct ril_devmon_ds_io {
|
||||
struct ril_devmon_io pub;
|
||||
struct ril_connman *connman;
|
||||
struct sailfish_cell_info *cell_info;
|
||||
struct ofono_cell_info *cell_info;
|
||||
MceBattery *battery;
|
||||
MceCharger *charger;
|
||||
MceDisplay *display;
|
||||
@@ -201,7 +201,7 @@ static void ril_devmon_ds_io_update_low_data(DevMonIo *self)
|
||||
|
||||
static void ril_devmon_ds_io_set_cell_info_update_interval(DevMonIo *self)
|
||||
{
|
||||
sailfish_cell_info_set_update_interval(self->cell_info,
|
||||
ofono_cell_info_set_update_interval(self->cell_info,
|
||||
(ril_devmon_ds_display_on(self->display) &&
|
||||
(ril_devmon_ds_charging(self->charger) ||
|
||||
ril_devmon_ds_battery_ok(self->battery))) ?
|
||||
@@ -257,12 +257,12 @@ static void ril_devmon_ds_io_free(struct ril_devmon_io *devmon_io)
|
||||
grilio_channel_cancel_request(self->io, self->charging_req_id, FALSE);
|
||||
grilio_channel_unref(self->io);
|
||||
|
||||
sailfish_cell_info_unref(self->cell_info);
|
||||
ofono_cell_info_unref(self->cell_info);
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
static struct ril_devmon_io *ril_devmon_ds_start_io(struct ril_devmon *devmon,
|
||||
GRilIoChannel *io, struct sailfish_cell_info *cell_info)
|
||||
GRilIoChannel *io, struct ofono_cell_info *cell_info)
|
||||
{
|
||||
DevMon *ds = ril_devmon_ds_cast(devmon);
|
||||
DevMonIo *self = g_new0(DevMonIo, 1);
|
||||
@@ -271,7 +271,7 @@ static struct ril_devmon_io *ril_devmon_ds_start_io(struct ril_devmon *devmon,
|
||||
self->low_data_supported = TRUE;
|
||||
self->charging_supported = TRUE;
|
||||
self->io = grilio_channel_ref(io);
|
||||
self->cell_info = sailfish_cell_info_ref(cell_info);
|
||||
self->cell_info = ofono_cell_info_ref(cell_info);
|
||||
|
||||
self->connman = ril_connman_ref(ds->connman);
|
||||
self->connman_event_id[CONNMAN_EVENT_VALID] =
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2019 Jolla Ltd.
|
||||
* Copyright (C) 2019-2021 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -56,7 +56,7 @@ typedef struct ril_devmon_ss {
|
||||
|
||||
typedef struct ril_devmon_ss_io {
|
||||
struct ril_devmon_io pub;
|
||||
struct sailfish_cell_info *cell_info;
|
||||
struct ofono_cell_info *cell_info;
|
||||
MceBattery *battery;
|
||||
MceCharger *charger;
|
||||
MceDisplay *display;
|
||||
@@ -131,7 +131,7 @@ static void ril_devmon_ss_io_send_screen_state(DevMonIo *self)
|
||||
|
||||
static void ril_devmon_ss_io_set_cell_info_update_interval(DevMonIo *self)
|
||||
{
|
||||
sailfish_cell_info_set_update_interval(self->cell_info,
|
||||
ofono_cell_info_set_update_interval(self->cell_info,
|
||||
(self->display_on && (ril_devmon_ss_charging(self->charger) ||
|
||||
ril_devmon_ss_battery_ok(self->battery))) ?
|
||||
self->cell_info_interval_short_ms :
|
||||
@@ -176,12 +176,12 @@ static void ril_devmon_ss_io_free(struct ril_devmon_io *devmon_io)
|
||||
grilio_channel_cancel_request(self->io, self->req_id, FALSE);
|
||||
grilio_channel_unref(self->io);
|
||||
|
||||
sailfish_cell_info_unref(self->cell_info);
|
||||
ofono_cell_info_unref(self->cell_info);
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
static struct ril_devmon_io *ril_devmon_ss_start_io(struct ril_devmon *devmon,
|
||||
GRilIoChannel *io, struct sailfish_cell_info *cell_info)
|
||||
GRilIoChannel *io, struct ofono_cell_info *cell_info)
|
||||
{
|
||||
DevMon *ss = ril_devmon_ss_cast(devmon);
|
||||
DevMonIo *self = g_new0(DevMonIo, 1);
|
||||
@@ -189,7 +189,7 @@ static struct ril_devmon_io *ril_devmon_ss_start_io(struct ril_devmon *devmon,
|
||||
self->pub.free = ril_devmon_ss_io_free;
|
||||
self->screen_state_supported = TRUE;
|
||||
self->io = grilio_channel_ref(io);
|
||||
self->cell_info = sailfish_cell_info_ref(cell_info);
|
||||
self->cell_info = ofono_cell_info_ref(cell_info);
|
||||
|
||||
self->battery = mce_battery_ref(ss->battery);
|
||||
self->battery_event_id[BATTERY_EVENT_VALID] =
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2019 Jolla Ltd.
|
||||
* Copyright (C) 2019-2021 Jolla Ltd.
|
||||
* Copyright (C) 2020 Open Mobile Platform LLC
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -61,7 +61,7 @@ typedef struct ril_devmon_ur {
|
||||
|
||||
typedef struct ril_devmon_ur_io {
|
||||
struct ril_devmon_io pub;
|
||||
struct sailfish_cell_info *cell_info;
|
||||
struct ofono_cell_info *cell_info;
|
||||
MceBattery *battery;
|
||||
MceCharger *charger;
|
||||
MceDisplay *display;
|
||||
@@ -137,7 +137,7 @@ static void ril_devmon_ur_io_set_unsol_response_filter(DevMonIo *self)
|
||||
|
||||
static void ril_devmon_ur_io_set_cell_info_update_interval(DevMonIo *self)
|
||||
{
|
||||
sailfish_cell_info_set_update_interval(self->cell_info,
|
||||
ofono_cell_info_set_update_interval(self->cell_info,
|
||||
(self->display_on && (ril_devmon_ur_charging(self->charger) ||
|
||||
ril_devmon_ur_battery_ok(self->battery))) ?
|
||||
self->cell_info_interval_short_ms :
|
||||
@@ -182,12 +182,12 @@ static void ril_devmon_ur_io_free(struct ril_devmon_io *devmon_io)
|
||||
grilio_channel_cancel_request(self->io, self->req_id, FALSE);
|
||||
grilio_channel_unref(self->io);
|
||||
|
||||
sailfish_cell_info_unref(self->cell_info);
|
||||
ofono_cell_info_unref(self->cell_info);
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
static struct ril_devmon_io *ril_devmon_ur_start_io(struct ril_devmon *devmon,
|
||||
GRilIoChannel *io, struct sailfish_cell_info *cell_info)
|
||||
GRilIoChannel *io, struct ofono_cell_info *cell_info)
|
||||
{
|
||||
DevMon *ur = ril_devmon_ur_cast(devmon);
|
||||
DevMonIo *self = g_new0(DevMonIo, 1);
|
||||
@@ -195,7 +195,7 @@ static struct ril_devmon_io *ril_devmon_ur_start_io(struct ril_devmon *devmon,
|
||||
self->pub.free = ril_devmon_ur_io_free;
|
||||
self->unsol_filter_supported = TRUE;
|
||||
self->io = grilio_channel_ref(io);
|
||||
self->cell_info = sailfish_cell_info_ref(cell_info);
|
||||
self->cell_info = ofono_cell_info_ref(cell_info);
|
||||
|
||||
self->battery = mce_battery_ref(ur->battery);
|
||||
self->battery_event_id[BATTERY_EVENT_VALID] =
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2016 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 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
|
||||
@@ -15,11 +15,12 @@
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_network.h"
|
||||
#include "ril_netreg.h"
|
||||
#include "ril_data.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "common.h"
|
||||
#include <ofono/misc.h>
|
||||
|
||||
/*
|
||||
* This module is the ofono_gprs_driver implementation for rilmodem.
|
||||
@@ -47,7 +48,7 @@ struct ril_gprs {
|
||||
GRilIoQueue *q;
|
||||
gboolean attached;
|
||||
int max_cids;
|
||||
enum network_registration_status registration_status;
|
||||
enum ofono_netreg_status registration_status;
|
||||
guint register_id;
|
||||
gulong network_event_id;
|
||||
gulong data_event_id;
|
||||
@@ -78,11 +79,11 @@ static struct ril_gprs_cbd *ril_gprs_cbd_new(struct ril_gprs *gd,
|
||||
return cbd;
|
||||
}
|
||||
|
||||
static enum network_registration_status ril_gprs_fix_registration_status(
|
||||
struct ril_gprs *gd, enum network_registration_status status)
|
||||
static enum ofono_netreg_status ril_gprs_fix_registration_status(
|
||||
struct ril_gprs *gd, enum ofono_netreg_status status)
|
||||
{
|
||||
if (!ril_data_allowed(gd->data)) {
|
||||
return NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
|
||||
return OFONO_NETREG_STATUS_NOT_REGISTERED;
|
||||
} else {
|
||||
/* TODO: need a way to make sure that SPDI information has
|
||||
* already been read from the SIM (i.e. sim_spdi_read_cb in
|
||||
@@ -94,13 +95,13 @@ static enum network_registration_status ril_gprs_fix_registration_status(
|
||||
|
||||
static void ril_gprs_data_update_registration_state(struct ril_gprs *gd)
|
||||
{
|
||||
const enum network_registration_status status =
|
||||
const enum ofono_netreg_status status =
|
||||
ril_gprs_fix_registration_status(gd, gd->network->data.status);
|
||||
|
||||
if (gd->registration_status != status) {
|
||||
ofono_info("data reg changed %d -> %d (%s), attached %d",
|
||||
gd->registration_status, status,
|
||||
registration_status_to_string(status),
|
||||
ofono_netreg_status_to_string(status),
|
||||
gd->attached);
|
||||
gd->registration_status = status;
|
||||
ofono_gprs_status_notify(gd->gprs, gd->registration_status);
|
||||
@@ -188,12 +189,10 @@ static void ril_gprs_registration_status(struct ofono_gprs *gprs,
|
||||
{
|
||||
struct ril_gprs *gd = ril_gprs_get_data(gprs);
|
||||
struct ofono_error error;
|
||||
const enum network_registration_status status = gd->attached ?
|
||||
gd->registration_status :
|
||||
NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
|
||||
const enum ofono_netreg_status status = gd->attached ?
|
||||
gd->registration_status : OFONO_NETREG_STATUS_NOT_REGISTERED;
|
||||
|
||||
|
||||
DBG("%d (%s)", status, registration_status_to_string(status));
|
||||
DBG("%d (%s)", status, ofono_netreg_status_to_string(status));
|
||||
cb(ril_error_ok(&error), status, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,18 +15,17 @@
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_network.h"
|
||||
#include "ril_netreg.h"
|
||||
#include "ril_data.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include <ofono/mtu-limit.h>
|
||||
|
||||
#include <gutil_strv.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "ofono.h"
|
||||
#include "common.h"
|
||||
#include "mtu-watch.h"
|
||||
|
||||
#define CTX_ID_NONE ((unsigned int)(-1))
|
||||
|
||||
#define MAX_MMS_MTU 1280
|
||||
@@ -44,7 +43,7 @@ struct ril_gprs_context {
|
||||
struct ril_data *data;
|
||||
guint active_ctx_cid;
|
||||
gulong calls_changed_id;
|
||||
struct mtu_watch *mtu_watch;
|
||||
struct ofono_mtu_limit *mtu_limit;
|
||||
struct ril_data_call *active_call;
|
||||
struct ril_gprs_context_call activate;
|
||||
struct ril_gprs_context_call deactivate;
|
||||
@@ -96,9 +95,9 @@ static void ril_gprs_context_free_active_call(struct ril_gprs_context *gcd)
|
||||
ril_data_remove_handler(gcd->data, gcd->calls_changed_id);
|
||||
gcd->calls_changed_id = 0;
|
||||
}
|
||||
if (gcd->mtu_watch) {
|
||||
mtu_watch_free(gcd->mtu_watch);
|
||||
gcd->mtu_watch = NULL;
|
||||
if (gcd->mtu_limit) {
|
||||
ofono_mtu_limit_free(gcd->mtu_limit);
|
||||
gcd->mtu_limit = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,11 +113,12 @@ static void ril_gprs_context_set_active_call(struct ril_gprs_context *gcd,
|
||||
* Some MMS providers have a problem with MTU
|
||||
* greater than 1280. Let's be safe.
|
||||
*/
|
||||
if (!gcd->mtu_watch) {
|
||||
gcd->mtu_watch = mtu_watch_new(MAX_MMS_MTU);
|
||||
if (!gcd->mtu_limit) {
|
||||
gcd->mtu_limit =
|
||||
ofono_mtu_limit_new(MAX_MMS_MTU);
|
||||
}
|
||||
}
|
||||
mtu_watch_set_ifname(gcd->mtu_watch, call->ifname);
|
||||
ofono_mtu_limit_set_ifname(gcd->mtu_limit, call->ifname);
|
||||
ril_data_call_grab(gcd->data, call->cid, gcd);
|
||||
} else {
|
||||
ril_gprs_context_free_active_call(gcd);
|
||||
@@ -487,14 +487,14 @@ static void ril_gprs_context_activate_primary(struct ofono_gprs_context *gc,
|
||||
{
|
||||
struct ril_gprs_context *gcd = ril_gprs_context_get_data(gc);
|
||||
struct ofono_netreg *netreg = ril_modem_ofono_netreg(gcd->modem);
|
||||
const int rs = ofono_netreg_get_status(netreg);
|
||||
const enum ofono_netreg_status rs = ofono_netreg_get_status(netreg);
|
||||
|
||||
/* Let's make sure that we aren't connecting when roaming not allowed */
|
||||
if (rs == NETWORK_REGISTRATION_STATUS_ROAMING) {
|
||||
if (rs == OFONO_NETREG_STATUS_ROAMING) {
|
||||
struct ofono_gprs *gprs = ril_modem_ofono_gprs(gcd->modem);
|
||||
if (!__ofono_gprs_get_roaming_allowed(gprs) &&
|
||||
if (!ofono_gprs_get_roaming_allowed(gprs) &&
|
||||
ril_netreg_check_if_really_roaming(netreg, rs) ==
|
||||
NETWORK_REGISTRATION_STATUS_ROAMING) {
|
||||
OFONO_NETREG_STATUS_ROAMING) {
|
||||
struct ofono_error error;
|
||||
ofono_info("Can't activate context %u (roaming)",
|
||||
ctx->cid);
|
||||
@@ -511,7 +511,7 @@ static void ril_gprs_context_activate_primary(struct ofono_gprs_context *gc,
|
||||
gcd->activate.cb = cb;
|
||||
gcd->activate.data = data;
|
||||
gcd->activate.req = ril_data_call_setup(gcd->data, ctx,
|
||||
__ofono_gprs_context_get_assigned_type(gc),
|
||||
ofono_gprs_context_get_assigned_type(gc),
|
||||
ril_gprs_context_activate_primary_cb, gcd);
|
||||
}
|
||||
|
||||
@@ -623,7 +623,7 @@ static void ril_gprs_context_remove(struct ofono_gprs_context *gc)
|
||||
ril_data_unref(gcd->data);
|
||||
ril_network_unref(gcd->network);
|
||||
ril_data_call_free(gcd->active_call);
|
||||
mtu_watch_free(gcd->mtu_watch);
|
||||
ofono_mtu_limit_free(gcd->mtu_limit);
|
||||
g_free(gcd);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,9 @@
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "ofono.h"
|
||||
|
||||
#include <ofono/message-waiting.h>
|
||||
#include <ofono/cell-info.h>
|
||||
#include <ofono/sim-auth.h>
|
||||
#include <ofono/watch.h>
|
||||
|
||||
#define ONLINE_TIMEOUT_SECS (15) /* 20 sec is hardcoded in ofono core */
|
||||
@@ -91,40 +92,26 @@ static struct ril_modem_data *ril_modem_data_from_ofono(struct ofono_modem *o)
|
||||
return md;
|
||||
}
|
||||
|
||||
static void *ril_modem_get_atom_data(struct ril_modem *modem,
|
||||
enum ofono_atom_type type)
|
||||
struct ofono_sim *ril_modem_ofono_sim(struct ril_modem *m)
|
||||
{
|
||||
if (modem && modem->ofono) {
|
||||
struct ofono_atom *atom =
|
||||
__ofono_modem_find_atom(modem->ofono, type);
|
||||
|
||||
if (atom) {
|
||||
return __ofono_atom_get_data(atom);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return (m && m->ofono) ? ofono_modem_get_sim(m->ofono) : NULL;
|
||||
}
|
||||
|
||||
struct ofono_sim *ril_modem_ofono_sim(struct ril_modem *modem)
|
||||
struct ofono_gprs *ril_modem_ofono_gprs(struct ril_modem *m)
|
||||
{
|
||||
return ril_modem_get_atom_data(modem, OFONO_ATOM_TYPE_SIM);
|
||||
return (m && m->ofono) ? ofono_modem_get_gprs(m->ofono) : NULL;
|
||||
}
|
||||
|
||||
struct ofono_gprs *ril_modem_ofono_gprs(struct ril_modem *modem)
|
||||
struct ofono_netreg *ril_modem_ofono_netreg(struct ril_modem *m)
|
||||
{
|
||||
return ril_modem_get_atom_data(modem, OFONO_ATOM_TYPE_GPRS);
|
||||
}
|
||||
|
||||
struct ofono_netreg *ril_modem_ofono_netreg(struct ril_modem *modem)
|
||||
{
|
||||
return ril_modem_get_atom_data(modem, OFONO_ATOM_TYPE_NETREG);
|
||||
return (m && m->ofono) ? ofono_modem_get_netreg(m->ofono) : NULL;
|
||||
}
|
||||
|
||||
static inline struct ofono_radio_settings *ril_modem_radio_settings(
|
||||
struct ril_modem *modem)
|
||||
{
|
||||
return ril_modem_get_atom_data(modem, OFONO_ATOM_TYPE_RADIO_SETTINGS);
|
||||
return (modem && modem->ofono) ?
|
||||
ofono_modem_get_radio_settings(modem->ofono) : NULL;
|
||||
}
|
||||
|
||||
void ril_modem_delete(struct ril_modem *md)
|
||||
@@ -447,7 +434,7 @@ static void ril_modem_remove(struct ofono_modem *ofono)
|
||||
ril_network_unref(modem->network);
|
||||
ril_sim_card_unref(modem->sim_card);
|
||||
ril_data_unref(modem->data);
|
||||
sailfish_cell_info_unref(modem->cell_info);
|
||||
ofono_cell_info_unref(modem->cell_info);
|
||||
grilio_channel_unref(modem->io);
|
||||
grilio_queue_cancel_all(md->q, FALSE);
|
||||
grilio_queue_unref(md->q);
|
||||
@@ -466,7 +453,7 @@ struct ril_modem *ril_modem_create(GRilIoChannel *io, const char *log_prefix,
|
||||
struct ril_radio *radio, struct ril_network *network,
|
||||
struct ril_sim_card *card, struct ril_data *data,
|
||||
struct ril_sim_settings *settings, struct ril_vendor *vendor,
|
||||
struct sailfish_cell_info *cell_info)
|
||||
struct ofono_cell_info *cell_info)
|
||||
{
|
||||
/* Skip the slash from the path, it looks like "/ril_0" */
|
||||
struct ofono_modem *ofono = ofono_modem_create(path + 1,
|
||||
@@ -497,7 +484,7 @@ struct ril_modem *ril_modem_create(GRilIoChannel *io, const char *log_prefix,
|
||||
modem->network = ril_network_ref(network);
|
||||
modem->sim_card = ril_sim_card_ref(card);
|
||||
modem->sim_settings = ril_sim_settings_ref(settings);
|
||||
modem->cell_info = sailfish_cell_info_ref(cell_info);
|
||||
modem->cell_info = ofono_cell_info_ref(cell_info);
|
||||
modem->data = ril_data_ref(data);
|
||||
modem->io = grilio_channel_ref(io);
|
||||
md->q = grilio_queue_new(io);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2018 Jolla Ltd.
|
||||
* Copyright (C) 2016-2021 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,13 +17,12 @@
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include <sailfish_cell_info.h>
|
||||
|
||||
#include "ofono.h"
|
||||
#include <ofono/sim-mnclength.h>
|
||||
#include <ofono/cell-info.h>
|
||||
|
||||
struct ril_netmon {
|
||||
struct ofono_netmon *netmon;
|
||||
struct sailfish_cell_info *cell_info;
|
||||
struct ofono_cell_info *cell_info;
|
||||
guint register_id;
|
||||
};
|
||||
|
||||
@@ -48,7 +47,9 @@ static void ril_netmon_format_mccmnc(char *s_mcc, char *s_mnc, int mcc, int mnc)
|
||||
if (mcc >= 0 && mcc <= 999) {
|
||||
snprintf(s_mcc, OFONO_MAX_MCC_LENGTH + 1, "%03d", mcc);
|
||||
if (mnc >= 0 && mnc <= 999) {
|
||||
const unsigned int mnclen = mnclength(mcc, mnc);
|
||||
const int mnclen =
|
||||
ofono_sim_mnclength_get_mnclength_mccmnc(mcc,
|
||||
mnc);
|
||||
const char *format[] = { "%d", "%02d", "%03d" };
|
||||
const char *fmt = (mnclen > 0 &&
|
||||
mnclen <= G_N_ELEMENTS(format)) ?
|
||||
@@ -69,7 +70,7 @@ static void ril_netmon_notify_ofono(struct ofono_netmon *netmon,
|
||||
/* Better not to push uninitialized data to the stack ... */
|
||||
for (i = nparams; i < RIL_NETMON_MAX_OFONO_PARAMS; i++) {
|
||||
params[i].type = OFONO_NETMON_INFO_INVALID;
|
||||
params[i].value = SAILFISH_CELL_INVALID_VALUE;
|
||||
params[i].value = OFONO_CELL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
ril_netmon_format_mccmnc(s_mcc, s_mnc, mcc, mnc);
|
||||
@@ -88,36 +89,36 @@ static void ril_netmon_notify_ofono(struct ofono_netmon *netmon,
|
||||
}
|
||||
|
||||
static void ril_netmon_notify_gsm(struct ofono_netmon *netmon,
|
||||
const struct sailfish_cell_info_gsm *gsm)
|
||||
const struct ofono_cell_info_gsm *gsm)
|
||||
{
|
||||
struct ril_netmon_ofono_param params[RIL_NETMON_MAX_OFONO_PARAMS];
|
||||
int n = 0;
|
||||
|
||||
if (gsm->lac != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (gsm->lac != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_LAC;
|
||||
params[n].value = gsm->lac;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (gsm->cid != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (gsm->cid != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_CI;
|
||||
params[n].value = gsm->cid;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (gsm->arfcn != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (gsm->arfcn != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_ARFCN;
|
||||
params[n].value = gsm->arfcn;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (gsm->signalStrength != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (gsm->signalStrength != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_RSSI;
|
||||
params[n].value = gsm->signalStrength;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (gsm->bitErrorRate != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (gsm->bitErrorRate != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_BER;
|
||||
params[n].value = gsm->bitErrorRate;
|
||||
n++;
|
||||
@@ -128,42 +129,42 @@ static void ril_netmon_notify_gsm(struct ofono_netmon *netmon,
|
||||
}
|
||||
|
||||
static void ril_netmon_notify_wcdma(struct ofono_netmon *netmon,
|
||||
const struct sailfish_cell_info_wcdma *wcdma)
|
||||
const struct ofono_cell_info_wcdma *wcdma)
|
||||
{
|
||||
struct ril_netmon_ofono_param params[RIL_NETMON_MAX_OFONO_PARAMS];
|
||||
int n = 0;
|
||||
|
||||
if (wcdma->lac != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (wcdma->lac != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_LAC;
|
||||
params[n].value = wcdma->lac;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (wcdma->cid != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (wcdma->cid != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_CI;
|
||||
params[n].value = wcdma->cid;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (wcdma->psc != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (wcdma->psc != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_PSC;
|
||||
params[n].value = wcdma->psc;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (wcdma->uarfcn != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (wcdma->uarfcn != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_ARFCN;
|
||||
params[n].value = wcdma->uarfcn;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (wcdma->signalStrength != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (wcdma->signalStrength != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_RSSI;
|
||||
params[n].value = wcdma->signalStrength;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (wcdma->bitErrorRate != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (wcdma->bitErrorRate != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_BER;
|
||||
params[n].value = wcdma->bitErrorRate;
|
||||
n++;
|
||||
@@ -174,48 +175,48 @@ static void ril_netmon_notify_wcdma(struct ofono_netmon *netmon,
|
||||
}
|
||||
|
||||
static void ril_netmon_notify_lte(struct ofono_netmon *netmon,
|
||||
const struct sailfish_cell_info_lte *lte)
|
||||
const struct ofono_cell_info_lte *lte)
|
||||
{
|
||||
struct ril_netmon_ofono_param params[RIL_NETMON_MAX_OFONO_PARAMS];
|
||||
int n = 0;
|
||||
|
||||
if (lte->ci != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (lte->ci != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_CI;
|
||||
params[n].value = lte->ci;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (lte->earfcn != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (lte->earfcn != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_EARFCN;
|
||||
params[n].value = lte->earfcn;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (lte->signalStrength != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (lte->signalStrength != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_RSSI;
|
||||
params[n].value = lte->signalStrength;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (lte->rsrp != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (lte->rsrp != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_RSRQ;
|
||||
params[n].value = lte->rsrp;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (lte->rsrq != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (lte->rsrq != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_RSRP;
|
||||
params[n].value = lte->rsrq;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (lte->cqi != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (lte->cqi != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_CQI;
|
||||
params[n].value = lte->cqi;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (lte->timingAdvance != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (lte->timingAdvance != OFONO_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_TIMING_ADVANCE;
|
||||
params[n].value = lte->timingAdvance;
|
||||
n++;
|
||||
@@ -229,28 +230,32 @@ static void ril_netmon_request_update(struct ofono_netmon *netmon,
|
||||
ofono_netmon_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_netmon *nm = ril_netmon_get_data(netmon);
|
||||
const ofono_cell_ptr *cells = nm->cell_info->cells;
|
||||
struct ofono_error error;
|
||||
GSList *l;
|
||||
|
||||
for (l = nm->cell_info->cells; l; l = l->next) {
|
||||
const struct sailfish_cell *cell = l->data;
|
||||
if (cells) {
|
||||
const ofono_cell_ptr *ptr;
|
||||
|
||||
if (cell->registered) {
|
||||
switch (cell->type) {
|
||||
case SAILFISH_CELL_TYPE_GSM:
|
||||
ril_netmon_notify_gsm(netmon,
|
||||
&cell->info.gsm);
|
||||
break;
|
||||
case SAILFISH_CELL_TYPE_WCDMA:
|
||||
ril_netmon_notify_wcdma(netmon,
|
||||
&cell->info.wcdma);
|
||||
break;
|
||||
case SAILFISH_CELL_TYPE_LTE:
|
||||
ril_netmon_notify_lte(netmon,
|
||||
&cell->info.lte);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
for (ptr = cells; *ptr; ptr++) {
|
||||
const struct ofono_cell *cell = *ptr;
|
||||
|
||||
if (cell->registered) {
|
||||
switch (cell->type) {
|
||||
case OFONO_CELL_TYPE_GSM:
|
||||
ril_netmon_notify_gsm(netmon,
|
||||
&cell->info.gsm);
|
||||
break;
|
||||
case OFONO_CELL_TYPE_WCDMA:
|
||||
ril_netmon_notify_wcdma(netmon,
|
||||
&cell->info.wcdma);
|
||||
break;
|
||||
case OFONO_CELL_TYPE_LTE:
|
||||
ril_netmon_notify_lte(netmon,
|
||||
&cell->info.lte);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -278,7 +283,7 @@ static int ril_netmon_probe(struct ofono_netmon *netmon, unsigned int vendor,
|
||||
if (modem->cell_info) {
|
||||
struct ril_netmon *nm = g_slice_new0(struct ril_netmon);
|
||||
|
||||
nm->cell_info = sailfish_cell_info_ref(modem->cell_info);
|
||||
nm->cell_info = ofono_cell_info_ref(modem->cell_info);
|
||||
nm->netmon = netmon;
|
||||
|
||||
ofono_netmon_set_data(netmon, nm);
|
||||
@@ -304,7 +309,7 @@ static void ril_netmon_remove(struct ofono_netmon *netmon)
|
||||
g_source_remove(nm->register_id);
|
||||
}
|
||||
|
||||
sailfish_cell_info_unref(nm->cell_info);
|
||||
ofono_cell_info_unref(nm->cell_info);
|
||||
g_slice_free(struct ril_netmon, nm);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
* Copyright (C) 2019-2020 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -16,15 +16,13 @@
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_network.h"
|
||||
#include "ril_netreg.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_vendor.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "ofono.h"
|
||||
#include "common.h"
|
||||
#include "simutil.h"
|
||||
|
||||
#include <ofono/watch.h>
|
||||
#include <ofono/gprs-provision.h>
|
||||
|
||||
#define REGISTRATION_MAX_RETRIES (2)
|
||||
|
||||
@@ -93,20 +91,17 @@ static struct ril_netreg_cbd *ril_netreg_cbd_new(struct ril_netreg *nd,
|
||||
return cbd;
|
||||
}
|
||||
|
||||
int ril_netreg_check_if_really_roaming(struct ofono_netreg *netreg,
|
||||
gint status)
|
||||
enum ofono_netreg_status ril_netreg_check_if_really_roaming
|
||||
(struct ofono_netreg *netreg, enum ofono_netreg_status status)
|
||||
{
|
||||
if (status == NETWORK_REGISTRATION_STATUS_ROAMING) {
|
||||
if (status == OFONO_NETREG_STATUS_ROAMING) {
|
||||
/* These functions tolerate NULL argument */
|
||||
const char *net_mcc = ofono_netreg_get_mcc(netreg);
|
||||
const char *net_mnc = ofono_netreg_get_mnc(netreg);
|
||||
struct sim_spdi *spdi = ofono_netreg_get_spdi(netreg);
|
||||
|
||||
if (spdi && net_mcc && net_mnc) {
|
||||
if (sim_spdi_lookup(spdi, net_mcc, net_mnc)) {
|
||||
ofono_info("not roaming based on spdi");
|
||||
return NETWORK_REGISTRATION_STATUS_REGISTERED;
|
||||
}
|
||||
if (ofono_netreg_spdi_lookup(netreg, net_mcc, net_mnc)) {
|
||||
ofono_info("not roaming based on spdi");
|
||||
return OFONO_NETREG_STATUS_REGISTERED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +197,7 @@ static gboolean ril_netreg_strange(const struct ofono_network_operator *op,
|
||||
{
|
||||
gsize mcclen;
|
||||
|
||||
if (sim && op->status != OPERATOR_STATUS_CURRENT) {
|
||||
if (sim && op->status != OFONO_OPERATOR_STATUS_CURRENT) {
|
||||
const char *spn = ofono_sim_get_spn(sim);
|
||||
const char *mcc = ofono_sim_get_mcc(sim);
|
||||
const char *mnc = ofono_sim_get_mnc(sim);
|
||||
@@ -243,7 +238,7 @@ static void ril_netreg_process_operators(struct ril_netreg *nd,
|
||||
int np = 0;
|
||||
|
||||
if (ril_netreg_strange(op, nd->watch->sim) &&
|
||||
__ofono_gprs_provision_get_settings(op->mcc,
|
||||
ofono_gprs_provision_get_settings(op->mcc,
|
||||
op->mnc, NULL, &prov, &np)) {
|
||||
/* Use the first entry */
|
||||
if (np > 0 && prov->provider_name &&
|
||||
@@ -253,7 +248,7 @@ static void ril_netreg_process_operators(struct ril_netreg *nd,
|
||||
strncpy(op->name, prov->provider_name,
|
||||
OFONO_MAX_OPERATOR_NAME_LENGTH);
|
||||
}
|
||||
__ofono_gprs_provision_free_settings(prov, np);
|
||||
ofono_gprs_provision_free_settings(prov, np);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,16 +301,15 @@ static void ril_netreg_list_operators_cb(GRilIoChannel *io, int status,
|
||||
}
|
||||
|
||||
/* Set the proper status */
|
||||
if (!status) {
|
||||
op->status = OPERATOR_STATUS_UNKNOWN;
|
||||
} else if (!strcmp(status, "available")) {
|
||||
op->status = OPERATOR_STATUS_AVAILABLE;
|
||||
} else if (!strcmp(status, "current")) {
|
||||
op->status = OPERATOR_STATUS_CURRENT;
|
||||
} else if (!strcmp(status, "forbidden")) {
|
||||
op->status = OPERATOR_STATUS_FORBIDDEN;
|
||||
} else {
|
||||
op->status = OPERATOR_STATUS_UNKNOWN;
|
||||
op->status = OFONO_OPERATOR_STATUS_UNKNOWN;
|
||||
if (status) {
|
||||
if (!strcmp(status, "available")) {
|
||||
op->status = OFONO_OPERATOR_STATUS_AVAILABLE;
|
||||
} else if (!strcmp(status, "current")) {
|
||||
op->status = OFONO_OPERATOR_STATUS_CURRENT;
|
||||
} else if (!strcmp(status, "forbidden")) {
|
||||
op->status = OFONO_OPERATOR_STATUS_FORBIDDEN;
|
||||
}
|
||||
}
|
||||
|
||||
op->tech = -1;
|
||||
|
||||
34
ofono/drivers/ril/ril_netreg.h
Normal file
34
ofono/drivers/ril/ril_netreg.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2021 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RIL_NETREG_H
|
||||
#define RIL_NETREG_H
|
||||
|
||||
#include "ril_types.h"
|
||||
|
||||
#include <ofono/netreg.h>
|
||||
|
||||
enum ofono_netreg_status ril_netreg_check_if_really_roaming
|
||||
(struct ofono_netreg *reg, enum ofono_netreg_status status);
|
||||
|
||||
#endif /* RIL_NETREG_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -34,11 +34,9 @@
|
||||
|
||||
#include <ofono/netreg.h>
|
||||
#include <ofono/watch.h>
|
||||
#include <ofono/misc.h>
|
||||
#include <ofono/gprs.h>
|
||||
|
||||
#include "ofono.h"
|
||||
#include "common.h"
|
||||
|
||||
#define SET_PREF_MODE_HOLDOFF_SEC RIL_RETRY_SECS
|
||||
|
||||
typedef GObjectClass RilNetworkClass;
|
||||
@@ -188,7 +186,7 @@ static void ril_network_stop_timer(struct ril_network *self,
|
||||
static void ril_network_reset_state(struct ril_registration_state *reg)
|
||||
{
|
||||
memset(reg, 0, sizeof(*reg));
|
||||
reg->status = NETWORK_REGISTRATION_STATUS_UNKNOWN;
|
||||
reg->status = OFONO_NETREG_STATUS_NONE;
|
||||
reg->access_tech = -1;
|
||||
reg->ril_tech = -1;
|
||||
reg->lac = -1;
|
||||
@@ -274,10 +272,10 @@ static gboolean ril_network_parse_response(struct ril_network *self,
|
||||
reg->access_tech = ril_parse_tech(stech, ®->ril_tech);
|
||||
|
||||
DBG_(self, "%s,%s,%s,%d,%s,%s,%s",
|
||||
registration_status_to_string(reg->status),
|
||||
slac, sci, reg->ril_tech,
|
||||
registration_tech_to_string(reg->access_tech),
|
||||
sreason, smax);
|
||||
ofono_netreg_status_to_string(reg->status),
|
||||
slac, sci, reg->ril_tech,
|
||||
ofono_access_technology_to_string(reg->access_tech),
|
||||
sreason, smax);
|
||||
|
||||
g_free(sstatus);
|
||||
g_free(slac);
|
||||
@@ -343,7 +341,7 @@ static void ril_network_poll_operator_cb(GRilIoChannel *io, int req_status,
|
||||
op.tech = -1;
|
||||
if (ril_parse_mcc_mnc(numeric, &op)) {
|
||||
if (op.tech < 0) op.tech = self->voice.access_tech;
|
||||
op.status = OPERATOR_STATUS_CURRENT;
|
||||
op.status = OFONO_OPERATOR_STATUS_CURRENT;
|
||||
op.name[0] = 0;
|
||||
if (lalpha) {
|
||||
strncpy(op.name, lalpha, sizeof(op.name));
|
||||
@@ -372,7 +370,8 @@ static void ril_network_poll_operator_cb(GRilIoChannel *io, int req_status,
|
||||
"%s, mcc=%s, mnc=%s, %s",
|
||||
lalpha, salpha, numeric,
|
||||
op.name, op.mcc, op.mnc,
|
||||
registration_tech_to_string(op.tech));
|
||||
ofono_access_technology_to_string
|
||||
(op.tech));
|
||||
} else {
|
||||
DBG_(self, "no operator");
|
||||
}
|
||||
@@ -539,8 +538,8 @@ enum ofono_radio_access_mode ril_network_max_supported_mode
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
const struct ril_radio_caps *caps = priv->caps;
|
||||
|
||||
return caps ? __ofono_radio_access_max_mode(caps->supported_modes) :
|
||||
__ofono_radio_access_max_mode(settings->techs);
|
||||
return caps ? ofono_radio_access_max_mode(caps->supported_modes) :
|
||||
ofono_radio_access_max_mode(settings->techs);
|
||||
}
|
||||
|
||||
static enum ofono_radio_access_mode ril_network_actual_pref_mode
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
* Copyright (C) 2020 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -19,14 +19,16 @@
|
||||
|
||||
#include "ril_types.h"
|
||||
|
||||
#include <ofono/netreg.h>
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
struct ofono_network_operator;
|
||||
struct ril_radio_caps;
|
||||
|
||||
struct ril_registration_state {
|
||||
int status; /* enum network_registration_status */
|
||||
int access_tech; /* enum access_technology or -1 if none */
|
||||
enum ofono_netreg_status status;
|
||||
enum ofono_access_technology access_tech;
|
||||
int ril_tech;
|
||||
int max_calls;
|
||||
int lac;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
* Copyright (C) 2020 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -18,8 +18,9 @@
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "gdbus.h"
|
||||
#include "ofono.h"
|
||||
#include <ofono/gdbus.h>
|
||||
#include <ofono/dbus.h>
|
||||
#include <ofono/dbus-access.h>
|
||||
|
||||
#define RIL_OEM_RAW_INTERFACE "org.ofono.OemRaw"
|
||||
#define RIL_OEM_RAW_TIMEOUT (60*1000) /* 60 sec */
|
||||
@@ -56,10 +57,10 @@ static void ril_oem_raw_send_cb(GRilIoChannel *io, int ril_status,
|
||||
dbus_message_iter_close_container(&it, &array);
|
||||
} else if (ril_status == GRILIO_STATUS_TIMEOUT) {
|
||||
DBG("Timed out");
|
||||
reply = __ofono_error_timed_out(msg);
|
||||
reply = ofono_dbus_error_timed_out(msg);
|
||||
} else {
|
||||
DBG("Error %s", ril_error_to_string(ril_status));
|
||||
reply = __ofono_error_failed(msg);
|
||||
reply = ofono_dbus_error_failed(msg);
|
||||
}
|
||||
|
||||
g_dbus_send_message(ofono_dbus_get_connection(), reply);
|
||||
@@ -71,10 +72,10 @@ static DBusMessage *ril_oem_raw_send(DBusConnection *conn, DBusMessage *msg,
|
||||
DBusMessageIter it;
|
||||
struct ril_oem_raw *oem = user_data;
|
||||
|
||||
if (!__ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
if (!ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
OFONO_DBUS_ACCESS_INTF_OEMRAW,
|
||||
OFONO_DBUS_ACCESS_OEMRAW_SEND, NULL)) {
|
||||
return __ofono_error_access_denied(msg);
|
||||
return ofono_dbus_error_access_denied(msg);
|
||||
}
|
||||
|
||||
dbus_message_iter_init(msg, &it);
|
||||
@@ -104,7 +105,7 @@ static DBusMessage *ril_oem_raw_send(DBusConnection *conn, DBusMessage *msg,
|
||||
return NULL;
|
||||
} else {
|
||||
DBG_(oem, "Unexpected signature");
|
||||
return __ofono_error_invalid_args(msg);
|
||||
return ofono_dbus_error_invalid_args(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
* Copyright (C) ST-Ericsson SA 2010.
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2013-2016 Jolla Ltd
|
||||
* Contact: Jussi Kangas <jussi.kangas@tieto.com>
|
||||
* Copyright (C) 2013-2021 Jolla Ltd
|
||||
* Copyright (C) 2014 Canonical Ltd
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,10 +20,9 @@
|
||||
|
||||
#include "ril_plugin.h"
|
||||
|
||||
#include <ofono.h>
|
||||
|
||||
#include "simutil.h"
|
||||
#include "util.h"
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/misc.h>
|
||||
#include <ofono/log.h>
|
||||
|
||||
#define CALLBACK_WITH_FAILURE(cb, args...) \
|
||||
do { \
|
||||
@@ -44,6 +42,8 @@
|
||||
} while (0)
|
||||
|
||||
#define SIM_EFPBR_FILEID 0x4F30
|
||||
#define SIM_EFADN_FILEID 0x6F3A
|
||||
#define SIM_EFEXT1_FILEID 0x6F4A
|
||||
|
||||
#define UNUSED 0xFF
|
||||
|
||||
@@ -148,8 +148,7 @@ static gint comp_int(gconstpointer a, gconstpointer b)
|
||||
return a_val - b_val;
|
||||
}
|
||||
|
||||
static const struct pb_file_info *
|
||||
ext1_info(const GSList *pb_files)
|
||||
static const struct pb_file_info *ext1_info(const GSList *pb_files)
|
||||
{
|
||||
const GSList *l;
|
||||
for (l = pb_files; l; l = l->next) {
|
||||
@@ -170,7 +169,7 @@ static struct phonebook_entry *handle_adn(size_t len, const unsigned char *msg,
|
||||
unsigned extension_record = UNUSED;
|
||||
unsigned i, prefix;
|
||||
char *number = NULL;
|
||||
char *name = sim_string_to_utf8(msg, name_length);
|
||||
char *name = ofono_sim_string_to_utf8(msg, name_length);
|
||||
struct phonebook_entry *new_entry;
|
||||
|
||||
/* Length contains also TON & NPI */
|
||||
@@ -245,7 +244,7 @@ static struct phonebook_entry *handle_adn(size_t len, const unsigned char *msg,
|
||||
return new_entry;
|
||||
|
||||
end:
|
||||
g_free(name);
|
||||
ofono_sim_string_free(name);
|
||||
g_free(number);
|
||||
|
||||
return NULL;
|
||||
@@ -303,7 +302,7 @@ static void handle_sne(size_t len, const unsigned char *msg,
|
||||
if (rec_data->set_by_iap)
|
||||
len -= 2;
|
||||
|
||||
sne = sim_string_to_utf8(msg, len);
|
||||
sne = ofono_sim_string_to_utf8(msg, len);
|
||||
|
||||
if (sne && *sne != '\0') {
|
||||
struct phonebook_entry *entry;
|
||||
@@ -312,19 +311,17 @@ static void handle_sne(size_t len, const unsigned char *msg,
|
||||
GINT_TO_POINTER(rec_data->adn_idx));
|
||||
if (entry) {
|
||||
/* If one already exists, delete it */
|
||||
if (entry->sne)
|
||||
g_free(entry->sne);
|
||||
ofono_sim_string_free(entry->sne);
|
||||
|
||||
DBG("Adding SNE %s to %d", sne, rec_data->adn_idx);
|
||||
DBG("name %s", entry->name);
|
||||
|
||||
entry->sne = sne;
|
||||
} else {
|
||||
g_free(sne);
|
||||
sne = NULL;
|
||||
}
|
||||
} else {
|
||||
g_free(sne);
|
||||
}
|
||||
|
||||
ofono_sim_string_free(sne);
|
||||
}
|
||||
|
||||
static void handle_anr(size_t len,
|
||||
@@ -418,33 +415,31 @@ static void handle_email(size_t len, const unsigned char *msg,
|
||||
const struct record_to_read *rec_data)
|
||||
{
|
||||
char *email;
|
||||
struct phonebook_entry *entry;
|
||||
|
||||
/* There are additional fields for type 2 files */
|
||||
if (rec_data->set_by_iap)
|
||||
len -= 2;
|
||||
|
||||
email = sim_string_to_utf8(msg, len);
|
||||
if (email == NULL || *email == '\0') {
|
||||
g_free(email);
|
||||
return;
|
||||
}
|
||||
email = ofono_sim_string_to_utf8(msg, len);
|
||||
|
||||
entry = g_tree_lookup(ref->phonebook,
|
||||
if (email && *email) {
|
||||
struct phonebook_entry *entry;
|
||||
|
||||
entry = g_tree_lookup(ref->phonebook,
|
||||
GINT_TO_POINTER(rec_data->adn_idx));
|
||||
if (entry == NULL) {
|
||||
g_free(email);
|
||||
return;
|
||||
if (entry) {
|
||||
/* if one already exists, delete it */
|
||||
ofono_sim_string_free(entry->email);
|
||||
|
||||
DBG("Adding email to entry %d", rec_data->adn_idx);
|
||||
DBG("name %s", entry->name);
|
||||
|
||||
entry->email = email;
|
||||
email = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* if one already exists, delete it */
|
||||
if (entry->email)
|
||||
g_free(entry->email);
|
||||
|
||||
DBG("Adding email to entry %d", rec_data->adn_idx);
|
||||
DBG("name %s", entry->name);
|
||||
|
||||
entry->email = email;
|
||||
ofono_sim_string_free(email);
|
||||
}
|
||||
|
||||
static void handle_ext1(size_t len, const unsigned char *msg,
|
||||
@@ -571,11 +566,11 @@ static gboolean free_entry(gpointer key, gpointer value, gpointer data)
|
||||
{
|
||||
struct phonebook_entry *entry = value;
|
||||
|
||||
g_free(entry->name);
|
||||
ofono_sim_string_free(entry->name);
|
||||
ofono_sim_string_free(entry->email);
|
||||
ofono_sim_string_free(entry->sne);
|
||||
g_free(entry->number);
|
||||
g_free(entry->email);
|
||||
g_free(entry->anr);
|
||||
g_free(entry->sne);
|
||||
g_free(entry);
|
||||
|
||||
return FALSE;
|
||||
@@ -1022,7 +1017,7 @@ static int ril_phonebook_probe(struct ofono_phonebook *pb,
|
||||
if (pd == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
pd->sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem);
|
||||
pd->sim = ofono_modem_get_sim(modem);
|
||||
if (pd->sim == NULL)
|
||||
return -ENOENT;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2019 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
* Copyright (C) 2019 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -18,7 +18,6 @@
|
||||
#define RIL_PLUGIN_H
|
||||
|
||||
#include "ril_types.h"
|
||||
#include "sailfish_manager.h"
|
||||
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/call-barring.h>
|
||||
@@ -52,7 +51,7 @@ struct ril_modem {
|
||||
const char *log_prefix;
|
||||
const char *ecclist_file;
|
||||
struct ofono_modem *ofono;
|
||||
struct sailfish_cell_info *cell_info;
|
||||
struct ofono_cell_info *cell_info;
|
||||
struct ril_vendor *vendor;
|
||||
struct ril_radio *radio;
|
||||
struct ril_data *data;
|
||||
@@ -73,7 +72,7 @@ struct ril_modem *ril_modem_create(GRilIoChannel *io, const char *log_prefix,
|
||||
struct ril_radio *radio, struct ril_network *network,
|
||||
struct ril_sim_card *card, struct ril_data *data,
|
||||
struct ril_sim_settings *settings, struct ril_vendor *vendor,
|
||||
struct sailfish_cell_info *cell_info);
|
||||
struct ofono_cell_info *cell_info);
|
||||
void ril_modem_delete(struct ril_modem *modem);
|
||||
struct ofono_sim *ril_modem_ofono_sim(struct ril_modem *modem);
|
||||
struct ofono_gprs *ril_modem_ofono_gprs(struct ril_modem *modem);
|
||||
@@ -85,7 +84,6 @@ struct ofono_netreg *ril_modem_ofono_netreg(struct ril_modem *modem);
|
||||
#define ril_modem_io(modem) ((modem)->io)
|
||||
|
||||
int ril_sim_app_type(struct ofono_sim *sim);
|
||||
int ril_netreg_check_if_really_roaming(struct ofono_netreg *reg, gint status);
|
||||
|
||||
extern const struct ofono_call_barring_driver ril_call_barring_driver;
|
||||
extern const struct ofono_call_forwarding_driver ril_call_forwarding_driver;
|
||||
|
||||
@@ -18,14 +18,11 @@
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include <ofono/misc.h>
|
||||
#include <ofono/watch.h>
|
||||
|
||||
#include <gutil_misc.h>
|
||||
|
||||
#include "simutil.h"
|
||||
#include "util.h"
|
||||
#include "ofono.h"
|
||||
|
||||
#define SIM_STATE_CHANGE_TIMEOUT_SECS (5)
|
||||
#define FAC_LOCK_QUERY_TIMEOUT_SECS (10)
|
||||
#define FAC_LOCK_QUERY_RETRIES (1)
|
||||
@@ -351,7 +348,7 @@ static void ril_sim_append_path(struct ril_sim *sd, GRilIoRequest *req,
|
||||
const int fileid, const guchar *path, const guint path_len)
|
||||
{
|
||||
const enum ril_app_type app_type = ril_sim_card_app_type(sd->card);
|
||||
guchar db_path[6] = { 0x00 };
|
||||
guchar db_path[OFONO_EF_PATH_BUFFER_SIZE] = { 0x00 };
|
||||
char *hex_path = NULL;
|
||||
int len;
|
||||
|
||||
@@ -359,16 +356,16 @@ static void ril_sim_append_path(struct ril_sim *sd, GRilIoRequest *req,
|
||||
memcpy(db_path, path, path_len);
|
||||
len = path_len;
|
||||
} else if (app_type == RIL_APPTYPE_USIM) {
|
||||
len = sim_ef_db_get_path_3g(fileid, db_path);
|
||||
len = ofono_get_ef_path_3g(fileid, db_path);
|
||||
} else if (app_type == RIL_APPTYPE_SIM) {
|
||||
len = sim_ef_db_get_path_2g(fileid, db_path);
|
||||
len = ofono_get_ef_path_2g(fileid, db_path);
|
||||
} else {
|
||||
ofono_error("Unsupported app type %d", app_type);
|
||||
len = 0;
|
||||
}
|
||||
|
||||
if (len > 0) {
|
||||
hex_path = encode_hex(db_path, len, 0);
|
||||
hex_path = ril_encode_hex(db_path, len);
|
||||
grilio_request_append_utf8(req, hex_path);
|
||||
DBG_(sd, "%s", hex_path);
|
||||
g_free(hex_path);
|
||||
@@ -393,17 +390,15 @@ static struct ril_sim_io_response *ril_sim_parse_io_response(const void *data,
|
||||
|
||||
if (grilio_parser_get_int32(&rilp, &sw1) &&
|
||||
grilio_parser_get_int32(&rilp, &sw2)) {
|
||||
char *hex_data = grilio_parser_get_utf8(&rilp);
|
||||
char *hex = grilio_parser_get_utf8(&rilp);
|
||||
|
||||
DBG("sw1=0x%02X,sw2=0x%02X,%s", sw1, sw2, hex_data);
|
||||
DBG("sw1=0x%02X,sw2=0x%02X,%s", sw1, sw2, hex);
|
||||
res = g_slice_new0(struct ril_sim_io_response);
|
||||
res->sw1 = sw1;
|
||||
res->sw2 = sw2;
|
||||
if (hex_data) {
|
||||
long num_bytes = 0;
|
||||
res->data = decode_hex(hex_data, -1, &num_bytes, 0);
|
||||
res->data_len = num_bytes;
|
||||
g_free(hex_data);
|
||||
if (hex) {
|
||||
res->data = ril_decode_hex(hex, -1, &res->data_len);
|
||||
g_free(hex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,15 +504,15 @@ static void ril_sim_file_info_cb(GRilIoChannel *io, int status,
|
||||
gboolean ok = FALSE;
|
||||
guchar access[3] = { 0x00, 0x00, 0x00 };
|
||||
guchar file_status = EF_STATUS_VALID;
|
||||
int flen = 0, rlen = 0, str = 0;
|
||||
unsigned int flen = 0, rlen = 0, str = 0;
|
||||
|
||||
if (res->data_len) {
|
||||
if (res->data[0] == 0x62) {
|
||||
ok = sim_parse_3g_get_response(res->data,
|
||||
ok = ofono_parse_get_response_3g(res->data,
|
||||
res->data_len, &flen, &rlen, &str,
|
||||
access, NULL);
|
||||
} else {
|
||||
ok = sim_parse_2g_get_response(res->data,
|
||||
ok = ofono_parse_get_response_2g(res->data,
|
||||
res->data_len, &flen, &rlen, &str,
|
||||
access, &file_status);
|
||||
}
|
||||
@@ -658,7 +653,8 @@ static void ril_sim_write(struct ofono_sim *sim, guint cmd, int fileid,
|
||||
ofono_sim_write_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_sim *sd = ril_sim_get_data(sim);
|
||||
char *hex_data = encode_hex(value, length, 0);
|
||||
char *hex_data = ril_encode_hex(value, length);
|
||||
|
||||
ril_sim_request_io(sd, cmd, fileid, p1, p2, length, hex_data, path,
|
||||
path_len, ril_sim_write_cb, ril_sim_cbd_io_new(sd, cb, data));
|
||||
g_free(hex_data);
|
||||
@@ -1201,8 +1197,7 @@ static void ril_sim_pin_change_state_cb(GRilIoChannel *io, int ril_status,
|
||||
ril_status, cbd->passwd_type, retry_count);
|
||||
|
||||
if (ril_status == RIL_E_SUCCESS && retry_count == 0) {
|
||||
enum ofono_sim_password_type associated_pin =
|
||||
__ofono_sim_puk2pin(type);
|
||||
enum ofono_sim_password_type pin_type = ofono_sim_puk2pin(type);
|
||||
/*
|
||||
* If PIN/PUK request has succeeded, zero retry count
|
||||
* makes no sense, we have to assume that it's unknown.
|
||||
@@ -1210,9 +1205,9 @@ static void ril_sim_pin_change_state_cb(GRilIoChannel *io, int ril_status,
|
||||
* it can't be queried it will remain unknown.
|
||||
*/
|
||||
sd->retries[type] = -1;
|
||||
if (associated_pin != OFONO_SIM_PASSWORD_INVALID) {
|
||||
if (pin_type != OFONO_SIM_PASSWORD_INVALID) {
|
||||
/* Successful PUK requests affect PIN retry count */
|
||||
sd->retries[associated_pin] = -1;
|
||||
sd->retries[pin_type] = -1;
|
||||
}
|
||||
} else {
|
||||
sd->retries[type] = retry_count;
|
||||
@@ -1488,12 +1483,11 @@ static gboolean ril_sim_list_apps_cb(void *data)
|
||||
for (i = 0; i < n; i++) {
|
||||
const char *hex = status->apps[i].aid;
|
||||
gsize hex_len = hex ? strlen(hex) : 0;
|
||||
long aid_size;
|
||||
guint8 aid[16];
|
||||
|
||||
if (hex_len >= 2 && hex_len <= 2 * sizeof(aid) &&
|
||||
!(hex_len & 0x01) && decode_hex_own_buf(hex,
|
||||
hex_len, &aid_size, 0, aid)) {
|
||||
gutil_hex2bin(hex, hex_len, aid)) {
|
||||
const guint8 aid_size = (guint8)hex_len/2;
|
||||
guint8 buf[4];
|
||||
|
||||
/*
|
||||
@@ -1504,9 +1498,9 @@ static gboolean ril_sim_list_apps_cb(void *data)
|
||||
* Application template TLV object.
|
||||
*/
|
||||
buf[0] = APP_TEMPLATE_TAG;
|
||||
buf[1] = (guint8)(aid_size + 2);
|
||||
buf[1] = aid_size + 2;
|
||||
buf[2] = APP_ID_TAG;
|
||||
buf[3] = (guint8)(aid_size);
|
||||
buf[3] = aid_size;
|
||||
g_byte_array_append(tlv, buf, sizeof(buf));
|
||||
g_byte_array_append(tlv, aid, aid_size);
|
||||
}
|
||||
@@ -1570,7 +1564,7 @@ static void ril_sim_open_channel(struct ofono_sim *sim,
|
||||
struct ril_sim *sd = ril_sim_get_data(sim);
|
||||
struct ril_sim_cbd_io *cbd = ril_sim_cbd_io_new(sd, cb, data);
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
char *aid_hex = encode_hex(aid, len, 0);
|
||||
char *aid_hex = ril_encode_hex(aid, len);
|
||||
|
||||
DBG_(sd, "%s", aid_hex);
|
||||
grilio_request_append_utf8(req, aid_hex);
|
||||
@@ -1713,7 +1707,7 @@ static void ril_sim_logical_access(struct ofono_sim *sim, int session_id,
|
||||
|
||||
GASSERT(len >= 5);
|
||||
if (len > 5) {
|
||||
hex_data = tmp = encode_hex(pdu + 5, len - 5, 0);
|
||||
hex_data = tmp = ril_encode_hex(pdu + 5, len - 5);
|
||||
} else {
|
||||
tmp = NULL;
|
||||
hex_data = "";
|
||||
@@ -1768,7 +1762,7 @@ static void ril_sim_refresh_cb(GRilIoChannel *io, guint code,
|
||||
* so we could be more descrete here. However I have't actually
|
||||
* seen that in real life, let's just refresh everything for now.
|
||||
*/
|
||||
__ofono_sim_refresh(sd->sim, NULL, TRUE, TRUE);
|
||||
ofono_sim_refresh_full(sd->sim);
|
||||
}
|
||||
|
||||
static gboolean ril_sim_register(gpointer user)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 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,10 +17,6 @@
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "smsutil.h"
|
||||
#include "util.h"
|
||||
#include "simutil.h"
|
||||
|
||||
#define RIL_SMS_ACK_RETRY_MS 1000
|
||||
#define RIL_SMS_ACK_RETRY_COUNT 10
|
||||
|
||||
@@ -246,10 +242,10 @@ static void ril_sms_submit(struct ofono_sms *sms, const unsigned char *pdu,
|
||||
/* TPDU:
|
||||
*
|
||||
* 'pdu' is a raw hexadecimal string
|
||||
* encode_hex() turns it into an ASCII/hex UTF8 buffer
|
||||
* ril_encode_hex() turns it into an ASCII/hex buffer (subset of utf8)
|
||||
* grilio_request_append_utf8() encodes utf8 -> utf16
|
||||
*/
|
||||
tpdu = encode_hex(pdu + smsc_len, tpdu_len, 0);
|
||||
tpdu = ril_encode_hex(pdu + smsc_len, tpdu_len);
|
||||
grilio_request_append_utf8(req, tpdu);
|
||||
|
||||
DBG("%s", tpdu);
|
||||
@@ -296,7 +292,7 @@ static void ril_sms_notify(GRilIoChannel *io, guint ril_event,
|
||||
char *ril_pdu;
|
||||
int ril_pdu_len;
|
||||
unsigned int smsc_len;
|
||||
long ril_buf_len;
|
||||
guint ril_buf_len;
|
||||
guchar *ril_data;
|
||||
|
||||
ril_pdu = NULL;
|
||||
@@ -312,7 +308,7 @@ static void ril_sms_notify(GRilIoChannel *io, guint ril_event,
|
||||
ril_pdu_len = strlen(ril_pdu);
|
||||
|
||||
DBG("ril_pdu_len is %d", ril_pdu_len);
|
||||
ril_data = decode_hex(ril_pdu, ril_pdu_len, &ril_buf_len, -1);
|
||||
ril_data = ril_decode_hex(ril_pdu, ril_pdu_len, &ril_buf_len);
|
||||
if (ril_data == NULL)
|
||||
goto error;
|
||||
|
||||
@@ -325,14 +321,16 @@ static void ril_sms_notify(GRilIoChannel *io, guint ril_event,
|
||||
ofono_info("sms received, smsc_len is %d", smsc_len);
|
||||
DBG("(%s)", ril_pdu);
|
||||
|
||||
if (ril_event == RIL_UNSOL_RESPONSE_NEW_SMS) {
|
||||
/* Last parameter is 'tpdu_len' ( substract SMSC length ) */
|
||||
ofono_sms_deliver_notify(sd->sms, ril_data, ril_buf_len,
|
||||
if (ril_buf_len >= smsc_len) {
|
||||
if (ril_event == RIL_UNSOL_RESPONSE_NEW_SMS) {
|
||||
/* Last parameter is tpdu_len (substract SMSC length) */
|
||||
ofono_sms_deliver_notify(sd->sms, ril_data, ril_buf_len,
|
||||
ril_buf_len - smsc_len);
|
||||
} else {
|
||||
GASSERT(ril_event == RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT);
|
||||
ofono_sms_status_notify(sd->sms, ril_data, ril_buf_len,
|
||||
} else {
|
||||
/* RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT */
|
||||
ofono_sms_status_notify(sd->sms, ril_data, ril_buf_len,
|
||||
ril_buf_len - smsc_len);
|
||||
}
|
||||
}
|
||||
|
||||
g_free(ril_pdu);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 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,6 @@
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#ifndef UI_LANG
|
||||
# define UI_LANG "/var/lib/environment/nemo/locale.conf"
|
||||
#endif
|
||||
@@ -83,7 +81,7 @@ static void ril_stk_envelope(struct ofono_stk *stk, int length,
|
||||
{
|
||||
struct ril_stk *sd = ril_stk_get_data(stk);
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
char *hex_envelope = encode_hex(cmd, length, 0);
|
||||
char *hex_envelope = ril_encode_hex(cmd, length);
|
||||
|
||||
DBG("%s", hex_envelope);
|
||||
grilio_request_append_utf8(req, hex_envelope);
|
||||
@@ -117,7 +115,7 @@ static void ril_stk_terminal_response(struct ofono_stk *stk, int length,
|
||||
{
|
||||
struct ril_stk *sd = ril_stk_get_data(stk);
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
char *hex_tr = encode_hex(resp, length, 0);
|
||||
char *hex_tr = ril_encode_hex(resp, length);
|
||||
|
||||
DBG("rilmodem terminal response: %s", hex_tr);
|
||||
grilio_request_append_utf8(req, hex_tr);
|
||||
@@ -150,19 +148,21 @@ static void ril_stk_pcmd_notify(GRilIoChannel *io, guint code,
|
||||
struct ril_stk *sd = user_data;
|
||||
GRilIoParser rilp;
|
||||
char *pcmd;
|
||||
guchar *pdu;
|
||||
long len = 0;
|
||||
void *pdu;
|
||||
guint len;
|
||||
|
||||
GASSERT(code == RIL_UNSOL_STK_PROACTIVE_COMMAND);
|
||||
grilio_parser_init(&rilp, data, data_len);
|
||||
pcmd = grilio_parser_get_utf8(&rilp);
|
||||
DBG("pcmd: %s", pcmd);
|
||||
|
||||
pdu = decode_hex(pcmd, strlen(pcmd), &len, -1);
|
||||
pdu = ril_decode_hex(pcmd, -1, &len);
|
||||
if (pdu) {
|
||||
DBG("pcmd: %s", pcmd);
|
||||
ofono_stk_proactive_command_notify(sd->stk, len, pdu);
|
||||
g_free(pdu);
|
||||
} else {
|
||||
ofono_warn("Failed to parse STK command %s", pcmd);
|
||||
}
|
||||
g_free(pcmd);
|
||||
|
||||
ofono_stk_proactive_command_notify(sd->stk, len, pdu);
|
||||
g_free(pdu);
|
||||
}
|
||||
|
||||
static void ril_stk_event_notify(GRilIoChannel *io, guint code,
|
||||
@@ -170,20 +170,23 @@ static void ril_stk_event_notify(GRilIoChannel *io, guint code,
|
||||
{
|
||||
struct ril_stk *sd = user_data;
|
||||
GRilIoParser rilp;
|
||||
char *pcmd = NULL;
|
||||
guchar *pdu = NULL;
|
||||
long len;
|
||||
char *pcmd;
|
||||
void *pdu;
|
||||
guint len;
|
||||
|
||||
/* Proactive command has been handled by the modem. */
|
||||
GASSERT(code == RIL_UNSOL_STK_EVENT_NOTIFY);
|
||||
grilio_parser_init(&rilp, data, data_len);
|
||||
pcmd = grilio_parser_get_utf8(&rilp);
|
||||
DBG("pcmd: %s", pcmd);
|
||||
pdu = decode_hex(pcmd, strlen(pcmd), &len, -1);
|
||||
pdu = ril_decode_hex(pcmd, -1, &len);
|
||||
if (pdu) {
|
||||
DBG("pcmd: %s", pcmd);
|
||||
ofono_stk_proactive_command_handled_notify(sd->stk, len, pdu);
|
||||
g_free(pdu);
|
||||
} else {
|
||||
ofono_warn("Failed to parse STK event %s", pcmd);
|
||||
}
|
||||
g_free(pcmd);
|
||||
|
||||
ofono_stk_proactive_command_handled_notify(sd->stk, len, pdu);
|
||||
g_free(pdu);
|
||||
}
|
||||
|
||||
static void ril_stk_session_end_notify(GRilIoChannel *io, guint code,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
* Copyright (C) 2019-2020 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -83,6 +83,22 @@ struct ril_slot_config {
|
||||
int cell_info_interval_long_ms;
|
||||
};
|
||||
|
||||
/* Some values copied from ofono's internal common.h */
|
||||
|
||||
/* 27.007 Section 7.11 */
|
||||
enum bearer_class {
|
||||
BEARER_CLASS_VOICE = 1,
|
||||
BEARER_CLASS_DATA = 2,
|
||||
BEARER_CLASS_FAX = 4,
|
||||
BEARER_CLASS_DEFAULT = 7,
|
||||
BEARER_CLASS_SMS = 8,
|
||||
BEARER_CLASS_DATA_SYNC = 16,
|
||||
BEARER_CLASS_DATA_ASYNC = 32,
|
||||
BEARER_CLASS_SS_DEFAULT = 61,
|
||||
BEARER_CLASS_PACKET = 64,
|
||||
BEARER_CLASS_PAD = 128
|
||||
};
|
||||
|
||||
#endif /* RIL_TYPES_H */
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2019 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
* Copyright (C) 2019 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -18,8 +18,7 @@
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "smsutil.h"
|
||||
#include "util.h"
|
||||
#include <ofono/misc.h>
|
||||
|
||||
#define USSD_REQUEST_TIMEOUT_SEC (30)
|
||||
#define USSD_CANCEL_TIMEOUT_SEC (20)
|
||||
@@ -96,7 +95,7 @@ static void ril_ussd_request(struct ofono_ussd *ussd, int dcs,
|
||||
const unsigned char *pdu, int len, ofono_ussd_cb_t cb, void *data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
enum sms_charset charset;
|
||||
enum ofono_sms_charset charset;
|
||||
struct ril_ussd *ud = ril_ussd_get_data(ussd);
|
||||
|
||||
ofono_info("send ussd, len:%d", len);
|
||||
@@ -106,47 +105,42 @@ static void ril_ussd_request(struct ofono_ussd *ussd, int dcs,
|
||||
ud->request_id = 0;
|
||||
}
|
||||
|
||||
if (cbs_dcs_decode(dcs, NULL, NULL, &charset, NULL, NULL, NULL)) {
|
||||
if (charset == SMS_CHARSET_7BIT) {
|
||||
unsigned char unpacked_buf[182];
|
||||
long written = 0;
|
||||
if (ofono_decode_cbs_dcs_charset(dcs, &charset) &&
|
||||
charset == OFONO_SMS_CHARSET_7BIT) {
|
||||
char unpacked[182];
|
||||
unsigned int written = ofono_unpack_7bit(pdu, len,
|
||||
OFONO_UNPACK_7BIT_USSD, unpacked, sizeof(unpacked)-1);
|
||||
|
||||
unpack_7bit_own_buf(pdu, len, 0, TRUE,
|
||||
sizeof(unpacked_buf)-1, &written, 0,
|
||||
unpacked_buf);
|
||||
unpacked[written] = 0;
|
||||
if (written >= 1) {
|
||||
/*
|
||||
* When USSD was packed, additional CR
|
||||
* might have been added (according to
|
||||
* 23.038 6.1.2.3.1). So if the last
|
||||
* character is CR, it should be removed
|
||||
* here.
|
||||
*
|
||||
* Over 2 characters long USSD string must
|
||||
* end with # (checked in valid_ussd_string),
|
||||
* so it should be safe to remove extra CR.
|
||||
*/
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
int length = strlen(unpacked);
|
||||
|
||||
unpacked_buf[written] = 0;
|
||||
if (written >= 1) {
|
||||
/*
|
||||
* When USSD was packed, additional CR
|
||||
* might have been added (according to
|
||||
* 23.038 6.1.2.3.1). So if the last
|
||||
* character is CR, it should be removed
|
||||
* here.
|
||||
*
|
||||
* Over 2 characters long USSD string must
|
||||
* end with # (checked in valid_ussd_string),
|
||||
* so it should be safe to remove extra CR.
|
||||
*/
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
int length = strlen((char *)unpacked_buf);
|
||||
while (length > 2 &&
|
||||
unpacked_buf[length-1] == '\r') {
|
||||
unpacked_buf[--length] = 0;
|
||||
}
|
||||
grilio_request_append_utf8_chars(req, (char*)
|
||||
unpacked_buf, length);
|
||||
grilio_request_set_timeout(req,
|
||||
USSD_REQUEST_TIMEOUT_SEC * 1000);
|
||||
ud->request_id =
|
||||
grilio_queue_send_request_full(ud->q,
|
||||
req, RIL_REQUEST_SEND_USSD,
|
||||
ril_ussd_response,
|
||||
ril_ussd_cbd_free,
|
||||
ril_ussd_cbd_new(ud, cb, data));
|
||||
grilio_request_unref(req);
|
||||
return;
|
||||
while (length > 2 && unpacked[length-1] == '\r') {
|
||||
unpacked[--length] = 0;
|
||||
}
|
||||
grilio_request_append_utf8_chars(req, (char*)
|
||||
unpacked, length);
|
||||
grilio_request_set_timeout(req,
|
||||
USSD_REQUEST_TIMEOUT_SEC * 1000);
|
||||
ud->request_id = grilio_queue_send_request_full(ud->q,
|
||||
req, RIL_REQUEST_SEND_USSD,
|
||||
ril_ussd_response,
|
||||
ril_ussd_cbd_free,
|
||||
ril_ussd_cbd_new(ud, cb, data));
|
||||
grilio_request_unref(req);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2019 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 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,12 +20,10 @@
|
||||
|
||||
#include <gutil_misc.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <ofono/netreg.h>
|
||||
#include <ofono/misc.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "netreg.h"
|
||||
|
||||
#define RIL_PROTO_IP_STR "IP"
|
||||
#define RIL_PROTO_IPV6_STR "IPV6"
|
||||
#define RIL_PROTO_IPV4V6_STR "IPV4V6"
|
||||
@@ -381,43 +379,43 @@ enum ril_auth ril_auth_method_from_ofono(enum ofono_gprs_auth_method auth)
|
||||
return RIL_AUTH_BOTH;
|
||||
}
|
||||
|
||||
/* Returns enum access_technology or -1 on failure. */
|
||||
int ril_parse_tech(const char *stech, int *ril_tech)
|
||||
enum ofono_access_technology ril_parse_tech(const char *stech, int *ril_tech)
|
||||
{
|
||||
int access_tech = -1;
|
||||
int tech = -1;
|
||||
enum ofono_access_technology access_tech =
|
||||
OFONO_ACCESS_TECHNOLOGY_NONE;
|
||||
|
||||
if (gutil_parse_int(stech, 0, &tech)) {
|
||||
switch (tech) {
|
||||
case RADIO_TECH_GPRS:
|
||||
case RADIO_TECH_GSM:
|
||||
access_tech = ACCESS_TECHNOLOGY_GSM;
|
||||
access_tech = OFONO_ACCESS_TECHNOLOGY_GSM;
|
||||
break;
|
||||
case RADIO_TECH_EDGE:
|
||||
access_tech = ACCESS_TECHNOLOGY_GSM_EGPRS;
|
||||
access_tech = OFONO_ACCESS_TECHNOLOGY_GSM_EGPRS;
|
||||
break;
|
||||
case RADIO_TECH_UMTS:
|
||||
access_tech = ACCESS_TECHNOLOGY_UTRAN;
|
||||
access_tech = OFONO_ACCESS_TECHNOLOGY_UTRAN;
|
||||
break;
|
||||
case RADIO_TECH_HSDPA:
|
||||
access_tech = ACCESS_TECHNOLOGY_UTRAN_HSDPA;
|
||||
access_tech = OFONO_ACCESS_TECHNOLOGY_UTRAN_HSDPA;
|
||||
break;
|
||||
case RADIO_TECH_HSUPA:
|
||||
access_tech = ACCESS_TECHNOLOGY_UTRAN_HSUPA;
|
||||
access_tech = OFONO_ACCESS_TECHNOLOGY_UTRAN_HSUPA;
|
||||
break;
|
||||
case RADIO_TECH_HSPA:
|
||||
case RADIO_TECH_HSPAP:
|
||||
access_tech = ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA;
|
||||
access_tech = OFONO_ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA;
|
||||
break;
|
||||
case RADIO_TECH_LTE:
|
||||
case RADIO_TECH_LTE_CA:
|
||||
access_tech = ACCESS_TECHNOLOGY_EUTRAN;
|
||||
access_tech = OFONO_ACCESS_TECHNOLOGY_EUTRAN;
|
||||
break;
|
||||
default:
|
||||
DBG("Unknown RIL tech %s", stech);
|
||||
/* no break */
|
||||
case RADIO_TECH_IWLAN:
|
||||
case RADIO_TECH_UNKNOWN:
|
||||
tech = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -472,6 +470,39 @@ gboolean ril_parse_mcc_mnc(const char *str, struct ofono_network_operator *op)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
char* ril_encode_hex(const void *in, guint size)
|
||||
{
|
||||
char *out = g_new(char, size * 2 + 1);
|
||||
|
||||
ofono_encode_hex(in, size, out);
|
||||
return out;
|
||||
}
|
||||
|
||||
void *ril_decode_hex(const char *hex, int len, guint *out_size)
|
||||
{
|
||||
void *out = NULL;
|
||||
guint size = 0;
|
||||
|
||||
if (hex) {
|
||||
if (len < 0) {
|
||||
len = (int) strlen(hex);
|
||||
}
|
||||
if (len > 0 && !(len & 1)) {
|
||||
size = len/2;
|
||||
out = g_malloc(size);
|
||||
if (!gutil_hex2bin(hex, len, out)) {
|
||||
g_free(out);
|
||||
out = NULL;
|
||||
size = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (out_size) {
|
||||
*out_size = size;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2019 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 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
|
||||
@@ -29,7 +29,7 @@ const char *ril_radio_state_to_string(int radio_state);
|
||||
const char *ril_protocol_from_ofono(enum ofono_gprs_proto proto);
|
||||
int ril_protocol_to_ofono(const char *str);
|
||||
enum ril_auth ril_auth_method_from_ofono(enum ofono_gprs_auth_method auth);
|
||||
int ril_parse_tech(const char *stech, int *ril_tech);
|
||||
enum ofono_access_technology ril_parse_tech(const char *stech, int *ril_tech);
|
||||
gboolean ril_parse_mcc_mnc(const char *str, struct ofono_network_operator *op);
|
||||
|
||||
#define ril_error_init_ok(err) \
|
||||
@@ -43,6 +43,9 @@ gboolean ril_parse_mcc_mnc(const char *str, struct ofono_network_operator *op);
|
||||
#define ril_error_failure(err) (ril_error_init_failure(err), err)
|
||||
#define ril_error_sim(err,sw1,sw2) (ril_error_init_sim_error(err,sw1,sw2), err)
|
||||
|
||||
char *ril_encode_hex(const void *in, guint size);
|
||||
void *ril_decode_hex(const char *hex, int len, guint *out_size);
|
||||
|
||||
#endif /* RIL_UTIL_H */
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2019 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 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,13 +18,13 @@
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <gutil_ints.h>
|
||||
#include <gutil_ring.h>
|
||||
#include <gutil_idlequeue.h>
|
||||
#include <gutil_intarray.h>
|
||||
|
||||
#include <ofono/misc.h>
|
||||
|
||||
#define FLAG_NEED_CLIP 1
|
||||
|
||||
#define VOICECALL_BLOCK_TIMEOUT_MS (5*1000)
|
||||
@@ -138,7 +138,11 @@ static GSList *ril_voicecall_parse_clcc(const void *data, guint len)
|
||||
gint tmp;
|
||||
|
||||
ofono_call_init(call);
|
||||
grilio_parser_get_int32(&rilp, &call->status);
|
||||
|
||||
tmp = OFONO_CALL_STATUS_DISCONNECTED;
|
||||
grilio_parser_get_int32(&rilp, &tmp);
|
||||
call->status = tmp;
|
||||
|
||||
grilio_parser_get_uint32(&rilp, &call->id);
|
||||
grilio_parser_get_int32(&rilp, &call->phone_number.type);
|
||||
grilio_parser_get_int32(&rilp, NULL); /* isMpty */
|
||||
@@ -146,8 +150,8 @@ static GSList *ril_voicecall_parse_clcc(const void *data, guint len)
|
||||
tmp = 0;
|
||||
grilio_parser_get_int32(&rilp, &tmp);
|
||||
call->direction = (tmp ? /* isMT */
|
||||
CALL_DIRECTION_MOBILE_TERMINATED :
|
||||
CALL_DIRECTION_MOBILE_ORIGINATED);
|
||||
OFONO_CALL_DIRECTION_MOBILE_TERMINATED :
|
||||
OFONO_CALL_DIRECTION_MOBILE_ORIGINATED);
|
||||
|
||||
grilio_parser_get_int32(&rilp, NULL); /* als */
|
||||
grilio_parser_get_int32(&rilp, &call->type); /* isVoice */
|
||||
@@ -293,21 +297,21 @@ static void ril_voicecall_lastcause_cb(GRilIoChannel *io, int status,
|
||||
|
||||
case CALL_FAIL_NORMAL_UNSPECIFIED:
|
||||
call_status = ril_voicecall_status_with_id(vc, id);
|
||||
if (call_status == CALL_STATUS_ACTIVE ||
|
||||
call_status == CALL_STATUS_HELD ||
|
||||
call_status == CALL_STATUS_DIALING ||
|
||||
call_status == CALL_STATUS_ALERTING) {
|
||||
if (call_status == OFONO_CALL_STATUS_ACTIVE ||
|
||||
call_status == OFONO_CALL_STATUS_HELD ||
|
||||
call_status == OFONO_CALL_STATUS_DIALING ||
|
||||
call_status == OFONO_CALL_STATUS_ALERTING) {
|
||||
reason = OFONO_DISCONNECT_REASON_REMOTE_HANGUP;
|
||||
} else if (call_status == CALL_STATUS_INCOMING) {
|
||||
} else if (call_status == OFONO_CALL_STATUS_INCOMING) {
|
||||
reason = OFONO_DISCONNECT_REASON_LOCAL_HANGUP;
|
||||
}
|
||||
break;
|
||||
|
||||
case CALL_FAIL_ERROR_UNSPECIFIED:
|
||||
call_status = ril_voicecall_status_with_id(vc, id);
|
||||
if (call_status == CALL_STATUS_DIALING ||
|
||||
call_status == CALL_STATUS_ALERTING ||
|
||||
call_status == CALL_STATUS_INCOMING) {
|
||||
if (call_status == OFONO_CALL_STATUS_DIALING ||
|
||||
call_status == OFONO_CALL_STATUS_ALERTING ||
|
||||
call_status == OFONO_CALL_STATUS_INCOMING) {
|
||||
reason = OFONO_DISCONNECT_REASON_REMOTE_HANGUP;
|
||||
}
|
||||
break;
|
||||
@@ -420,7 +424,7 @@ static void ril_voicecall_clcc_poll_cb(GRilIoChannel *io, int status,
|
||||
* arrives, or RING is used, then signal the call
|
||||
* here
|
||||
*/
|
||||
if (nc->status == CALL_STATUS_INCOMING &&
|
||||
if (nc->status == OFONO_CALL_STATUS_INCOMING &&
|
||||
(vd->flags & FLAG_NEED_CLIP)) {
|
||||
if (nc->type) {
|
||||
ofono_voicecall_notify(vd->vc, nc);
|
||||
@@ -548,7 +552,8 @@ static void ril_voicecall_dial(struct ofono_voicecall *vc,
|
||||
void *data)
|
||||
{
|
||||
struct ril_voicecall *vd = ril_voicecall_get_data(vc);
|
||||
const char *phstr = phone_number_to_string(ph);
|
||||
char phbuf[OFONO_PHONE_NUMBER_BUFFER_SIZE];
|
||||
const char *phstr = ofono_phone_number_to_string(ph, phbuf);
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
ofono_info("dialing \"%s\"", phstr);
|
||||
@@ -631,14 +636,14 @@ static void ril_voicecall_hangup(struct ofono_voicecall *vc,
|
||||
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:
|
||||
case OFONO_CALL_STATUS_ACTIVE:
|
||||
case OFONO_CALL_STATUS_DIALING:
|
||||
case OFONO_CALL_STATUS_ALERTING:
|
||||
case OFONO_CALL_STATUS_INCOMING:
|
||||
return TRUE;
|
||||
case CALL_STATUS_HELD:
|
||||
case CALL_STATUS_WAITING:
|
||||
case CALL_STATUS_DISCONNECTED:
|
||||
case OFONO_CALL_STATUS_HELD:
|
||||
case OFONO_CALL_STATUS_WAITING:
|
||||
case OFONO_CALL_STATUS_DISCONNECTED:
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017-2019 Jolla Ltd.
|
||||
* Copyright (C) 2017-2021 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
|
||||
@@ -13,20 +13,26 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef SAILFISH_CELL_INFO_H
|
||||
#define SAILFISH_CELL_INFO_H
|
||||
#ifndef OFONO_CELL_INFO_H
|
||||
#define OFONO_CELL_INFO_H
|
||||
|
||||
#include <glib.h>
|
||||
/* This API exists since mer/1.24+git2 */
|
||||
|
||||
enum sailfish_cell_type {
|
||||
SAILFISH_CELL_TYPE_GSM,
|
||||
SAILFISH_CELL_TYPE_WCDMA,
|
||||
SAILFISH_CELL_TYPE_LTE
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ofono/types.h>
|
||||
|
||||
enum ofono_cell_type {
|
||||
OFONO_CELL_TYPE_GSM,
|
||||
OFONO_CELL_TYPE_WCDMA,
|
||||
OFONO_CELL_TYPE_LTE
|
||||
};
|
||||
|
||||
#define SAILFISH_CELL_INVALID_VALUE (INT_MAX)
|
||||
#define OFONO_CELL_INVALID_VALUE (INT_MAX)
|
||||
|
||||
struct sailfish_cell_info_gsm {
|
||||
struct ofono_cell_info_gsm {
|
||||
int mcc; /* Mobile Country Code (0..999) */
|
||||
int mnc; /* Mobile Network Code (0..999) */
|
||||
int lac; /* Location Area Code (0..65535) */
|
||||
@@ -38,7 +44,7 @@ struct sailfish_cell_info_gsm {
|
||||
int timingAdvance; /* Timing Advance. 1 period = 48/13 us */
|
||||
};
|
||||
|
||||
struct sailfish_cell_info_wcdma {
|
||||
struct ofono_cell_info_wcdma {
|
||||
int mcc; /* Mobile Country Code (0..999) */
|
||||
int mnc; /* Mobile Network Code (0..999) */
|
||||
int lac; /* Location Area Code (0..65535) */
|
||||
@@ -49,7 +55,7 @@ struct sailfish_cell_info_wcdma {
|
||||
int bitErrorRate; /* (0-7, 99) TS 27.007 */
|
||||
};
|
||||
|
||||
struct sailfish_cell_info_lte {
|
||||
struct ofono_cell_info_lte {
|
||||
int mcc; /* Mobile Country Code (0..999) */
|
||||
int mnc; /* Mobile Network Code (0..999) */
|
||||
int ci; /* Cell Identity */
|
||||
@@ -64,54 +70,50 @@ struct sailfish_cell_info_lte {
|
||||
int timingAdvance; /* (Distance = 300m/us) TS 36.321 */
|
||||
};
|
||||
|
||||
struct sailfish_cell {
|
||||
enum sailfish_cell_type type;
|
||||
gboolean registered;
|
||||
typedef struct ofono_cell {
|
||||
enum ofono_cell_type type;
|
||||
ofono_bool_t registered;
|
||||
union {
|
||||
struct sailfish_cell_info_gsm gsm;
|
||||
struct sailfish_cell_info_wcdma wcdma;
|
||||
struct sailfish_cell_info_lte lte;
|
||||
struct ofono_cell_info_gsm gsm;
|
||||
struct ofono_cell_info_wcdma wcdma;
|
||||
struct ofono_cell_info_lte lte;
|
||||
} info;
|
||||
} *ofono_cell_ptr;
|
||||
|
||||
struct ofono_cell_info {
|
||||
const struct ofono_cell_info_proc *proc;
|
||||
const ofono_cell_ptr *cells; /* NULL-terminated */
|
||||
};
|
||||
|
||||
struct sailfish_cell_info {
|
||||
const struct sailfish_cell_info_proc *proc;
|
||||
GSList *cells;
|
||||
typedef void (*ofono_cell_info_cb_t)(struct ofono_cell_info *ci, void *data);
|
||||
|
||||
struct ofono_cell_info_proc {
|
||||
void (*ref)(struct ofono_cell_info *ci);
|
||||
void (*unref)(struct ofono_cell_info *ci);
|
||||
unsigned long (*add_change_handler)(struct ofono_cell_info *ci,
|
||||
ofono_cell_info_cb_t cb, void *data);
|
||||
void (*remove_handler)(struct ofono_cell_info *ci, unsigned long id);
|
||||
void (*set_update_interval)(struct ofono_cell_info *ci, int ms);
|
||||
void (*set_enabled)(struct ofono_cell_info *ci, ofono_bool_t enabled);
|
||||
};
|
||||
|
||||
typedef void (*sailfish_cell_info_cb_t)(struct sailfish_cell_info *info,
|
||||
void *arg);
|
||||
/* Wrappers for ofono_cell_info objects */
|
||||
struct ofono_cell_info *ofono_cell_info_ref(struct ofono_cell_info *ci);
|
||||
void ofono_cell_info_unref(struct ofono_cell_info *ci);
|
||||
unsigned long ofono_cell_info_add_change_handler(struct ofono_cell_info *ci,
|
||||
ofono_cell_info_cb_t cb, void *data);
|
||||
void ofono_cell_info_remove_handler(struct ofono_cell_info *ci,
|
||||
unsigned long id);
|
||||
void ofono_cell_info_set_update_interval(struct ofono_cell_info *ci, int ms);
|
||||
void ofono_cell_info_set_enabled(struct ofono_cell_info *ci, ofono_bool_t on);
|
||||
int ofono_cell_compare_location(const struct ofono_cell *c1,
|
||||
const struct ofono_cell *c2);
|
||||
|
||||
struct sailfish_cell_info_proc {
|
||||
void (*ref)(struct sailfish_cell_info *info);
|
||||
void (*unref)(struct sailfish_cell_info *info);
|
||||
gulong (*add_cells_changed_handler)(struct sailfish_cell_info *info,
|
||||
sailfish_cell_info_cb_t cb, void *arg);
|
||||
void (*remove_handler)(struct sailfish_cell_info *info, gulong id);
|
||||
void (*set_update_interval)(struct sailfish_cell_info *info, int ms);
|
||||
void (*set_enabled)(struct sailfish_cell_info *info, gboolean enabled);
|
||||
};
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Utilities */
|
||||
gint sailfish_cell_compare_func(gconstpointer v1, gconstpointer v2);
|
||||
gint sailfish_cell_compare_location(const struct sailfish_cell *c1,
|
||||
const struct sailfish_cell *c2);
|
||||
|
||||
/* Cell info object API */
|
||||
struct sailfish_cell_info *sailfish_cell_info_ref
|
||||
(struct sailfish_cell_info *info);
|
||||
void sailfish_cell_info_unref(struct sailfish_cell_info *info);
|
||||
gulong sailfish_cell_info_add_cells_changed_handler
|
||||
(struct sailfish_cell_info *info,
|
||||
sailfish_cell_info_cb_t cb, void *arg);
|
||||
void sailfish_cell_info_remove_handler(struct sailfish_cell_info *info,
|
||||
gulong id);
|
||||
void sailfish_cell_info_set_update_interval(struct sailfish_cell_info *info,
|
||||
int ms);
|
||||
void sailfish_cell_info_set_enabled(struct sailfish_cell_info *info,
|
||||
gboolean enabled);
|
||||
|
||||
#endif /* SAILFISH_CELINFO_H */
|
||||
#endif /* OFONO_CELL_INFO_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
61
ofono/include/conf.h
Normal file
61
ofono/include/conf.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2021 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_CONF_H
|
||||
#define OFONO_CONF_H
|
||||
|
||||
/* This API exists since mer/1.24+git2 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
/* If a value isn't found in the specified group, it's looked up in this one */
|
||||
#define OFONO_COMMON_SETTINGS_GROUP "Settings"
|
||||
|
||||
/* Utilities for parsing config files */
|
||||
void ofono_conf_merge_files(GKeyFile *conf, const char *file);
|
||||
char *ofono_conf_get_string(GKeyFile *conf, const char *group,
|
||||
const char *key) G_GNUC_WARN_UNUSED_RESULT;
|
||||
char **ofono_conf_get_strings(GKeyFile *conf, const char *group,
|
||||
const char *key, char delimiter) G_GNUC_WARN_UNUSED_RESULT;
|
||||
gboolean ofono_conf_get_integer(GKeyFile *conf, const char *group,
|
||||
const char *key, int *value);
|
||||
gboolean ofono_conf_get_boolean(GKeyFile *conf, const char *group,
|
||||
const char *key, gboolean *value);
|
||||
gboolean ofono_conf_get_flag(GKeyFile *conf, const char *group,
|
||||
const char *key, int flag, int *flags);
|
||||
gboolean ofono_conf_get_enum(GKeyFile *conf, const char *group,
|
||||
const char *key, int *result, const char *name, int value, ...)
|
||||
G_GNUC_NULL_TERMINATED;
|
||||
gboolean ofono_conf_get_mask(GKeyFile *conf, const char *group,
|
||||
const char *key, int *result, const char *name, int value, ...)
|
||||
G_GNUC_NULL_TERMINATED;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* OFONO_CONF_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2019-2020 Jolla Ltd.
|
||||
* Copyright (C) 2019-2021 Jolla Ltd.
|
||||
* Copyright (C) 2020 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -158,6 +158,10 @@ 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);
|
||||
|
||||
/* Since mer/1.24+git2 */
|
||||
ofono_bool_t ofono_dbus_access_method_allowed(const char *sender,
|
||||
enum ofono_dbus_access_intf iface, int method, const char *arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -113,6 +113,31 @@ DBusMessage *ofono_dbus_signal_new_property_changed(const char *path,
|
||||
const char *interface,
|
||||
const char *name,
|
||||
int type, const void *value);
|
||||
|
||||
/* Since mer/1.24+git2 */
|
||||
DBusMessage *ofono_dbus_error_invalid_args(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_invalid_format(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_not_implemented(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_failed(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_busy(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_not_found(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_not_active(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_not_supported(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_not_available(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_timed_out(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_sim_not_ready(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_in_use(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_not_attached(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_attach_in_progress(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_not_registered(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_canceled(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_access_denied(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_emergency_active(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_incorrect_password(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_not_allowed(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_not_recognized(DBusMessage *msg);
|
||||
DBusMessage *ofono_dbus_error_network_terminated(DBusMessage *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -146,6 +146,9 @@ void ofono_gprs_context_set_ipv6_proxy_cscf(struct ofono_gprs_context *gc,
|
||||
void ofono_gprs_context_signal_change(struct ofono_gprs_context *gc,
|
||||
unsigned int cid);
|
||||
|
||||
enum ofono_gprs_context_type ofono_gprs_context_get_assigned_type(
|
||||
struct ofono_gprs_context *gc); /* Since mer/1.24+git2 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Telephony stack for Linux
|
||||
*
|
||||
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -55,6 +56,14 @@ int ofono_gprs_provision_driver_register(
|
||||
void ofono_gprs_provision_driver_unregister(
|
||||
const struct ofono_gprs_provision_driver *driver);
|
||||
|
||||
/* Since mer/1.24+git2 */
|
||||
ofono_bool_t ofono_gprs_provision_get_settings(const char *mcc,
|
||||
const char *mnc, const char *spn,
|
||||
struct ofono_gprs_provision_data **settings,
|
||||
int *count);
|
||||
void ofono_gprs_provision_free_settings(
|
||||
struct ofono_gprs_provision_data *settings,
|
||||
int count);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2017-2021 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
|
||||
@@ -87,6 +88,9 @@ 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);
|
||||
|
||||
/* Since mer/1.24+git2 */
|
||||
ofono_bool_t ofono_gprs_get_roaming_allowed(struct ofono_gprs *gprs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
67
ofono/include/misc.h
Normal file
67
ofono/include/misc.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2021 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_MISC_H
|
||||
#define __OFONO_MISC_H
|
||||
|
||||
/*
|
||||
* Miscellaneous utilities which do not fall into any other category.
|
||||
*
|
||||
* This file exists since mer/1.24+git2
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ofono/netreg.h>
|
||||
|
||||
const char *ofono_netreg_status_to_string(enum ofono_netreg_status status);
|
||||
const char *ofono_access_technology_to_string(enum ofono_access_technology t);
|
||||
|
||||
char *ofono_sim_string_to_utf8(const unsigned char *buffer, int length);
|
||||
void ofono_sim_string_free(char *str);
|
||||
|
||||
void ofono_encode_hex(const void *in, unsigned int n, char out[/* 2*n+1 */]);
|
||||
|
||||
#define OFONO_UNPACK_7BIT_USSD (0x01) /* flags */
|
||||
unsigned int ofono_unpack_7bit(const void *in, unsigned int len,
|
||||
unsigned int flags, void *out_buf, unsigned int out_buf_size);
|
||||
|
||||
#define OFONO_PHONE_NUMBER_BUFFER_SIZE (OFONO_MAX_PHONE_NUMBER_LENGTH + 2)
|
||||
const char *ofono_phone_number_to_string(const struct ofono_phone_number *ph,
|
||||
char buffer[/* OFONO_PHONE_NUMBER_BUFFER_SIZE */]);
|
||||
|
||||
#define OFONO_EF_PATH_BUFFER_SIZE 6
|
||||
unsigned int ofono_get_ef_path_2g(unsigned short id,
|
||||
unsigned char path[/* OFONO_EF_PATH_BUFFER_SIZE */]);
|
||||
unsigned int ofono_get_ef_path_3g(unsigned short id,
|
||||
unsigned char path[/* OFONO_EF_PATH_BUFFER_SIZE */]);
|
||||
ofono_bool_t ofono_parse_get_response_2g(const void *response, unsigned int len,
|
||||
unsigned int *file_len, unsigned int *record_len,
|
||||
unsigned int *structure, unsigned char *access,
|
||||
unsigned char *file_status);
|
||||
ofono_bool_t ofono_parse_get_response_3g(const void *response, unsigned int len,
|
||||
unsigned int *file_len, unsigned int *record_len,
|
||||
unsigned int *structure, unsigned char *access,
|
||||
unsigned short *efid);
|
||||
ofono_bool_t ofono_decode_cbs_dcs_charset(unsigned char dcs,
|
||||
enum ofono_sms_charset *charset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __OFONO_MISC_H */
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2015-2021 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
|
||||
@@ -86,6 +87,9 @@ 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);
|
||||
struct ofono_netreg *ofono_modem_get_netreg(struct ofono_modem *modem);
|
||||
struct ofono_radio_settings *ofono_modem_get_radio_settings
|
||||
(struct ofono_modem *modem); /* Since mer/1.24+git2 */
|
||||
|
||||
void ofono_modem_set_data(struct ofono_modem *modem, void *data);
|
||||
void *ofono_modem_get_data(struct ofono_modem *modem);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2016-2017 Jolla Ltd.
|
||||
* Copyright (C) 2016-2021 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
|
||||
@@ -13,13 +13,15 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef MTU_WATCH_H
|
||||
#define MTU_WATCH_H
|
||||
#ifndef __OFONO_MTU_LIMIT_H
|
||||
#define __OFONO_MTU_LIMIT_H
|
||||
|
||||
struct mtu_watch;
|
||||
/* This API exists since mer/1.24+git2 */
|
||||
|
||||
struct mtu_watch *mtu_watch_new(int max_mtu);
|
||||
void mtu_watch_free(struct mtu_watch *mw);
|
||||
void mtu_watch_set_ifname(struct mtu_watch *mw, const char *ifname);
|
||||
struct ofono_mtu_limit;
|
||||
|
||||
#endif /* MTU_WATCH_H */
|
||||
struct ofono_mtu_limit *ofono_mtu_limit_new(int max_mtu);
|
||||
void ofono_mtu_limit_free(struct ofono_mtu_limit *ml);
|
||||
void ofono_mtu_limit_set_ifname(struct ofono_mtu_limit *ml, const char *ifname);
|
||||
|
||||
#endif /* __OFONO_MTU_LIMIT_H */
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -28,8 +29,28 @@ extern "C" {
|
||||
|
||||
#include <ofono/types.h>
|
||||
|
||||
struct ofono_modem;
|
||||
struct ofono_netreg;
|
||||
|
||||
enum ofono_netreg_status {
|
||||
OFONO_NETREG_STATUS_NONE = -1,
|
||||
/* 27.007 Section 7.2 <stat> */
|
||||
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
|
||||
}; /* Since mer/1.24+git2 */
|
||||
|
||||
/* 27.007 Section 7.3 <stat> */
|
||||
enum ofono_operator_status {
|
||||
OFONO_OPERATOR_STATUS_UNKNOWN = 0,
|
||||
OFONO_OPERATOR_STATUS_AVAILABLE = 1,
|
||||
OFONO_OPERATOR_STATUS_CURRENT = 2,
|
||||
OFONO_OPERATOR_STATUS_FORBIDDEN = 3
|
||||
}; /* Since mer/1.24+git2 */
|
||||
|
||||
/* Theoretical limit is 16, but each GSM char can be encoded into
|
||||
* * 3 UTF8 characters resulting in 16*3=48 chars
|
||||
* */
|
||||
@@ -39,8 +60,8 @@ struct ofono_network_operator {
|
||||
char name[OFONO_MAX_OPERATOR_NAME_LENGTH + 1];
|
||||
char mcc[OFONO_MAX_MCC_LENGTH + 1];
|
||||
char mnc[OFONO_MAX_MNC_LENGTH + 1];
|
||||
int status;
|
||||
int tech;
|
||||
enum ofono_operator_status status;
|
||||
enum ofono_access_technology tech;
|
||||
};
|
||||
|
||||
typedef void (*ofono_netreg_operator_cb_t)(const struct ofono_error *error,
|
||||
@@ -110,13 +131,17 @@ void *ofono_netreg_get_data(struct ofono_netreg *netreg);
|
||||
|
||||
int ofono_netreg_get_location(struct ofono_netreg *netreg);
|
||||
int ofono_netreg_get_cellid(struct ofono_netreg *netreg);
|
||||
int ofono_netreg_get_status(struct ofono_netreg *netreg);
|
||||
enum ofono_netreg_status ofono_netreg_get_status(struct ofono_netreg *netreg);
|
||||
int ofono_netreg_get_technology(struct ofono_netreg *netreg);
|
||||
const char *ofono_netreg_get_mcc(struct ofono_netreg *netreg);
|
||||
const char *ofono_netreg_get_mnc(struct ofono_netreg *netreg);
|
||||
const char *ofono_netreg_get_name(struct ofono_netreg *netreg);
|
||||
struct sim_spdi *ofono_netreg_get_spdi(struct ofono_netreg *netreg);
|
||||
|
||||
/* Since mer/1.24+git2 */
|
||||
ofono_bool_t ofono_netreg_spdi_lookup(struct ofono_netreg *netreg,
|
||||
const char *mcc, const char *mnc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
* Copyright (C) 2015-2021 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
|
||||
@@ -139,6 +140,8 @@ struct ofono_modem *ofono_radio_settings_get_modem(
|
||||
const char *ofono_radio_access_mode_to_string(enum ofono_radio_access_mode m);
|
||||
ofono_bool_t ofono_radio_access_mode_from_string(const char *str,
|
||||
enum ofono_radio_access_mode *mode);
|
||||
enum ofono_radio_access_mode ofono_radio_access_max_mode( /* mer/1.24+git2 */
|
||||
enum ofono_radio_access_mode mask);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*
|
||||
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
* Copyright (C) 2013 Canonical Ltd.
|
||||
* Copyright (C) 2015-2021 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,17 +28,21 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
struct ofono_sim_mnclength_driver {
|
||||
const char *name;
|
||||
int (*get_mnclength)(const char *imsi);
|
||||
/* Since mer/1.24+git2 */
|
||||
int (*get_mnclength_mccmnc)(int mcc, int mnc);
|
||||
};
|
||||
|
||||
int ofono_sim_mnclength_driver_register(
|
||||
struct ofono_sim_mnclength_driver *driver);
|
||||
const struct ofono_sim_mnclength_driver *driver);
|
||||
void ofono_sim_mnclength_driver_unregister(
|
||||
const struct ofono_sim_mnclength_driver *driver);
|
||||
|
||||
/* Since mer/1.24+git2 */
|
||||
int ofono_sim_mnclength_get_mnclength(const char *imsi);
|
||||
int ofono_sim_mnclength_get_mnclength_mccmnc(int mcc, int mnc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -241,6 +241,10 @@ const unsigned char *ofono_sim_get_cphs_service_table(struct ofono_sim *sim);
|
||||
|
||||
enum ofono_sim_password_type ofono_sim_get_password_type(struct ofono_sim *sim);
|
||||
|
||||
void ofono_sim_refresh_full(struct ofono_sim *sim); /* Since mer/1.24+git2 */
|
||||
enum ofono_sim_password_type ofono_sim_puk2pin( /* Since mer/1.24+git2 */
|
||||
enum ofono_sim_password_type type);
|
||||
|
||||
unsigned int ofono_sim_add_state_watch(struct ofono_sim *sim,
|
||||
ofono_sim_state_event_cb_t cb,
|
||||
void *data, ofono_destroy_func destroy);
|
||||
|
||||
159
ofono/include/slot.h
Normal file
159
ofono/include/slot.h
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017-2021 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_SLOT_H
|
||||
#define __OFONO_SLOT_H
|
||||
|
||||
/*
|
||||
* Slots are built-in non-removable modems. Which may or may not apprear
|
||||
* in the list reported by org.ofono.Manager.GetModems D-Bus call.
|
||||
*
|
||||
* This API exists since mer/1.24+git2
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ofono_modem;
|
||||
|
||||
#include <ofono/types.h>
|
||||
#include <ofono/radio-settings.h>
|
||||
|
||||
enum ofono_slot_sim_presence {
|
||||
OFONO_SLOT_SIM_UNKNOWN,
|
||||
OFONO_SLOT_SIM_ABSENT,
|
||||
OFONO_SLOT_SIM_PRESENT
|
||||
};
|
||||
|
||||
/* Should be treated as a bitmask although currently it's not */
|
||||
enum ofono_slot_data_role {
|
||||
OFONO_SLOT_DATA_NONE = 0,
|
||||
OFONO_SLOT_DATA_MMS = 0x01,
|
||||
OFONO_SLOT_DATA_INTERNET = 0x02
|
||||
};
|
||||
|
||||
enum ofono_slot_property {
|
||||
OFONO_SLOT_PROPERTY_ANY,
|
||||
OFONO_SLOT_PROPERTY_ENABLED,
|
||||
OFONO_SLOT_PROPERTY_SIM_PRESENCE,
|
||||
OFONO_SLOT_PROPERTY_DATA_ROLE
|
||||
#define OFONO_SLOT_PROPERTY_LAST OFONO_SLOT_PROPERTY_DATA_ROLE
|
||||
};
|
||||
|
||||
enum ofono_slot_manager_property {
|
||||
OFONO_SLOT_MANAGER_PROPERTY_ANY,
|
||||
OFONO_SLOT_MANAGER_PROPERTY_MMS_IMSI,
|
||||
OFONO_SLOT_MANAGER_PROPERTY_MMS_PATH,
|
||||
OFONO_SLOT_MANAGER_PROPERTY_DEFAULT_VOICE_IMSI,
|
||||
OFONO_SLOT_MANAGER_PROPERTY_DEFAULT_DATA_IMSI,
|
||||
OFONO_SLOT_MANAGER_PROPERTY_DEFAULT_VOICE_PATH,
|
||||
OFONO_SLOT_MANAGER_PROPERTY_DEFAULT_DATA_PATH,
|
||||
OFONO_SLOT_MANAGER_PROPERTY_READY
|
||||
#define OFONO_SLOT_MANAGER_PROPERTY_LAST OFONO_SLOT_MANAGER_PROPERTY_READY
|
||||
};
|
||||
|
||||
enum ofono_slot_flags {
|
||||
OFONO_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. */
|
||||
OFONO_SLOT_FLAG_SINGLE_CONTEXT = 0x01
|
||||
};
|
||||
|
||||
typedef struct ofono_slot {
|
||||
const char *path;
|
||||
const char *imei;
|
||||
const char *imeisv;
|
||||
ofono_bool_t enabled;
|
||||
enum ofono_slot_sim_presence sim_presence;
|
||||
enum ofono_slot_data_role data_role;
|
||||
} const *ofono_slot_ptr;
|
||||
|
||||
struct ofono_slot_manager {
|
||||
const char *mms_imsi;
|
||||
const char *mms_path;
|
||||
const char *default_voice_imsi;
|
||||
const char *default_data_imsi;
|
||||
const char *default_voice_path;
|
||||
const char *default_data_path;
|
||||
const ofono_slot_ptr *slots;
|
||||
ofono_bool_t ready;
|
||||
};
|
||||
|
||||
#define OFONO_SLOT_API_VERSION (1)
|
||||
|
||||
struct ofono_slot_driver {
|
||||
const char *name;
|
||||
int api_version; /* OFONO_SLOT_API_VERSION */
|
||||
|
||||
struct ofono_slot_driver_data *(*init)(struct ofono_slot_manager *m);
|
||||
unsigned int (*start)(struct ofono_slot_driver_data *d);
|
||||
void (*cancel)(struct ofono_slot_driver_data *d, unsigned int id);
|
||||
void (*cleanup)(struct ofono_slot_driver_data *d);
|
||||
};
|
||||
|
||||
typedef void (*ofono_slot_property_cb)(struct ofono_slot *slot,
|
||||
enum ofono_slot_property property, void* user_data);
|
||||
typedef void (*ofono_slot_manager_property_cb)(struct ofono_slot_manager *m,
|
||||
enum ofono_slot_property property, void* user_data);
|
||||
|
||||
struct ofono_slot_driver_data;
|
||||
struct ofono_slot_driver_reg;
|
||||
struct ofono_slot_driver_reg *ofono_slot_driver_register
|
||||
(const struct ofono_slot_driver *driver);
|
||||
struct ofono_slot_driver_data *ofono_slot_driver_get_data
|
||||
(struct ofono_slot_driver_reg *reg);
|
||||
void ofono_slot_driver_unregister(struct ofono_slot_driver_reg *reg);
|
||||
void ofono_slot_driver_started(struct ofono_slot_driver_reg *reg);
|
||||
|
||||
struct ofono_slot_manager *ofono_slot_manager_ref(struct ofono_slot_manager *m);
|
||||
void ofono_slot_manager_unref(struct ofono_slot_manager *m);
|
||||
void ofono_slot_manager_error(struct ofono_slot_manager *m, const char *key,
|
||||
const char *message);
|
||||
unsigned long ofono_slot_manager_add_property_handler
|
||||
(struct ofono_slot_manager *m, enum ofono_slot_manager_property p,
|
||||
ofono_slot_manager_property_cb cb, void* data);
|
||||
void ofono_slot_manager_remove_handler(struct ofono_slot_manager *m,
|
||||
unsigned long id);
|
||||
void ofono_slot_manager_remove_handlers(struct ofono_slot_manager *m,
|
||||
unsigned long *ids, unsigned int n);
|
||||
|
||||
struct ofono_cell_info;
|
||||
struct ofono_slot *ofono_slot_add(struct ofono_slot_manager *m,
|
||||
const char *path, enum ofono_radio_access_mode techs, const char *imei,
|
||||
const char *imeisv, enum ofono_slot_sim_presence sim_presence,
|
||||
enum ofono_slot_flags flags);
|
||||
struct ofono_slot *ofono_slot_ref(struct ofono_slot *s);
|
||||
void ofono_slot_unref(struct ofono_slot *s);
|
||||
void ofono_slot_error(struct ofono_slot *s, const char *key, const char *msg);
|
||||
void ofono_slot_set_cell_info(struct ofono_slot *s, struct ofono_cell_info *ci);
|
||||
unsigned long ofono_slot_add_property_handler(struct ofono_slot *s,
|
||||
enum ofono_slot_property p, ofono_slot_property_cb cb, void* data);
|
||||
void ofono_slot_remove_handler(struct ofono_slot *s, unsigned long id);
|
||||
void ofono_slot_remove_handlers(struct ofono_slot *s, unsigned long *ids,
|
||||
unsigned int n);
|
||||
void ofono_slot_set_sim_presence(struct ofono_slot *s,
|
||||
enum ofono_slot_sim_presence sim_presence);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __OFONO_SLOT_H */
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2015-2021 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
|
||||
@@ -42,11 +43,61 @@ typedef int ofono_bool_t;
|
||||
|
||||
typedef void (*ofono_destroy_func)(void *data);
|
||||
|
||||
enum ofono_access_technology {
|
||||
OFONO_ACCESS_TECHNOLOGY_NONE = -1,
|
||||
/* 27.007 Section 7.3 <AcT> */
|
||||
OFONO_ACCESS_TECHNOLOGY_GSM = 0,
|
||||
OFONO_ACCESS_TECHNOLOGY_GSM_COMPACT = 1,
|
||||
OFONO_ACCESS_TECHNOLOGY_UTRAN = 2,
|
||||
OFONO_ACCESS_TECHNOLOGY_GSM_EGPRS = 3,
|
||||
OFONO_ACCESS_TECHNOLOGY_UTRAN_HSDPA = 4,
|
||||
OFONO_ACCESS_TECHNOLOGY_UTRAN_HSUPA = 5,
|
||||
OFONO_ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA = 6,
|
||||
OFONO_ACCESS_TECHNOLOGY_EUTRAN = 7
|
||||
};
|
||||
|
||||
/* 27.007 Section 6.2 */
|
||||
enum ofono_clir_option {
|
||||
OFONO_CLIR_OPTION_DEFAULT = 0,
|
||||
OFONO_CLIR_OPTION_INVOCATION,
|
||||
OFONO_CLIR_OPTION_SUPPRESSION,
|
||||
OFONO_CLIR_OPTION_INVOCATION = 1,
|
||||
OFONO_CLIR_OPTION_SUPPRESSION = 2,
|
||||
};
|
||||
|
||||
/* 27.007 Section 7.6 */
|
||||
enum ofono_clip_validity {
|
||||
OFONO_CLIP_VALIDITY_VALID = 0,
|
||||
OFONO_CLIP_VALIDITY_WITHHELD = 1,
|
||||
OFONO_CLIP_VALIDITY_NOT_AVAILABLE = 2
|
||||
};
|
||||
|
||||
/* 27.007 Section 7.30 */
|
||||
enum ofono_cnap_validity {
|
||||
OFONO_CNAP_VALIDITY_VALID = 0,
|
||||
OFONO_CNAP_VALIDITY_WITHHELD = 1,
|
||||
OFONO_CNAP_VALIDITY_NOT_AVAILABLE = 2
|
||||
};
|
||||
|
||||
/* 27.007 Section 7.18 */
|
||||
enum ofono_call_status {
|
||||
OFONO_CALL_STATUS_ACTIVE = 0,
|
||||
OFONO_CALL_STATUS_HELD = 1,
|
||||
OFONO_CALL_STATUS_DIALING = 2,
|
||||
OFONO_CALL_STATUS_ALERTING = 3,
|
||||
OFONO_CALL_STATUS_INCOMING = 4,
|
||||
OFONO_CALL_STATUS_WAITING = 5,
|
||||
OFONO_CALL_STATUS_DISCONNECTED
|
||||
};
|
||||
|
||||
/* 27.007 Section 7.18 */
|
||||
enum ofono_call_direction {
|
||||
OFONO_CALL_DIRECTION_MOBILE_ORIGINATED = 0,
|
||||
OFONO_CALL_DIRECTION_MOBILE_TERMINATED = 1
|
||||
};
|
||||
|
||||
enum ofono_sms_charset {
|
||||
OFONO_SMS_CHARSET_7BIT = 0,
|
||||
OFONO_SMS_CHARSET_8BIT = 1,
|
||||
OFONO_SMS_CHARSET_UCS2 = 2
|
||||
};
|
||||
|
||||
enum ofono_error_type {
|
||||
@@ -96,13 +147,13 @@ struct ofono_cdma_phone_number {
|
||||
struct ofono_call {
|
||||
unsigned int id;
|
||||
int type;
|
||||
int direction;
|
||||
int status;
|
||||
enum ofono_call_direction direction;
|
||||
enum ofono_call_status status;
|
||||
struct ofono_phone_number phone_number;
|
||||
struct ofono_phone_number called_number;
|
||||
char name[OFONO_MAX_CALLER_NAME_LENGTH + 1];
|
||||
int clip_validity;
|
||||
int cnap_validity;
|
||||
enum ofono_clip_validity clip_validity;
|
||||
enum ofono_cnap_validity cnap_validity;
|
||||
};
|
||||
|
||||
struct ofono_network_time {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2018 Jolla Ltd.
|
||||
* Copyright (C) 2018-2021 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,37 +22,6 @@ extern "C" {
|
||||
|
||||
#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*/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017-2019 Jolla Ltd.
|
||||
* Copyright (C) 2017-2021 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,21 +17,12 @@
|
||||
#define OFONO_WATCH_H
|
||||
|
||||
#include <ofono/gprs-context.h>
|
||||
#include <ofono/netreg.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;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2013 Canonical Ltd.
|
||||
* Copyright (C) 2015-2021 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
|
||||
@@ -318,7 +319,7 @@ static int comp_mcc(const void *key, const void *value)
|
||||
return mcc - mccmnc->mcc;
|
||||
}
|
||||
|
||||
int mnclength(int mcc, int mnc)
|
||||
static int mnclength_mccmnc(int mcc, int mnc)
|
||||
{
|
||||
int mccmnc_num = 1000*mcc + mnc;
|
||||
int *mccmnc3_res = bsearch(&mccmnc_num, codes_mnclen3_db,
|
||||
@@ -381,7 +382,8 @@ static int mnclength_get_mnclength(const char *imsi)
|
||||
|
||||
static struct ofono_sim_mnclength_driver mnclength_driver = {
|
||||
.name = "MNC length",
|
||||
.get_mnclength = mnclength_get_mnclength
|
||||
.get_mnclength = mnclength_get_mnclength,
|
||||
.get_mnclength_mccmnc = mnclength_mccmnc
|
||||
};
|
||||
|
||||
static int mnclength_init(void)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,143 +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_MANAGER_H
|
||||
#define SAILFISH_MANAGER_H
|
||||
|
||||
struct ofono_modem;
|
||||
|
||||
#include <ofono/types.h>
|
||||
#include <ofono/radio-settings.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
struct sailfish_manager;
|
||||
struct sailfish_slot;
|
||||
struct sailfish_slot_impl;
|
||||
struct sailfish_slot_driver;
|
||||
struct sailfish_slot_driver_reg;
|
||||
struct sailfish_slot_manager;
|
||||
struct sailfish_slot_manager_impl;
|
||||
struct sailfish_cell_info;
|
||||
|
||||
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;
|
||||
const char *imeisv;
|
||||
gboolean sim_present;
|
||||
gboolean enabled;
|
||||
} const *sailfish_slot_ptr;
|
||||
|
||||
struct sailfish_manager {
|
||||
const char *mms_imsi;
|
||||
const char *mms_path;
|
||||
const char *default_voice_imsi;
|
||||
const char *default_data_imsi;
|
||||
const char *default_voice_path;
|
||||
const char *default_data_path;
|
||||
const sailfish_slot_ptr *slots;
|
||||
gboolean ready;
|
||||
};
|
||||
|
||||
enum sailfish_sim_state {
|
||||
SAILFISH_SIM_STATE_UNKNOWN,
|
||||
SAILFISH_SIM_STATE_ABSENT,
|
||||
SAILFISH_SIM_STATE_PRESENT,
|
||||
SAILFISH_SIM_STATE_ERROR
|
||||
};
|
||||
|
||||
enum sailfish_data_role {
|
||||
SAILFISH_DATA_ROLE_NONE, /* Data not allowed */
|
||||
SAILFISH_DATA_ROLE_MMS, /* Data is allowed at any speed */
|
||||
SAILFISH_DATA_ROLE_INTERNET /* Data is allowed at full speed */
|
||||
};
|
||||
|
||||
/* Register/unregister the driver */
|
||||
struct sailfish_slot_driver_reg *sailfish_slot_driver_register
|
||||
(const struct sailfish_slot_driver *d);
|
||||
void sailfish_slot_driver_unregister(struct sailfish_slot_driver_reg *r);
|
||||
|
||||
/* For use by the driver implementations */
|
||||
void sailfish_manager_foreach_slot_manager
|
||||
(struct sailfish_slot_driver_reg *r,
|
||||
sailfish_slot_manager_impl_cb_t cb, void *user_data);
|
||||
struct sailfish_slot *sailfish_manager_slot_add
|
||||
(struct sailfish_slot_manager *m, struct sailfish_slot_impl *i,
|
||||
const char *path, enum ofono_radio_access_mode techs,
|
||||
const char *imei, const char *imeisv,
|
||||
enum sailfish_sim_state sim_state);
|
||||
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);
|
||||
void sailfish_manager_set_sim_state(struct sailfish_slot *s,
|
||||
enum sailfish_sim_state state);
|
||||
void sailfish_slot_manager_started(struct sailfish_slot_manager *m);
|
||||
void sailfish_manager_slot_error(struct sailfish_slot *s, const char *key,
|
||||
const char *message);
|
||||
void sailfish_manager_error(struct sailfish_slot_manager *m, const char *key,
|
||||
const char *message);
|
||||
void sailfish_manager_set_cell_info(struct sailfish_slot *s,
|
||||
struct sailfish_cell_info *ci);
|
||||
|
||||
/* Callbacks provided by slot plugins */
|
||||
struct sailfish_slot_driver {
|
||||
const char *name;
|
||||
int priority;
|
||||
|
||||
/* Slot manager methods */
|
||||
struct sailfish_slot_manager_impl *(*manager_create)
|
||||
(struct sailfish_slot_manager *m);
|
||||
guint (*manager_start)(struct sailfish_slot_manager_impl *s);
|
||||
void (*manager_cancel_start)(struct sailfish_slot_manager_impl *s,
|
||||
guint id);
|
||||
void (*manager_free)(struct sailfish_slot_manager_impl *s);
|
||||
|
||||
/* Slot methods */
|
||||
void (*slot_enabled_changed)(struct sailfish_slot_impl *s);
|
||||
void (*slot_set_data_role)(struct sailfish_slot_impl *s,
|
||||
enum sailfish_data_role role);
|
||||
void (*slot_free)(struct sailfish_slot_impl *s);
|
||||
};
|
||||
|
||||
#endif /* SAILFISH_MANAGER_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2016-2017 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef SAILFISH_MANAGER_DBUS_H
|
||||
#define SAILFISH_MANAGER_DBUS_H
|
||||
|
||||
#include <sailfish_manager.h>
|
||||
|
||||
struct sailfish_manager_dbus;
|
||||
|
||||
enum sailfish_manager_dbus_block {
|
||||
SAILFISH_MANAGER_DBUS_BLOCK_NONE = 0,
|
||||
SAILFISH_MANAGER_DBUS_BLOCK_MODEM = 0x01,
|
||||
SAILFISH_MANAGER_DBUS_BLOCK_IMEI = 0x02,
|
||||
SAILFISH_MANAGER_DBUS_BLOCK_ALL = 0x03
|
||||
};
|
||||
|
||||
enum sailfish_manager_dbus_signal {
|
||||
SAILFISH_MANAGER_SIGNAL_NONE = 0,
|
||||
SAILFISH_MANAGER_SIGNAL_VOICE_IMSI = 0x01,
|
||||
SAILFISH_MANAGER_SIGNAL_DATA_IMSI = 0x02,
|
||||
SAILFISH_MANAGER_SIGNAL_VOICE_PATH = 0x04,
|
||||
SAILFISH_MANAGER_SIGNAL_DATA_PATH = 0x08,
|
||||
SAILFISH_MANAGER_SIGNAL_ENABLED_SLOTS = 0x10,
|
||||
SAILFISH_MANAGER_SIGNAL_MMS_IMSI = 0x20,
|
||||
SAILFISH_MANAGER_SIGNAL_MMS_PATH = 0x40,
|
||||
SAILFISH_MANAGER_SIGNAL_READY = 0x80
|
||||
};
|
||||
|
||||
/* Functionality provided by sailfish_manager to sailfish_manager_dbus */
|
||||
struct sailfish_manager_dbus_cb {
|
||||
GHashTable *(*get_errors)(struct sailfish_manager *m);
|
||||
GHashTable *(*get_slot_errors)(const struct sailfish_slot *s);
|
||||
void (*set_enabled_slots)(struct sailfish_manager *m, char **slots);
|
||||
gboolean (*set_mms_imsi)(struct sailfish_manager *m, const char *imsi);
|
||||
void (*set_default_voice_imsi)(struct sailfish_manager *m,
|
||||
const char *imsi);
|
||||
void (*set_default_data_imsi)(struct sailfish_manager *m,
|
||||
const char *imsi);
|
||||
};
|
||||
|
||||
struct sailfish_manager_dbus *sailfish_manager_dbus_new
|
||||
(struct sailfish_manager *m,
|
||||
const struct sailfish_manager_dbus_cb *cb);
|
||||
void sailfish_manager_dbus_free(struct sailfish_manager_dbus *d);
|
||||
void sailfish_manager_dbus_set_block(struct sailfish_manager_dbus *d,
|
||||
enum sailfish_manager_dbus_block b);
|
||||
void sailfish_manager_dbus_signal(struct sailfish_manager_dbus *d,
|
||||
enum sailfish_manager_dbus_signal m);
|
||||
void sailfish_manager_dbus_signal_sim(struct sailfish_manager_dbus *d,
|
||||
int index, gboolean present);
|
||||
void sailfish_manager_dbus_signal_error(struct sailfish_manager_dbus *d,
|
||||
const char *id, const char *message);
|
||||
void sailfish_manager_dbus_signal_modem_error(struct sailfish_manager_dbus *d,
|
||||
int index, const char *id, const char *msg);
|
||||
|
||||
#endif /* SAILFISH_MANAGER_DBUS_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,80 +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.
|
||||
*/
|
||||
|
||||
#ifndef SAILFISH_SIM_INFO_H
|
||||
#define SAILFISH_SIM_INFO_H
|
||||
|
||||
#include <ofono/types.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
/*
|
||||
* Note that iccid, imsi and spn provided by this class can be cached,
|
||||
* i.e. become available before the pin code is entered and before those
|
||||
* are known to the ofono core. That's the whole purpose of this thing.
|
||||
*
|
||||
* If you need to follow imsi known to the ofono core, you can use
|
||||
* sailfish_sim_settings for that (or fight with ofono imsi watchers
|
||||
* directly).
|
||||
*/
|
||||
struct ofono_modem;
|
||||
struct sailfish_sim_info_priv;
|
||||
struct sailfish_sim_info {
|
||||
GObject object;
|
||||
struct sailfish_sim_info_priv *priv;
|
||||
const char *path;
|
||||
const char *iccid;
|
||||
const char *imsi;
|
||||
const char *spn;
|
||||
};
|
||||
|
||||
typedef void (*sailfish_sim_info_cb_t)(struct sailfish_sim_info *si,
|
||||
void *user_data);
|
||||
|
||||
/* SIM info object associated with the particular slot */
|
||||
struct sailfish_sim_info *sailfish_sim_info_new(const char *path);
|
||||
struct sailfish_sim_info *sailfish_sim_info_ref(struct sailfish_sim_info *si);
|
||||
void sailfish_sim_info_unref(struct sailfish_sim_info *si);
|
||||
gulong sailfish_sim_info_add_iccid_changed_handler(struct sailfish_sim_info *si,
|
||||
sailfish_sim_info_cb_t cb, void *user_data);
|
||||
gulong sailfish_sim_info_add_imsi_changed_handler(struct sailfish_sim_info *si,
|
||||
sailfish_sim_info_cb_t cb, void *user_data);
|
||||
gulong sailfish_sim_info_add_spn_changed_handler(struct sailfish_sim_info *si,
|
||||
sailfish_sim_info_cb_t cb, void *user_data);
|
||||
void sailfish_sim_info_remove_handler(struct sailfish_sim_info *si, gulong id);
|
||||
void sailfish_sim_info_remove_handlers(struct sailfish_sim_info *si,
|
||||
gulong *ids, int count);
|
||||
|
||||
#define sailfish_sim_info_remove_all_handlers(si,ids) \
|
||||
sailfish_sim_info_remove_handlers(si, ids, G_N_ELEMENTS(ids))
|
||||
|
||||
/* And the D-Bus interface for it */
|
||||
struct sailfish_sim_info_dbus;
|
||||
struct sailfish_sim_info_dbus *sailfish_sim_info_dbus_new
|
||||
(struct sailfish_sim_info *si);
|
||||
struct sailfish_sim_info_dbus *sailfish_sim_info_dbus_new_path
|
||||
(const char *path);
|
||||
void sailfish_sim_info_dbus_free(struct sailfish_sim_info_dbus *dbus);
|
||||
|
||||
#endif /* SAILFISH_SIM_INFO_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -13,9 +13,9 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "sailfish_cell_info_dbus.h"
|
||||
#include "sailfish_cell_info.h"
|
||||
#include "cell-info-dbus.h"
|
||||
|
||||
#include <ofono/cell-info.h>
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/dbus.h>
|
||||
#include <ofono/dbus-clients.h>
|
||||
@@ -23,21 +23,23 @@
|
||||
|
||||
#include <gdbus.h>
|
||||
|
||||
struct sailfish_cell_entry {
|
||||
#include "ofono.h"
|
||||
|
||||
typedef struct cell_entry {
|
||||
guint cell_id;
|
||||
char *path;
|
||||
struct sailfish_cell cell;
|
||||
};
|
||||
struct ofono_cell cell;
|
||||
} CellEntry;
|
||||
|
||||
struct sailfish_cell_info_dbus {
|
||||
struct sailfish_cell_info *info;
|
||||
typedef struct cell_info_dbus {
|
||||
struct ofono_cell_info *info;
|
||||
DBusConnection *conn;
|
||||
char *path;
|
||||
gulong handler_id;
|
||||
guint next_cell_id;
|
||||
GSList *entries;
|
||||
struct ofono_dbus_clients *clients;
|
||||
};
|
||||
} CellInfoDBus;
|
||||
|
||||
#define CELL_INFO_DBUS_INTERFACE "org.nemomobile.ofono.CellInfo"
|
||||
#define CELL_INFO_DBUS_CELLS_ADDED_SIGNAL "CellsAdded"
|
||||
@@ -50,20 +52,20 @@ struct sailfish_cell_info_dbus {
|
||||
#define CELL_DBUS_PROPERTY_CHANGED_SIGNAL "PropertyChanged"
|
||||
#define CELL_DBUS_REMOVED_SIGNAL "Removed"
|
||||
|
||||
struct sailfish_cell_property {
|
||||
struct cell_property {
|
||||
const char *name;
|
||||
glong off;
|
||||
int flag;
|
||||
};
|
||||
|
||||
#define CELL_GSM_PROPERTY(value,name) \
|
||||
{ #name, G_STRUCT_OFFSET(struct sailfish_cell_info_gsm,name), value }
|
||||
{ #name, G_STRUCT_OFFSET(struct ofono_cell_info_gsm,name), value }
|
||||
#define CELL_WCDMA_PROPERTY(value,name) \
|
||||
{ #name, G_STRUCT_OFFSET(struct sailfish_cell_info_wcdma,name), value }
|
||||
{ #name, G_STRUCT_OFFSET(struct ofono_cell_info_wcdma,name), value }
|
||||
#define CELL_LTE_PROPERTY(value,name) \
|
||||
{ #name, G_STRUCT_OFFSET(struct sailfish_cell_info_lte,name), value }
|
||||
{ #name, G_STRUCT_OFFSET(struct ofono_cell_info_lte,name), value }
|
||||
|
||||
static const struct sailfish_cell_property sailfish_cell_gsm_properties [] = {
|
||||
static const struct cell_property cell_gsm_properties [] = {
|
||||
CELL_GSM_PROPERTY(0x001,mcc),
|
||||
CELL_GSM_PROPERTY(0x002,mnc),
|
||||
CELL_GSM_PROPERTY(0x004,lac),
|
||||
@@ -75,7 +77,7 @@ static const struct sailfish_cell_property sailfish_cell_gsm_properties [] = {
|
||||
CELL_GSM_PROPERTY(0x100,timingAdvance)
|
||||
};
|
||||
|
||||
static const struct sailfish_cell_property sailfish_cell_wcdma_properties [] = {
|
||||
static const struct cell_property cell_wcdma_properties [] = {
|
||||
CELL_WCDMA_PROPERTY(0x01,mcc),
|
||||
CELL_WCDMA_PROPERTY(0x02,mnc),
|
||||
CELL_WCDMA_PROPERTY(0x04,lac),
|
||||
@@ -86,7 +88,7 @@ static const struct sailfish_cell_property sailfish_cell_wcdma_properties [] = {
|
||||
CELL_WCDMA_PROPERTY(0x80,bitErrorRate)
|
||||
};
|
||||
|
||||
static const struct sailfish_cell_property sailfish_cell_lte_properties [] = {
|
||||
static const struct cell_property cell_lte_properties [] = {
|
||||
CELL_LTE_PROPERTY(0x001,mcc),
|
||||
CELL_LTE_PROPERTY(0x002,mnc),
|
||||
CELL_LTE_PROPERTY(0x004,ci),
|
||||
@@ -101,47 +103,45 @@ static const struct sailfish_cell_property sailfish_cell_lte_properties [] = {
|
||||
CELL_LTE_PROPERTY(0x800,timingAdvance)
|
||||
};
|
||||
|
||||
#define SAILFISH_CELL_PROPERTY_REGISTERED 0x1000
|
||||
#define CELL_PROPERTY_REGISTERED 0x1000
|
||||
|
||||
typedef void (*sailfish_cell_info_dbus_append_fn)(DBusMessageIter *it,
|
||||
const struct sailfish_cell_entry *entry);
|
||||
typedef void (*cell_info_dbus_append_fn)(DBusMessageIter *it,
|
||||
const CellEntry *entry);
|
||||
|
||||
static const char *sailfish_cell_info_dbus_cell_type_str
|
||||
(enum sailfish_cell_type type)
|
||||
static const char *cell_info_dbus_cell_type_str(enum ofono_cell_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case SAILFISH_CELL_TYPE_GSM:
|
||||
case OFONO_CELL_TYPE_GSM:
|
||||
return "gsm";
|
||||
case SAILFISH_CELL_TYPE_WCDMA:
|
||||
case OFONO_CELL_TYPE_WCDMA:
|
||||
return "wcdma";
|
||||
case SAILFISH_CELL_TYPE_LTE:
|
||||
case OFONO_CELL_TYPE_LTE:
|
||||
return "lte";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
};
|
||||
|
||||
static const struct sailfish_cell_property *
|
||||
sailfish_cell_info_dbus_cell_properties(
|
||||
enum sailfish_cell_type type, int *count)
|
||||
static const struct cell_property *cell_info_dbus_cell_properties
|
||||
(enum ofono_cell_type type, int *count)
|
||||
{
|
||||
switch (type) {
|
||||
case SAILFISH_CELL_TYPE_GSM:
|
||||
*count = G_N_ELEMENTS(sailfish_cell_gsm_properties);
|
||||
return sailfish_cell_gsm_properties;
|
||||
case SAILFISH_CELL_TYPE_WCDMA:
|
||||
*count = G_N_ELEMENTS(sailfish_cell_wcdma_properties);
|
||||
return sailfish_cell_wcdma_properties;
|
||||
case SAILFISH_CELL_TYPE_LTE:
|
||||
*count = G_N_ELEMENTS(sailfish_cell_lte_properties);
|
||||
return sailfish_cell_lte_properties;
|
||||
case OFONO_CELL_TYPE_GSM:
|
||||
*count = G_N_ELEMENTS(cell_gsm_properties);
|
||||
return cell_gsm_properties;
|
||||
case OFONO_CELL_TYPE_WCDMA:
|
||||
*count = G_N_ELEMENTS(cell_wcdma_properties);
|
||||
return cell_wcdma_properties;
|
||||
case OFONO_CELL_TYPE_LTE:
|
||||
*count = G_N_ELEMENTS(cell_lte_properties);
|
||||
return cell_lte_properties;
|
||||
default:
|
||||
*count = 0;
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
static void sailfish_cell_info_destroy_entry(struct sailfish_cell_entry *entry)
|
||||
static void cell_info_destroy_entry(CellEntry *entry)
|
||||
{
|
||||
if (entry) {
|
||||
g_free(entry->path);
|
||||
@@ -149,9 +149,8 @@ static void sailfish_cell_info_destroy_entry(struct sailfish_cell_entry *entry)
|
||||
}
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_cell_info_dbus_reply(DBusMessage *msg,
|
||||
const struct sailfish_cell_entry *entry,
|
||||
sailfish_cell_info_dbus_append_fn append)
|
||||
static DBusMessage *cell_info_dbus_reply(DBusMessage *msg,
|
||||
const CellEntry *entry, cell_info_dbus_append_fn append)
|
||||
{
|
||||
DBusMessage *reply = dbus_message_new_method_return(msg);
|
||||
DBusMessageIter it;
|
||||
@@ -161,118 +160,116 @@ static DBusMessage *sailfish_cell_info_dbus_reply(DBusMessage *msg,
|
||||
return reply;
|
||||
}
|
||||
|
||||
static void sailfish_cell_info_dbus_append_version(DBusMessageIter *it,
|
||||
const struct sailfish_cell_entry *entry)
|
||||
static void cell_info_dbus_append_version(DBusMessageIter *it,
|
||||
const CellEntry *entry)
|
||||
{
|
||||
dbus_int32_t version = CELL_DBUS_INTERFACE_VERSION;
|
||||
|
||||
dbus_message_iter_append_basic(it, DBUS_TYPE_INT32, &version);
|
||||
}
|
||||
|
||||
static void sailfish_cell_info_dbus_append_type(DBusMessageIter *it,
|
||||
const struct sailfish_cell_entry *entry)
|
||||
static void cell_info_dbus_append_type(DBusMessageIter *it,
|
||||
const CellEntry *entry)
|
||||
{
|
||||
const char *type =
|
||||
sailfish_cell_info_dbus_cell_type_str(entry->cell.type);
|
||||
const char *type = cell_info_dbus_cell_type_str(entry->cell.type);
|
||||
|
||||
dbus_message_iter_append_basic(it, DBUS_TYPE_STRING, &type);
|
||||
}
|
||||
|
||||
static void sailfish_cell_info_dbus_append_registered(DBusMessageIter *it,
|
||||
const struct sailfish_cell_entry *entry)
|
||||
static void cell_info_dbus_append_registered(DBusMessageIter *it,
|
||||
const CellEntry *entry)
|
||||
{
|
||||
const dbus_bool_t registered = (entry->cell.registered != FALSE);
|
||||
|
||||
dbus_message_iter_append_basic(it, DBUS_TYPE_BOOLEAN, ®istered);
|
||||
}
|
||||
|
||||
static void sailfish_cell_info_dbus_append_properties(DBusMessageIter *it,
|
||||
const struct sailfish_cell_entry *entry)
|
||||
static void cell_info_dbus_append_properties(DBusMessageIter *it,
|
||||
const CellEntry *entry)
|
||||
{
|
||||
int i, n;
|
||||
DBusMessageIter dict;
|
||||
const struct sailfish_cell *cell = &entry->cell;
|
||||
const struct sailfish_cell_property *prop =
|
||||
sailfish_cell_info_dbus_cell_properties(cell->type, &n);
|
||||
const struct ofono_cell *cell = &entry->cell;
|
||||
const struct cell_property *prop =
|
||||
cell_info_dbus_cell_properties(cell->type, &n);
|
||||
|
||||
dbus_message_iter_open_container(it, DBUS_TYPE_ARRAY, "{sv}", &dict);
|
||||
for (i = 0; i < n; i++) {
|
||||
gint32 value = G_STRUCT_MEMBER(int, &cell->info, prop[i].off);
|
||||
if (value != SAILFISH_CELL_INVALID_VALUE) {
|
||||
if (value != OFONO_CELL_INVALID_VALUE) {
|
||||
ofono_dbus_dict_append(&dict, prop[i].name,
|
||||
DBUS_TYPE_INT32, &value);
|
||||
DBUS_TYPE_INT32, &value);
|
||||
}
|
||||
}
|
||||
dbus_message_iter_close_container(it, &dict);
|
||||
}
|
||||
|
||||
static void sailfish_cell_info_dbus_append_all(DBusMessageIter *it,
|
||||
const struct sailfish_cell_entry *entry)
|
||||
static void cell_info_dbus_append_all(DBusMessageIter *it, const CellEntry *ce)
|
||||
{
|
||||
sailfish_cell_info_dbus_append_version(it, entry);
|
||||
sailfish_cell_info_dbus_append_type(it, entry);
|
||||
sailfish_cell_info_dbus_append_registered(it, entry);
|
||||
sailfish_cell_info_dbus_append_properties(it, entry);
|
||||
cell_info_dbus_append_version(it, ce);
|
||||
cell_info_dbus_append_type(it, ce);
|
||||
cell_info_dbus_append_registered(it, ce);
|
||||
cell_info_dbus_append_properties(it, ce);
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_cell_info_dbus_cell_get_all
|
||||
(DBusConnection *conn, DBusMessage *msg, void *data)
|
||||
static DBusMessage *cell_info_dbus_cell_get_all(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
return sailfish_cell_info_dbus_reply(msg, (struct sailfish_cell_entry*)
|
||||
data, sailfish_cell_info_dbus_append_all);
|
||||
return cell_info_dbus_reply(msg, (CellEntry*) data,
|
||||
cell_info_dbus_append_all);
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_cell_info_dbus_cell_get_version
|
||||
(DBusConnection *conn, DBusMessage *msg, void *data)
|
||||
static DBusMessage *cell_info_dbus_cell_get_version(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
return sailfish_cell_info_dbus_reply(msg, (struct sailfish_cell_entry*)
|
||||
data, sailfish_cell_info_dbus_append_version);
|
||||
return cell_info_dbus_reply(msg, (CellEntry*) data,
|
||||
cell_info_dbus_append_version);
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_cell_info_dbus_cell_get_type
|
||||
(DBusConnection *conn, DBusMessage *msg, void *data)
|
||||
static DBusMessage *cell_info_dbus_cell_get_type(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
return sailfish_cell_info_dbus_reply(msg, (struct sailfish_cell_entry*)
|
||||
data, sailfish_cell_info_dbus_append_type);
|
||||
return cell_info_dbus_reply(msg, (CellEntry*) data,
|
||||
cell_info_dbus_append_type);
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_cell_info_dbus_cell_get_registered
|
||||
(DBusConnection *conn, DBusMessage *msg, void *data)
|
||||
static DBusMessage *cell_info_dbus_cell_get_registered(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
return sailfish_cell_info_dbus_reply(msg, (struct sailfish_cell_entry*)
|
||||
data, sailfish_cell_info_dbus_append_registered);
|
||||
return cell_info_dbus_reply(msg, (CellEntry*) data,
|
||||
cell_info_dbus_append_registered);
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_cell_info_dbus_cell_get_properties
|
||||
(DBusConnection *conn, DBusMessage *msg, void *data)
|
||||
static DBusMessage *cell_info_dbus_cell_get_properties(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
return sailfish_cell_info_dbus_reply(msg, (struct sailfish_cell_entry*)
|
||||
data, sailfish_cell_info_dbus_append_properties);
|
||||
return cell_info_dbus_reply(msg, (CellEntry*) data,
|
||||
cell_info_dbus_append_properties);
|
||||
}
|
||||
|
||||
static const GDBusMethodTable sailfish_cell_info_dbus_cell_methods[] = {
|
||||
static const GDBusMethodTable cell_info_dbus_cell_methods[] = {
|
||||
{ GDBUS_METHOD("GetAll", NULL,
|
||||
GDBUS_ARGS({ "version", "i" },
|
||||
{ "type", "s" },
|
||||
{ "registered", "b" },
|
||||
{ "properties", "a{sv}" }),
|
||||
sailfish_cell_info_dbus_cell_get_all) },
|
||||
cell_info_dbus_cell_get_all) },
|
||||
{ GDBUS_METHOD("GetInterfaceVersion", NULL,
|
||||
GDBUS_ARGS({ "version", "i" }),
|
||||
sailfish_cell_info_dbus_cell_get_version) },
|
||||
cell_info_dbus_cell_get_version) },
|
||||
{ GDBUS_METHOD("GetType", NULL,
|
||||
GDBUS_ARGS({ "type", "s" }),
|
||||
sailfish_cell_info_dbus_cell_get_type) },
|
||||
cell_info_dbus_cell_get_type) },
|
||||
{ GDBUS_METHOD("GetRegistered", NULL,
|
||||
GDBUS_ARGS({ "registered", "b" }),
|
||||
sailfish_cell_info_dbus_cell_get_registered) },
|
||||
cell_info_dbus_cell_get_registered) },
|
||||
{ GDBUS_METHOD("GetProperties", NULL,
|
||||
GDBUS_ARGS({ "properties", "a{sv}" }),
|
||||
sailfish_cell_info_dbus_cell_get_properties) },
|
||||
cell_info_dbus_cell_get_properties) },
|
||||
{ }
|
||||
};
|
||||
|
||||
static const GDBusSignalTable sailfish_cell_info_dbus_cell_signals[] = {
|
||||
static const GDBusSignalTable cell_info_dbus_cell_signals[] = {
|
||||
{ GDBUS_SIGNAL(CELL_DBUS_REGISTERED_CHANGED_SIGNAL,
|
||||
GDBUS_ARGS({ "registered", "b" })) },
|
||||
{ GDBUS_SIGNAL(CELL_DBUS_PROPERTY_CHANGED_SIGNAL,
|
||||
@@ -282,12 +279,13 @@ static const GDBusSignalTable sailfish_cell_info_dbus_cell_signals[] = {
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct sailfish_cell_entry *sailfish_cell_info_dbus_find_id
|
||||
(struct sailfish_cell_info_dbus *dbus, guint id)
|
||||
static CellEntry *cell_info_dbus_find_id(CellInfoDBus *dbus, guint id)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
for (l = dbus->entries; l; l = l->next) {
|
||||
struct sailfish_cell_entry *entry = l->data;
|
||||
CellEntry *entry = l->data;
|
||||
|
||||
if (entry->cell_id == id) {
|
||||
return entry;
|
||||
}
|
||||
@@ -295,41 +293,52 @@ static struct sailfish_cell_entry *sailfish_cell_info_dbus_find_id
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static guint sailfish_cell_info_dbus_next_cell_id
|
||||
(struct sailfish_cell_info_dbus *dbus)
|
||||
static guint cell_info_dbus_next_cell_id(CellInfoDBus *dbus)
|
||||
{
|
||||
while (sailfish_cell_info_dbus_find_id(dbus, dbus->next_cell_id)) {
|
||||
while (cell_info_dbus_find_id(dbus, dbus->next_cell_id)) {
|
||||
dbus->next_cell_id++;
|
||||
}
|
||||
return dbus->next_cell_id++;
|
||||
}
|
||||
|
||||
static struct sailfish_cell_entry *sailfish_cell_info_dbus_find_cell
|
||||
(struct sailfish_cell_info_dbus *dbus,
|
||||
const struct sailfish_cell *cell)
|
||||
static const struct ofono_cell *cell_info_dbus_find_ofono_cell
|
||||
(struct ofono_cell_info *info, const struct ofono_cell *cell)
|
||||
{
|
||||
const ofono_cell_ptr *c;
|
||||
|
||||
for (c = info->cells; *c; c++) {
|
||||
if (!ofono_cell_compare_location(*c, cell)) {
|
||||
return *c;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static CellEntry *cell_info_dbus_find_cell(CellInfoDBus *dbus,
|
||||
const struct ofono_cell *cell)
|
||||
{
|
||||
if (cell) {
|
||||
GSList *l;
|
||||
|
||||
for (l = dbus->entries; l; l = l->next) {
|
||||
struct sailfish_cell_entry *entry = l->data;
|
||||
if (!sailfish_cell_compare_location(&entry->cell,
|
||||
cell)) {
|
||||
return entry;
|
||||
CellEntry *e = l->data;
|
||||
|
||||
if (!ofono_cell_compare_location(&e->cell, cell)) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void sailfish_cell_info_dbus_emit_path_list
|
||||
(struct sailfish_cell_info_dbus *dbus, const char *name,
|
||||
GPtrArray *list)
|
||||
static void cell_info_dbus_emit_path_list(CellInfoDBus *dbus, const char *name,
|
||||
GPtrArray *list)
|
||||
{
|
||||
if (ofono_dbus_clients_count(dbus->clients)) {
|
||||
guint i;
|
||||
DBusMessageIter it, a;
|
||||
DBusMessage *signal = dbus_message_new_signal(dbus->path,
|
||||
CELL_INFO_DBUS_INTERFACE, name);
|
||||
CELL_INFO_DBUS_INTERFACE, name);
|
||||
|
||||
dbus_message_iter_init_append(signal, &it);
|
||||
dbus_message_iter_open_container(&it, DBUS_TYPE_ARRAY, "o", &a);
|
||||
@@ -337,7 +346,7 @@ static void sailfish_cell_info_dbus_emit_path_list
|
||||
const char* path = list->pdata[i];
|
||||
|
||||
dbus_message_iter_append_basic(&a,
|
||||
DBUS_TYPE_OBJECT_PATH, &path);
|
||||
DBUS_TYPE_OBJECT_PATH, &path);
|
||||
}
|
||||
dbus_message_iter_close_container(&it, &a);
|
||||
ofono_dbus_clients_signal(dbus->clients, signal);
|
||||
@@ -345,22 +354,23 @@ static void sailfish_cell_info_dbus_emit_path_list
|
||||
}
|
||||
}
|
||||
|
||||
static int sailfish_cell_info_dbus_compare(const struct sailfish_cell *c1,
|
||||
const struct sailfish_cell *c2)
|
||||
static int cell_info_dbus_compare(const struct ofono_cell *c1,
|
||||
const struct ofono_cell *c2)
|
||||
{
|
||||
if (c1->type == c2->type) {
|
||||
int i, n, mask = 0;
|
||||
const struct sailfish_cell_property *prop =
|
||||
sailfish_cell_info_dbus_cell_properties(c1->type, &n);
|
||||
const struct cell_property *prop =
|
||||
cell_info_dbus_cell_properties(c1->type, &n);
|
||||
|
||||
if (c1->registered != c2->registered) {
|
||||
mask |= SAILFISH_CELL_PROPERTY_REGISTERED;
|
||||
mask |= CELL_PROPERTY_REGISTERED;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
const glong offset = prop[i].off;
|
||||
gint32 v1 = G_STRUCT_MEMBER(int, &c1->info, offset);
|
||||
gint32 v2 = G_STRUCT_MEMBER(int, &c2->info, offset);
|
||||
|
||||
if (v1 != v2) {
|
||||
mask |= prop[i].flag;
|
||||
}
|
||||
@@ -372,10 +382,8 @@ static int sailfish_cell_info_dbus_compare(const struct sailfish_cell *c1,
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_cell_info_dbus_emit_signal
|
||||
(struct sailfish_cell_info_dbus *dbus,
|
||||
const char *path, const char *intf,
|
||||
const char *name, int type, ...)
|
||||
static void cell_info_dbus_emit_signal(CellInfoDBus *dbus, const char *path,
|
||||
const char *intf, const char *name, int type, ...)
|
||||
{
|
||||
if (ofono_dbus_clients_count(dbus->clients)) {
|
||||
va_list args;
|
||||
@@ -389,23 +397,22 @@ static void sailfish_cell_info_dbus_emit_signal
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_cell_info_dbus_property_changed
|
||||
(struct sailfish_cell_info_dbus *dbus,
|
||||
const struct sailfish_cell_entry *entry, int mask)
|
||||
static void cell_info_dbus_property_changed(CellInfoDBus *dbus,
|
||||
const CellEntry *entry, int mask)
|
||||
{
|
||||
int i, n;
|
||||
const struct sailfish_cell *cell = &entry->cell;
|
||||
const struct sailfish_cell_property *prop =
|
||||
sailfish_cell_info_dbus_cell_properties(cell->type, &n);
|
||||
const struct ofono_cell *cell = &entry->cell;
|
||||
const struct cell_property *prop =
|
||||
cell_info_dbus_cell_properties(cell->type, &n);
|
||||
|
||||
if (mask & SAILFISH_CELL_PROPERTY_REGISTERED) {
|
||||
if (mask & CELL_PROPERTY_REGISTERED) {
|
||||
const dbus_bool_t registered = (cell->registered != FALSE);
|
||||
|
||||
sailfish_cell_info_dbus_emit_signal(dbus, entry->path,
|
||||
cell_info_dbus_emit_signal(dbus, entry->path,
|
||||
CELL_DBUS_INTERFACE,
|
||||
CELL_DBUS_REGISTERED_CHANGED_SIGNAL,
|
||||
DBUS_TYPE_BOOLEAN, ®istered, DBUS_TYPE_INVALID);
|
||||
mask &= ~SAILFISH_CELL_PROPERTY_REGISTERED;
|
||||
mask &= ~CELL_PROPERTY_REGISTERED;
|
||||
}
|
||||
|
||||
for (i = 0; i < n && mask; i++) {
|
||||
@@ -420,74 +427,72 @@ static void sailfish_cell_info_dbus_property_changed
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_cell_info_dbus_update_entries
|
||||
(struct sailfish_cell_info_dbus *dbus, gboolean emit_signals)
|
||||
static void cell_info_dbus_update_entries(CellInfoDBus *dbus, gboolean emit)
|
||||
{
|
||||
GSList *l;
|
||||
GPtrArray* added = NULL;
|
||||
GPtrArray* removed = NULL;
|
||||
const ofono_cell_ptr *c;
|
||||
|
||||
/* Remove non-existent cells */
|
||||
l = dbus->entries;
|
||||
while (l) {
|
||||
GSList *next = l->next;
|
||||
struct sailfish_cell_entry *entry = l->data;
|
||||
if (!g_slist_find_custom(dbus->info->cells, &entry->cell,
|
||||
sailfish_cell_compare_func)) {
|
||||
CellEntry *entry = l->data;
|
||||
|
||||
if (!cell_info_dbus_find_ofono_cell(dbus->info, &entry->cell)) {
|
||||
DBG("%s removed", entry->path);
|
||||
dbus->entries = g_slist_delete_link(dbus->entries, l);
|
||||
sailfish_cell_info_dbus_emit_signal(dbus, entry->path,
|
||||
CELL_DBUS_INTERFACE,
|
||||
CELL_DBUS_REMOVED_SIGNAL,
|
||||
DBUS_TYPE_INVALID);
|
||||
cell_info_dbus_emit_signal(dbus, entry->path,
|
||||
CELL_DBUS_INTERFACE,
|
||||
CELL_DBUS_REMOVED_SIGNAL,
|
||||
DBUS_TYPE_INVALID);
|
||||
g_dbus_unregister_interface(dbus->conn, entry->path,
|
||||
CELL_DBUS_INTERFACE);
|
||||
if (emit_signals) {
|
||||
CELL_DBUS_INTERFACE);
|
||||
if (emit) {
|
||||
if (!removed) {
|
||||
removed =
|
||||
g_ptr_array_new_with_free_func(
|
||||
g_free);
|
||||
removed = g_ptr_array_new_with_free_func
|
||||
(g_free);
|
||||
}
|
||||
/* Steal the path */
|
||||
g_ptr_array_add(removed, entry->path);
|
||||
entry->path = NULL;
|
||||
}
|
||||
sailfish_cell_info_destroy_entry(entry);
|
||||
cell_info_destroy_entry(entry);
|
||||
}
|
||||
l = next;
|
||||
}
|
||||
|
||||
/* Add new cells */
|
||||
for (l = dbus->info->cells; l; l = l->next) {
|
||||
const struct sailfish_cell *cell = l->data;
|
||||
struct sailfish_cell_entry *entry =
|
||||
sailfish_cell_info_dbus_find_cell(dbus, cell);
|
||||
for (c = dbus->info->cells; *c; c++) {
|
||||
const struct ofono_cell *cell = *c;
|
||||
CellEntry *entry = cell_info_dbus_find_cell(dbus, cell);
|
||||
|
||||
if (entry) {
|
||||
if (emit_signals) {
|
||||
int diff = sailfish_cell_info_dbus_compare(cell,
|
||||
&entry->cell);
|
||||
if (emit) {
|
||||
const int diff = cell_info_dbus_compare(cell,
|
||||
&entry->cell);
|
||||
|
||||
entry->cell = *cell;
|
||||
sailfish_cell_info_dbus_property_changed(dbus,
|
||||
entry, diff);
|
||||
cell_info_dbus_property_changed(dbus, entry,
|
||||
diff);
|
||||
} else {
|
||||
entry->cell = *cell;
|
||||
}
|
||||
} else {
|
||||
entry = g_new0(struct sailfish_cell_entry, 1);
|
||||
entry = g_new0(CellEntry, 1);
|
||||
entry->cell = *cell;
|
||||
entry->cell_id =
|
||||
sailfish_cell_info_dbus_next_cell_id(dbus);
|
||||
entry->cell_id = cell_info_dbus_next_cell_id(dbus);
|
||||
entry->path = g_strdup_printf("%s/cell_%u", dbus->path,
|
||||
entry->cell_id);
|
||||
entry->cell_id);
|
||||
dbus->entries = g_slist_append(dbus->entries, entry);
|
||||
DBG("%s added", entry->path);
|
||||
g_dbus_register_interface(dbus->conn, entry->path,
|
||||
CELL_DBUS_INTERFACE,
|
||||
sailfish_cell_info_dbus_cell_methods,
|
||||
sailfish_cell_info_dbus_cell_signals, NULL,
|
||||
cell_info_dbus_cell_methods,
|
||||
cell_info_dbus_cell_signals, NULL,
|
||||
entry, NULL);
|
||||
if (emit_signals) {
|
||||
if (emit) {
|
||||
if (!added) {
|
||||
added = g_ptr_array_new();
|
||||
}
|
||||
@@ -497,37 +502,36 @@ static void sailfish_cell_info_dbus_update_entries
|
||||
}
|
||||
|
||||
if (removed) {
|
||||
sailfish_cell_info_dbus_emit_path_list(dbus,
|
||||
cell_info_dbus_emit_path_list(dbus,
|
||||
CELL_INFO_DBUS_CELLS_REMOVED_SIGNAL, removed);
|
||||
g_ptr_array_free(removed, TRUE);
|
||||
}
|
||||
|
||||
if (added) {
|
||||
sailfish_cell_info_dbus_emit_path_list(dbus,
|
||||
cell_info_dbus_emit_path_list(dbus,
|
||||
CELL_INFO_DBUS_CELLS_ADDED_SIGNAL, added);
|
||||
g_ptr_array_free(added, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_cell_info_dbus_cells_changed_cb
|
||||
(struct sailfish_cell_info *info, void *arg)
|
||||
static void cell_info_dbus_cells_changed_cb(struct ofono_cell_info *info,
|
||||
void *data)
|
||||
{
|
||||
DBG("");
|
||||
sailfish_cell_info_dbus_update_entries
|
||||
((struct sailfish_cell_info_dbus *)arg, TRUE);
|
||||
cell_info_dbus_update_entries((CellInfoDBus *) data, TRUE);
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_cell_info_dbus_error_failed(DBusMessage *msg,
|
||||
const char *explanation)
|
||||
static DBusMessage *cell_info_dbus_error_failed(DBusMessage *msg,
|
||||
const char *explanation)
|
||||
{
|
||||
return g_dbus_create_error(msg, OFONO_ERROR_INTERFACE ".Failed", "%s",
|
||||
explanation);
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_cell_info_dbus_get_cells(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
static DBusMessage *cell_info_dbus_get_cells(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
struct sailfish_cell_info_dbus *dbus = data;
|
||||
CellInfoDBus *dbus = data;
|
||||
const char *sender = dbus_message_get_sender(msg);
|
||||
|
||||
if (ofono_dbus_clients_add(dbus->clients, sender)) {
|
||||
@@ -535,11 +539,11 @@ static DBusMessage *sailfish_cell_info_dbus_get_cells(DBusConnection *conn,
|
||||
DBusMessageIter it, a;
|
||||
GSList *l;
|
||||
|
||||
sailfish_cell_info_set_enabled(dbus->info, TRUE);
|
||||
ofono_cell_info_set_enabled(dbus->info, TRUE);
|
||||
dbus_message_iter_init_append(reply, &it);
|
||||
dbus_message_iter_open_container(&it, DBUS_TYPE_ARRAY, "o", &a);
|
||||
for (l = dbus->entries; l; l = l->next) {
|
||||
const struct sailfish_cell_entry *entry = l->data;
|
||||
const CellEntry *entry = l->data;
|
||||
|
||||
dbus_message_iter_append_basic(&a,
|
||||
DBUS_TYPE_OBJECT_PATH, &entry->path);
|
||||
@@ -547,13 +551,13 @@ static DBusMessage *sailfish_cell_info_dbus_get_cells(DBusConnection *conn,
|
||||
dbus_message_iter_close_container(&it, &a);
|
||||
return reply;
|
||||
}
|
||||
return sailfish_cell_info_dbus_error_failed(msg, "Operation failed");
|
||||
return cell_info_dbus_error_failed(msg, "Operation failed");
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_cell_info_dbus_unsubscribe(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
static DBusMessage *cell_info_dbus_unsubscribe(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
struct sailfish_cell_info_dbus *dbus = data;
|
||||
CellInfoDBus *dbus = data;
|
||||
const char *sender = dbus_message_get_sender(msg);
|
||||
|
||||
DBG("%s", sender);
|
||||
@@ -563,25 +567,25 @@ static DBusMessage *sailfish_cell_info_dbus_unsubscribe(DBusConnection *conn,
|
||||
CELL_INFO_DBUS_UNSUBSCRIBED_SIGNAL);
|
||||
|
||||
if (!ofono_dbus_clients_count(dbus->clients)) {
|
||||
sailfish_cell_info_set_enabled(dbus->info, FALSE);
|
||||
ofono_cell_info_set_enabled(dbus->info, FALSE);
|
||||
}
|
||||
dbus_message_set_destination(signal, sender);
|
||||
g_dbus_send_message(dbus->conn, signal);
|
||||
return dbus_message_new_method_return(msg);
|
||||
}
|
||||
return sailfish_cell_info_dbus_error_failed(msg, "Not subscribed");
|
||||
return cell_info_dbus_error_failed(msg, "Not subscribed");
|
||||
}
|
||||
|
||||
static const GDBusMethodTable sailfish_cell_info_dbus_methods[] = {
|
||||
static const GDBusMethodTable cell_info_dbus_methods[] = {
|
||||
{ GDBUS_METHOD("GetCells", NULL,
|
||||
GDBUS_ARGS({ "paths", "ao" }),
|
||||
sailfish_cell_info_dbus_get_cells) },
|
||||
cell_info_dbus_get_cells) },
|
||||
{ GDBUS_METHOD("Unsubscribe", NULL, NULL,
|
||||
sailfish_cell_info_dbus_unsubscribe) },
|
||||
cell_info_dbus_unsubscribe) },
|
||||
{ }
|
||||
};
|
||||
|
||||
static const GDBusSignalTable sailfish_cell_info_dbus_signals[] = {
|
||||
static const GDBusSignalTable cell_info_dbus_signals[] = {
|
||||
{ GDBUS_SIGNAL(CELL_INFO_DBUS_CELLS_ADDED_SIGNAL,
|
||||
GDBUS_ARGS({ "paths", "ao" })) },
|
||||
{ GDBUS_SIGNAL(CELL_INFO_DBUS_CELLS_REMOVED_SIGNAL,
|
||||
@@ -591,51 +595,49 @@ static const GDBusSignalTable sailfish_cell_info_dbus_signals[] = {
|
||||
{ }
|
||||
};
|
||||
|
||||
static void sailfish_cell_info_dbus_disconnect_cb(const char *name, void *data)
|
||||
static void cell_info_dbus_disconnect_cb(const char *name, void *data)
|
||||
{
|
||||
struct sailfish_cell_info_dbus *dbus = data;
|
||||
CellInfoDBus *dbus = data;
|
||||
|
||||
if (!ofono_dbus_clients_count(dbus->clients)) {
|
||||
sailfish_cell_info_set_enabled(dbus->info, FALSE);
|
||||
ofono_cell_info_set_enabled(dbus->info, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
struct sailfish_cell_info_dbus *sailfish_cell_info_dbus_new
|
||||
(struct ofono_modem *modem, struct sailfish_cell_info *info)
|
||||
CellInfoDBus *cell_info_dbus_new(struct ofono_modem *modem,
|
||||
struct ofono_cell_info *info)
|
||||
{
|
||||
if (modem && info) {
|
||||
struct sailfish_cell_info_dbus *dbus =
|
||||
g_new0(struct sailfish_cell_info_dbus, 1);
|
||||
CellInfoDBus *dbus = g_new0(CellInfoDBus, 1);
|
||||
|
||||
DBG("%s", ofono_modem_get_path(modem));
|
||||
dbus->path = g_strdup(ofono_modem_get_path(modem));
|
||||
dbus->conn = dbus_connection_ref(ofono_dbus_get_connection());
|
||||
dbus->info = sailfish_cell_info_ref(info);
|
||||
dbus->handler_id =
|
||||
sailfish_cell_info_add_cells_changed_handler(info,
|
||||
sailfish_cell_info_dbus_cells_changed_cb, dbus);
|
||||
dbus->info = ofono_cell_info_ref(info);
|
||||
dbus->handler_id = ofono_cell_info_add_change_handler(info,
|
||||
cell_info_dbus_cells_changed_cb, dbus);
|
||||
|
||||
/* Register D-Bus interface */
|
||||
if (g_dbus_register_interface(dbus->conn, dbus->path,
|
||||
CELL_INFO_DBUS_INTERFACE,
|
||||
sailfish_cell_info_dbus_methods,
|
||||
sailfish_cell_info_dbus_signals,
|
||||
NULL, dbus, NULL)) {
|
||||
CELL_INFO_DBUS_INTERFACE,
|
||||
cell_info_dbus_methods,
|
||||
cell_info_dbus_signals,
|
||||
NULL, dbus, NULL)) {
|
||||
ofono_modem_add_interface(modem,
|
||||
CELL_INFO_DBUS_INTERFACE);
|
||||
sailfish_cell_info_dbus_update_entries(dbus, FALSE);
|
||||
CELL_INFO_DBUS_INTERFACE);
|
||||
cell_info_dbus_update_entries(dbus, FALSE);
|
||||
dbus->clients = ofono_dbus_clients_new(dbus->conn,
|
||||
sailfish_cell_info_dbus_disconnect_cb, dbus);
|
||||
cell_info_dbus_disconnect_cb, dbus);
|
||||
return dbus;
|
||||
} else {
|
||||
ofono_error("CellInfo D-Bus register failed");
|
||||
sailfish_cell_info_dbus_free(dbus);
|
||||
cell_info_dbus_free(dbus);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void sailfish_cell_info_dbus_free(struct sailfish_cell_info_dbus *dbus)
|
||||
void cell_info_dbus_free(CellInfoDBus *dbus)
|
||||
{
|
||||
if (dbus) {
|
||||
GSList *l;
|
||||
@@ -643,23 +645,23 @@ void sailfish_cell_info_dbus_free(struct sailfish_cell_info_dbus *dbus)
|
||||
DBG("%s", dbus->path);
|
||||
ofono_dbus_clients_free(dbus->clients);
|
||||
g_dbus_unregister_interface(dbus->conn, dbus->path,
|
||||
CELL_INFO_DBUS_INTERFACE);
|
||||
CELL_INFO_DBUS_INTERFACE);
|
||||
|
||||
/* Unregister cells */
|
||||
l = dbus->entries;
|
||||
while (l) {
|
||||
struct sailfish_cell_entry *entry = l->data;
|
||||
CellEntry *entry = l->data;
|
||||
g_dbus_unregister_interface(dbus->conn, entry->path,
|
||||
CELL_DBUS_INTERFACE);
|
||||
sailfish_cell_info_destroy_entry(entry);
|
||||
CELL_DBUS_INTERFACE);
|
||||
cell_info_destroy_entry(entry);
|
||||
l = l->next;
|
||||
}
|
||||
g_slist_free(dbus->entries);
|
||||
|
||||
dbus_connection_unref(dbus->conn);
|
||||
|
||||
sailfish_cell_info_remove_handler(dbus->info, dbus->handler_id);
|
||||
sailfish_cell_info_unref(dbus->info);
|
||||
ofono_cell_info_remove_handler(dbus->info, dbus->handler_id);
|
||||
ofono_cell_info_unref(dbus->info);
|
||||
|
||||
g_free(dbus->path);
|
||||
g_free(dbus);
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2017 Jolla Ltd.
|
||||
* Copyright (C) 2016-2021 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
|
||||
@@ -13,19 +13,18 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef SAILFISH_CELL_INFO_DBUS_H
|
||||
#define SAILFISH_CELL_INFO_DBUS_H
|
||||
#ifndef CELL_INFO_DBUS_H
|
||||
#define CELL_INFO_DBUS_H
|
||||
|
||||
struct ofono_modem;
|
||||
struct ofono_cell_info;
|
||||
|
||||
struct sailfish_cell_info;
|
||||
struct sailfish_cell_info_dbus;
|
||||
struct cell_info_dbus;
|
||||
struct cell_info_dbus *cell_info_dbus_new(struct ofono_modem *modem,
|
||||
struct ofono_cell_info *ci);
|
||||
void cell_info_dbus_free(struct cell_info_dbus *dbus);
|
||||
|
||||
struct sailfish_cell_info_dbus *sailfish_cell_info_dbus_new
|
||||
(struct ofono_modem *modem, struct sailfish_cell_info *info);
|
||||
void sailfish_cell_info_dbus_free(struct sailfish_cell_info_dbus *dbus);
|
||||
|
||||
#endif /* SAILFISH_CELL_INFO_DBUS_H */
|
||||
#endif /* CELL_INFO_DBUS_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017-2019 Jolla Ltd.
|
||||
* Copyright (C) 2017-2021 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
|
||||
@@ -13,19 +13,17 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <sailfish_cell_info.h>
|
||||
#include "ofono.h"
|
||||
|
||||
#include <gutil_log.h>
|
||||
|
||||
gint sailfish_cell_compare_location(const struct sailfish_cell *c1,
|
||||
const struct sailfish_cell *c2)
|
||||
int ofono_cell_compare_location(const struct ofono_cell *c1,
|
||||
const struct ofono_cell *c2)
|
||||
{
|
||||
if (c1 && c2) {
|
||||
if (c1->type != c2->type) {
|
||||
return c1->type - c2->type;
|
||||
} else if (c1->type == SAILFISH_CELL_TYPE_GSM) {
|
||||
const struct sailfish_cell_info_gsm *g1;
|
||||
const struct sailfish_cell_info_gsm *g2;
|
||||
} else if (c1->type == OFONO_CELL_TYPE_GSM) {
|
||||
const struct ofono_cell_info_gsm *g1;
|
||||
const struct ofono_cell_info_gsm *g2;
|
||||
|
||||
g1 = &c1->info.gsm;
|
||||
g2 = &c2->info.gsm;
|
||||
@@ -38,9 +36,9 @@ gint sailfish_cell_compare_location(const struct sailfish_cell *c1,
|
||||
} else {
|
||||
return g1->cid - g2->cid;
|
||||
}
|
||||
} else if (c2->type == SAILFISH_CELL_TYPE_WCDMA) {
|
||||
const struct sailfish_cell_info_wcdma *w1;
|
||||
const struct sailfish_cell_info_wcdma *w2;
|
||||
} else if (c1->type == OFONO_CELL_TYPE_WCDMA) {
|
||||
const struct ofono_cell_info_wcdma *w1;
|
||||
const struct ofono_cell_info_wcdma *w2;
|
||||
|
||||
w1 = &c1->info.wcdma;
|
||||
w2 = &c2->info.wcdma;
|
||||
@@ -53,13 +51,12 @@ gint sailfish_cell_compare_location(const struct sailfish_cell *c1,
|
||||
} else {
|
||||
return w1->cid - w2->cid;
|
||||
}
|
||||
} else {
|
||||
const struct sailfish_cell_info_lte *l1 =
|
||||
} else if (c1->type == OFONO_CELL_TYPE_LTE) {
|
||||
const struct ofono_cell_info_lte *l1 =
|
||||
&c1->info.lte;
|
||||
const struct sailfish_cell_info_lte *l2 =
|
||||
const struct ofono_cell_info_lte *l2 =
|
||||
&c2->info.lte;
|
||||
|
||||
GASSERT(c1->type == SAILFISH_CELL_TYPE_LTE);
|
||||
l1 = &c1->info.lte;
|
||||
l2 = &c2->info.lte;
|
||||
if (l1->mcc != l2->mcc) {
|
||||
@@ -73,6 +70,9 @@ gint sailfish_cell_compare_location(const struct sailfish_cell *c1,
|
||||
} else {
|
||||
return l1->tac - l2->tac;
|
||||
}
|
||||
} else {
|
||||
ofono_warn("Unexpected cell type");
|
||||
return 0;
|
||||
}
|
||||
} else if (c1) {
|
||||
return 1;
|
||||
@@ -83,56 +83,48 @@ gint sailfish_cell_compare_location(const struct sailfish_cell *c1,
|
||||
}
|
||||
}
|
||||
|
||||
gint sailfish_cell_compare_func(gconstpointer v1, gconstpointer v2)
|
||||
struct ofono_cell_info *ofono_cell_info_ref(struct ofono_cell_info *ci)
|
||||
{
|
||||
return sailfish_cell_compare_location(v1, v2);
|
||||
}
|
||||
|
||||
struct sailfish_cell_info *sailfish_cell_info_ref
|
||||
(struct sailfish_cell_info *info)
|
||||
{
|
||||
if (info) {
|
||||
info->proc->ref(info);
|
||||
return info;
|
||||
if (ci && ci->proc->ref) {
|
||||
ci->proc->ref(ci);
|
||||
}
|
||||
return NULL;
|
||||
return ci;
|
||||
}
|
||||
|
||||
void sailfish_cell_info_unref(struct sailfish_cell_info *info)
|
||||
void ofono_cell_info_unref(struct ofono_cell_info *ci)
|
||||
{
|
||||
if (info) {
|
||||
info->proc->unref(info);
|
||||
if (ci && ci->proc->unref) {
|
||||
ci->proc->unref(ci);
|
||||
}
|
||||
}
|
||||
|
||||
gulong sailfish_cell_info_add_cells_changed_handler
|
||||
(struct sailfish_cell_info *info,
|
||||
sailfish_cell_info_cb_t cb, void *arg)
|
||||
unsigned long ofono_cell_info_add_change_handler(struct ofono_cell_info *ci,
|
||||
ofono_cell_info_cb_t cb, void *data)
|
||||
{
|
||||
return info ? info->proc->add_cells_changed_handler(info, cb, arg) : 0;
|
||||
return (ci && ci->proc->add_change_handler && cb) ?
|
||||
ci->proc->add_change_handler(ci, cb, data) : 0;
|
||||
}
|
||||
|
||||
void sailfish_cell_info_remove_handler(struct sailfish_cell_info *info,
|
||||
gulong id)
|
||||
void ofono_cell_info_remove_handler(struct ofono_cell_info *ci,
|
||||
unsigned long id)
|
||||
{
|
||||
if (info) {
|
||||
info->proc->remove_handler(info, id);
|
||||
if (ci && ci->proc->remove_handler && id) {
|
||||
ci->proc->remove_handler(ci, id);
|
||||
}
|
||||
}
|
||||
|
||||
void sailfish_cell_info_set_update_interval(struct sailfish_cell_info *info,
|
||||
int ms)
|
||||
void ofono_cell_info_set_update_interval(struct ofono_cell_info *ci, int ms)
|
||||
{
|
||||
if (info && info->proc->set_update_interval) {
|
||||
info->proc->set_update_interval(info, ms);
|
||||
if (ci && ci->proc->set_update_interval) {
|
||||
ci->proc->set_update_interval(ci, ms);
|
||||
}
|
||||
}
|
||||
|
||||
void sailfish_cell_info_set_enabled(struct sailfish_cell_info *info,
|
||||
gboolean enabled)
|
||||
void ofono_cell_info_set_enabled(struct ofono_cell_info *ci,
|
||||
ofono_bool_t enabled)
|
||||
{
|
||||
if (info && info->proc->set_enabled) {
|
||||
info->proc->set_enabled(info, enabled);
|
||||
if (ci && ci->proc->set_enabled) {
|
||||
ci->proc->set_enabled(ci, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2015-2021 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
|
||||
@@ -29,7 +30,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <ofono/types.h>
|
||||
#include <ofono/misc.h>
|
||||
#include <ofono/gprs-context.h>
|
||||
#include "common.h"
|
||||
#include "util.h"
|
||||
@@ -422,10 +423,9 @@ int mmi_service_code_to_bearer_class(int code)
|
||||
return cls;
|
||||
}
|
||||
|
||||
const char *phone_number_to_string(const struct ofono_phone_number *ph)
|
||||
const char *ofono_phone_number_to_string(const struct ofono_phone_number *ph,
|
||||
char buffer[/* OFONO_MAX_PHONE_NUMBER_BUFFER_SIZE */])
|
||||
{
|
||||
static char buffer[OFONO_MAX_PHONE_NUMBER_LENGTH + 2];
|
||||
|
||||
if (ph->type == 145 && (strlen(ph->number) > 0) &&
|
||||
ph->number[0] != '+') {
|
||||
buffer[0] = '+';
|
||||
@@ -439,6 +439,13 @@ const char *phone_number_to_string(const struct ofono_phone_number *ph)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
const char *phone_number_to_string(const struct ofono_phone_number *ph)
|
||||
{
|
||||
static char buffer[OFONO_PHONE_NUMBER_BUFFER_SIZE];
|
||||
|
||||
return ofono_phone_number_to_string(ph, buffer);
|
||||
}
|
||||
|
||||
void string_to_phone_number(const char *str, struct ofono_phone_number *ph)
|
||||
{
|
||||
if (str[0] == '+') {
|
||||
@@ -654,7 +661,7 @@ const char *bearer_class_to_string(enum bearer_class cls)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *registration_status_to_string(int status)
|
||||
const char *registration_status_to_string(enum ofono_netreg_status status)
|
||||
{
|
||||
switch (status) {
|
||||
case NETWORK_REGISTRATION_STATUS_NOT_REGISTERED:
|
||||
@@ -669,12 +676,14 @@ const char *registration_status_to_string(int status)
|
||||
return "unknown";
|
||||
case NETWORK_REGISTRATION_STATUS_ROAMING:
|
||||
return "roaming";
|
||||
case OFONO_NETREG_STATUS_NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
const char *registration_tech_to_string(int tech)
|
||||
const char *registration_tech_to_string(enum ofono_access_technology tech)
|
||||
{
|
||||
switch (tech) {
|
||||
case ACCESS_TECHNOLOGY_GSM:
|
||||
@@ -693,9 +702,10 @@ const char *registration_tech_to_string(int tech)
|
||||
return "hspa";
|
||||
case ACCESS_TECHNOLOGY_EUTRAN:
|
||||
return "lte";
|
||||
default:
|
||||
return "";
|
||||
case OFONO_ACCESS_TECHNOLOGY_NONE:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
gboolean is_valid_apn(const char *apn)
|
||||
@@ -765,3 +775,15 @@ const char *call_status_to_string(enum call_status status)
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
/* Public API exported to external plugins */
|
||||
|
||||
const char *ofono_netreg_status_to_string(enum ofono_netreg_status status)
|
||||
{
|
||||
return registration_status_to_string(status);
|
||||
}
|
||||
|
||||
const char *ofono_access_technology_to_string(enum ofono_access_technology tech)
|
||||
{
|
||||
return registration_tech_to_string(tech);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2015-2021 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,43 +23,88 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <ofono/types.h>
|
||||
#include <ofono/netreg.h>
|
||||
|
||||
/* 27.007 Section 7.3 <AcT> */
|
||||
enum access_technology {
|
||||
ACCESS_TECHNOLOGY_GSM = 0,
|
||||
ACCESS_TECHNOLOGY_GSM_COMPACT = 1,
|
||||
ACCESS_TECHNOLOGY_UTRAN = 2,
|
||||
ACCESS_TECHNOLOGY_GSM_EGPRS = 3,
|
||||
ACCESS_TECHNOLOGY_UTRAN_HSDPA = 4,
|
||||
ACCESS_TECHNOLOGY_UTRAN_HSUPA = 5,
|
||||
ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA = 6,
|
||||
ACCESS_TECHNOLOGY_EUTRAN = 7,
|
||||
};
|
||||
#define ACCESS_TECHNOLOGY_GSM \
|
||||
OFONO_ACCESS_TECHNOLOGY_GSM /* 0 */
|
||||
#define ACCESS_TECHNOLOGY_GSM_COMPACT \
|
||||
OFONO_ACCESS_TECHNOLOGY_GSM_COMPACT /* 1 */
|
||||
#define ACCESS_TECHNOLOGY_UTRAN \
|
||||
OFONO_ACCESS_TECHNOLOGY_UTRAN /* 2 */
|
||||
#define ACCESS_TECHNOLOGY_GSM_EGPRS \
|
||||
OFONO_ACCESS_TECHNOLOGY_GSM_EGPRS /* 3 */
|
||||
#define ACCESS_TECHNOLOGY_UTRAN_HSDPA \
|
||||
OFONO_ACCESS_TECHNOLOGY_UTRAN_HSDPA /* 4 */
|
||||
#define ACCESS_TECHNOLOGY_UTRAN_HSUPA \
|
||||
OFONO_ACCESS_TECHNOLOGY_UTRAN_HSUPA /* 5 */
|
||||
#define ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA \
|
||||
OFONO_ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA /* 6 */
|
||||
#define ACCESS_TECHNOLOGY_EUTRAN \
|
||||
OFONO_ACCESS_TECHNOLOGY_EUTRAN /* 7 */
|
||||
|
||||
/* 27.007 Section 7.2 <stat> */
|
||||
enum network_registration_status {
|
||||
NETWORK_REGISTRATION_STATUS_NOT_REGISTERED = 0,
|
||||
NETWORK_REGISTRATION_STATUS_REGISTERED = 1,
|
||||
NETWORK_REGISTRATION_STATUS_SEARCHING = 2,
|
||||
NETWORK_REGISTRATION_STATUS_DENIED = 3,
|
||||
NETWORK_REGISTRATION_STATUS_UNKNOWN = 4,
|
||||
NETWORK_REGISTRATION_STATUS_ROAMING = 5,
|
||||
};
|
||||
#define NETWORK_REGISTRATION_STATUS_NOT_REGISTERED \
|
||||
OFONO_NETREG_STATUS_NOT_REGISTERED /* 0 */
|
||||
#define NETWORK_REGISTRATION_STATUS_REGISTERED \
|
||||
OFONO_NETREG_STATUS_REGISTERED /* 1 */
|
||||
#define NETWORK_REGISTRATION_STATUS_SEARCHING \
|
||||
OFONO_NETREG_STATUS_SEARCHING /* 2 */
|
||||
#define NETWORK_REGISTRATION_STATUS_DENIED \
|
||||
OFONO_NETREG_STATUS_DENIED /* 3 */
|
||||
#define NETWORK_REGISTRATION_STATUS_UNKNOWN \
|
||||
OFONO_NETREG_STATUS_UNKNOWN /* 4 */
|
||||
#define NETWORK_REGISTRATION_STATUS_ROAMING \
|
||||
OFONO_NETREG_STATUS_ROAMING /* 5 */
|
||||
|
||||
/* 27.007 Section 7.3 <stat> */
|
||||
enum operator_status {
|
||||
OPERATOR_STATUS_UNKNOWN = 0,
|
||||
OPERATOR_STATUS_AVAILABLE = 1,
|
||||
OPERATOR_STATUS_CURRENT = 2,
|
||||
OPERATOR_STATUS_FORBIDDEN = 3,
|
||||
};
|
||||
#define OPERATOR_STATUS_UNKNOWN \
|
||||
OFONO_OPERATOR_STATUS_UNKNOWN /* 0 */
|
||||
#define OPERATOR_STATUS_AVAILABLE \
|
||||
OFONO_OPERATOR_STATUS_AVAILABLE /* 1 */
|
||||
#define OPERATOR_STATUS_CURRENT \
|
||||
OFONO_OPERATOR_STATUS_CURRENT /* 2 */
|
||||
#define OPERATOR_STATUS_FORBIDDEN \
|
||||
OFONO_OPERATOR_STATUS_FORBIDDEN /* 3 */
|
||||
|
||||
/* 27.007 Section 7.6 */
|
||||
enum clip_validity {
|
||||
CLIP_VALIDITY_VALID = 0,
|
||||
CLIP_VALIDITY_WITHHELD = 1,
|
||||
CLIP_VALIDITY_NOT_AVAILABLE = 2,
|
||||
};
|
||||
#define CLIP_VALIDITY_VALID \
|
||||
OFONO_CLIP_VALIDITY_VALID /* 0 */
|
||||
#define CLIP_VALIDITY_WITHHELD \
|
||||
OFONO_CLIP_VALIDITY_WITHHELD /* 1 */
|
||||
#define CLIP_VALIDITY_NOT_AVAILABLE \
|
||||
OFONO_CLIP_VALIDITY_NOT_AVAILABLE /* 2 */
|
||||
|
||||
/* 27.007 Section 7.30 */
|
||||
#define CNAP_VALIDITY_VALID \
|
||||
OFONO_CNAP_VALIDITY_VALID /* 0 */
|
||||
#define CNAP_VALIDITY_WITHHELD \
|
||||
OFONO_CNAP_VALIDITY_WITHHELD /* 1 */
|
||||
#define CNAP_VALIDITY_NOT_AVAILABLE \
|
||||
OFONO_CNAP_VALIDITY_NOT_AVAILABLE /* 2 */
|
||||
|
||||
/* 27.007 Section 7.18 */
|
||||
#define call_status ofono_call_status
|
||||
#define CALL_STATUS_ACTIVE \
|
||||
OFONO_CALL_STATUS_ACTIVE /* 0 */
|
||||
#define CALL_STATUS_HELD \
|
||||
OFONO_CALL_STATUS_HELD /* 1 */
|
||||
#define CALL_STATUS_DIALING \
|
||||
OFONO_CALL_STATUS_DIALING /* 2 */
|
||||
#define CALL_STATUS_ALERTING \
|
||||
OFONO_CALL_STATUS_ALERTING /* 3 */
|
||||
#define CALL_STATUS_INCOMING \
|
||||
OFONO_CALL_STATUS_INCOMING /* 4 */
|
||||
#define CALL_STATUS_WAITING \
|
||||
OFONO_CALL_STATUS_WAITING /* 5 */
|
||||
#define CALL_STATUS_DISCONNECTED \
|
||||
OFONO_CALL_STATUS_DISCONNECTED
|
||||
|
||||
/* 27.007 Section 7.18 */
|
||||
#define CALL_DIRECTION_MOBILE_ORIGINATED \
|
||||
OFONO_CALL_DIRECTION_MOBILE_ORIGINATED /* 0 */
|
||||
#define CALL_DIRECTION_MOBILE_TERMINATED \
|
||||
OFONO_CALL_DIRECTION_MOBILE_TERMINATED /* 1 */
|
||||
|
||||
/* 27.007 Section 7.29 */
|
||||
enum packet_bearer {
|
||||
@@ -72,30 +118,6 @@ enum packet_bearer {
|
||||
PACKET_BEARER_EPS = 7,
|
||||
};
|
||||
|
||||
/* 27.007 Section 7.30 */
|
||||
enum cnap_validity {
|
||||
CNAP_VALIDITY_VALID = 0,
|
||||
CNAP_VALIDITY_WITHHELD = 1,
|
||||
CNAP_VALIDITY_NOT_AVAILABLE = 2,
|
||||
};
|
||||
|
||||
/* 27.007 Section 7.18 */
|
||||
enum call_status {
|
||||
CALL_STATUS_ACTIVE = 0,
|
||||
CALL_STATUS_HELD = 1,
|
||||
CALL_STATUS_DIALING = 2,
|
||||
CALL_STATUS_ALERTING = 3,
|
||||
CALL_STATUS_INCOMING = 4,
|
||||
CALL_STATUS_WAITING = 5,
|
||||
CALL_STATUS_DISCONNECTED
|
||||
};
|
||||
|
||||
/* 27.007 Section 7.18 */
|
||||
enum call_direction {
|
||||
CALL_DIRECTION_MOBILE_ORIGINATED = 0,
|
||||
CALL_DIRECTION_MOBILE_TERMINATED = 1,
|
||||
};
|
||||
|
||||
/* 27.007 Section 7.11 */
|
||||
enum bearer_class {
|
||||
BEARER_CLASS_VOICE = 1,
|
||||
@@ -179,8 +201,8 @@ const char *ss_control_type_to_string(enum ss_control_type type);
|
||||
|
||||
const char *bearer_class_to_string(enum bearer_class cls);
|
||||
|
||||
const char *registration_status_to_string(int status);
|
||||
const char *registration_tech_to_string(int tech);
|
||||
const char *registration_status_to_string(enum ofono_netreg_status status);
|
||||
const char *registration_tech_to_string(enum ofono_access_technology tech);
|
||||
const char *packet_bearer_to_string(int bearer);
|
||||
|
||||
gboolean is_valid_apn(const char *apn);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2015-2019 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
* Copyright (C) 2019 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -18,7 +18,8 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "ofono.h"
|
||||
#include <ofono/conf.h>
|
||||
#include <ofono/log.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
@@ -26,7 +27,7 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
/**
|
||||
* The config_merge_files() function does the following:
|
||||
* The ofono_conf_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/")
|
||||
@@ -76,12 +77,12 @@
|
||||
* c=5
|
||||
*
|
||||
* Note that the list separator is assumed to be ',' (rather than default ';').
|
||||
* The keyfile passed to config_merge_files() should use the same list
|
||||
* The keyfile passed to ofono_conf_merge_files() should use the same list
|
||||
* separator, because the default values are copied from the config files
|
||||
* as is.
|
||||
*/
|
||||
|
||||
static gint config_sort_files(gconstpointer a, gconstpointer b)
|
||||
static gint conf_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
|
||||
@@ -89,7 +90,7 @@ static gint config_sort_files(gconstpointer a, gconstpointer b)
|
||||
return strcmp(*(char**)a, *(char**)b);
|
||||
}
|
||||
|
||||
static char **config_collect_files(const char *path, const char *suffix)
|
||||
static char **conf_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").
|
||||
@@ -119,7 +120,7 @@ static char **config_collect_files(const char *path, const char *suffix)
|
||||
}
|
||||
|
||||
if (list->len > 0) {
|
||||
g_ptr_array_sort(list, config_sort_files);
|
||||
g_ptr_array_sort(list, conf_sort_files);
|
||||
g_ptr_array_add(list, NULL);
|
||||
files = (char**)g_ptr_array_free(list, FALSE);
|
||||
} else {
|
||||
@@ -131,7 +132,7 @@ static char **config_collect_files(const char *path, const char *suffix)
|
||||
return files;
|
||||
}
|
||||
|
||||
static int config_list_find(char **list, gsize len, const char *value)
|
||||
static int conf_list_find(char **list, gsize len, const char *value)
|
||||
{
|
||||
guint i;
|
||||
|
||||
@@ -144,9 +145,8 @@ static int config_list_find(char **list, gsize len, const char *value)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void config_list_append(GKeyFile *conf, GKeyFile *k,
|
||||
const char *group, const char *key,
|
||||
char **values, gsize n, gboolean unique)
|
||||
static void conf_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) {
|
||||
@@ -163,7 +163,7 @@ static void config_list_append(GKeyFile *conf, GKeyFile *k,
|
||||
for (i = 0; i < (int)n; i++) {
|
||||
char *val = values[i];
|
||||
|
||||
if (!unique || config_list_find((char**)
|
||||
if (!unique || conf_list_find((char**)
|
||||
newlist->pdata, newlist->len, val) < 0) {
|
||||
/* Move the string to the new list */
|
||||
g_ptr_array_add(newlist, val);
|
||||
@@ -186,8 +186,8 @@ static void config_list_append(GKeyFile *conf, GKeyFile *k,
|
||||
}
|
||||
}
|
||||
|
||||
static void config_list_remove(GKeyFile *conf, GKeyFile *k,
|
||||
const char *group, const char *key, char **values, gsize n)
|
||||
static void conf_list_remove(GKeyFile *conf, GKeyFile *k,
|
||||
const char *group, const char *key, char **values, gsize n)
|
||||
{
|
||||
if (n > 0) {
|
||||
gsize len = 0;
|
||||
@@ -202,7 +202,7 @@ static void config_list_remove(GKeyFile *conf, GKeyFile *k,
|
||||
int pos;
|
||||
|
||||
/* Remove all matching values */
|
||||
while ((pos = config_list_find(list, len,
|
||||
while ((pos = conf_list_find(list, len,
|
||||
values[i])) >= 0) {
|
||||
g_free(list[pos]);
|
||||
memmove(list + pos, list + pos + 1,
|
||||
@@ -221,8 +221,7 @@ static void config_list_remove(GKeyFile *conf, GKeyFile *k,
|
||||
}
|
||||
}
|
||||
|
||||
static void config_merge_group(GKeyFile *conf, GKeyFile *k,
|
||||
const char *group)
|
||||
static void conf_merge_group(GKeyFile *conf, GKeyFile *k, const char *group)
|
||||
{
|
||||
gsize i, n = 0;
|
||||
char **keys = g_key_file_get_keys(k, group, &n, NULL);
|
||||
@@ -244,7 +243,7 @@ static void config_merge_group(GKeyFile *conf, GKeyFile *k,
|
||||
group, key, &count, NULL);
|
||||
|
||||
key[len-1] = 0;
|
||||
config_list_append(conf, k, group, key,
|
||||
conf_list_append(conf, k, group, key,
|
||||
values, count, last == '?');
|
||||
g_strfreev(values);
|
||||
} else if (last == '-') {
|
||||
@@ -253,7 +252,7 @@ static void config_merge_group(GKeyFile *conf, GKeyFile *k,
|
||||
group, key, &count, NULL);
|
||||
|
||||
key[len-1] = 0;
|
||||
config_list_remove(conf, k, group, key,
|
||||
conf_list_remove(conf, k, group, key,
|
||||
values, count);
|
||||
g_strfreev(values);
|
||||
} else {
|
||||
@@ -281,7 +280,7 @@ static void config_merge_group(GKeyFile *conf, GKeyFile *k,
|
||||
g_strfreev(keys);
|
||||
}
|
||||
|
||||
static void config_merge_keyfile(GKeyFile *conf, GKeyFile *k)
|
||||
static void conf_merge_keyfile(GKeyFile *conf, GKeyFile *k)
|
||||
{
|
||||
gsize i, n = 0;
|
||||
char **groups = g_key_file_get_groups(k, &n);
|
||||
@@ -292,27 +291,27 @@ static void config_merge_keyfile(GKeyFile *conf, GKeyFile *k)
|
||||
if (group[0] == '!') {
|
||||
g_key_file_remove_group(conf, group + 1, NULL);
|
||||
} else {
|
||||
config_merge_group(conf, k, group);
|
||||
conf_merge_group(conf, k, group);
|
||||
}
|
||||
}
|
||||
|
||||
g_strfreev(groups);
|
||||
}
|
||||
|
||||
static void config_merge_file(GKeyFile *conf, const char *file)
|
||||
static void conf_merge_file(GKeyFile *conf, const char *file)
|
||||
{
|
||||
GKeyFile *k = g_key_file_new();
|
||||
|
||||
g_key_file_set_list_separator(k, ',');
|
||||
|
||||
if (g_key_file_load_from_file(k, file, 0, NULL)) {
|
||||
config_merge_keyfile(conf, k);
|
||||
conf_merge_keyfile(conf, k);
|
||||
}
|
||||
|
||||
g_key_file_unref(k);
|
||||
}
|
||||
|
||||
void config_merge_files(GKeyFile *conf, const char *file)
|
||||
void ofono_conf_merge_files(GKeyFile *conf, const char *file)
|
||||
{
|
||||
if (conf && file && file[0]) {
|
||||
char *dot = strrchr(file, '.');
|
||||
@@ -334,13 +333,13 @@ void config_merge_files(GKeyFile *conf, const char *file)
|
||||
suffix = dot + 1;
|
||||
}
|
||||
|
||||
files = config_collect_files(dir, suffix);
|
||||
files = conf_collect_files(dir, suffix);
|
||||
g_free(dir);
|
||||
|
||||
/* Load the main config */
|
||||
/* Load the main conf */
|
||||
if (g_file_test(file, G_FILE_TEST_EXISTS)) {
|
||||
DBG("Loading %s", file);
|
||||
config_merge_file(conf, file);
|
||||
conf_merge_file(conf, file);
|
||||
}
|
||||
|
||||
if (files) {
|
||||
@@ -348,7 +347,7 @@ void config_merge_files(GKeyFile *conf, const char *file)
|
||||
|
||||
for (ptr = files; *ptr; ptr++) {
|
||||
DBG("Merging %s", *ptr);
|
||||
config_merge_file(conf, *ptr);
|
||||
conf_merge_file(conf, *ptr);
|
||||
}
|
||||
|
||||
g_strfreev(files);
|
||||
@@ -356,6 +355,228 @@ void config_merge_files(GKeyFile *conf, const char *file)
|
||||
}
|
||||
}
|
||||
|
||||
char *ofono_conf_get_string(GKeyFile *file, const char *group, const char *key)
|
||||
{
|
||||
char *val = g_key_file_get_string(file, group, key, NULL);
|
||||
|
||||
if (!val && strcmp(group, OFONO_COMMON_SETTINGS_GROUP)) {
|
||||
/* Check the common section */
|
||||
val = g_key_file_get_string(file, OFONO_COMMON_SETTINGS_GROUP,
|
||||
key, NULL);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
char **ofono_conf_get_strings(GKeyFile *file, const char *group,
|
||||
const char *key, char delimiter)
|
||||
{
|
||||
char *str = ofono_conf_get_string(file, group, key);
|
||||
|
||||
if (str) {
|
||||
char **strv, **p;
|
||||
char delimiter_str[2];
|
||||
|
||||
delimiter_str[0] = delimiter;
|
||||
delimiter_str[1] = 0;
|
||||
strv = g_strsplit(str, delimiter_str, -1);
|
||||
|
||||
/* Strip whitespaces */
|
||||
for (p = strv; *p; p++) {
|
||||
*p = g_strstrip(*p);
|
||||
}
|
||||
|
||||
g_free(str);
|
||||
return strv;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean ofono_conf_get_integer(GKeyFile *file, const char *group,
|
||||
const char *key, int *out_value)
|
||||
{
|
||||
GError *error = NULL;
|
||||
int value = g_key_file_get_integer(file, group, key, &error);
|
||||
|
||||
if (!error) {
|
||||
if (out_value) {
|
||||
*out_value = value;
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
g_error_free(error);
|
||||
if (strcmp(group, OFONO_COMMON_SETTINGS_GROUP)) {
|
||||
/* Check the common section */
|
||||
error = NULL;
|
||||
value = g_key_file_get_integer(file,
|
||||
OFONO_COMMON_SETTINGS_GROUP, key, &error);
|
||||
if (!error) {
|
||||
if (out_value) {
|
||||
*out_value = value;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
g_error_free(error);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean ofono_conf_get_boolean(GKeyFile *file, const char *group,
|
||||
const char *key, gboolean *out_value)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gboolean value = g_key_file_get_boolean(file, group, key, &error);
|
||||
|
||||
if (!error) {
|
||||
if (out_value) {
|
||||
*out_value = value;
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
g_error_free(error);
|
||||
if (strcmp(group, OFONO_COMMON_SETTINGS_GROUP)) {
|
||||
/* Check the common section */
|
||||
error = NULL;
|
||||
value = g_key_file_get_boolean(file,
|
||||
OFONO_COMMON_SETTINGS_GROUP, key, &error);
|
||||
if (!error) {
|
||||
if (out_value) {
|
||||
*out_value = value;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
g_error_free(error);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean ofono_conf_get_flag(GKeyFile *file, const char *group,
|
||||
const char *key, int flag, int *flags)
|
||||
{
|
||||
gboolean value;
|
||||
|
||||
if (ofono_conf_get_boolean(file, group, key, &value)) {
|
||||
if (value) {
|
||||
*flags |= flag;
|
||||
} else {
|
||||
*flags &= ~flag;
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean ofono_conf_get_enum(GKeyFile *file, const char *group,
|
||||
const char *key, int *result, const char *name, int value, ...)
|
||||
{
|
||||
char *str = ofono_conf_get_string(file, group, key);
|
||||
|
||||
if (str) {
|
||||
/*
|
||||
* Some people are thinking that # is a comment
|
||||
* anywhere on the line, not just at the beginning
|
||||
*/
|
||||
char *comment = strchr(str, '#');
|
||||
|
||||
if (comment) *comment = 0;
|
||||
g_strstrip(str);
|
||||
if (strcasecmp(str, name)) {
|
||||
va_list args;
|
||||
va_start(args, value);
|
||||
while ((name = va_arg(args, char*)) != NULL) {
|
||||
value = va_arg(args, int);
|
||||
if (!strcasecmp(str, name)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
ofono_error("Invalid %s config value (%s)", key, str);
|
||||
}
|
||||
|
||||
g_free(str);
|
||||
|
||||
if (name) {
|
||||
if (result) {
|
||||
*result = value;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean ofono_conf_get_mask(GKeyFile *file, const char *group,
|
||||
const char *key, int *result, const char *name, int value, ...)
|
||||
{
|
||||
char *str = ofono_conf_get_string(file, group, key);
|
||||
gboolean ok = FALSE;
|
||||
|
||||
if (result) {
|
||||
*result = 0;
|
||||
}
|
||||
|
||||
if (str) {
|
||||
/*
|
||||
* Some people are thinking that # is a comment
|
||||
* anywhere on the line, not just at the beginning
|
||||
*/
|
||||
char *comment = strchr(str, '#');
|
||||
char **values, **ptr;
|
||||
|
||||
if (comment) *comment = 0;
|
||||
values = g_strsplit(str, "+", -1);
|
||||
|
||||
for (ok = TRUE, ptr = values; *ptr && ok; ptr++) {
|
||||
const char* found_str = NULL;
|
||||
const char* s = g_strstrip(*ptr);
|
||||
|
||||
if (!strcasecmp(s, name)) {
|
||||
found_str = name;
|
||||
if (result) {
|
||||
*result |= value;
|
||||
}
|
||||
} else {
|
||||
va_list args;
|
||||
const char* known;
|
||||
|
||||
va_start(args, value);
|
||||
while ((known = va_arg(args, char*)) != NULL) {
|
||||
const int bit = va_arg(args, int);
|
||||
|
||||
if (!strcasecmp(s, known)) {
|
||||
found_str = known;
|
||||
if (result) {
|
||||
*result |= bit;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
if (!found_str) {
|
||||
ofono_error("Unknown bit '%s' in %s", s, key);
|
||||
ok = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
g_strfreev(values);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
if (!ok && result) {
|
||||
*result = 0;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2019-2020 Jolla Ltd.
|
||||
* Copyright (C) 2019-2021 Jolla Ltd.
|
||||
* Copyright (C) 2020 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -192,7 +192,7 @@ const char *ofono_dbus_access_method_name(enum ofono_dbus_access_intf intf,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean __ofono_dbus_access_method_allowed(const char *sender,
|
||||
ofono_bool_t ofono_dbus_access_method_allowed(const char *sender,
|
||||
enum ofono_dbus_access_intf intf,
|
||||
int method, const char *arg)
|
||||
{
|
||||
|
||||
@@ -463,6 +463,9 @@ static gboolean notify_ring(void *user_data)
|
||||
case CLIP_VALIDITY_WITHHELD:
|
||||
g_at_server_send_unsolicited(em->server, "+CLIP: \"\",128");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
* Copyright (C) 2015-2021 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
|
||||
@@ -23,13 +24,14 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include "ofono.h"
|
||||
|
||||
#include <ofono/gprs-provision.h>
|
||||
#include <ofono/log.h>
|
||||
|
||||
static GSList *g_drivers = NULL;
|
||||
|
||||
void __ofono_gprs_provision_free_settings(
|
||||
void ofono_gprs_provision_free_settings(
|
||||
struct ofono_gprs_provision_data *settings,
|
||||
int count)
|
||||
{
|
||||
@@ -48,7 +50,7 @@ void __ofono_gprs_provision_free_settings(
|
||||
g_free(settings);
|
||||
}
|
||||
|
||||
ofono_bool_t __ofono_gprs_provision_get_settings(const char *mcc,
|
||||
ofono_bool_t ofono_gprs_provision_get_settings(const char *mcc,
|
||||
const char *mnc, const char *spn,
|
||||
struct ofono_gprs_provision_data **settings,
|
||||
int *count)
|
||||
|
||||
@@ -1062,7 +1062,7 @@ static gboolean pri_deactivation_required(struct pri_context *ctx,
|
||||
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),
|
||||
return ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
OFONO_DBUS_ACCESS_INTF_CONNCTX, method, arg);
|
||||
}
|
||||
|
||||
@@ -1085,7 +1085,7 @@ static DBusMessage *pri_provision_context(DBusConnection *conn,
|
||||
if (sim == NULL)
|
||||
return __ofono_error_failed(msg);
|
||||
|
||||
if (__ofono_gprs_provision_get_settings(ofono_sim_get_mcc(sim),
|
||||
if (ofono_gprs_provision_get_settings(ofono_sim_get_mcc(sim),
|
||||
ofono_sim_get_mnc(sim), ofono_sim_get_spn(sim),
|
||||
&settings, &count) == FALSE)
|
||||
return __ofono_error_failed(msg);
|
||||
@@ -1109,7 +1109,7 @@ static DBusMessage *pri_provision_context(DBusConnection *conn,
|
||||
}
|
||||
}
|
||||
|
||||
__ofono_gprs_provision_free_settings(settings, count);
|
||||
ofono_gprs_provision_free_settings(settings, count);
|
||||
|
||||
return reply ? reply : __ofono_error_not_available(msg);
|
||||
}
|
||||
@@ -2221,7 +2221,7 @@ static DBusMessage *gprs_get_properties(DBusConnection *conn,
|
||||
static gboolean gprs_allow(DBusMessage *msg,
|
||||
enum ofono_dbus_access_connmgr_method method, const char *arg)
|
||||
{
|
||||
return __ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
return ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
OFONO_DBUS_ACCESS_INTF_CONNMGR, method, arg);
|
||||
}
|
||||
|
||||
@@ -2882,7 +2882,7 @@ static void provision_contexts(struct ofono_gprs *gprs, const char *mcc,
|
||||
int count;
|
||||
int i;
|
||||
|
||||
if (__ofono_gprs_provision_get_settings(mcc, mnc, spn,
|
||||
if (ofono_gprs_provision_get_settings(mcc, mnc, spn,
|
||||
&settings, &count) == FALSE) {
|
||||
ofono_warn("Provisioning failed");
|
||||
return;
|
||||
@@ -2896,7 +2896,7 @@ static void provision_contexts(struct ofono_gprs *gprs, const char *mcc,
|
||||
}
|
||||
}
|
||||
|
||||
__ofono_gprs_provision_free_settings(settings, count);
|
||||
ofono_gprs_provision_free_settings(settings, count);
|
||||
}
|
||||
|
||||
static gboolean all_contexts_configured(struct ofono_gprs *gprs)
|
||||
@@ -3987,8 +3987,8 @@ void *ofono_gprs_get_data(struct ofono_gprs *gprs)
|
||||
return gprs->driver_data;
|
||||
}
|
||||
|
||||
gboolean __ofono_gprs_get_roaming_allowed(struct ofono_gprs *gprs)
|
||||
{
|
||||
ofono_bool_t ofono_gprs_get_roaming_allowed(struct ofono_gprs *gprs)
|
||||
{ /* Since mer/1.24+git2 */
|
||||
return gprs->roaming_allowed;
|
||||
}
|
||||
|
||||
@@ -4010,8 +4010,8 @@ const struct ofono_gprs_primary_context *ofono_gprs_context_settings_by_type
|
||||
return NULL;
|
||||
}
|
||||
|
||||
enum ofono_gprs_context_type __ofono_gprs_context_get_assigned_type(
|
||||
struct ofono_gprs_context *gc)
|
||||
enum ofono_gprs_context_type ofono_gprs_context_get_assigned_type(
|
||||
struct ofono_gprs_context *gc) /* Since mer/1.24+git2 */
|
||||
{
|
||||
if (gc) {
|
||||
struct ofono_gprs *gprs = gc->gprs;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
* Copyright (C) 2019-2020 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -305,6 +305,8 @@ int main(int argc, char **argv)
|
||||
|
||||
__ofono_manager_init();
|
||||
|
||||
__ofono_slot_manager_init();
|
||||
|
||||
__ofono_plugin_init(option_plugin, option_noplugin);
|
||||
|
||||
g_free(option_plugin);
|
||||
@@ -319,6 +321,8 @@ int main(int argc, char **argv)
|
||||
|
||||
__ofono_plugin_cleanup();
|
||||
|
||||
__ofono_slot_manager_cleanup();
|
||||
|
||||
__ofono_manager_cleanup();
|
||||
|
||||
__ofono_modemwatch_cleanup();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2015-2021 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
|
||||
@@ -83,7 +84,7 @@ static DBusMessage *message_cancel(DBusConnection *conn,
|
||||
struct message *m = data;
|
||||
int res;
|
||||
|
||||
if (!__ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
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);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2015-2021 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
|
||||
@@ -200,6 +201,17 @@ struct ofono_voicecall *ofono_modem_get_voicecall(struct ofono_modem *modem)
|
||||
return __ofono_atom_find(OFONO_ATOM_TYPE_VOICECALL, modem);
|
||||
}
|
||||
|
||||
struct ofono_netreg *ofono_modem_get_netreg(struct ofono_modem *modem)
|
||||
{
|
||||
return __ofono_atom_find(OFONO_ATOM_TYPE_NETREG, modem);
|
||||
}
|
||||
|
||||
struct ofono_radio_settings *ofono_modem_get_radio_settings
|
||||
(struct ofono_modem *modem)
|
||||
{
|
||||
return __ofono_atom_find(OFONO_ATOM_TYPE_RADIO_SETTINGS, modem);
|
||||
}
|
||||
|
||||
struct ofono_atom *__ofono_modem_add_atom(struct ofono_modem *modem,
|
||||
enum ofono_atom_type type,
|
||||
void (*destruct)(struct ofono_atom *),
|
||||
@@ -1101,7 +1113,7 @@ static DBusMessage *modem_set_property(DBusConnection *conn,
|
||||
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),
|
||||
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);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2016-2017 Jolla Ltd.
|
||||
* Copyright (C) 2016-2021 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
|
||||
@@ -13,8 +13,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "mtu-watch.h"
|
||||
|
||||
#include <ofono/mtu-limit.h>
|
||||
#include <ofono/log.h>
|
||||
|
||||
#include <glib.h>
|
||||
@@ -29,7 +28,7 @@
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
|
||||
struct mtu_watch {
|
||||
struct ofono_mtu_limit {
|
||||
int max_mtu;
|
||||
char *ifname;
|
||||
void *buf;
|
||||
@@ -39,9 +38,10 @@ struct mtu_watch {
|
||||
int fd;
|
||||
};
|
||||
|
||||
static void mtu_watch_limit_mtu(struct mtu_watch *self)
|
||||
static void mtu_limit_apply(struct ofono_mtu_limit *self)
|
||||
{
|
||||
int fd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
if (fd >= 0) {
|
||||
struct ifreq ifr;
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
@@ -59,11 +59,12 @@ static void mtu_watch_limit_mtu(struct mtu_watch *self)
|
||||
}
|
||||
}
|
||||
|
||||
static void mtu_watch_handle_rtattr(struct mtu_watch *self,
|
||||
static void mtu_limit_handle_rtattr(struct ofono_mtu_limit *self,
|
||||
const struct rtattr *rta, unsigned int len)
|
||||
{
|
||||
int mtu = 0;
|
||||
const char *ifname = NULL;
|
||||
|
||||
while (len > 0 && RTA_OK(rta, len) && (!mtu || !ifname)) {
|
||||
switch (rta->rta_type) {
|
||||
case IFLA_IFNAME:
|
||||
@@ -77,43 +78,45 @@ static void mtu_watch_handle_rtattr(struct mtu_watch *self,
|
||||
}
|
||||
if (mtu > self->max_mtu && !g_strcmp0(ifname, self->ifname)) {
|
||||
DBG("%s %d", ifname, mtu);
|
||||
mtu_watch_limit_mtu(self);
|
||||
mtu_limit_apply(self);
|
||||
}
|
||||
}
|
||||
|
||||
static void mtu_watch_handle_ifinfomsg(struct mtu_watch *self,
|
||||
static void mtu_limit_handle_ifinfomsg(struct ofono_mtu_limit *self,
|
||||
const struct ifinfomsg *ifi, unsigned int len)
|
||||
{
|
||||
if (ifi->ifi_flags & IFF_UP) {
|
||||
const struct rtattr *rta = IFLA_RTA(ifi);
|
||||
mtu_watch_handle_rtattr(self, rta,
|
||||
|
||||
mtu_limit_handle_rtattr(self, rta,
|
||||
len - ((char*)rta - (char*)ifi));
|
||||
}
|
||||
}
|
||||
|
||||
static void mtu_watch_handle_nlmsg(struct mtu_watch *self,
|
||||
static void mtu_limit_handle_nlmsg(struct ofono_mtu_limit *self,
|
||||
const struct nlmsghdr *hdr, unsigned int len)
|
||||
{
|
||||
while (len > 0 && NLMSG_OK(hdr, len)) {
|
||||
if (hdr->nlmsg_type == RTM_NEWLINK) {
|
||||
mtu_watch_handle_ifinfomsg(self, NLMSG_DATA(hdr),
|
||||
mtu_limit_handle_ifinfomsg(self, NLMSG_DATA(hdr),
|
||||
IFLA_PAYLOAD(hdr));
|
||||
}
|
||||
hdr = NLMSG_NEXT(hdr, len);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean mtu_watch_event(GIOChannel *ch, GIOCondition cond,
|
||||
static gboolean mtu_limit_event(GIOChannel *ch, GIOCondition cond,
|
||||
gpointer data)
|
||||
{
|
||||
struct mtu_watch *self = data;
|
||||
struct ofono_mtu_limit *self = data;
|
||||
struct sockaddr_nl addr;
|
||||
socklen_t addrlen = sizeof(addr);
|
||||
ssize_t result = recvfrom(self->fd, self->buf, self->bufsize, 0,
|
||||
(struct sockaddr *)&addr, &addrlen);
|
||||
|
||||
if (result > 0) {
|
||||
if (!addr.nl_pid) {
|
||||
mtu_watch_handle_nlmsg(self, self->buf, result);
|
||||
mtu_limit_handle_nlmsg(self, self->buf, result);
|
||||
}
|
||||
return G_SOURCE_CONTINUE;
|
||||
} else if (result == 0 || errno == EINTR || errno == EAGAIN) {
|
||||
@@ -125,11 +128,12 @@ static gboolean mtu_watch_event(GIOChannel *ch, GIOCondition cond,
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean mtu_watch_open_socket(struct mtu_watch *self)
|
||||
static gboolean mtu_limit_open_socket(struct ofono_mtu_limit *self)
|
||||
{
|
||||
self->fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
||||
if (self->fd >= 0) {
|
||||
struct sockaddr_nl nl;
|
||||
|
||||
memset(&nl, 0, sizeof(nl));
|
||||
nl.nl_pid = getpid();
|
||||
nl.nl_family = AF_NETLINK;
|
||||
@@ -146,18 +150,18 @@ static gboolean mtu_watch_open_socket(struct mtu_watch *self)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean mtu_watch_start(struct mtu_watch *self)
|
||||
static gboolean mtu_limit_start(struct ofono_mtu_limit *self)
|
||||
{
|
||||
if (self->fd >= 0) {
|
||||
return TRUE;
|
||||
} else if (mtu_watch_open_socket(self)) {
|
||||
} else if (mtu_limit_open_socket(self)) {
|
||||
self->channel = g_io_channel_unix_new(self->fd);
|
||||
if (self->channel) {
|
||||
g_io_channel_set_encoding(self->channel, NULL, NULL);
|
||||
g_io_channel_set_buffered(self->channel, FALSE);
|
||||
self->io_watch = g_io_add_watch(self->channel,
|
||||
G_IO_IN | G_IO_NVAL | G_IO_HUP,
|
||||
mtu_watch_event, self);
|
||||
mtu_limit_event, self);
|
||||
return TRUE;
|
||||
}
|
||||
close(self->fd);
|
||||
@@ -166,7 +170,7 @@ static gboolean mtu_watch_start(struct mtu_watch *self)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void mtu_watch_stop(struct mtu_watch *self)
|
||||
static void mtu_limit_stop(struct ofono_mtu_limit *self)
|
||||
{
|
||||
if (self->io_watch) {
|
||||
g_source_remove(self->io_watch);
|
||||
@@ -183,9 +187,10 @@ static void mtu_watch_stop(struct mtu_watch *self)
|
||||
}
|
||||
}
|
||||
|
||||
struct mtu_watch *mtu_watch_new(int max_mtu)
|
||||
struct ofono_mtu_limit *ofono_mtu_limit_new(int max_mtu)
|
||||
{
|
||||
struct mtu_watch *self = g_new0(struct mtu_watch, 1);
|
||||
struct ofono_mtu_limit *self = g_new0(struct ofono_mtu_limit, 1);
|
||||
|
||||
self->fd = -1;
|
||||
self->max_mtu = max_mtu;
|
||||
self->bufsize = 4096;
|
||||
@@ -193,27 +198,27 @@ struct mtu_watch *mtu_watch_new(int max_mtu)
|
||||
return self;
|
||||
}
|
||||
|
||||
void mtu_watch_free(struct mtu_watch *self)
|
||||
void ofono_mtu_limit_free(struct ofono_mtu_limit *self)
|
||||
{
|
||||
if (self) {
|
||||
mtu_watch_stop(self);
|
||||
mtu_limit_stop(self);
|
||||
g_free(self->ifname);
|
||||
g_free(self->buf);
|
||||
g_free(self);
|
||||
}
|
||||
}
|
||||
|
||||
void mtu_watch_set_ifname(struct mtu_watch *self, const char *ifname)
|
||||
void ofono_mtu_limit_set_ifname(struct ofono_mtu_limit *self, const char *name)
|
||||
{
|
||||
if (self && g_strcmp0(self->ifname, ifname)) {
|
||||
if (self && g_strcmp0(self->ifname, name)) {
|
||||
g_free(self->ifname);
|
||||
if (ifname) {
|
||||
self->ifname = g_strdup(ifname);
|
||||
mtu_watch_limit_mtu(self);
|
||||
mtu_watch_start(self);
|
||||
if (name) {
|
||||
self->ifname = g_strdup(name);
|
||||
mtu_limit_apply(self);
|
||||
mtu_limit_start(self);
|
||||
} else {
|
||||
self->ifname = NULL;
|
||||
mtu_watch_stop(self);
|
||||
mtu_limit_stop(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1799,6 +1799,12 @@ struct sim_spdi *ofono_netreg_get_spdi(struct ofono_netreg *netreg)
|
||||
return netreg->spdi;
|
||||
}
|
||||
|
||||
ofono_bool_t ofono_netreg_spdi_lookup(struct ofono_netreg *netreg,
|
||||
const char *mcc, const char *mnc)
|
||||
{
|
||||
return mcc && mnc && netreg && sim_spdi_lookup(netreg->spdi, mcc, mnc);
|
||||
}
|
||||
|
||||
int ofono_netreg_driver_register(const struct ofono_netreg_driver *d)
|
||||
{
|
||||
DBG("driver: %p, name: %s", d, d->name);
|
||||
|
||||
@@ -51,28 +51,28 @@ void __ofono_log_enable(struct ofono_debug_desc *start,
|
||||
int __ofono_dbus_init(DBusConnection *conn);
|
||||
void __ofono_dbus_cleanup(void);
|
||||
|
||||
DBusMessage *__ofono_error_invalid_args(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_invalid_format(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_not_implemented(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_failed(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_busy(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_not_found(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_not_active(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_not_supported(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_not_available(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_timed_out(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_sim_not_ready(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_in_use(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_not_attached(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_attach_in_progress(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_not_registered(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_canceled(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_access_denied(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_emergency_active(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_incorrect_password(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_not_allowed(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_not_recognized(DBusMessage *msg);
|
||||
DBusMessage *__ofono_error_network_terminated(DBusMessage *msg);
|
||||
#define __ofono_error_invalid_args ofono_dbus_error_invalid_args
|
||||
#define __ofono_error_invalid_format ofono_dbus_error_invalid_format
|
||||
#define __ofono_error_not_implemented ofono_dbus_error_not_implemented
|
||||
#define __ofono_error_failed ofono_dbus_error_failed
|
||||
#define __ofono_error_busy ofono_dbus_error_busy
|
||||
#define __ofono_error_not_found ofono_dbus_error_not_found
|
||||
#define __ofono_error_not_active ofono_dbus_error_not_active
|
||||
#define __ofono_error_not_supported ofono_dbus_error_not_supported
|
||||
#define __ofono_error_not_available ofono_dbus_error_not_available
|
||||
#define __ofono_error_timed_out ofono_dbus_error_timed_out
|
||||
#define __ofono_error_sim_not_ready ofono_dbus_error_sim_not_ready
|
||||
#define __ofono_error_in_use ofono_dbus_error_in_use
|
||||
#define __ofono_error_not_attached ofono_dbus_error_not_attached
|
||||
#define __ofono_error_attach_in_progress ofono_dbus_error_attach_in_progress
|
||||
#define __ofono_error_not_registered ofono_dbus_error_not_registered
|
||||
#define __ofono_error_canceled ofono_dbus_error_canceled
|
||||
#define __ofono_error_access_denied ofono_dbus_error_access_denied
|
||||
#define __ofono_error_emergency_active ofono_dbus_error_emergency_active
|
||||
#define __ofono_error_incorrect_password ofono_dbus_error_incorrect_password
|
||||
#define __ofono_error_not_allowed ofono_dbus_error_not_allowed
|
||||
#define __ofono_error_not_recognized ofono_dbus_error_not_recognized
|
||||
#define __ofono_error_network_terminated ofono_dbus_error_network_terminated
|
||||
|
||||
DBusMessage *__ofono_error_from_error(const struct ofono_error *error,
|
||||
DBusMessage *msg);
|
||||
@@ -274,19 +274,8 @@ gboolean __ofono_call_settings_is_busy(struct ofono_call_settings *cs);
|
||||
#include <ofono/devinfo.h>
|
||||
#include <ofono/phonebook.h>
|
||||
#include <ofono/gprs.h>
|
||||
|
||||
gboolean __ofono_gprs_get_roaming_allowed(struct ofono_gprs *gprs);
|
||||
|
||||
#include <ofono/gprs-context.h>
|
||||
|
||||
enum ofono_gprs_context_type __ofono_gprs_context_get_assigned_type(
|
||||
struct ofono_gprs_context *gc);
|
||||
|
||||
#include <ofono/radio-settings.h>
|
||||
|
||||
enum ofono_radio_access_mode __ofono_radio_access_max_mode(
|
||||
enum ofono_radio_access_mode modes);
|
||||
|
||||
#include <ofono/audio-settings.h>
|
||||
#include <ofono/ctm.h>
|
||||
#include <ofono/location-reporting.h>
|
||||
@@ -552,16 +541,7 @@ void __ofono_nettime_info_received(struct ofono_modem *modem,
|
||||
#include <ofono/cdma-voicecall.h>
|
||||
#include <ofono/cdma-connman.h>
|
||||
#include <ofono/sim-auth.h>
|
||||
|
||||
#include <ofono/gprs-provision.h>
|
||||
ofono_bool_t __ofono_gprs_provision_get_settings(const char *mcc,
|
||||
const char *mnc, const char *spn,
|
||||
struct ofono_gprs_provision_data **settings,
|
||||
int *count);
|
||||
void __ofono_gprs_provision_free_settings(
|
||||
struct ofono_gprs_provision_data *settings,
|
||||
int count);
|
||||
|
||||
#include <ofono/emulator.h>
|
||||
|
||||
enum ofono_emulator_slc_condition {
|
||||
@@ -677,19 +657,17 @@ void __ofono_voicecall_filter_chain_incoming(struct voicecall_filter_chain *c,
|
||||
ofono_destroy_func destroy, void *user_data);
|
||||
|
||||
#include <ofono/dbus-access.h>
|
||||
#include <ofono/slot.h>
|
||||
|
||||
gboolean __ofono_dbus_access_method_allowed(const char *sender,
|
||||
enum ofono_dbus_access_intf iface,
|
||||
int method, const char *arg);
|
||||
void __ofono_slot_manager_init(void);
|
||||
void __ofono_slot_manager_cleanup(void);
|
||||
|
||||
#include <ofono/cell-info.h>
|
||||
#include <ofono/sim-mnclength.h>
|
||||
|
||||
int __ofono_sim_mnclength_get_mnclength(const char *imsi);
|
||||
int mnclength(int mcc, int mnc);
|
||||
|
||||
#include <ofono/netmon.h>
|
||||
#include <ofono/lte.h>
|
||||
#include <ofono/ims.h>
|
||||
#include <ofono/watch.h>
|
||||
#include <ofono/storage.h>
|
||||
|
||||
void __ofono_set_config_dir(const char *dir);
|
||||
void config_merge_files(GKeyFile *conf, const char *file);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
* Copyright (C) 2014-2020 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 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
|
||||
@@ -62,7 +62,7 @@ struct ofono_radio_settings {
|
||||
struct ofono_atom *atom;
|
||||
};
|
||||
|
||||
enum ofono_radio_access_mode __ofono_radio_access_max_mode(
|
||||
enum ofono_radio_access_mode ofono_radio_access_max_mode(
|
||||
enum ofono_radio_access_mode mask)
|
||||
{
|
||||
return (mask & OFONO_RADIO_ACCESS_MODE_LTE) ?
|
||||
@@ -77,7 +77,7 @@ enum ofono_radio_access_mode __ofono_radio_access_max_mode(
|
||||
#define radio_access_mode_to_string ofono_radio_access_mode_to_string
|
||||
const char *ofono_radio_access_mode_to_string(enum ofono_radio_access_mode m)
|
||||
{
|
||||
switch (__ofono_radio_access_max_mode(m)) {
|
||||
switch (ofono_radio_access_max_mode(m)) {
|
||||
case OFONO_RADIO_ACCESS_MODE_ANY:
|
||||
return "any";
|
||||
case OFONO_RADIO_ACCESS_MODE_GSM:
|
||||
@@ -569,7 +569,7 @@ static DBusMessage *radio_set_property_handler(DBusMessage *msg, void *data)
|
||||
dbus_message_iter_get_basic(&iter, &property);
|
||||
dbus_message_iter_next(&iter);
|
||||
|
||||
if (!__ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
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);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017-2019 Jolla Ltd.
|
||||
* Copyright (C) 2017-2021 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
|
||||
@@ -13,7 +13,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "sailfish_sim_info.h"
|
||||
#include "sim-info.h"
|
||||
|
||||
#include <ofono/dbus.h>
|
||||
#include <ofono/watch.h>
|
||||
@@ -34,13 +34,13 @@ enum sim_info_event_id {
|
||||
SIM_INFO_EVENT_COUNT
|
||||
};
|
||||
|
||||
struct sailfish_sim_info_dbus {
|
||||
struct sailfish_sim_info *info;
|
||||
typedef struct sim_info_dbus {
|
||||
struct sim_info *info;
|
||||
struct ofono_watch *watch;
|
||||
DBusConnection *conn;
|
||||
gulong watch_event_id[WATCH_EVENT_COUNT];
|
||||
gulong info_event_id[SIM_INFO_EVENT_COUNT];
|
||||
};
|
||||
} SimInfoDBus;
|
||||
|
||||
#define SIM_INFO_DBUS_INTERFACE "org.nemomobile.ofono.SimInfo"
|
||||
#define SIM_INFO_DBUS_INTERFACE_VERSION (1)
|
||||
@@ -49,80 +49,79 @@ struct sailfish_sim_info_dbus {
|
||||
#define SIM_INFO_DBUS_IMSI_CHANGED_SIGNAL "SubscriberIdentityChanged"
|
||||
#define SIM_INFO_DBUS_SPN_CHANGED_SIGNAL "ServiceProviderNameChanged"
|
||||
|
||||
static void sailfish_sim_info_dbus_append_version(DBusMessageIter *it)
|
||||
static void sim_info_dbus_append_version(DBusMessageIter *it)
|
||||
{
|
||||
const dbus_int32_t version = SIM_INFO_DBUS_INTERFACE_VERSION;
|
||||
|
||||
dbus_message_iter_append_basic(it, DBUS_TYPE_INT32, &version);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_dbus_append_string(DBusMessageIter *it,
|
||||
const char *str)
|
||||
static void sim_info_dbus_append_string(DBusMessageIter *it, const char *str)
|
||||
{
|
||||
if (!str) str = "";
|
||||
dbus_message_iter_append_basic(it, DBUS_TYPE_STRING, &str);
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_sim_info_dbus_reply_with_string(DBusMessage *msg,
|
||||
const char *str)
|
||||
static DBusMessage *sim_info_dbus_reply_with_string(DBusMessage *msg,
|
||||
const char *str)
|
||||
{
|
||||
DBusMessage *reply = dbus_message_new_method_return(msg);
|
||||
DBusMessageIter iter;
|
||||
|
||||
dbus_message_iter_init_append(reply, &iter);
|
||||
sailfish_sim_info_dbus_append_string(&iter, str);
|
||||
sim_info_dbus_append_string(&iter, str);
|
||||
return reply;
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_sim_info_dbus_get_all(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
static DBusMessage *sim_info_dbus_get_all(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
struct sailfish_sim_info_dbus *dbus = data;
|
||||
struct sailfish_sim_info *info = dbus->info;
|
||||
SimInfoDBus *dbus = data;
|
||||
struct sim_info *info = dbus->info;
|
||||
DBusMessage *reply = dbus_message_new_method_return(msg);
|
||||
DBusMessageIter it;
|
||||
|
||||
dbus_message_iter_init_append(reply, &it);
|
||||
sailfish_sim_info_dbus_append_version(&it);
|
||||
sailfish_sim_info_dbus_append_string(&it, info->iccid);
|
||||
sailfish_sim_info_dbus_append_string(&it, info->imsi);
|
||||
sailfish_sim_info_dbus_append_string(&it, info->spn);
|
||||
sim_info_dbus_append_version(&it);
|
||||
sim_info_dbus_append_string(&it, info->iccid);
|
||||
sim_info_dbus_append_string(&it, info->imsi);
|
||||
sim_info_dbus_append_string(&it, info->spn);
|
||||
return reply;
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_sim_info_dbus_get_version(DBusConnection *dc,
|
||||
DBusMessage *msg, void *data)
|
||||
static DBusMessage *sim_info_dbus_get_version(DBusConnection *dc,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
DBusMessage *reply = dbus_message_new_method_return(msg);
|
||||
DBusMessageIter it;
|
||||
|
||||
dbus_message_iter_init_append(reply, &it);
|
||||
sailfish_sim_info_dbus_append_version(&it);
|
||||
sim_info_dbus_append_version(&it);
|
||||
return reply;
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_sim_info_dbus_get_iccid(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
static DBusMessage *sim_info_dbus_get_iccid(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
struct sailfish_sim_info_dbus *dbus = data;
|
||||
SimInfoDBus *dbus = data;
|
||||
|
||||
return sailfish_sim_info_dbus_reply_with_string(msg, dbus->info->iccid);
|
||||
return sim_info_dbus_reply_with_string(msg, dbus->info->iccid);
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_sim_info_dbus_get_imsi(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
static DBusMessage *sim_info_dbus_get_imsi(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
struct sailfish_sim_info_dbus *dbus = data;
|
||||
SimInfoDBus *dbus = data;
|
||||
|
||||
return sailfish_sim_info_dbus_reply_with_string(msg, dbus->info->imsi);
|
||||
return sim_info_dbus_reply_with_string(msg, dbus->info->imsi);
|
||||
}
|
||||
|
||||
static DBusMessage *sailfish_sim_info_dbus_get_spn(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
static DBusMessage *sim_info_dbus_get_spn(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
struct sailfish_sim_info_dbus *dbus = data;
|
||||
SimInfoDBus *dbus = data;
|
||||
|
||||
return sailfish_sim_info_dbus_reply_with_string(msg, dbus->info->spn);
|
||||
return sim_info_dbus_reply_with_string(msg, dbus->info->spn);
|
||||
}
|
||||
|
||||
#define SIM_INFO_DBUS_VERSION_ARG {"version", "i"}
|
||||
@@ -136,26 +135,26 @@ static DBusMessage *sailfish_sim_info_dbus_get_spn(DBusConnection *conn,
|
||||
SIM_INFO_DBUS_IMSI_ARG, \
|
||||
SIM_INFO_DBUS_SPN_ARG
|
||||
|
||||
static const GDBusMethodTable sailfish_sim_info_dbus_methods[] = {
|
||||
static const GDBusMethodTable sim_info_dbus_methods[] = {
|
||||
{ GDBUS_METHOD("GetAll",
|
||||
NULL, GDBUS_ARGS(SIM_INFO_DBUS_GET_ALL_ARGS),
|
||||
sailfish_sim_info_dbus_get_all) },
|
||||
sim_info_dbus_get_all) },
|
||||
{ GDBUS_METHOD("GetInterfaceVersion",
|
||||
NULL, GDBUS_ARGS(SIM_INFO_DBUS_VERSION_ARG),
|
||||
sailfish_sim_info_dbus_get_version) },
|
||||
sim_info_dbus_get_version) },
|
||||
{ GDBUS_METHOD("GetCardIdentifier",
|
||||
NULL, GDBUS_ARGS(SIM_INFO_DBUS_ICCID_ARG),
|
||||
sailfish_sim_info_dbus_get_iccid) },
|
||||
sim_info_dbus_get_iccid) },
|
||||
{ GDBUS_METHOD("GetSubscriberIdentity",
|
||||
NULL, GDBUS_ARGS(SIM_INFO_DBUS_IMSI_ARG),
|
||||
sailfish_sim_info_dbus_get_imsi) },
|
||||
sim_info_dbus_get_imsi) },
|
||||
{ GDBUS_METHOD("GetServiceProviderName",
|
||||
NULL, GDBUS_ARGS(SIM_INFO_DBUS_SPN_ARG),
|
||||
sailfish_sim_info_dbus_get_spn) },
|
||||
sim_info_dbus_get_spn) },
|
||||
{ }
|
||||
};
|
||||
|
||||
static const GDBusSignalTable sailfish_sim_info_dbus_signals[] = {
|
||||
static const GDBusSignalTable sim_info_dbus_signals[] = {
|
||||
{ GDBUS_SIGNAL(SIM_INFO_DBUS_ICCID_CHANGED_SIGNAL,
|
||||
GDBUS_ARGS(SIM_INFO_DBUS_ICCID_ARG)) },
|
||||
{ GDBUS_SIGNAL(SIM_INFO_DBUS_IMSI_CHANGED_SIGNAL,
|
||||
@@ -165,105 +164,96 @@ static const GDBusSignalTable sailfish_sim_info_dbus_signals[] = {
|
||||
{ }
|
||||
};
|
||||
|
||||
static void sailfish_sim_info_dbus_modem_cb(struct ofono_watch *watch,
|
||||
void *data)
|
||||
static void sim_info_dbus_modem_cb(struct ofono_watch *watch, void *data)
|
||||
{
|
||||
if (watch->modem) {
|
||||
ofono_modem_add_interface(watch->modem,
|
||||
SIM_INFO_DBUS_INTERFACE);
|
||||
SIM_INFO_DBUS_INTERFACE);
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_dbus_emit(struct sailfish_sim_info_dbus *dbus,
|
||||
const char *signal, const char *value)
|
||||
static void sim_info_dbus_emit(SimInfoDBus *dbus,
|
||||
const char *signal, const char *value)
|
||||
{
|
||||
const char *arg = value;
|
||||
|
||||
if (!arg) arg = "";
|
||||
g_dbus_emit_signal(dbus->conn, dbus->info->path,
|
||||
SIM_INFO_DBUS_INTERFACE, signal,
|
||||
DBUS_TYPE_STRING, &arg, DBUS_TYPE_INVALID);
|
||||
SIM_INFO_DBUS_INTERFACE, signal,
|
||||
DBUS_TYPE_STRING, &arg, DBUS_TYPE_INVALID);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_dbus_iccid_cb(struct sailfish_sim_info *info,
|
||||
void *data)
|
||||
static void sim_info_dbus_iccid_cb(struct sim_info *info, void *data)
|
||||
{
|
||||
sailfish_sim_info_dbus_emit((struct sailfish_sim_info_dbus *)data,
|
||||
sim_info_dbus_emit((SimInfoDBus *)data,
|
||||
SIM_INFO_DBUS_ICCID_CHANGED_SIGNAL, info->iccid);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_dbus_imsi_cb(struct sailfish_sim_info *info,
|
||||
void *data)
|
||||
static void sim_info_dbus_imsi_cb(struct sim_info *info, void *data)
|
||||
{
|
||||
sailfish_sim_info_dbus_emit((struct sailfish_sim_info_dbus *)data,
|
||||
sim_info_dbus_emit((SimInfoDBus *)data,
|
||||
SIM_INFO_DBUS_IMSI_CHANGED_SIGNAL, info->imsi);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_dbus_spn_cb(struct sailfish_sim_info *info,
|
||||
void *data)
|
||||
static void sim_info_dbus_spn_cb(struct sim_info *info, void *data)
|
||||
{
|
||||
sailfish_sim_info_dbus_emit((struct sailfish_sim_info_dbus *)data,
|
||||
sim_info_dbus_emit((SimInfoDBus *)data,
|
||||
SIM_INFO_DBUS_SPN_CHANGED_SIGNAL, info->spn);
|
||||
}
|
||||
|
||||
struct sailfish_sim_info_dbus *sailfish_sim_info_dbus_new
|
||||
(struct sailfish_sim_info *info)
|
||||
SimInfoDBus *sim_info_dbus_new(struct sim_info *info)
|
||||
{
|
||||
struct sailfish_sim_info_dbus *dbus =
|
||||
g_slice_new0(struct sailfish_sim_info_dbus);
|
||||
SimInfoDBus *dbus = g_new0(SimInfoDBus, 1);
|
||||
|
||||
DBG("%s", info->path);
|
||||
dbus->info = sailfish_sim_info_ref(info);
|
||||
dbus->info = sim_info_ref(info);
|
||||
dbus->watch = ofono_watch_new(info->path);
|
||||
dbus->conn = dbus_connection_ref(ofono_dbus_get_connection());
|
||||
|
||||
/* Register D-Bus interface */
|
||||
if (g_dbus_register_interface(dbus->conn, dbus->info->path,
|
||||
SIM_INFO_DBUS_INTERFACE,
|
||||
sailfish_sim_info_dbus_methods,
|
||||
sailfish_sim_info_dbus_signals,
|
||||
NULL, dbus, NULL)) {
|
||||
SIM_INFO_DBUS_INTERFACE, sim_info_dbus_methods,
|
||||
sim_info_dbus_signals, NULL, dbus, NULL)) {
|
||||
if (dbus->watch->modem) {
|
||||
ofono_modem_add_interface(dbus->watch->modem,
|
||||
SIM_INFO_DBUS_INTERFACE);
|
||||
SIM_INFO_DBUS_INTERFACE);
|
||||
}
|
||||
|
||||
dbus->watch_event_id[WATCH_EVENT_MODEM] =
|
||||
ofono_watch_add_modem_changed_handler(dbus->watch,
|
||||
sailfish_sim_info_dbus_modem_cb, dbus);
|
||||
sim_info_dbus_modem_cb, dbus);
|
||||
dbus->info_event_id[SIM_INFO_EVENT_ICCID] =
|
||||
sailfish_sim_info_add_iccid_changed_handler(info,
|
||||
sailfish_sim_info_dbus_iccid_cb, dbus);
|
||||
sim_info_add_iccid_changed_handler(info,
|
||||
sim_info_dbus_iccid_cb, dbus);
|
||||
dbus->info_event_id[SIM_INFO_EVENT_IMSI] =
|
||||
sailfish_sim_info_add_imsi_changed_handler(info,
|
||||
sailfish_sim_info_dbus_imsi_cb, dbus);
|
||||
sim_info_add_imsi_changed_handler(info,
|
||||
sim_info_dbus_imsi_cb, dbus);
|
||||
dbus->info_event_id[SIM_INFO_EVENT_SPN] =
|
||||
sailfish_sim_info_add_spn_changed_handler(info,
|
||||
sailfish_sim_info_dbus_spn_cb, dbus);
|
||||
sim_info_add_spn_changed_handler(info,
|
||||
sim_info_dbus_spn_cb, dbus);
|
||||
|
||||
return dbus;
|
||||
} else {
|
||||
ofono_error("SimInfo D-Bus register failed");
|
||||
sailfish_sim_info_dbus_free(dbus);
|
||||
sim_info_dbus_free(dbus);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
struct sailfish_sim_info_dbus *sailfish_sim_info_dbus_new_path
|
||||
(const char *path)
|
||||
SimInfoDBus *sim_info_dbus_new_path(const char *path)
|
||||
{
|
||||
struct sailfish_sim_info_dbus *dbus = NULL;
|
||||
struct sailfish_sim_info *info = sailfish_sim_info_new(path);
|
||||
SimInfoDBus *dbus = NULL;
|
||||
struct sim_info *info = sim_info_new(path);
|
||||
|
||||
if (info) {
|
||||
dbus = sailfish_sim_info_dbus_new(info);
|
||||
sailfish_sim_info_unref(info);
|
||||
dbus = sim_info_dbus_new(info);
|
||||
sim_info_unref(info);
|
||||
}
|
||||
|
||||
return dbus;
|
||||
}
|
||||
|
||||
void sailfish_sim_info_dbus_free(struct sailfish_sim_info_dbus *dbus)
|
||||
void sim_info_dbus_free(SimInfoDBus *dbus)
|
||||
{
|
||||
if (dbus) {
|
||||
DBG("%s", dbus->info->path);
|
||||
@@ -276,14 +266,13 @@ void sailfish_sim_info_dbus_free(struct sailfish_sim_info_dbus *dbus)
|
||||
dbus_connection_unref(dbus->conn);
|
||||
|
||||
ofono_watch_remove_all_handlers(dbus->watch,
|
||||
dbus->watch_event_id);
|
||||
dbus->watch_event_id);
|
||||
ofono_watch_unref(dbus->watch);
|
||||
|
||||
sailfish_sim_info_remove_all_handlers(dbus->info,
|
||||
dbus->info_event_id);
|
||||
sailfish_sim_info_unref(dbus->info);
|
||||
sim_info_remove_all_handlers(dbus->info, dbus->info_event_id);
|
||||
sim_info_unref(dbus->info);
|
||||
|
||||
g_slice_free(struct sailfish_sim_info_dbus, dbus);
|
||||
g_free(dbus);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017-2020 Jolla Ltd.
|
||||
* Copyright (C) 2017-2021 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,29 +21,28 @@
|
||||
|
||||
#include <ofono/watch.h>
|
||||
|
||||
#include "sailfish_sim_info.h"
|
||||
|
||||
#include <gutil_misc.h>
|
||||
#include <gutil_log.h>
|
||||
|
||||
#include "src/ofono.h"
|
||||
#include "src/common.h"
|
||||
#include "src/storage.h"
|
||||
#include "ofono.h"
|
||||
#include "common.h"
|
||||
#include "storage.h"
|
||||
#include "sim-info.h"
|
||||
|
||||
#define SAILFISH_SIM_INFO_STORE "cache"
|
||||
#define SAILFISH_SIM_INFO_STORE_GROUP "sim"
|
||||
#define SAILFISH_SIM_INFO_STORE_SPN "spn"
|
||||
#define SIM_INFO_STORE "cache"
|
||||
#define SIM_INFO_STORE_GROUP "sim"
|
||||
#define SIM_INFO_STORE_SPN "spn"
|
||||
|
||||
/* ICCID -> IMSI map */
|
||||
#define SAILFISH_SIM_ICCID_MAP "iccidmap"
|
||||
#define SAILFISH_SIM_ICCID_MAP_IMSI "imsi"
|
||||
#define SIM_ICCID_MAP "iccidmap"
|
||||
#define SIM_ICCID_MAP_IMSI "imsi"
|
||||
|
||||
#define DEFAULT_SPN_BUFSIZE 8
|
||||
G_STATIC_ASSERT(DEFAULT_SPN_BUFSIZE >= \
|
||||
OFONO_MAX_MCC_LENGTH + OFONO_MAX_MNC_LENGTH + 1);
|
||||
|
||||
typedef GObjectClass SailfishSimInfoClass;
|
||||
typedef struct sailfish_sim_info SailfishSimInfo;
|
||||
typedef GObjectClass SimInfoClass;
|
||||
typedef struct sim_info SimInfo;
|
||||
|
||||
enum ofono_watch_events {
|
||||
WATCH_EVENT_SIM,
|
||||
@@ -55,7 +54,7 @@ enum ofono_watch_events {
|
||||
WATCH_EVENT_COUNT
|
||||
};
|
||||
|
||||
struct sailfish_sim_info_priv {
|
||||
typedef struct sim_info_priv {
|
||||
struct ofono_watch *watch;
|
||||
struct ofono_netreg *netreg;
|
||||
char *iccid;
|
||||
@@ -69,9 +68,9 @@ struct sailfish_sim_info_priv {
|
||||
gboolean update_imsi_cache;
|
||||
gboolean update_iccid_map;
|
||||
int queued_signals;
|
||||
};
|
||||
} SimInfoPriv;
|
||||
|
||||
enum sailfish_sim_info_signal {
|
||||
enum sim_info_signal {
|
||||
SIGNAL_ICCID_CHANGED,
|
||||
SIGNAL_IMSI_CHANGED,
|
||||
SIGNAL_SPN_CHANGED,
|
||||
@@ -82,15 +81,15 @@ enum sailfish_sim_info_signal {
|
||||
#define SIGNAL_IMSI_CHANGED_NAME "sailfish-siminfo-imsi-changed"
|
||||
#define SIGNAL_SPN_CHANGED_NAME "sailfish-siminfo-spn-changed"
|
||||
|
||||
static guint sailfish_sim_info_signals[SIGNAL_COUNT] = { 0 };
|
||||
static guint sim_info_signals[SIGNAL_COUNT] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE(SailfishSimInfo, sailfish_sim_info, G_TYPE_OBJECT)
|
||||
#define SAILFISH_SIMINFO_TYPE (sailfish_sim_info_get_type())
|
||||
#define SAILFISH_SIMINFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
|
||||
SAILFISH_SIMINFO_TYPE, SailfishSimInfo))
|
||||
G_DEFINE_TYPE(SimInfo, sim_info, G_TYPE_OBJECT)
|
||||
#define SIMINFO_TYPE (sim_info_get_type())
|
||||
#define SIMINFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
|
||||
SIMINFO_TYPE, SimInfo))
|
||||
|
||||
#define NEW_SIGNAL(klass,name) \
|
||||
sailfish_sim_info_signals[SIGNAL_##name##_CHANGED] = \
|
||||
sim_info_signals[SIGNAL_##name##_CHANGED] = \
|
||||
g_signal_new(SIGNAL_##name##_CHANGED_NAME, \
|
||||
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
|
||||
0, NULL, NULL, NULL, G_TYPE_NONE, 0)
|
||||
@@ -98,56 +97,50 @@ G_DEFINE_TYPE(SailfishSimInfo, sailfish_sim_info, G_TYPE_OBJECT)
|
||||
/* Skip the leading slash from the modem path: */
|
||||
#define DBG_(obj,fmt,args...) DBG("%s " fmt, (obj)->path+1, ##args)
|
||||
|
||||
static int sailfish_sim_info_signal_bit(enum sailfish_sim_info_signal id)
|
||||
static int sim_info_signal_bit(enum sim_info_signal id)
|
||||
{
|
||||
return (1 << id);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_signal_emit(struct sailfish_sim_info *self,
|
||||
enum sailfish_sim_info_signal id)
|
||||
static void sim_info_signal_emit(SimInfo *self, enum sim_info_signal id)
|
||||
{
|
||||
self->priv->queued_signals &= ~sailfish_sim_info_signal_bit(id);
|
||||
g_signal_emit(self, sailfish_sim_info_signals[id], 0);
|
||||
self->priv->queued_signals &= ~sim_info_signal_bit(id);
|
||||
g_signal_emit(self, sim_info_signals[id], 0);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_signal_queue(struct sailfish_sim_info *self,
|
||||
enum sailfish_sim_info_signal id)
|
||||
static void sim_info_signal_queue(SimInfo *self, enum sim_info_signal id)
|
||||
{
|
||||
self->priv->queued_signals |= sailfish_sim_info_signal_bit(id);
|
||||
self->priv->queued_signals |= sim_info_signal_bit(id);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_emit_queued_signals
|
||||
(struct sailfish_sim_info *self)
|
||||
static void sim_info_emit_queued_signals(SimInfo *self)
|
||||
{
|
||||
struct sailfish_sim_info_priv *priv = self->priv;
|
||||
SimInfoPriv *priv = self->priv;
|
||||
int i;
|
||||
|
||||
for (i = 0; priv->queued_signals && i < SIGNAL_COUNT; i++) {
|
||||
if (priv->queued_signals & sailfish_sim_info_signal_bit(i)) {
|
||||
sailfish_sim_info_signal_emit(self, i);
|
||||
if (priv->queued_signals & sim_info_signal_bit(i)) {
|
||||
sim_info_signal_emit(self, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_update_imsi_cache(struct sailfish_sim_info *self)
|
||||
static void sim_info_update_imsi_cache(SimInfo *self)
|
||||
{
|
||||
struct sailfish_sim_info_priv *priv = self->priv;
|
||||
SimInfoPriv *priv = self->priv;
|
||||
|
||||
if (priv->update_imsi_cache && priv->imsi && priv->imsi[0] &&
|
||||
priv->cached_spn && priv->cached_spn[0]) {
|
||||
priv->cached_spn && priv->cached_spn[0]) {
|
||||
gboolean save = FALSE;
|
||||
const char *store = SAILFISH_SIM_INFO_STORE;
|
||||
const char *store = SIM_INFO_STORE;
|
||||
GKeyFile *cache = storage_open(priv->imsi, store);
|
||||
char *spn = g_key_file_get_string(cache,
|
||||
SAILFISH_SIM_INFO_STORE_GROUP,
|
||||
SAILFISH_SIM_INFO_STORE_SPN, NULL);
|
||||
char *spn = g_key_file_get_string(cache, SIM_INFO_STORE_GROUP,
|
||||
SIM_INFO_STORE_SPN, NULL);
|
||||
|
||||
if (g_strcmp0(priv->cached_spn, spn)) {
|
||||
save = TRUE;
|
||||
g_key_file_set_string(cache,
|
||||
SAILFISH_SIM_INFO_STORE_GROUP,
|
||||
SAILFISH_SIM_INFO_STORE_SPN,
|
||||
priv->cached_spn);
|
||||
g_key_file_set_string(cache, SIM_INFO_STORE_GROUP,
|
||||
SIM_INFO_STORE_SPN, priv->cached_spn);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -157,7 +150,7 @@ static void sailfish_sim_info_update_imsi_cache(struct sailfish_sim_info *self)
|
||||
*/
|
||||
if (save) {
|
||||
DBG_(self, "updating " STORAGEDIR "/%s/%s",
|
||||
priv->imsi, store);
|
||||
priv->imsi, store);
|
||||
storage_close(priv->imsi, store, cache, TRUE);
|
||||
} else {
|
||||
g_key_file_free(cache);
|
||||
@@ -168,16 +161,16 @@ static void sailfish_sim_info_update_imsi_cache(struct sailfish_sim_info *self)
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_update_iccid_map(struct sailfish_sim_info *self)
|
||||
static void sim_info_update_iccid_map(SimInfo *self)
|
||||
{
|
||||
struct sailfish_sim_info_priv *priv = self->priv;
|
||||
SimInfoPriv *priv = self->priv;
|
||||
|
||||
if (priv->update_iccid_map && priv->iccid && priv->iccid[0] &&
|
||||
priv->imsi && priv->imsi[0]) {
|
||||
const char *store = SAILFISH_SIM_ICCID_MAP;
|
||||
priv->imsi && priv->imsi[0]) {
|
||||
const char *store = SIM_ICCID_MAP;
|
||||
GKeyFile *map = storage_open(NULL, store);
|
||||
char *imsi = g_key_file_get_string(map,
|
||||
SAILFISH_SIM_ICCID_MAP_IMSI, priv->iccid, NULL);
|
||||
SIM_ICCID_MAP_IMSI, priv->iccid, NULL);
|
||||
|
||||
/*
|
||||
* Since we are most likely running on flash which
|
||||
@@ -186,7 +179,7 @@ static void sailfish_sim_info_update_iccid_map(struct sailfish_sim_info *self)
|
||||
*/
|
||||
if (g_strcmp0(imsi, priv->imsi)) {
|
||||
DBG_(self, "updating " STORAGEDIR "/%s", store);
|
||||
g_key_file_set_string(map, SAILFISH_SIM_ICCID_MAP_IMSI,
|
||||
g_key_file_set_string(map, SIM_ICCID_MAP_IMSI,
|
||||
priv->iccid, priv->imsi);
|
||||
storage_close(NULL, store, map, TRUE);
|
||||
} else {
|
||||
@@ -198,12 +191,12 @@ static void sailfish_sim_info_update_iccid_map(struct sailfish_sim_info *self)
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_update_public_spn(struct sailfish_sim_info *self)
|
||||
static void sim_info_update_public_spn(SimInfo *self)
|
||||
{
|
||||
struct sailfish_sim_info_priv *priv = self->priv;
|
||||
SimInfoPriv *priv = self->priv;
|
||||
const char *spn = priv->sim_spn ? priv->sim_spn :
|
||||
priv->cached_spn ? priv->cached_spn :
|
||||
priv->default_spn;
|
||||
priv->cached_spn ? priv->cached_spn :
|
||||
priv->default_spn;
|
||||
|
||||
if (g_strcmp0(priv->public_spn, spn)) {
|
||||
g_free(priv->public_spn);
|
||||
@@ -215,14 +208,13 @@ static void sailfish_sim_info_update_public_spn(struct sailfish_sim_info *self)
|
||||
priv->public_spn = NULL;
|
||||
}
|
||||
self->spn = priv->public_spn;
|
||||
sailfish_sim_info_signal_queue(self, SIGNAL_SPN_CHANGED);
|
||||
sim_info_signal_queue(self, SIGNAL_SPN_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_set_cached_spn(struct sailfish_sim_info *self,
|
||||
const char *spn)
|
||||
static void sim_info_set_cached_spn(SimInfo *self, const char *spn)
|
||||
{
|
||||
struct sailfish_sim_info_priv *priv = self->priv;
|
||||
SimInfoPriv *priv = self->priv;
|
||||
|
||||
GASSERT(spn);
|
||||
if (g_strcmp0(priv->cached_spn, spn)) {
|
||||
@@ -230,15 +222,14 @@ static void sailfish_sim_info_set_cached_spn(struct sailfish_sim_info *self,
|
||||
g_free(priv->cached_spn);
|
||||
priv->cached_spn = g_strdup(spn);
|
||||
priv->update_imsi_cache = TRUE;
|
||||
sailfish_sim_info_update_imsi_cache(self);
|
||||
sailfish_sim_info_update_public_spn(self);
|
||||
sim_info_update_imsi_cache(self);
|
||||
sim_info_update_public_spn(self);
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_set_spn(struct sailfish_sim_info *self,
|
||||
const char *spn)
|
||||
static void sim_info_set_spn(SimInfo *self, const char *spn)
|
||||
{
|
||||
struct sailfish_sim_info_priv *priv = self->priv;
|
||||
SimInfoPriv *priv = self->priv;
|
||||
|
||||
GASSERT(spn);
|
||||
if (g_strcmp0(priv->sim_spn, spn)) {
|
||||
@@ -246,24 +237,24 @@ static void sailfish_sim_info_set_spn(struct sailfish_sim_info *self,
|
||||
g_free(priv->sim_spn);
|
||||
priv->sim_spn = g_strdup(spn);
|
||||
priv->update_imsi_cache = TRUE;
|
||||
sailfish_sim_info_set_cached_spn(self, spn);
|
||||
sailfish_sim_info_update_imsi_cache(self);
|
||||
sailfish_sim_info_update_public_spn(self);
|
||||
sim_info_set_cached_spn(self, spn);
|
||||
sim_info_update_imsi_cache(self);
|
||||
sim_info_update_public_spn(self);
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_update_spn(struct sailfish_sim_info *self)
|
||||
static void sim_info_update_spn(SimInfo *self)
|
||||
{
|
||||
struct ofono_watch *watch = self->priv->watch;
|
||||
|
||||
if (watch->spn && watch->spn[0]) {
|
||||
sailfish_sim_info_set_spn(self, watch->spn);
|
||||
sim_info_set_spn(self, watch->spn);
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_update_default_spn(struct sailfish_sim_info *self)
|
||||
static void sim_info_update_default_spn(SimInfo *self)
|
||||
{
|
||||
struct sailfish_sim_info_priv *priv = self->priv;
|
||||
SimInfoPriv *priv = self->priv;
|
||||
struct ofono_sim *sim = priv->watch->sim;
|
||||
char buf[DEFAULT_SPN_BUFSIZE];
|
||||
const char *mcc = NULL;
|
||||
@@ -284,13 +275,13 @@ static void sailfish_sim_info_update_default_spn(struct sailfish_sim_info *self)
|
||||
if (strcmp(buf, priv->default_spn)) {
|
||||
strncpy(priv->default_spn, buf, DEFAULT_SPN_BUFSIZE);
|
||||
DBG_(self, "default spn \"%s\"", priv->default_spn);
|
||||
sailfish_sim_info_update_public_spn(self);
|
||||
sim_info_update_public_spn(self);
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_update_imsi(struct sailfish_sim_info *self)
|
||||
static void sim_info_update_imsi(SimInfo *self)
|
||||
{
|
||||
struct sailfish_sim_info_priv *priv = self->priv;
|
||||
SimInfoPriv *priv = self->priv;
|
||||
const char *imsi = priv->watch->imsi;
|
||||
|
||||
/* IMSI only gets reset when ICCID disappears, ignore NULL IMSI here */
|
||||
@@ -299,25 +290,25 @@ static void sailfish_sim_info_update_imsi(struct sailfish_sim_info *self)
|
||||
g_free(priv->imsi);
|
||||
self->imsi = priv->imsi = g_strdup(imsi);
|
||||
priv->update_iccid_map = TRUE;
|
||||
sailfish_sim_info_update_iccid_map(self);
|
||||
sailfish_sim_info_update_imsi_cache(self);
|
||||
sailfish_sim_info_signal_queue(self, SIGNAL_IMSI_CHANGED);
|
||||
sim_info_update_iccid_map(self);
|
||||
sim_info_update_imsi_cache(self);
|
||||
sim_info_signal_queue(self, SIGNAL_IMSI_CHANGED);
|
||||
}
|
||||
|
||||
/* Check if MCC/MNC have changed */
|
||||
sailfish_sim_info_update_default_spn(self);
|
||||
sim_info_update_default_spn(self);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_network_check(struct sailfish_sim_info *self)
|
||||
static void sim_info_network_check(SimInfo *self)
|
||||
{
|
||||
struct sailfish_sim_info_priv *priv = self->priv;
|
||||
SimInfoPriv *priv = self->priv;
|
||||
struct ofono_sim *sim = priv->watch->sim;
|
||||
enum network_registration_status reg_status =
|
||||
enum ofono_netreg_status reg_status =
|
||||
ofono_netreg_get_status(priv->netreg);
|
||||
|
||||
if (sim && ofono_sim_get_state(sim) == OFONO_SIM_STATE_READY &&
|
||||
(reg_status == NETWORK_REGISTRATION_STATUS_REGISTERED ||
|
||||
reg_status == NETWORK_REGISTRATION_STATUS_ROAMING)) {
|
||||
reg_status == NETWORK_REGISTRATION_STATUS_ROAMING)) {
|
||||
const char *sim_mcc = ofono_sim_get_mcc(sim);
|
||||
const char *sim_mnc = ofono_sim_get_mnc(sim);
|
||||
const char *net_mcc = ofono_netreg_get_mcc(priv->netreg);
|
||||
@@ -335,22 +326,22 @@ static void sailfish_sim_info_network_check(struct sailfish_sim_info *self)
|
||||
*/
|
||||
DBG_(self, "home network \"%s\"", name);
|
||||
if (!priv->sim_spn) {
|
||||
sailfish_sim_info_set_cached_spn(self, name);
|
||||
sim_info_set_cached_spn(self, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_load_cache(struct sailfish_sim_info *self)
|
||||
static void sim_info_load_cache(SimInfo *self)
|
||||
{
|
||||
struct sailfish_sim_info_priv *priv = self->priv;
|
||||
SimInfoPriv *priv = self->priv;
|
||||
|
||||
if (priv->iccid && priv->iccid[0]) {
|
||||
GKeyFile *map = storage_open(NULL, SAILFISH_SIM_ICCID_MAP);
|
||||
char *imsi = g_key_file_get_string(map,
|
||||
SAILFISH_SIM_ICCID_MAP_IMSI, priv->iccid, NULL);
|
||||
g_key_file_free(map);
|
||||
GKeyFile *map = storage_open(NULL, SIM_ICCID_MAP);
|
||||
char *imsi = g_key_file_get_string(map, SIM_ICCID_MAP_IMSI,
|
||||
priv->iccid, NULL);
|
||||
|
||||
g_key_file_free(map);
|
||||
if (imsi && imsi[0] && g_strcmp0(priv->imsi, imsi)) {
|
||||
if (priv->imsi && priv->imsi[0]) {
|
||||
/* Need to update ICCID -> IMSI map */
|
||||
@@ -361,9 +352,9 @@ static void sailfish_sim_info_load_cache(struct sailfish_sim_info *self)
|
||||
g_free(priv->imsi);
|
||||
self->imsi = priv->imsi = imsi;
|
||||
DBG_(self, "imsi[%s] = %s", priv->iccid, imsi);
|
||||
sailfish_sim_info_update_iccid_map(self);
|
||||
sailfish_sim_info_update_default_spn(self);
|
||||
sailfish_sim_info_signal_queue(self,
|
||||
sim_info_update_iccid_map(self);
|
||||
sim_info_update_default_spn(self);
|
||||
sim_info_signal_queue(self,
|
||||
SIGNAL_IMSI_CHANGED);
|
||||
} else if (imsi) {
|
||||
g_free(imsi);
|
||||
@@ -373,25 +364,23 @@ static void sailfish_sim_info_load_cache(struct sailfish_sim_info *self)
|
||||
}
|
||||
|
||||
if (priv->imsi && priv->imsi[0]) {
|
||||
GKeyFile *cache = storage_open(priv->imsi,
|
||||
SAILFISH_SIM_INFO_STORE);
|
||||
char *spn = g_key_file_get_string(cache,
|
||||
SAILFISH_SIM_INFO_STORE_GROUP,
|
||||
SAILFISH_SIM_INFO_STORE_SPN, NULL);
|
||||
g_key_file_free(cache);
|
||||
GKeyFile *cache = storage_open(priv->imsi, SIM_INFO_STORE);
|
||||
char *spn = g_key_file_get_string(cache, SIM_INFO_STORE_GROUP,
|
||||
SIM_INFO_STORE_SPN, NULL);
|
||||
|
||||
g_key_file_free(cache);
|
||||
if (spn && spn[0] && g_strcmp0(priv->cached_spn, spn)) {
|
||||
if (priv->cached_spn && priv->cached_spn[0]) {
|
||||
/* Need to update the cache file */
|
||||
DBG_(self, "spn changing %s -> %s",
|
||||
priv->cached_spn, spn);
|
||||
priv->cached_spn, spn);
|
||||
priv->update_imsi_cache = TRUE;
|
||||
}
|
||||
g_free(priv->cached_spn);
|
||||
priv->cached_spn = spn;
|
||||
DBG_(self, "spn[%s] = \"%s\"", priv->imsi, spn);
|
||||
sailfish_sim_info_update_imsi_cache(self);
|
||||
sailfish_sim_info_update_public_spn(self);
|
||||
sim_info_update_imsi_cache(self);
|
||||
sim_info_update_public_spn(self);
|
||||
} else if (spn) {
|
||||
g_free(spn);
|
||||
} else {
|
||||
@@ -400,24 +389,23 @@ static void sailfish_sim_info_load_cache(struct sailfish_sim_info *self)
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_set_iccid(struct sailfish_sim_info *self,
|
||||
const char *iccid)
|
||||
static void sim_info_set_iccid(SimInfo *self, const char *iccid)
|
||||
{
|
||||
struct sailfish_sim_info_priv *priv = self->priv;
|
||||
SimInfoPriv *priv = self->priv;
|
||||
|
||||
if (g_strcmp0(priv->iccid, iccid)) {
|
||||
g_free(priv->iccid);
|
||||
self->iccid = priv->iccid = g_strdup(iccid);
|
||||
sailfish_sim_info_signal_queue(self, SIGNAL_ICCID_CHANGED);
|
||||
sim_info_signal_queue(self, SIGNAL_ICCID_CHANGED);
|
||||
if (iccid) {
|
||||
sailfish_sim_info_load_cache(self);
|
||||
sim_info_load_cache(self);
|
||||
} else {
|
||||
DBG_(self, "no more iccid");
|
||||
if (priv->imsi) {
|
||||
g_free(priv->imsi);
|
||||
self->imsi = priv->imsi = NULL;
|
||||
sailfish_sim_info_signal_queue(self,
|
||||
SIGNAL_IMSI_CHANGED);
|
||||
sim_info_signal_queue(self,
|
||||
SIGNAL_IMSI_CHANGED);
|
||||
}
|
||||
if (priv->sim_spn) {
|
||||
g_free(priv->sim_spn);
|
||||
@@ -429,61 +417,57 @@ static void sailfish_sim_info_set_iccid(struct sailfish_sim_info *self,
|
||||
}
|
||||
/* No more default SPN too */
|
||||
priv->default_spn[0] = 0;
|
||||
sailfish_sim_info_update_public_spn(self);
|
||||
sim_info_update_public_spn(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_iccid_watch_cb(struct ofono_watch *watch,
|
||||
void *data)
|
||||
static void sim_info_iccid_watch_cb(struct ofono_watch *watch, void *data)
|
||||
{
|
||||
struct sailfish_sim_info *self = SAILFISH_SIMINFO(data);
|
||||
SimInfo *self = SIMINFO(data);
|
||||
|
||||
DBG_(self, "%s", watch->iccid);
|
||||
sailfish_sim_info_set_iccid(self, watch->iccid);
|
||||
sailfish_sim_info_emit_queued_signals(self);
|
||||
sim_info_set_iccid(self, watch->iccid);
|
||||
sim_info_emit_queued_signals(self);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_imsi_watch_cb(struct ofono_watch *watch,
|
||||
void *data)
|
||||
static void sim_info_imsi_watch_cb(struct ofono_watch *watch, void *data)
|
||||
{
|
||||
struct sailfish_sim_info *self = SAILFISH_SIMINFO(data);
|
||||
SimInfo *self = SIMINFO(data);
|
||||
|
||||
sailfish_sim_info_update_imsi(self);
|
||||
sailfish_sim_info_emit_queued_signals(self);
|
||||
sim_info_update_imsi(self);
|
||||
sim_info_emit_queued_signals(self);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_spn_watch_cb(struct ofono_watch *watch,
|
||||
void *data)
|
||||
static void sim_info_spn_watch_cb(struct ofono_watch *watch, void *data)
|
||||
{
|
||||
struct sailfish_sim_info *self = SAILFISH_SIMINFO(data);
|
||||
SimInfo *self = SIMINFO(data);
|
||||
|
||||
sailfish_sim_info_update_spn(self);
|
||||
sailfish_sim_info_emit_queued_signals(self);
|
||||
sim_info_update_spn(self);
|
||||
sim_info_emit_queued_signals(self);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_netreg_watch(int status, int lac, int ci,
|
||||
static void sim_info_netreg_watch(int status, int lac, int ci,
|
||||
int tech, const char *mcc, const char *mnc, void *data)
|
||||
{
|
||||
struct sailfish_sim_info *self = SAILFISH_SIMINFO(data);
|
||||
SimInfo *self = SIMINFO(data);
|
||||
|
||||
sailfish_sim_info_network_check(self);
|
||||
sailfish_sim_info_emit_queued_signals(self);
|
||||
sim_info_network_check(self);
|
||||
sim_info_emit_queued_signals(self);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_netreg_watch_done(void *data)
|
||||
static void sim_info_netreg_watch_done(void *data)
|
||||
{
|
||||
struct sailfish_sim_info *self = SAILFISH_SIMINFO(data);
|
||||
struct sailfish_sim_info_priv *priv = self->priv;
|
||||
SimInfo *self = SIMINFO(data);
|
||||
SimInfoPriv *priv = self->priv;
|
||||
|
||||
GASSERT(priv->netreg_status_watch_id);
|
||||
priv->netreg_status_watch_id = 0;
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_set_netreg(struct sailfish_sim_info *self,
|
||||
struct ofono_netreg *netreg)
|
||||
static void sim_info_set_netreg(SimInfo *self, struct ofono_netreg *netreg)
|
||||
{
|
||||
struct sailfish_sim_info_priv *priv = self->priv;
|
||||
SimInfoPriv *priv = self->priv;
|
||||
|
||||
if (priv->netreg != netreg) {
|
||||
if (netreg) {
|
||||
@@ -491,9 +475,9 @@ static void sailfish_sim_info_set_netreg(struct sailfish_sim_info *self,
|
||||
priv->netreg = netreg;
|
||||
priv->netreg_status_watch_id =
|
||||
__ofono_netreg_add_status_watch(netreg,
|
||||
sailfish_sim_info_netreg_watch, self,
|
||||
sailfish_sim_info_netreg_watch_done);
|
||||
sailfish_sim_info_network_check(self);
|
||||
sim_info_netreg_watch, self,
|
||||
sim_info_netreg_watch_done);
|
||||
sim_info_network_check(self);
|
||||
} else if (priv->netreg) {
|
||||
if (priv->netreg_status_watch_id) {
|
||||
__ofono_netreg_remove_status_watch(priv->netreg,
|
||||
@@ -506,44 +490,43 @@ static void sailfish_sim_info_set_netreg(struct sailfish_sim_info *self,
|
||||
}
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_netreg_changed(struct ofono_watch *watch,
|
||||
void *data)
|
||||
static void sim_info_netreg_changed(struct ofono_watch *watch, void *data)
|
||||
{
|
||||
struct sailfish_sim_info *self = SAILFISH_SIMINFO(data);
|
||||
SimInfo *self = SIMINFO(data);
|
||||
|
||||
sailfish_sim_info_set_netreg(self, watch->netreg);
|
||||
sailfish_sim_info_emit_queued_signals(self);
|
||||
sim_info_set_netreg(self, watch->netreg);
|
||||
sim_info_emit_queued_signals(self);
|
||||
}
|
||||
|
||||
struct sailfish_sim_info *sailfish_sim_info_new(const char *path)
|
||||
SimInfo *sim_info_new(const char *path)
|
||||
{
|
||||
struct sailfish_sim_info *self = NULL;
|
||||
SimInfo *self = NULL;
|
||||
|
||||
if (path) {
|
||||
struct ofono_watch *watch = ofono_watch_new(path);
|
||||
struct sailfish_sim_info_priv *priv;
|
||||
SimInfoPriv *priv;
|
||||
|
||||
self = g_object_new(SAILFISH_SIMINFO_TYPE, NULL);
|
||||
self = g_object_new(SIMINFO_TYPE, NULL);
|
||||
priv = self->priv;
|
||||
priv->watch = watch;
|
||||
self->path = watch->path;
|
||||
priv->watch_event_id[WATCH_EVENT_ICCID] =
|
||||
ofono_watch_add_iccid_changed_handler(watch,
|
||||
sailfish_sim_info_iccid_watch_cb, self);
|
||||
sim_info_iccid_watch_cb, self);
|
||||
priv->watch_event_id[WATCH_EVENT_IMSI] =
|
||||
ofono_watch_add_imsi_changed_handler(watch,
|
||||
sailfish_sim_info_imsi_watch_cb, self);
|
||||
sim_info_imsi_watch_cb, self);
|
||||
priv->watch_event_id[WATCH_EVENT_SPN] =
|
||||
ofono_watch_add_spn_changed_handler(watch,
|
||||
sailfish_sim_info_spn_watch_cb, self);
|
||||
sim_info_spn_watch_cb, self);
|
||||
priv->watch_event_id[WATCH_EVENT_NETREG] =
|
||||
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);
|
||||
sailfish_sim_info_update_imsi(self);
|
||||
sailfish_sim_info_update_spn(self);
|
||||
sailfish_sim_info_network_check(self);
|
||||
sim_info_netreg_changed, self);
|
||||
sim_info_set_iccid(self, watch->iccid);
|
||||
sim_info_set_netreg(self, watch->netreg);
|
||||
sim_info_update_imsi(self);
|
||||
sim_info_update_spn(self);
|
||||
sim_info_network_check(self);
|
||||
|
||||
/* Clear queued events, if any */
|
||||
priv->queued_signals = 0;
|
||||
@@ -551,67 +534,66 @@ struct sailfish_sim_info *sailfish_sim_info_new(const char *path)
|
||||
return self;
|
||||
}
|
||||
|
||||
struct sailfish_sim_info *sailfish_sim_info_ref(struct sailfish_sim_info *self)
|
||||
SimInfo *sim_info_ref(SimInfo *self)
|
||||
{
|
||||
if (self) {
|
||||
g_object_ref(SAILFISH_SIMINFO(self));
|
||||
g_object_ref(SIMINFO(self));
|
||||
return self;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void sailfish_sim_info_unref(struct sailfish_sim_info *self)
|
||||
void sim_info_unref(SimInfo *self)
|
||||
{
|
||||
if (self) {
|
||||
g_object_unref(SAILFISH_SIMINFO(self));
|
||||
g_object_unref(SIMINFO(self));
|
||||
}
|
||||
}
|
||||
|
||||
gulong sailfish_sim_info_add_iccid_changed_handler(struct sailfish_sim_info *s,
|
||||
sailfish_sim_info_cb_t cb, void *arg)
|
||||
gulong sim_info_add_iccid_changed_handler(SimInfo *s, sim_info_cb_t cb,
|
||||
void *arg)
|
||||
{
|
||||
return (s && cb) ? g_signal_connect(s, SIGNAL_ICCID_CHANGED_NAME,
|
||||
G_CALLBACK(cb), arg) : 0;
|
||||
G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
gulong sailfish_sim_info_add_imsi_changed_handler(struct sailfish_sim_info *s,
|
||||
sailfish_sim_info_cb_t cb, void *arg)
|
||||
gulong sim_info_add_imsi_changed_handler(SimInfo *s, sim_info_cb_t cb,
|
||||
void *arg)
|
||||
{
|
||||
return (s && cb) ? g_signal_connect(s, SIGNAL_IMSI_CHANGED_NAME,
|
||||
G_CALLBACK(cb), arg) : 0;
|
||||
G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
gulong sailfish_sim_info_add_spn_changed_handler(struct sailfish_sim_info *s,
|
||||
sailfish_sim_info_cb_t cb, void *arg)
|
||||
gulong sim_info_add_spn_changed_handler(SimInfo *s,
|
||||
sim_info_cb_t cb, void *arg)
|
||||
{
|
||||
return (s && cb) ? g_signal_connect(s, SIGNAL_SPN_CHANGED_NAME,
|
||||
G_CALLBACK(cb), arg) : 0;
|
||||
G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
void sailfish_sim_info_remove_handler(struct sailfish_sim_info *s, gulong id)
|
||||
void sim_info_remove_handler(SimInfo *s, gulong id)
|
||||
{
|
||||
if (s && id) {
|
||||
g_signal_handler_disconnect(s, id);
|
||||
}
|
||||
}
|
||||
|
||||
void sailfish_sim_info_remove_handlers(struct sailfish_sim_info *self,
|
||||
gulong *ids, int count)
|
||||
void sim_info_remove_handlers(SimInfo *self, gulong *ids, int count)
|
||||
{
|
||||
gutil_disconnect_handlers(self, ids, count);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_init(struct sailfish_sim_info *self)
|
||||
static void sim_info_init(SimInfo *self)
|
||||
{
|
||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self, SAILFISH_SIMINFO_TYPE,
|
||||
struct sailfish_sim_info_priv);
|
||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self, SIMINFO_TYPE,
|
||||
SimInfoPriv);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_finalize(GObject *object)
|
||||
static void sim_info_finalize(GObject *object)
|
||||
{
|
||||
struct sailfish_sim_info *self = SAILFISH_SIMINFO(object);
|
||||
struct sailfish_sim_info_priv *priv = self->priv;
|
||||
SimInfo *self = SIMINFO(object);
|
||||
SimInfoPriv *priv = self->priv;
|
||||
|
||||
ofono_watch_remove_all_handlers(priv->watch, priv->watch_event_id);
|
||||
ofono_watch_unref(priv->watch);
|
||||
@@ -620,13 +602,13 @@ static void sailfish_sim_info_finalize(GObject *object)
|
||||
g_free(priv->sim_spn);
|
||||
g_free(priv->cached_spn);
|
||||
g_free(priv->public_spn);
|
||||
G_OBJECT_CLASS(sailfish_sim_info_parent_class)->finalize(object);
|
||||
G_OBJECT_CLASS(sim_info_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void sailfish_sim_info_class_init(SailfishSimInfoClass *klass)
|
||||
static void sim_info_class_init(SimInfoClass *klass)
|
||||
{
|
||||
G_OBJECT_CLASS(klass)->finalize = sailfish_sim_info_finalize;
|
||||
g_type_class_add_private(klass, sizeof(struct sailfish_sim_info_priv));
|
||||
G_OBJECT_CLASS(klass)->finalize = sim_info_finalize;
|
||||
g_type_class_add_private(klass, sizeof(SimInfoPriv));
|
||||
NEW_SIGNAL(klass, ICCID);
|
||||
NEW_SIGNAL(klass, IMSI);
|
||||
NEW_SIGNAL(klass, SPN);
|
||||
72
ofono/src/sim-info.h
Normal file
72
ofono/src/sim-info.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017-2021 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 SIM_INFO_H
|
||||
#define SIM_INFO_H
|
||||
|
||||
#include <ofono/types.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
/*
|
||||
* Note that iccid, imsi and spn provided by this class can be cached,
|
||||
* i.e. become available before the pin code is entered and before those
|
||||
* are known to the ofono core. That's the whole purpose of this thing.
|
||||
*/
|
||||
struct ofono_modem;
|
||||
struct sim_info_priv;
|
||||
struct sim_info {
|
||||
GObject object;
|
||||
struct sim_info_priv *priv;
|
||||
const char *path;
|
||||
const char *iccid;
|
||||
const char *imsi;
|
||||
const char *spn;
|
||||
};
|
||||
|
||||
typedef void (*sim_info_cb_t)(struct sim_info *si, void *user_data);
|
||||
|
||||
/* SIM info object associated with the particular slot */
|
||||
struct sim_info *sim_info_new(const char *path);
|
||||
struct sim_info *sim_info_ref(struct sim_info *si);
|
||||
void sim_info_unref(struct sim_info *si);
|
||||
gulong sim_info_add_iccid_changed_handler(struct sim_info *si,
|
||||
sim_info_cb_t cb, void *user_data);
|
||||
gulong sim_info_add_imsi_changed_handler(struct sim_info *si,
|
||||
sim_info_cb_t cb, void *user_data);
|
||||
gulong sim_info_add_spn_changed_handler(struct sim_info *si,
|
||||
sim_info_cb_t cb, void *user_data);
|
||||
void sim_info_remove_handler(struct sim_info *si, gulong id);
|
||||
void sim_info_remove_handlers(struct sim_info *si, gulong *ids, int count);
|
||||
|
||||
#define sim_info_remove_all_handlers(si,ids) \
|
||||
sim_info_remove_handlers(si, ids, G_N_ELEMENTS(ids))
|
||||
|
||||
/* And the D-Bus interface for it */
|
||||
struct sim_info_dbus;
|
||||
struct sim_info_dbus *sim_info_dbus_new (struct sim_info *si);
|
||||
struct sim_info_dbus *sim_info_dbus_new_path(const char *path);
|
||||
void sim_info_dbus_free(struct sim_info_dbus *dbus);
|
||||
|
||||
#endif /* SIM_INFO_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -4,6 +4,7 @@
|
||||
*
|
||||
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
* Copyright (C) 2013 Canonical Ltd.
|
||||
* Copyright (C) 2015-2021 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
|
||||
@@ -31,7 +32,7 @@
|
||||
|
||||
static GSList *g_drivers = NULL;
|
||||
|
||||
int __ofono_sim_mnclength_get_mnclength(const char *imsi)
|
||||
int ofono_sim_mnclength_get_mnclength(const char *imsi)
|
||||
{
|
||||
GSList *d;
|
||||
int mnclen;
|
||||
@@ -53,12 +54,35 @@ int __ofono_sim_mnclength_get_mnclength(const char *imsi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ofono_sim_mnclength_get_mnclength_mccmnc(int mcc, int mnc)
|
||||
{
|
||||
GSList *d;
|
||||
int mnclen;
|
||||
|
||||
for (d = g_drivers; d != NULL; d = d->next) {
|
||||
const struct ofono_sim_mnclength_driver *driver = d->data;
|
||||
|
||||
if (driver->get_mnclength_mccmnc == NULL)
|
||||
continue;
|
||||
|
||||
DBG("Calling mnclength plugin '%s' for %d %d",
|
||||
driver->name, mcc, mnc);
|
||||
|
||||
if ((mnclen = driver->get_mnclength_mccmnc(mcc, mnc)) <= 0)
|
||||
continue;
|
||||
|
||||
return mnclen;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ofono_sim_mnclength_driver_register(
|
||||
struct ofono_sim_mnclength_driver *driver)
|
||||
const struct ofono_sim_mnclength_driver *driver)
|
||||
{
|
||||
DBG("driver: %p name: %s", driver, driver->name);
|
||||
|
||||
g_drivers = g_slist_prepend(g_drivers, driver);
|
||||
g_drivers = g_slist_prepend(g_drivers, (void*) driver);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -224,9 +224,9 @@ static gboolean password_is_pin(enum ofono_sim_password_type type)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define puk2pin(type) __ofono_sim_puk2pin(type)
|
||||
#define puk2pin(type) ofono_sim_puk2pin(type)
|
||||
|
||||
enum ofono_sim_password_type __ofono_sim_puk2pin(
|
||||
enum ofono_sim_password_type ofono_sim_puk2pin(
|
||||
enum ofono_sim_password_type type)
|
||||
{
|
||||
switch (type) {
|
||||
@@ -680,7 +680,7 @@ static gboolean set_own_numbers(struct ofono_sim *sim,
|
||||
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),
|
||||
return ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
OFONO_DBUS_ACCESS_INTF_SIMMGR, method, arg);
|
||||
}
|
||||
|
||||
@@ -1680,7 +1680,7 @@ static void sim_imsi_obtained(struct ofono_sim *sim, const char *imsi)
|
||||
*/
|
||||
if (sim->mnc_length == 0) {
|
||||
int mnc_aux =
|
||||
__ofono_sim_mnclength_get_mnclength(sim->imsi);
|
||||
ofono_sim_mnclength_get_mnclength(sim->imsi);
|
||||
if (mnc_aux > 0)
|
||||
sim->mnc_length = mnc_aux;
|
||||
}
|
||||
@@ -3575,6 +3575,11 @@ static void sim_file_changed_flush(struct ofono_sim *sim, int id)
|
||||
sim_fs_cache_flush_file(sim->simfs, id);
|
||||
}
|
||||
|
||||
void ofono_sim_refresh_full(struct ofono_sim *sim)
|
||||
{
|
||||
__ofono_sim_refresh(sim, NULL, TRUE, TRUE);
|
||||
}
|
||||
|
||||
void __ofono_sim_refresh(struct ofono_sim *sim, GSList *file_list,
|
||||
ofono_bool_t full_file_change, ofono_bool_t naa_init)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <ofono/types.h>
|
||||
#include <ofono/misc.h>
|
||||
#include "simutil.h"
|
||||
#include "util.h"
|
||||
#include "smsutil.h"
|
||||
@@ -1825,3 +1825,35 @@ gboolean sim_parse_gsm_authenticate(const unsigned char *buffer, int len,
|
||||
gsm_end:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Public API exposed to external plugins */
|
||||
|
||||
unsigned int ofono_get_ef_path_2g(unsigned short id,
|
||||
unsigned char path[/* OFONO_EF_PATH_BUFFER_SIZE */])
|
||||
{
|
||||
return sim_ef_db_get_path_2g(id, path);
|
||||
}
|
||||
|
||||
unsigned int ofono_get_ef_path_3g(unsigned short id,
|
||||
unsigned char path[/* OFONO_EF_PATH_BUFFER_SIZE */])
|
||||
{
|
||||
return sim_ef_db_get_path_3g(id, path);
|
||||
}
|
||||
|
||||
ofono_bool_t ofono_parse_get_response_2g(const void *response, unsigned int len,
|
||||
unsigned int *file_len, unsigned int *record_len,
|
||||
unsigned int *structure, unsigned char *access,
|
||||
unsigned char *status)
|
||||
{
|
||||
return sim_parse_2g_get_response(response, len, (int *)file_len,
|
||||
(int *)record_len, (int *)structure, access, status);
|
||||
}
|
||||
|
||||
ofono_bool_t ofono_parse_get_response_3g(const void *response, unsigned int len,
|
||||
unsigned int *file_len, unsigned int *record_len,
|
||||
unsigned int *structure, unsigned char *access,
|
||||
unsigned short *efid)
|
||||
{
|
||||
return sim_parse_3g_get_response(response, len, (int *)file_len,
|
||||
(int *)record_len, (int *)structure, access, efid);
|
||||
}
|
||||
|
||||
1149
ofono/src/slot-manager-dbus.c
Normal file
1149
ofono/src/slot-manager-dbus.c
Normal file
File diff suppressed because it is too large
Load Diff
85
ofono/src/slot-manager-dbus.h
Normal file
85
ofono/src/slot-manager-dbus.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2016-2021 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 SLOT_MANAGER_DBUS_H
|
||||
#define SLOT_MANAGER_DBUS_H
|
||||
|
||||
#include <ofono/slot.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
struct slot_manager_dbus;
|
||||
|
||||
enum slot_manager_dbus_block {
|
||||
SLOT_MANAGER_DBUS_BLOCK_NONE = 0,
|
||||
SLOT_MANAGER_DBUS_BLOCK_MODEM = 0x01,
|
||||
SLOT_MANAGER_DBUS_BLOCK_IMEI = 0x02,
|
||||
SLOT_MANAGER_DBUS_BLOCK_ALL = 0x03
|
||||
};
|
||||
|
||||
enum slot_manager_dbus_signal {
|
||||
SLOT_MANAGER_DBUS_SIGNAL_NONE = 0,
|
||||
SLOT_MANAGER_DBUS_SIGNAL_VOICE_IMSI = 0x01,
|
||||
SLOT_MANAGER_DBUS_SIGNAL_DATA_IMSI = 0x02,
|
||||
SLOT_MANAGER_DBUS_SIGNAL_VOICE_PATH = 0x04,
|
||||
SLOT_MANAGER_DBUS_SIGNAL_DATA_PATH = 0x08,
|
||||
SLOT_MANAGER_DBUS_SIGNAL_ENABLED_SLOTS = 0x10,
|
||||
SLOT_MANAGER_DBUS_SIGNAL_MMS_IMSI = 0x20,
|
||||
SLOT_MANAGER_DBUS_SIGNAL_MMS_PATH = 0x40,
|
||||
SLOT_MANAGER_DBUS_SIGNAL_READY = 0x80
|
||||
};
|
||||
|
||||
enum slot_manager_dbus_slot_signal {
|
||||
SLOT_MANAGER_DBUS_SLOT_SIGNAL_NONE = 0,
|
||||
SLOT_MANAGER_DBUS_SLOT_SIGNAL_PRESENT = 0x01
|
||||
};
|
||||
|
||||
/* Functionality provided by slot_manager to slot_manager_dbus */
|
||||
struct slot_manager_dbus_cb {
|
||||
GHashTable *(*get_errors)(const struct ofono_slot_manager *mgr);
|
||||
GHashTable *(*get_slot_errors)(const struct ofono_slot *slot);
|
||||
void (*set_enabled_slots)(struct ofono_slot_manager *mgr, char **slots);
|
||||
gboolean (*set_mms_imsi)(struct ofono_slot_manager *mgr,
|
||||
const char *imsi);
|
||||
void (*set_default_voice_imsi)(struct ofono_slot_manager *mgr,
|
||||
const char *imsi);
|
||||
void (*set_default_data_imsi)(struct ofono_slot_manager *mgr,
|
||||
const char *imsi);
|
||||
};
|
||||
|
||||
struct slot_manager_dbus *slot_manager_dbus_new
|
||||
(struct ofono_slot_manager *m,
|
||||
const struct slot_manager_dbus_cb *cb);
|
||||
void slot_manager_dbus_free(struct slot_manager_dbus *d);
|
||||
void slot_manager_dbus_set_block(struct slot_manager_dbus *d,
|
||||
enum slot_manager_dbus_block b);
|
||||
void slot_manager_dbus_signal(struct slot_manager_dbus *d,
|
||||
enum slot_manager_dbus_signal mask);
|
||||
void slot_manager_dbus_signal_sim(struct slot_manager_dbus *d, int index,
|
||||
enum slot_manager_dbus_slot_signal mask);
|
||||
void slot_manager_dbus_signal_error(struct slot_manager_dbus *d,
|
||||
const char *id, const char *message);
|
||||
void slot_manager_dbus_signal_modem_error(struct slot_manager_dbus *d,
|
||||
int index, const char *id, const char *msg);
|
||||
|
||||
#endif /* SLOT_MANAGER_DBUS_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
1544
ofono/src/slot-manager.c
Normal file
1544
ofono/src/slot-manager.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2015-2021 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
|
||||
@@ -1033,7 +1034,7 @@ static DBusMessage *sms_send_message(DBusConnection *conn, DBusMessage *msg,
|
||||
struct sms_message_data *message;
|
||||
struct sms_address addr;
|
||||
|
||||
if (!__ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
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);
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
#include "storage.h"
|
||||
#include "smsutil.h"
|
||||
|
||||
#include <ofono/misc.h>
|
||||
|
||||
#define uninitialized_var(x) x = x
|
||||
|
||||
#define SMS_BACKUP_MODE 0600
|
||||
@@ -4789,3 +4791,11 @@ gboolean ussd_encode(const char *str, long *items_written, unsigned char *pdu)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Public API exposed to external plugins */
|
||||
|
||||
ofono_bool_t ofono_decode_cbs_dcs_charset(unsigned char dcs,
|
||||
enum ofono_sms_charset *charset)
|
||||
{
|
||||
return cbs_dcs_decode(dcs, NULL, NULL, charset, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 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 <ofono/types.h>
|
||||
|
||||
#define CBS_MAX_GSM_CHARS 93
|
||||
#define SMS_MSGID_LEN 20
|
||||
|
||||
@@ -149,11 +151,10 @@ enum sms_class {
|
||||
SMS_CLASS_UNSPECIFIED = 4,
|
||||
};
|
||||
|
||||
enum sms_charset {
|
||||
SMS_CHARSET_7BIT = 0,
|
||||
SMS_CHARSET_8BIT = 1,
|
||||
SMS_CHARSET_UCS2 = 2,
|
||||
};
|
||||
#define sms_charset ofono_sms_charset
|
||||
#define SMS_CHARSET_7BIT OFONO_SMS_CHARSET_7BIT /* 0 */
|
||||
#define SMS_CHARSET_8BIT OFONO_SMS_CHARSET_8BIT /* 1 */
|
||||
#define SMS_CHARSET_UCS2 OFONO_SMS_CHARSET_UCS2 /* 2 */
|
||||
|
||||
enum sms_alphabet {
|
||||
SMS_ALPHABET_DEFAULT = 0,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2020 Jolla Ltd.
|
||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
||||
* Copyright (C) 2020 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -727,7 +727,7 @@ static DBusMessage *stk_register_agent(DBusConnection *conn,
|
||||
if (!dbus_validate_path(agent_path, NULL))
|
||||
return __ofono_error_invalid_format(msg);
|
||||
|
||||
if (!__ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
if (!ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
OFONO_DBUS_ACCESS_INTF_STK,
|
||||
OFONO_DBUS_ACCESS_STK_REGISTER_AGENT,
|
||||
agent_path))
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
* Copyright (C) 2015-2021 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
|
||||
@@ -1507,3 +1508,37 @@ unsigned char *convert_ucs2_to_gsm(const unsigned char *text, long len,
|
||||
GSM_DIALECT_DEFAULT,
|
||||
GSM_DIALECT_DEFAULT);
|
||||
}
|
||||
|
||||
/* Public API exposed to external plugins */
|
||||
|
||||
#include <ofono/misc.h>
|
||||
|
||||
char *ofono_sim_string_to_utf8(const unsigned char *buffer, int length)
|
||||
{
|
||||
return sim_string_to_utf8(buffer, length);
|
||||
}
|
||||
|
||||
void ofono_sim_string_free(char *str)
|
||||
{
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
void ofono_encode_hex(const void *in, unsigned int size, char out[])
|
||||
{
|
||||
encode_hex_own_buf(in, size, 0, out);
|
||||
}
|
||||
|
||||
unsigned int ofono_unpack_7bit(const void *in, unsigned int len,
|
||||
unsigned int flags, void *out_buf, unsigned int out_buf_size)
|
||||
{
|
||||
if (len) {
|
||||
long written = 0;
|
||||
|
||||
unpack_7bit_own_buf(in, len, 0,
|
||||
(flags & OFONO_UNPACK_7BIT_USSD) != 0,
|
||||
out_buf_size, &written, 0, out_buf);
|
||||
return (unsigned int) written;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ static DBusMessage *voicecall_get_properties(DBusConnection *conn,
|
||||
static gboolean voicecall_allow(DBusMessage *msg,
|
||||
enum ofono_dbus_access_voicecall_method method)
|
||||
{
|
||||
return __ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
return ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
OFONO_DBUS_ACCESS_INTF_VOICECALL, method, NULL);
|
||||
}
|
||||
|
||||
@@ -864,6 +864,9 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc)
|
||||
case CALL_STATUS_WAITING:
|
||||
waiting = TRUE;
|
||||
break;
|
||||
|
||||
case CALL_STATUS_DISCONNECTED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1747,7 +1750,7 @@ static int voicecall_dial(struct ofono_voicecall *vc, const char *number,
|
||||
static gboolean manager_allow(DBusMessage *msg,
|
||||
enum ofono_dbus_access_voicecallmgr_method method)
|
||||
{
|
||||
return __ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
return ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
OFONO_DBUS_ACCESS_INTF_VOICECALLMGR, method, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,26 +16,26 @@ TESTS="\
|
||||
test-cdmasms \
|
||||
test-sms-root \
|
||||
test-caif \
|
||||
test-cell-info \
|
||||
test-cell-info-dbus \
|
||||
test-conf \
|
||||
test-dbus-queue \
|
||||
test-dbus-access \
|
||||
test-dbus-clients \
|
||||
test-gprs-filter \
|
||||
test-provision \
|
||||
test-config \
|
||||
test-watch \
|
||||
test-ril_util \
|
||||
test-ril_config \
|
||||
test-ril_ecclist \
|
||||
test-ril-transport \
|
||||
test-ril_vendor \
|
||||
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-sim-info \
|
||||
test-sim-info-dbus \
|
||||
test-slot-manager \
|
||||
test-sms-filter \
|
||||
test-voicecall-filter"
|
||||
|
||||
pushd `dirname $0` > /dev/null
|
||||
TEST_DIR="$PWD"
|
||||
|
||||
219
ofono/unit/fake_cell_info.c
Normal file
219
ofono/unit/fake_cell_info.c
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017-2021 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_cell_info.h"
|
||||
|
||||
#include <ofono/log.h>
|
||||
|
||||
#include <gutil_macros.h>
|
||||
#include <gutil_misc.h>
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
typedef GObjectClass FakeCellInfoClass;
|
||||
typedef struct fake_cell_info {
|
||||
GObject object;
|
||||
struct ofono_cell_info info;
|
||||
struct ofono_cell **cells;
|
||||
int interval;
|
||||
gboolean enabled;
|
||||
} FakeCellInfo;
|
||||
|
||||
typedef struct fake_cell_info_signal_data {
|
||||
ofono_cell_info_cb_t cb;
|
||||
void *arg;
|
||||
} FakeCellInfoSignalData;
|
||||
|
||||
enum fake_cell_info_signal {
|
||||
SIGNAL_CHANGED,
|
||||
SIGNAL_COUNT
|
||||
};
|
||||
|
||||
static guint fake_cell_info_signals[SIGNAL_COUNT] = { 0 };
|
||||
|
||||
#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), THIS_TYPE, FakeCellInfo)
|
||||
#define THIS_TYPE fake_cell_info_get_type()
|
||||
#define PARENT_TYPE G_TYPE_OBJECT
|
||||
#define PARENT_CLASS fake_cell_info_parent_class
|
||||
|
||||
G_DEFINE_TYPE(FakeCellInfo, fake_cell_info, PARENT_TYPE)
|
||||
|
||||
#define SIGNAL_CHANGED_NAME "fake-cell-info-changed"
|
||||
|
||||
static FakeCellInfo *fake_cell_info_cast(struct ofono_cell_info *info)
|
||||
{
|
||||
return G_CAST(info, FakeCellInfo, info);
|
||||
}
|
||||
|
||||
static void fake_cell_info_ref_proc(struct ofono_cell_info *info)
|
||||
{
|
||||
g_object_ref(fake_cell_info_cast(info));
|
||||
}
|
||||
|
||||
static void fake_cell_info_unref_proc(struct ofono_cell_info *info)
|
||||
{
|
||||
g_object_unref(fake_cell_info_cast(info));
|
||||
}
|
||||
|
||||
static void fake_cell_info_change_cb(FakeCellInfo *self, void *data)
|
||||
{
|
||||
FakeCellInfoSignalData *signal_data = data;
|
||||
|
||||
signal_data->cb(&self->info, signal_data->arg);
|
||||
}
|
||||
|
||||
static void fake_cell_info_change_free(gpointer data, GClosure *closure)
|
||||
{
|
||||
g_free(data);
|
||||
}
|
||||
|
||||
static gulong fake_cell_info_add_change_handler_proc
|
||||
(struct ofono_cell_info *info,
|
||||
ofono_cell_info_cb_t cb, void *arg)
|
||||
{
|
||||
if (cb) {
|
||||
FakeCellInfoSignalData *data =
|
||||
g_new0(FakeCellInfoSignalData, 1);
|
||||
|
||||
data->cb = cb;
|
||||
data->arg = arg;
|
||||
return g_signal_connect_data(fake_cell_info_cast(info),
|
||||
SIGNAL_CHANGED_NAME,
|
||||
G_CALLBACK(fake_cell_info_change_cb),
|
||||
data, fake_cell_info_change_free,
|
||||
G_CONNECT_AFTER);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void fake_cell_info_remove_handler_proc(struct ofono_cell_info *info,
|
||||
gulong id)
|
||||
{
|
||||
if (id) {
|
||||
g_signal_handler_disconnect(fake_cell_info_cast(info), id);
|
||||
}
|
||||
}
|
||||
|
||||
static void fake_cell_info_set_update_interval(struct ofono_cell_info *info,
|
||||
int ms)
|
||||
{
|
||||
DBG("%d", ms);
|
||||
fake_cell_info_cast(info)->interval = ms;
|
||||
}
|
||||
|
||||
static void fake_cell_info_set_enabled(struct ofono_cell_info *info,
|
||||
ofono_bool_t enabled)
|
||||
{
|
||||
DBG("%d", enabled);
|
||||
fake_cell_info_cast(info)->enabled = enabled;
|
||||
}
|
||||
|
||||
static void fake_cell_info_init(FakeCellInfo *self)
|
||||
{
|
||||
self->info.cells = self->cells = g_new0(struct ofono_cell*, 1);
|
||||
}
|
||||
|
||||
static void fake_cell_info_finalize(GObject *object)
|
||||
{
|
||||
FakeCellInfo *self = THIS(object);
|
||||
|
||||
gutil_ptrv_free((void**)self->cells);
|
||||
G_OBJECT_CLASS(PARENT_CLASS)->finalize(object);
|
||||
}
|
||||
|
||||
static void fake_cell_info_class_init(FakeCellInfoClass *klass)
|
||||
{
|
||||
G_OBJECT_CLASS(klass)->finalize = fake_cell_info_finalize;
|
||||
fake_cell_info_signals[SIGNAL_CHANGED] =
|
||||
g_signal_new(SIGNAL_CHANGED_NAME,
|
||||
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST,
|
||||
0, NULL, NULL, NULL, G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
struct ofono_cell_info *fake_cell_info_new()
|
||||
{
|
||||
static const struct ofono_cell_info_proc fake_cell_info_proc = {
|
||||
fake_cell_info_ref_proc,
|
||||
fake_cell_info_unref_proc,
|
||||
fake_cell_info_add_change_handler_proc,
|
||||
fake_cell_info_remove_handler_proc,
|
||||
fake_cell_info_set_update_interval,
|
||||
fake_cell_info_set_enabled
|
||||
};
|
||||
|
||||
FakeCellInfo *self = g_object_new(THIS_TYPE, 0);
|
||||
|
||||
self->info.proc = &fake_cell_info_proc;
|
||||
return &self->info;
|
||||
}
|
||||
|
||||
void fake_cell_info_add_cell(struct ofono_cell_info *info,
|
||||
const struct ofono_cell* c)
|
||||
{
|
||||
FakeCellInfo *self = fake_cell_info_cast(info);
|
||||
gsize n = gutil_ptrv_length(self->cells);
|
||||
|
||||
self->cells = g_renew(struct ofono_cell*, self->cells, n + 2);
|
||||
self->cells[n++] = g_memdup(c, sizeof(*c));
|
||||
self->cells[n] = NULL;
|
||||
info->cells = self->cells;
|
||||
}
|
||||
|
||||
ofono_bool_t fake_cell_info_remove_cell(struct ofono_cell_info *info,
|
||||
const struct ofono_cell* cell)
|
||||
{
|
||||
FakeCellInfo *self = fake_cell_info_cast(info);
|
||||
gsize i, n = gutil_ptrv_length(self->cells);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
struct ofono_cell *known_cell = self->cells[i];
|
||||
|
||||
if (!memcmp(cell, known_cell, sizeof(*cell))) {
|
||||
g_free(known_cell);
|
||||
memmove(self->cells + i, self->cells + i + 1,
|
||||
sizeof(struct ofono_cell*)*(n - i));
|
||||
self->cells = g_renew(struct ofono_cell*,
|
||||
self->cells, n);
|
||||
info->cells = self->cells;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void fake_cell_info_remove_all_cells(struct ofono_cell_info *info)
|
||||
{
|
||||
FakeCellInfo *self = fake_cell_info_cast(info);
|
||||
|
||||
if (gutil_ptrv_length(self->cells) > 0) {
|
||||
gutil_ptrv_free((void**)self->cells);
|
||||
self->info.cells = self->cells = g_new0(struct ofono_cell*, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void fake_cell_info_cells_changed(struct ofono_cell_info *info)
|
||||
{
|
||||
g_signal_emit(fake_cell_info_cast(info), fake_cell_info_signals
|
||||
[SIGNAL_CHANGED], 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2018 Jolla Ltd.
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -13,20 +13,20 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef SAILFISH_FAKE_CELL_INFO_H
|
||||
#define SAILFISH_FAKE_CELL_INFO_H
|
||||
#ifndef FAKE_CELL_INFO_H
|
||||
#define FAKE_CELL_INFO_H
|
||||
|
||||
#include "sailfish_cell_info.h"
|
||||
#include <ofono/cell-info.h>
|
||||
|
||||
struct sailfish_cell_info *fake_cell_info_new(void);
|
||||
void fake_cell_info_add_cell(struct sailfish_cell_info *info,
|
||||
const struct sailfish_cell* cell);
|
||||
gboolean fake_cell_info_remove_cell(struct sailfish_cell_info *info,
|
||||
const struct sailfish_cell* cell);
|
||||
void fake_cell_info_remove_all_cells(struct sailfish_cell_info *info);
|
||||
void fake_cell_info_cells_changed(struct sailfish_cell_info *info);
|
||||
struct ofono_cell_info *fake_cell_info_new(void);
|
||||
void fake_cell_info_add_cell(struct ofono_cell_info *info,
|
||||
const struct ofono_cell* cell);
|
||||
ofono_bool_t fake_cell_info_remove_cell(struct ofono_cell_info *info,
|
||||
const struct ofono_cell* cell);
|
||||
void fake_cell_info_remove_all_cells(struct ofono_cell_info *info);
|
||||
void fake_cell_info_cells_changed(struct ofono_cell_info *info);
|
||||
|
||||
#endif /* FAKE_SAILFISH_CELL_INFO_H */
|
||||
#endif /* FAKE_CELL_INFO_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
@@ -1,181 +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_cell_info.h"
|
||||
|
||||
#include <gutil_macros.h>
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
typedef GObjectClass FakeCellInfoClass;
|
||||
typedef struct fake_cell_info {
|
||||
GObject object;
|
||||
struct sailfish_cell_info info;
|
||||
} FakeCellInfo;
|
||||
|
||||
typedef struct fake_cell_info_signal_data {
|
||||
sailfish_cell_info_cb_t cb;
|
||||
void *arg;
|
||||
} FakeCellInfoSignalData;
|
||||
|
||||
enum fake_cell_info_signal {
|
||||
SIGNAL_CELLS_CHANGED,
|
||||
SIGNAL_COUNT
|
||||
};
|
||||
|
||||
static guint fake_cell_info_signals[SIGNAL_COUNT] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE(FakeCellInfo, fake_cell_info, G_TYPE_OBJECT)
|
||||
#define FAKE_CELL_INFO_TYPE (fake_cell_info_get_type())
|
||||
#define FAKE_CELL_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
|
||||
FAKE_CELL_INFO_TYPE, FakeCellInfo))
|
||||
|
||||
#define SIGNAL_CELLS_CHANGED_NAME "fake-cell-info-cells-changed"
|
||||
|
||||
static FakeCellInfo *fake_cell_info_cast(struct sailfish_cell_info *info)
|
||||
{
|
||||
return G_CAST(info, FakeCellInfo, info);
|
||||
}
|
||||
|
||||
static void fake_cell_info_ref_proc(struct sailfish_cell_info *info)
|
||||
{
|
||||
g_object_ref(fake_cell_info_cast(info));
|
||||
}
|
||||
|
||||
static void fake_cell_info_unref_proc(struct sailfish_cell_info *info)
|
||||
{
|
||||
g_object_unref(fake_cell_info_cast(info));
|
||||
}
|
||||
|
||||
static void fake_cell_info_cells_changed_cb(FakeCellInfo *self, void *data)
|
||||
{
|
||||
FakeCellInfoSignalData *signal_data = data;
|
||||
|
||||
signal_data->cb(&self->info, signal_data->arg);
|
||||
}
|
||||
|
||||
static void fake_cell_info_cells_disconnect_notify(gpointer data,
|
||||
GClosure *closure)
|
||||
{
|
||||
g_free(data);
|
||||
}
|
||||
|
||||
static gulong fake_cell_info_add_cells_changed_handler_proc
|
||||
(struct sailfish_cell_info *info,
|
||||
sailfish_cell_info_cb_t cb, void *arg)
|
||||
{
|
||||
if (cb) {
|
||||
FakeCellInfoSignalData *data =
|
||||
g_new0(FakeCellInfoSignalData, 1);
|
||||
|
||||
data->cb = cb;
|
||||
data->arg = arg;
|
||||
return g_signal_connect_data(fake_cell_info_cast(info),
|
||||
SIGNAL_CELLS_CHANGED_NAME,
|
||||
G_CALLBACK(fake_cell_info_cells_changed_cb),
|
||||
data, fake_cell_info_cells_disconnect_notify,
|
||||
G_CONNECT_AFTER);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void fake_cell_info_remove_handler_proc(struct sailfish_cell_info *info,
|
||||
gulong id)
|
||||
{
|
||||
if (id) {
|
||||
g_signal_handler_disconnect(fake_cell_info_cast(info), id);
|
||||
}
|
||||
}
|
||||
|
||||
static void fake_cell_info_init(FakeCellInfo *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void fake_cell_info_finalize(GObject *object)
|
||||
{
|
||||
FakeCellInfo *self = FAKE_CELL_INFO(object);
|
||||
|
||||
fake_cell_info_remove_all_cells(&self->info);
|
||||
G_OBJECT_CLASS(fake_cell_info_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void fake_cell_info_class_init(FakeCellInfoClass *klass)
|
||||
{
|
||||
G_OBJECT_CLASS(klass)->finalize = fake_cell_info_finalize;
|
||||
fake_cell_info_signals[SIGNAL_CELLS_CHANGED] =
|
||||
g_signal_new(SIGNAL_CELLS_CHANGED_NAME,
|
||||
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST,
|
||||
0, NULL, NULL, NULL, G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
struct sailfish_cell_info *fake_cell_info_new()
|
||||
{
|
||||
static const struct sailfish_cell_info_proc fake_cell_info_proc = {
|
||||
fake_cell_info_ref_proc,
|
||||
fake_cell_info_unref_proc,
|
||||
fake_cell_info_add_cells_changed_handler_proc,
|
||||
fake_cell_info_remove_handler_proc
|
||||
};
|
||||
|
||||
FakeCellInfo *self = g_object_new(FAKE_CELL_INFO_TYPE, 0);
|
||||
|
||||
self->info.proc = &fake_cell_info_proc;
|
||||
return &self->info;
|
||||
}
|
||||
|
||||
void fake_cell_info_add_cell(struct sailfish_cell_info *info,
|
||||
const struct sailfish_cell* cell)
|
||||
{
|
||||
info->cells = g_slist_append(info->cells,
|
||||
g_memdup(cell, sizeof(*cell)));
|
||||
}
|
||||
|
||||
gboolean fake_cell_info_remove_cell(struct sailfish_cell_info *info,
|
||||
const struct sailfish_cell* cell)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
for (l = info->cells; l; l = l->next) {
|
||||
struct sailfish_cell *known_cell = l->data;
|
||||
|
||||
if (!memcmp(cell, known_cell, sizeof(*cell))) {
|
||||
info->cells = g_slist_remove(info->cells, known_cell);
|
||||
g_free(known_cell);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void fake_cell_info_remove_all_cells(struct sailfish_cell_info *info)
|
||||
{
|
||||
g_slist_free_full(info->cells, g_free);
|
||||
info->cells = NULL;
|
||||
}
|
||||
|
||||
void fake_cell_info_cells_changed(struct sailfish_cell_info *info)
|
||||
{
|
||||
g_signal_emit(fake_cell_info_cast(info), fake_cell_info_signals
|
||||
[SIGNAL_CELLS_CHANGED], 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -15,9 +15,10 @@
|
||||
|
||||
#include "test-dbus.h"
|
||||
|
||||
#include "sailfish_cell_info.h"
|
||||
#include "sailfish_cell_info_dbus.h"
|
||||
#include "fake_sailfish_cell_info.h"
|
||||
#include <ofono/cell-info.h>
|
||||
|
||||
#include "cell-info-dbus.h"
|
||||
#include "fake_cell_info.h"
|
||||
|
||||
#include <gutil_log.h>
|
||||
#include <gutil_macros.h>
|
||||
@@ -181,7 +182,7 @@ static void test_check_get_cells_reply(DBusPendingCall *call,
|
||||
}
|
||||
|
||||
static void test_check_get_all_reply(DBusPendingCall *call,
|
||||
const struct sailfish_cell *cell, const char *type)
|
||||
const struct ofono_cell *cell, const char *type)
|
||||
{
|
||||
DBusMessage *reply = dbus_pending_call_steal_reply(call);
|
||||
DBusMessageIter it, array;
|
||||
@@ -220,12 +221,12 @@ static void test_check_error(DBusPendingCall *call, const char* name)
|
||||
dbus_message_unref(reply);
|
||||
}
|
||||
|
||||
static struct sailfish_cell *test_cell_init_gsm1(struct sailfish_cell *cell)
|
||||
static struct ofono_cell *test_cell_init_gsm1(struct ofono_cell *cell)
|
||||
{
|
||||
struct sailfish_cell_info_gsm *gsm = &cell->info.gsm;
|
||||
struct ofono_cell_info_gsm *gsm = &cell->info.gsm;
|
||||
|
||||
memset(cell, 0, sizeof(*cell));
|
||||
cell->type = SAILFISH_CELL_TYPE_GSM;
|
||||
cell->type = OFONO_CELL_TYPE_GSM;
|
||||
cell->registered = TRUE;
|
||||
gsm->mcc = 244;
|
||||
gsm->mnc = 5;
|
||||
@@ -239,12 +240,12 @@ static struct sailfish_cell *test_cell_init_gsm1(struct sailfish_cell *cell)
|
||||
return cell;
|
||||
}
|
||||
|
||||
static struct sailfish_cell *test_cell_init_gsm2(struct sailfish_cell *cell)
|
||||
static struct ofono_cell *test_cell_init_gsm2(struct ofono_cell *cell)
|
||||
{
|
||||
struct sailfish_cell_info_gsm *gsm = &cell->info.gsm;
|
||||
struct ofono_cell_info_gsm *gsm = &cell->info.gsm;
|
||||
|
||||
memset(cell, 0, sizeof(*cell));
|
||||
cell->type = SAILFISH_CELL_TYPE_GSM;
|
||||
cell->type = OFONO_CELL_TYPE_GSM;
|
||||
cell->registered = FALSE;
|
||||
gsm->mcc = 244;
|
||||
gsm->mnc = 5;
|
||||
@@ -258,12 +259,12 @@ static struct sailfish_cell *test_cell_init_gsm2(struct sailfish_cell *cell)
|
||||
return cell;
|
||||
}
|
||||
|
||||
static struct sailfish_cell *test_cell_init_wcdma1(struct sailfish_cell *cell)
|
||||
static struct ofono_cell *test_cell_init_wcdma1(struct ofono_cell *cell)
|
||||
{
|
||||
struct sailfish_cell_info_wcdma *wcdma = &cell->info.wcdma;
|
||||
struct ofono_cell_info_wcdma *wcdma = &cell->info.wcdma;
|
||||
|
||||
memset(cell, 0, sizeof(*cell));
|
||||
cell->type = SAILFISH_CELL_TYPE_WCDMA;
|
||||
cell->type = OFONO_CELL_TYPE_WCDMA;
|
||||
cell->registered = TRUE;
|
||||
wcdma->mcc = 250;
|
||||
wcdma->mnc = 99;
|
||||
@@ -276,12 +277,12 @@ static struct sailfish_cell *test_cell_init_wcdma1(struct sailfish_cell *cell)
|
||||
return cell;
|
||||
}
|
||||
|
||||
static struct sailfish_cell *test_cell_init_wcdma2(struct sailfish_cell *cell)
|
||||
static struct ofono_cell *test_cell_init_wcdma2(struct ofono_cell *cell)
|
||||
{
|
||||
struct sailfish_cell_info_wcdma *wcdma = &cell->info.wcdma;
|
||||
struct ofono_cell_info_wcdma *wcdma = &cell->info.wcdma;
|
||||
|
||||
memset(cell, 0, sizeof(*cell));
|
||||
cell->type = SAILFISH_CELL_TYPE_WCDMA;
|
||||
cell->type = OFONO_CELL_TYPE_WCDMA;
|
||||
cell->registered = FALSE;
|
||||
wcdma->mcc = INT_MAX;
|
||||
wcdma->mnc = INT_MAX;
|
||||
@@ -294,12 +295,12 @@ static struct sailfish_cell *test_cell_init_wcdma2(struct sailfish_cell *cell)
|
||||
return cell;
|
||||
}
|
||||
|
||||
static struct sailfish_cell *test_cell_init_lte(struct sailfish_cell *cell)
|
||||
static struct ofono_cell *test_cell_init_lte(struct ofono_cell *cell)
|
||||
{
|
||||
struct sailfish_cell_info_lte *lte = &cell->info.lte;
|
||||
struct ofono_cell_info_lte *lte = &cell->info.lte;
|
||||
|
||||
memset(cell, 0, sizeof(*cell));
|
||||
cell->type = SAILFISH_CELL_TYPE_LTE;
|
||||
cell->type = OFONO_CELL_TYPE_LTE;
|
||||
cell->registered = TRUE;
|
||||
lte->mcc = 244;
|
||||
lte->mnc = 91;
|
||||
@@ -325,9 +326,9 @@ static void test_misc(void)
|
||||
modem.path = TEST_MODEM_PATH;
|
||||
|
||||
/* NULL resistance */
|
||||
g_assert(!sailfish_cell_info_dbus_new(NULL, NULL));
|
||||
g_assert(!sailfish_cell_info_dbus_new(&modem, NULL));
|
||||
sailfish_cell_info_dbus_free(NULL);
|
||||
g_assert(!cell_info_dbus_new(NULL, NULL));
|
||||
g_assert(!cell_info_dbus_new(&modem, NULL));
|
||||
cell_info_dbus_free(NULL);
|
||||
|
||||
/* Calling __ofono_dbus_cleanup() without __ofono_dbus_init() is ok */
|
||||
__ofono_dbus_cleanup();
|
||||
@@ -338,8 +339,8 @@ static void test_misc(void)
|
||||
struct test_get_cells_data {
|
||||
struct ofono_modem modem;
|
||||
struct test_dbus_context context;
|
||||
struct sailfish_cell_info *info;
|
||||
struct sailfish_cell_info_dbus *dbus;
|
||||
struct cell_info_dbus *dbus;
|
||||
struct ofono_cell_info *info;
|
||||
};
|
||||
|
||||
static void test_get_cells_call(struct test_get_cells_data *test,
|
||||
@@ -374,7 +375,7 @@ static void test_get_cells_start_reply2(DBusPendingCall *call, void *data)
|
||||
{
|
||||
struct test_get_cells_data *test = data;
|
||||
const char *cell_added = "/test/cell_1";
|
||||
struct sailfish_cell cell;
|
||||
struct ofono_cell cell;
|
||||
DBusMessageIter it;
|
||||
DBusMessage *signal = test_dbus_take_signal(&test->context,
|
||||
test->modem.path, CELL_INFO_DBUS_INTERFACE,
|
||||
@@ -400,7 +401,7 @@ static void test_get_cells_start_reply2(DBusPendingCall *call, void *data)
|
||||
static void test_get_cells_start_reply1(DBusPendingCall *call, void *data)
|
||||
{
|
||||
struct test_get_cells_data *test = data;
|
||||
struct sailfish_cell cell;
|
||||
struct ofono_cell cell;
|
||||
|
||||
DBG("");
|
||||
test_check_get_cells_reply(call, "/test/cell_0", NULL);
|
||||
@@ -414,7 +415,7 @@ static void test_get_cells_start_reply1(DBusPendingCall *call, void *data)
|
||||
|
||||
static void test_get_cells_start(struct test_dbus_context *context)
|
||||
{
|
||||
struct sailfish_cell cell;
|
||||
struct ofono_cell cell;
|
||||
struct test_get_cells_data *test =
|
||||
G_CAST(context, struct test_get_cells_data, context);
|
||||
|
||||
@@ -422,7 +423,7 @@ static void test_get_cells_start(struct test_dbus_context *context)
|
||||
test->info = fake_cell_info_new();
|
||||
fake_cell_info_add_cell(test->info, test_cell_init_gsm1(&cell));
|
||||
|
||||
test->dbus = sailfish_cell_info_dbus_new(&test->modem, test->info);
|
||||
test->dbus = cell_info_dbus_new(&test->modem, test->info);
|
||||
g_assert(test->dbus);
|
||||
|
||||
test_get_cells_call(test, test_get_cells_start_reply1);
|
||||
@@ -440,8 +441,8 @@ static void test_get_cells(void)
|
||||
|
||||
g_main_loop_run(test.context.loop);
|
||||
|
||||
sailfish_cell_info_unref(test.info);
|
||||
sailfish_cell_info_dbus_free(test.dbus);
|
||||
ofono_cell_info_unref(test.info);
|
||||
cell_info_dbus_free(test.dbus);
|
||||
test_dbus_shutdown(&test.context);
|
||||
if (timeout) {
|
||||
g_source_remove(timeout);
|
||||
@@ -453,8 +454,8 @@ static void test_get_cells(void)
|
||||
struct test_get_all_data {
|
||||
struct ofono_modem modem;
|
||||
struct test_dbus_context context;
|
||||
struct sailfish_cell_info_dbus *dbus;
|
||||
struct sailfish_cell cell;
|
||||
struct cell_info_dbus *dbus;
|
||||
struct ofono_cell cell;
|
||||
const char *type;
|
||||
};
|
||||
|
||||
@@ -471,22 +472,22 @@ static void test_get_all_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
static void test_get_all_start(struct test_dbus_context *context)
|
||||
{
|
||||
struct sailfish_cell_info *info;
|
||||
struct ofono_cell_info *info;
|
||||
struct test_get_all_data *test =
|
||||
G_CAST(context, struct test_get_all_data, context);
|
||||
|
||||
DBG("");
|
||||
info = fake_cell_info_new();
|
||||
fake_cell_info_add_cell(info, &test->cell);
|
||||
test->dbus = sailfish_cell_info_dbus_new(&test->modem, info);
|
||||
test->dbus = cell_info_dbus_new(&test->modem, info);
|
||||
g_assert(test->dbus);
|
||||
sailfish_cell_info_unref(info);
|
||||
ofono_cell_info_unref(info);
|
||||
|
||||
test_submit_get_all_call(context->client_connection, "/test/cell_0",
|
||||
test_get_all_reply, test);
|
||||
}
|
||||
|
||||
static void test_get_all(const struct sailfish_cell *cell, const char *type)
|
||||
static void test_get_all(const struct ofono_cell *cell, const char *type)
|
||||
{
|
||||
struct test_get_all_data test;
|
||||
guint timeout = test_setup_timeout();
|
||||
@@ -500,7 +501,7 @@ static void test_get_all(const struct sailfish_cell *cell, const char *type)
|
||||
|
||||
g_main_loop_run(test.context.loop);
|
||||
|
||||
sailfish_cell_info_dbus_free(test.dbus);
|
||||
cell_info_dbus_free(test.dbus);
|
||||
test_dbus_shutdown(&test.context);
|
||||
if (timeout) {
|
||||
g_source_remove(timeout);
|
||||
@@ -509,28 +510,28 @@ static void test_get_all(const struct sailfish_cell *cell, const char *type)
|
||||
|
||||
static void test_get_all1(void)
|
||||
{
|
||||
struct sailfish_cell cell;
|
||||
struct ofono_cell cell;
|
||||
|
||||
test_get_all(test_cell_init_gsm1(&cell), "gsm");
|
||||
}
|
||||
|
||||
static void test_get_all2(void)
|
||||
{
|
||||
struct sailfish_cell cell;
|
||||
struct ofono_cell cell;
|
||||
|
||||
test_get_all(test_cell_init_wcdma2(&cell), "wcdma");
|
||||
}
|
||||
|
||||
static void test_get_all3(void)
|
||||
{
|
||||
struct sailfish_cell cell;
|
||||
struct ofono_cell cell;
|
||||
|
||||
test_get_all(test_cell_init_lte(&cell), "lte");
|
||||
}
|
||||
|
||||
static void test_get_all4(void)
|
||||
{
|
||||
struct sailfish_cell cell;
|
||||
struct ofono_cell cell;
|
||||
|
||||
/* Invalid cell */
|
||||
memset(&cell, 0xff, sizeof(cell));
|
||||
@@ -542,7 +543,7 @@ static void test_get_all4(void)
|
||||
struct test_get_version_data {
|
||||
struct ofono_modem modem;
|
||||
struct test_dbus_context context;
|
||||
struct sailfish_cell_info_dbus *dbus;
|
||||
struct cell_info_dbus *dbus;
|
||||
};
|
||||
|
||||
static void test_get_version_reply(DBusPendingCall *call, void *data)
|
||||
@@ -568,17 +569,17 @@ static void test_get_version_start(struct test_dbus_context *context)
|
||||
{
|
||||
DBusPendingCall *call;
|
||||
DBusMessage *msg;
|
||||
struct sailfish_cell cell;
|
||||
struct sailfish_cell_info *info;
|
||||
struct ofono_cell cell;
|
||||
struct ofono_cell_info *info;
|
||||
struct test_get_version_data *test =
|
||||
G_CAST(context, struct test_get_version_data, context);
|
||||
|
||||
DBG("");
|
||||
info = fake_cell_info_new();
|
||||
fake_cell_info_add_cell(info, test_cell_init_gsm1(&cell));
|
||||
test->dbus = sailfish_cell_info_dbus_new(&test->modem, info);
|
||||
test->dbus = cell_info_dbus_new(&test->modem, info);
|
||||
g_assert(test->dbus);
|
||||
sailfish_cell_info_unref(info);
|
||||
ofono_cell_info_unref(info);
|
||||
|
||||
msg = test_new_cell_call("/test/cell_0", "GetInterfaceVersion");
|
||||
g_assert(dbus_connection_send_with_reply(context->client_connection,
|
||||
@@ -599,7 +600,7 @@ static void test_get_version(void)
|
||||
|
||||
g_main_loop_run(test.context.loop);
|
||||
|
||||
sailfish_cell_info_dbus_free(test.dbus);
|
||||
cell_info_dbus_free(test.dbus);
|
||||
test_dbus_shutdown(&test.context);
|
||||
if (timeout) {
|
||||
g_source_remove(timeout);
|
||||
@@ -611,7 +612,7 @@ static void test_get_version(void)
|
||||
struct test_get_type_data {
|
||||
struct ofono_modem modem;
|
||||
struct test_dbus_context context;
|
||||
struct sailfish_cell_info_dbus *dbus;
|
||||
struct cell_info_dbus *dbus;
|
||||
};
|
||||
|
||||
static void test_get_type_reply(DBusPendingCall *call, void *data)
|
||||
@@ -636,17 +637,17 @@ static void test_get_type_start(struct test_dbus_context *context)
|
||||
{
|
||||
DBusPendingCall *call;
|
||||
DBusMessage *msg;
|
||||
struct sailfish_cell cell;
|
||||
struct sailfish_cell_info *info;
|
||||
struct ofono_cell cell;
|
||||
struct ofono_cell_info *info;
|
||||
struct test_get_type_data *test =
|
||||
G_CAST(context, struct test_get_type_data, context);
|
||||
|
||||
DBG("");
|
||||
info = fake_cell_info_new();
|
||||
fake_cell_info_add_cell(info, test_cell_init_wcdma1(&cell));
|
||||
test->dbus = sailfish_cell_info_dbus_new(&test->modem, info);
|
||||
test->dbus = cell_info_dbus_new(&test->modem, info);
|
||||
g_assert(test->dbus);
|
||||
sailfish_cell_info_unref(info);
|
||||
ofono_cell_info_unref(info);
|
||||
|
||||
msg = test_new_cell_call("/test/cell_0", "GetType");
|
||||
g_assert(dbus_connection_send_with_reply(context->client_connection,
|
||||
@@ -667,7 +668,7 @@ static void test_get_type(void)
|
||||
|
||||
g_main_loop_run(test.context.loop);
|
||||
|
||||
sailfish_cell_info_dbus_free(test.dbus);
|
||||
cell_info_dbus_free(test.dbus);
|
||||
test_dbus_shutdown(&test.context);
|
||||
if (timeout) {
|
||||
g_source_remove(timeout);
|
||||
@@ -679,7 +680,7 @@ static void test_get_type(void)
|
||||
struct test_get_registered_data {
|
||||
struct ofono_modem modem;
|
||||
struct test_dbus_context context;
|
||||
struct sailfish_cell_info_dbus *dbus;
|
||||
struct cell_info_dbus *dbus;
|
||||
};
|
||||
|
||||
static void test_get_registered_reply(DBusPendingCall *call, void *data)
|
||||
@@ -704,17 +705,17 @@ static void test_get_registered_start(struct test_dbus_context *context)
|
||||
{
|
||||
DBusPendingCall *call;
|
||||
DBusMessage *msg;
|
||||
struct sailfish_cell cell;
|
||||
struct sailfish_cell_info *info;
|
||||
struct ofono_cell cell;
|
||||
struct ofono_cell_info *info;
|
||||
struct test_get_registered_data *test =
|
||||
G_CAST(context, struct test_get_registered_data, context);
|
||||
|
||||
DBG("");
|
||||
info = fake_cell_info_new();
|
||||
fake_cell_info_add_cell(info, test_cell_init_wcdma1(&cell));
|
||||
test->dbus = sailfish_cell_info_dbus_new(&test->modem, info);
|
||||
test->dbus = cell_info_dbus_new(&test->modem, info);
|
||||
g_assert(test->dbus);
|
||||
sailfish_cell_info_unref(info);
|
||||
ofono_cell_info_unref(info);
|
||||
|
||||
msg = test_new_cell_call("/test/cell_0", "GetRegistered");
|
||||
g_assert(dbus_connection_send_with_reply(context->client_connection,
|
||||
@@ -736,7 +737,7 @@ static void test_get_registered(void)
|
||||
|
||||
g_main_loop_run(test.context.loop);
|
||||
|
||||
sailfish_cell_info_dbus_free(test.dbus);
|
||||
cell_info_dbus_free(test.dbus);
|
||||
test_dbus_shutdown(&test.context);
|
||||
if (timeout) {
|
||||
g_source_remove(timeout);
|
||||
@@ -748,7 +749,7 @@ static void test_get_registered(void)
|
||||
struct test_get_properties_data {
|
||||
struct ofono_modem modem;
|
||||
struct test_dbus_context context;
|
||||
struct sailfish_cell_info_dbus *dbus;
|
||||
struct cell_info_dbus *dbus;
|
||||
};
|
||||
|
||||
static void test_get_properties_reply(DBusPendingCall *call, void *data)
|
||||
@@ -776,17 +777,17 @@ static void test_get_properties_start(struct test_dbus_context *context)
|
||||
{
|
||||
DBusPendingCall *call;
|
||||
DBusMessage *msg;
|
||||
struct sailfish_cell cell;
|
||||
struct sailfish_cell_info *info;
|
||||
struct ofono_cell cell;
|
||||
struct ofono_cell_info *info;
|
||||
struct test_get_properties_data *test =
|
||||
G_CAST(context, struct test_get_properties_data, context);
|
||||
|
||||
DBG("");
|
||||
info = fake_cell_info_new();
|
||||
fake_cell_info_add_cell(info, test_cell_init_wcdma2(&cell));
|
||||
test->dbus = sailfish_cell_info_dbus_new(&test->modem, info);
|
||||
test->dbus = cell_info_dbus_new(&test->modem, info);
|
||||
g_assert(test->dbus);
|
||||
sailfish_cell_info_unref(info);
|
||||
ofono_cell_info_unref(info);
|
||||
|
||||
msg = test_new_cell_call("/test/cell_0", "GetProperties");
|
||||
g_assert(dbus_connection_send_with_reply(context->client_connection,
|
||||
@@ -808,7 +809,7 @@ static void test_get_properties(void)
|
||||
|
||||
g_main_loop_run(test.context.loop);
|
||||
|
||||
sailfish_cell_info_dbus_free(test.dbus);
|
||||
cell_info_dbus_free(test.dbus);
|
||||
test_dbus_shutdown(&test.context);
|
||||
if (timeout) {
|
||||
g_source_remove(timeout);
|
||||
@@ -820,9 +821,9 @@ static void test_get_properties(void)
|
||||
struct test_registered_changed_data {
|
||||
struct ofono_modem modem;
|
||||
struct test_dbus_context context;
|
||||
struct sailfish_cell_info *info;
|
||||
struct sailfish_cell_info_dbus *dbus;
|
||||
struct sailfish_cell cell;
|
||||
struct cell_info_dbus *dbus;
|
||||
struct ofono_cell_info *info;
|
||||
struct ofono_cell cell;
|
||||
const char *type;
|
||||
const char *cell_path;
|
||||
};
|
||||
@@ -841,14 +842,14 @@ static void test_registered_changed_reply2(DBusPendingCall *call, void *data)
|
||||
static void test_registered_changed_reply1(DBusPendingCall *call, void *data)
|
||||
{
|
||||
struct test_registered_changed_data *test = data;
|
||||
struct sailfish_cell *first_cell;
|
||||
struct ofono_cell *first_cell;
|
||||
|
||||
DBG("");
|
||||
test_check_get_cells_reply(call, test->cell_path, NULL);
|
||||
dbus_pending_call_unref(call);
|
||||
|
||||
/* Trigger "RegisteredChanged" signal */
|
||||
first_cell = test->info->cells->data;
|
||||
first_cell = test->info->cells[0];
|
||||
test->cell.registered =
|
||||
first_cell->registered = !first_cell->registered;
|
||||
fake_cell_info_cells_changed(test->info);
|
||||
@@ -865,7 +866,7 @@ static void test_registered_changed_start(struct test_dbus_context *context)
|
||||
DBG("");
|
||||
test->info = fake_cell_info_new();
|
||||
fake_cell_info_add_cell(test->info, &test->cell);
|
||||
test->dbus = sailfish_cell_info_dbus_new(&test->modem, test->info);
|
||||
test->dbus = cell_info_dbus_new(&test->modem, test->info);
|
||||
g_assert(test->dbus);
|
||||
|
||||
/* Submit GetCells to enable "RegisteredChanged" signals */
|
||||
@@ -892,8 +893,8 @@ static void test_registered_changed(void)
|
||||
g_assert(test_dbus_find_signal(&test.context, test.cell_path,
|
||||
CELL_DBUS_INTERFACE, CELL_DBUS_REGISTERED_CHANGED_SIGNAL));
|
||||
|
||||
sailfish_cell_info_unref(test.info);
|
||||
sailfish_cell_info_dbus_free(test.dbus);
|
||||
ofono_cell_info_unref(test.info);
|
||||
cell_info_dbus_free(test.dbus);
|
||||
test_dbus_shutdown(&test.context);
|
||||
if (timeout) {
|
||||
g_source_remove(timeout);
|
||||
@@ -905,9 +906,9 @@ static void test_registered_changed(void)
|
||||
struct test_property_changed_data {
|
||||
struct ofono_modem modem;
|
||||
struct test_dbus_context context;
|
||||
struct sailfish_cell_info *info;
|
||||
struct sailfish_cell_info_dbus *dbus;
|
||||
struct sailfish_cell cell;
|
||||
struct cell_info_dbus *dbus;
|
||||
struct ofono_cell_info *info;
|
||||
struct ofono_cell cell;
|
||||
const char *type;
|
||||
const char *cell_path;
|
||||
};
|
||||
@@ -927,14 +928,14 @@ static void test_property_changed_reply2(DBusPendingCall *call, void *data)
|
||||
static void test_property_changed_reply1(DBusPendingCall *call, void *data)
|
||||
{
|
||||
struct test_property_changed_data *test = data;
|
||||
struct sailfish_cell *first_cell;
|
||||
struct ofono_cell *first_cell;
|
||||
|
||||
DBG("");
|
||||
test_check_get_cells_reply(call, test->cell_path, NULL);
|
||||
dbus_pending_call_unref(call);
|
||||
|
||||
/* Trigger "PropertyChanged" signal */
|
||||
first_cell = test->info->cells->data;
|
||||
first_cell = test->info->cells[0];
|
||||
test->cell.info.gsm.signalStrength =
|
||||
(++(first_cell->info.gsm.signalStrength));
|
||||
fake_cell_info_cells_changed(test->info);
|
||||
@@ -951,7 +952,7 @@ static void test_property_changed_start(struct test_dbus_context *context)
|
||||
DBG("");
|
||||
test->info = fake_cell_info_new();
|
||||
fake_cell_info_add_cell(test->info, &test->cell);
|
||||
test->dbus = sailfish_cell_info_dbus_new(&test->modem, test->info);
|
||||
test->dbus = cell_info_dbus_new(&test->modem, test->info);
|
||||
g_assert(test->dbus);
|
||||
|
||||
/* Submit GetCells to enable "PropertyChanged" signals */
|
||||
@@ -978,8 +979,8 @@ static void test_property_changed(void)
|
||||
g_assert(test_dbus_find_signal(&test.context, test.cell_path,
|
||||
CELL_DBUS_INTERFACE, CELL_DBUS_PROPERTY_CHANGED_SIGNAL));
|
||||
|
||||
sailfish_cell_info_unref(test.info);
|
||||
sailfish_cell_info_dbus_free(test.dbus);
|
||||
ofono_cell_info_unref(test.info);
|
||||
cell_info_dbus_free(test.dbus);
|
||||
test_dbus_shutdown(&test.context);
|
||||
if (timeout) {
|
||||
g_source_remove(timeout);
|
||||
@@ -991,9 +992,9 @@ static void test_property_changed(void)
|
||||
struct test_unsubscribe_data {
|
||||
struct ofono_modem modem;
|
||||
struct test_dbus_context context;
|
||||
struct sailfish_cell_info *info;
|
||||
struct sailfish_cell_info_dbus *dbus;
|
||||
struct sailfish_cell cell;
|
||||
struct cell_info_dbus *dbus;
|
||||
struct ofono_cell_info *info;
|
||||
struct ofono_cell cell;
|
||||
const char *type;
|
||||
const char *cell_path;
|
||||
};
|
||||
@@ -1013,14 +1014,14 @@ static void test_unsubscribe_reply3(DBusPendingCall *call, void *data)
|
||||
static void test_unsubscribe_reply2(DBusPendingCall *call, void *data)
|
||||
{
|
||||
struct test_unsubscribe_data *test = data;
|
||||
struct sailfish_cell *first_cell;
|
||||
struct ofono_cell *first_cell;
|
||||
|
||||
DBG("");
|
||||
test_check_empty_reply(call);
|
||||
dbus_pending_call_unref(call);
|
||||
|
||||
/* No "PropertyChanged" signal is expected because it's disabled */
|
||||
first_cell = test->info->cells->data;
|
||||
first_cell = test->info->cells[0];
|
||||
test->cell.info.gsm.signalStrength =
|
||||
(++(first_cell->info.gsm.signalStrength));
|
||||
fake_cell_info_cells_changed(test->info);
|
||||
@@ -1051,7 +1052,7 @@ static void test_unsubscribe_start(struct test_dbus_context *context)
|
||||
DBG("");
|
||||
test->info = fake_cell_info_new();
|
||||
fake_cell_info_add_cell(test->info, &test->cell);
|
||||
test->dbus = sailfish_cell_info_dbus_new(&test->modem, test->info);
|
||||
test->dbus = cell_info_dbus_new(&test->modem, test->info);
|
||||
g_assert(test->dbus);
|
||||
|
||||
/* Submit GetCells to enable "PropertyChanged" signals */
|
||||
@@ -1078,15 +1079,15 @@ static void test_unsubscribe(void)
|
||||
g_assert(test_dbus_find_signal(&test.context, test.modem.path,
|
||||
CELL_INFO_DBUS_INTERFACE, CELL_INFO_DBUS_UNSUBSCRIBED_SIGNAL));
|
||||
|
||||
sailfish_cell_info_unref(test.info);
|
||||
sailfish_cell_info_dbus_free(test.dbus);
|
||||
ofono_cell_info_unref(test.info);
|
||||
cell_info_dbus_free(test.dbus);
|
||||
test_dbus_shutdown(&test.context);
|
||||
if (timeout) {
|
||||
g_source_remove(timeout);
|
||||
}
|
||||
}
|
||||
|
||||
#define TEST_(name) "/sailfish_cell_info_dbus/" name
|
||||
#define TEST_(name) "/cell-info-dbus/" name
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -1105,7 +1106,7 @@ int main(int argc, char *argv[])
|
||||
gutil_log_timestamp = FALSE;
|
||||
gutil_log_default.level = g_test_verbose() ?
|
||||
GLOG_LEVEL_VERBOSE : GLOG_LEVEL_NONE;
|
||||
__ofono_log_init("test-sailfish_cell_info_dbus",
|
||||
__ofono_log_init("test-cell-info-dbus",
|
||||
g_test_verbose() ? "*" : NULL,
|
||||
FALSE, FALSE);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user