[-]
[+]
|
Changed |
_service:tar_git:ofono.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:ofono.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">https://git.monich.net/git/ofono.git</param>
<param name="branch">master</param>
- <param name="revision">e0ea7b54</param>
+ <param name="revision">81ad45df</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.29+git3.tar.bz2/ofono/doc/ims-api.txt
^
|
@@ -16,7 +16,7 @@
changeable. On success a PropertyChanged signal
will be emitted.
- Possible Errors: [service].Error.InProgress
+ Possible Errors: [service].Error.AccessDenied
[service].Error.InvalidArguments
[service].Error.Failed
@@ -27,8 +27,10 @@
initiated successfully. The actual registration state
will be reflected by the 'Registered' property.
- Possible Errors: [service].Error.InProgress
+ Possible Errors: [service].Error.AccessDenied
+ [service].Error.NotAllowed
[service].Error.NotImplemented
+ [service].Error.Failed
void Unregister()
@@ -37,8 +39,9 @@
be initiated successfully. The actual unregistration
state will be reflected by the 'Registered' property.
- Possible Errors: [service].Error.InProgress
+ Possible Errors: [service].Error.AccessDenied
[service].Error.NotImplemented
+ [service].Error.Failed
Signals PropertyChanged(string property, variant value)
@@ -57,3 +60,15 @@
boolean SmsCapable [readonly, optional]
Boolean representing whether SMS-over-IMS is available.
+
+ string Registration [readwrite, Sailfish OS specific]
+
+ The IMS registration strategy. Valid values are:
+
+ "disabled" keep registration off
+ "enabled" manual registration
+ "auto" keep registration on
+
+ The Register() method, if implemented, will fail
+ with [service].Error.NotAllowed if the value of
+ this property is "disabled".
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.29+git3.tar.bz2/ofono/include/dbus-access.h
^
|
@@ -41,6 +41,8 @@
OFONO_DBUS_ACCESS_INTF_RADIOSETTINGS, /* org.ofono.RadioSettings */
OFONO_DBUS_ACCESS_INTF_STK, /* org.ofono.SimToolkit */
OFONO_DBUS_ACCESS_INTF_OEMRAW, /* org.ofono.OemRaw */
+ /* Since 1.29+git3 */
+ OFONO_DBUS_ACCESS_INTF_IMS, /* org.ofono.IpMultimediaSystem */
OFONO_DBUS_ACCESS_INTF_COUNT
};
@@ -132,6 +134,15 @@
OFONO_DBUS_ACCESS_OEMRAW_METHOD_COUNT
};
+/* OFONO_DBUS_ACCESS_INTF_IMS */
+enum ofono_dbus_access_ims_method {
+ /* Since 1.29+git3 */
+ OFONO_DBUS_ACCESS_IMS_SET_PROPERTY,
+ OFONO_DBUS_ACCESS_IMS_REGISTER,
+ OFONO_DBUS_ACCESS_IMS_UNREGISTER,
+ OFONO_DBUS_ACCESS_IMS_METHOD_COUNT
+};
+
#define OFONO_DBUS_ACCESS_PRIORITY_LOW (-100)
#define OFONO_DBUS_ACCESS_PRIORITY_DEFAULT (0)
#define OFONO_DBUS_ACCESS_PRIORITY_HIGH (100)
@@ -159,7 +170,7 @@
const char *ofono_dbus_access_method_name(enum ofono_dbus_access_intf intf,
int method);
-/* Since mer/1.24+git2 */
+/* Since 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);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.29+git3.tar.bz2/ofono/include/watch.h
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony
*
- * Copyright (C) 2017-2021 Jolla Ltd.
+ * Copyright (C) 2017-2022 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
@@ -36,13 +36,15 @@
const char *spn;
/* OFONO_ATOM_TYPE_NETREG */
struct ofono_netreg *netreg;
- /* Since mer/1.21+git47 */
+ /* Since 1.21+git47 */
enum ofono_netreg_status reg_status;
const char *reg_mcc;
const char *reg_mnc;
const char *reg_name;
/* OFONO_ATOM_TYPE_GPRS */
struct ofono_gprs *gprs;
+ /* Since 1.29+git3 */
+ enum ofono_access_technology reg_tech;
};
typedef void (*ofono_watch_cb_t)(struct ofono_watch *w, void *user_data);
@@ -78,7 +80,7 @@
#define ofono_watch_remove_all_handlers(w,ids) \
ofono_watch_remove_handlers(w, ids, sizeof(ids)/sizeof((ids)[0]))
-/* Since mer/1.21+git47 */
+/* Since 1.21+git47 */
unsigned long ofono_watch_add_reg_status_changed_handler(struct ofono_watch *w,
ofono_watch_cb_t cb, void *user_data);
unsigned long ofono_watch_add_reg_mcc_changed_handler(struct ofono_watch *w,
@@ -93,6 +95,10 @@
(struct ofono_watch *watch, ofono_watch_gprs_settings_cb_t cb,
void *user_data);
+/* Since 1.29+git3 */
+unsigned long ofono_watch_add_reg_tech_changed_handler(struct ofono_watch *w,
+ ofono_watch_cb_t cb, void *user_data);
+
#endif /* OFONO_WATCH_H */
/*
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.29+git3.tar.bz2/ofono/src/dbus-access.c
^
|
@@ -46,6 +46,8 @@
return OFONO_STK_INTERFACE;
case OFONO_DBUS_ACCESS_INTF_OEMRAW:
return "org.ofono.OemRaw";
+ case OFONO_DBUS_ACCESS_INTF_IMS:
+ return OFONO_IMS_INTERFACE;
case OFONO_DBUS_ACCESS_INTF_COUNT:
break;
}
@@ -188,6 +190,18 @@
break;
}
break;
+ case OFONO_DBUS_ACCESS_INTF_IMS:
+ switch ((enum ofono_dbus_access_ims_method)method) {
+ case OFONO_DBUS_ACCESS_IMS_SET_PROPERTY:
+ return "SetProperty";
+ case OFONO_DBUS_ACCESS_IMS_REGISTER:
+ return "Register";
+ case OFONO_DBUS_ACCESS_IMS_UNREGISTER:
+ return "Unregister";
+ case OFONO_DBUS_ACCESS_IMS_METHOD_COUNT:
+ break;
+ }
+ break;
case OFONO_DBUS_ACCESS_INTF_COUNT:
break;
}
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.29+git3.tar.bz2/ofono/src/ims.c
^
|
@@ -36,21 +36,343 @@
#include "ofono.h"
#include "common.h"
+#include "storage.h"
+#include "dbus-queue.h"
#define VOICE_CAPABLE_FLAG OFONO_IMS_VOICE_CAPABLE
#define SMS_CAPABLE_FLAG OFONO_IMS_SMS_CAPABLE
+#define RECHECK_TIMEOUT_SEC (10)
+
+enum ims_reg_strategy {
+ IMS_REG_DISABLED,
+ IMS_REG_ENABLED,
+ IMS_REG_AUTO
+#define IMS_REG_DEFAULT IMS_REG_AUTO
+};
+
+enum ims_watch_events {
+ WATCH_EVENT_REG_TECH,
+ WATCH_EVENT_IMSI,
+ WATCH_EVENT_COUNT
+};
+
+struct ims_call;
+
struct ofono_ims {
int reg_info;
int ext_info;
const struct ofono_ims_driver *driver;
void *driver_data;
struct ofono_atom *atom;
- DBusMessage *pending;
+ struct ofono_watch *watch;
+ struct ofono_dbus_queue *q;
+ struct ims_call *pending;
+ struct ims_call *tail;
+ enum ims_reg_strategy reg_strategy;
+ gboolean reg_check_pending;
+ gulong watch_id[WATCH_EVENT_COUNT];
+ char *imsi;
+ GKeyFile *settings;
+ guint recheck_timeout_id;
+};
+
+/* Calls to the driver are serialized */
+
+typedef void (*ims_cb_t)(void);
+typedef void (*ims_submit_cb_t)(struct ims_call *call);
+
+struct ims_call {
+ struct ims_call *next;
+ struct ofono_ims *ims;
+ ims_submit_cb_t submit;
+ union {
+ ofono_ims_register_cb_t register_cb;
+ ofono_ims_status_cb_t status_cb;
+ ims_cb_t fn;
+ } cb;
+ void *data;
};
+#define CALLBACK(f) ((ims_cb_t)(f))
+
+#define REGISTRATION_PROP "Registration"
+
+#define SETTINGS_STORE "ims"
+#define SETTINGS_GROUP "Settings"
+#define REGISTRATION_KEY REGISTRATION_PROP
+
static GSList *g_drivers = NULL;
+static const char *reg_strategy_name[] = { "disabled", "enabled", "auto" };
+
+static gboolean ims_registration_recheck_cb(gpointer user_data);
+
+static gboolean ims_ret_strategy_from_string(const char *str,
+ enum ims_reg_strategy *value)
+{
+ if (str) {
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS(reg_strategy_name); i++) {
+ if (!g_strcmp0(str, reg_strategy_name[i])) {
+ *value = i;
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+static inline gboolean ims_dbus_access_allowed(DBusMessage *msg,
+ enum ofono_dbus_access_ims_method method)
+{
+ return ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
+ OFONO_DBUS_ACCESS_INTF_IMS, method, NULL);
+}
+
+static void ims_call_done(struct ims_call *call)
+{
+ struct ofono_ims *ims = call->ims;
+
+ ims->pending = call->next;
+ g_slice_free(struct ims_call, call);
+
+ if (ims->pending) {
+ ims->pending->submit(ims->pending);
+ } else {
+ ims->tail = NULL;
+ }
+}
+
+static void ims_call_submit(struct ofono_ims *ims, ims_submit_cb_t submit,
+ ims_cb_t cb, void *data)
+{
+ struct ims_call *call = g_slice_new0(struct ims_call);
+
+ call->ims = ims;
+ call->submit = submit;
+ call->cb.fn = cb;
+ call->data = data;
+
+ if (ims->pending) {
+ ims->tail->next = call;
+ ims->tail = call;
+ } else {
+ ims->pending = ims->tail = call;
+ submit(call);
+ }
+}
+
+static void ims_call_register_cb(const struct ofono_error *error, void *data)
+{
+ struct ims_call *call = data;
+
+ if (call->cb.register_cb)
+ call->cb.register_cb(error, call->data);
+
+ ims_call_done(call);
+}
+
+static void ims_call_status_cb(const struct ofono_error *error,
+ int reg_info, int ext_info,
+ void *data)
+{
+ struct ims_call *call = data;
+
+ if (call->cb.status_cb)
+ call->cb.status_cb(error, reg_info, ext_info, call->data);
+
+ ims_call_done(call);
+}
+
+static void ims_call_submit_registration_status(struct ims_call *call)
+{
+ struct ofono_ims *ims = call->ims;
+
+ ims->driver->registration_status(ims, ims_call_status_cb, call);
+}
+
+static void ims_call_submit_register(struct ims_call *call)
+{
+ struct ofono_ims *ims = call->ims;
+
+ ims->driver->ims_register(ims, ims_call_register_cb, call);
+}
+
+static void ims_call_submit_unregister(struct ims_call *call)
+{
+ struct ofono_ims *ims = call->ims;
+
+ ims->driver->ims_unregister(ims, ims_call_register_cb, call);
+}
+
+static void ims_call_registration_status(struct ofono_ims *ims,
+ ofono_ims_status_cb_t cb, void *data)
+{
+ ims_call_submit(ims, ims_call_submit_registration_status,
+ CALLBACK(cb), data);
+}
+
+static void ims_call_register(struct ofono_ims *ims,
+ ofono_ims_register_cb_t cb, void *data)
+{
+ ims_call_submit(ims, ims_call_submit_register, CALLBACK(cb), data);
+}
+
+static void ims_call_unregister(struct ofono_ims *ims,
+ ofono_ims_register_cb_t cb, void *data)
+{
+ ims_call_submit(ims, ims_call_submit_unregister, CALLBACK(cb), data);
+}
+
+static gboolean ims_supported_reg_tech(struct ofono_ims *ims)
+{
+ return ims->watch &&
+ ims->watch->reg_tech >= OFONO_ACCESS_TECHNOLOGY_EUTRAN;
+}
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.29+git3.tar.bz2/ofono/src/watch.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony
*
- * Copyright (C) 2017-2021 Jolla Ltd.
+ * Copyright (C) 2017-2022 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
@@ -41,6 +41,7 @@
guint imsi_watch_id;
guint spn_watch_id;
guint netreg_watch_id;
+ guint netreg_status_watch_id;
guint gprs_watch_id;
};
@@ -67,6 +68,7 @@
SIGNAL_REG_MCC_CHANGED,
SIGNAL_REG_MNC_CHANGED,
SIGNAL_REG_NAME_CHANGED,
+ SIGNAL_REG_TECH_CHANGED,
SIGNAL_GPRS_CHANGED,
SIGNAL_GPRS_SETTINGS_CHANGED,
SIGNAL_COUNT
@@ -84,6 +86,7 @@
#define SIGNAL_REG_MCC_CHANGED_NAME "ofono-watch-reg-mcc-changed"
#define SIGNAL_REG_MNC_CHANGED_NAME "ofono-watch-reg-mnc-changed"
#define SIGNAL_REG_NAME_CHANGED_NAME "ofono-watch-reg-name-changed"
+#define SIGNAL_REG_TECH_CHANGED_NAME "ofono-watch-reg-tech-changed"
#define SIGNAL_GPRS_CHANGED_NAME "ofono-watch-gprs-changed"
#define SIGNAL_GPRS_SETTINGS_CHANGED_NAME "ofono-watch-gprs-settings-changed"
@@ -134,11 +137,13 @@
{
int i;
+ g_object_ref(self);
for (i = 0; self->queued_signals && i < SIGNAL_COUNT; i++) {
if (self->queued_signals & ofono_watch_signal_bit(i)) {
ofono_watch_signal_emit(self, i);
}
}
+ g_object_unref(self);
}
static void ofono_watch_iccid_update(struct ofono_watch_object *self,
@@ -349,6 +354,7 @@
struct ofono_watch *watch = &self->pub;
struct ofono_netreg *netreg = watch->netreg;
enum ofono_netreg_status status = ofono_netreg_get_status(netreg);
+ enum ofono_access_technology act = ofono_netreg_get_technology(netreg);
const char *mcc = ofono_netreg_get_mcc(netreg);
const char *mnc = ofono_netreg_get_mnc(netreg);
const char *name = ofono_netreg_get_name(netreg);
@@ -357,6 +363,10 @@
watch->reg_status = status;
ofono_watch_signal_queue(self, SIGNAL_REG_STATUS_CHANGED);
}
+ if (watch->reg_tech != act) {
+ watch->reg_tech = act;
+ ofono_watch_signal_queue(self, SIGNAL_REG_TECH_CHANGED);
+ }
if (g_strcmp0(self->reg_mcc, mcc)) {
g_free(self->reg_mcc);
watch->reg_mcc = self->reg_mcc = g_strdup(mcc);
@@ -374,17 +384,49 @@
}
}
+static void ofono_watch_netreg_status_notify(int status, int lac, int ci,
+ int tech, const char *mcc, const char *mnc, void *user_data)
+{
+ struct ofono_watch_object *self = OFONO_WATCH_OBJECT(user_data);
+
+ ofono_watch_netreg_update(self);
+ ofono_watch_emit_queued_signals(self);
+}
+
+static void ofono_watch_netreg_status_destroy(void *user_data)
+{
+ struct ofono_watch_object *self = OFONO_WATCH_OBJECT(user_data);
+
+ ASSERT(self->netreg_status_watch_id);
+ self->netreg_status_watch_id = 0;
+}
+
static void ofono_watch_set_netreg(struct ofono_watch_object *self,
struct ofono_netreg *netreg)
{
struct ofono_watch *watch = &self->pub;
if (watch->netreg != netreg) {
+ if (self->netreg_status_watch_id) {
+ __ofono_netreg_remove_status_watch(watch->netreg,
+ self->netreg_status_watch_id);
+ /* The destroy callback clears it */
+ ASSERT(!self->netreg_status_watch_id);
+ }
+
watch->netreg = netreg;
ofono_watch_signal_queue(self, SIGNAL_NETREG_CHANGED);
+
+ if (netreg) {
+ self->netreg_status_watch_id =
+ __ofono_netreg_add_status_watch(netreg,
+ ofono_watch_netreg_status_notify, self,
+ ofono_watch_netreg_status_destroy);
+ }
+
+ ofono_watch_netreg_update(self);
+ ofono_watch_emit_queued_signals(self);
}
- ofono_watch_netreg_update(self);
- ofono_watch_emit_queued_signals(self);
}
static void ofono_watch_netreg_notify(struct ofono_atom *atom,
@@ -417,6 +459,7 @@
if (watch->gprs != gprs) {
watch->gprs = gprs;
+
ofono_watch_signal_queue(self, SIGNAL_GPRS_CHANGED);
ofono_watch_emit_queued_signals(self);
}
@@ -730,6 +773,7 @@
ADD_SIGNAL_HANDLER_PROC(reg_mcc,REG_MCC)
ADD_SIGNAL_HANDLER_PROC(reg_mnc,REG_MNC)
ADD_SIGNAL_HANDLER_PROC(reg_name,REG_NAME)
+ADD_SIGNAL_HANDLER_PROC(reg_tech,REG_TECH)
ADD_SIGNAL_HANDLER_PROC(gprs,GPRS)
static void ofono_watch_gprs_settings_signal_cb(struct ofono_watch_object *src,
@@ -775,21 +819,6 @@
}
}
-void __ofono_watch_netreg_changed(const char *path)
-{
- if (path && ofono_watch_table) {
- struct ofono_watch_object *self =
- g_hash_table_lookup(ofono_watch_table, path);
-
- if (self) {
- g_object_ref(self);
- ofono_watch_netreg_update(self);
- ofono_watch_emit_queued_signals(self);
- g_object_unref(self);
- }
- }
-}
-
void __ofono_watch_gprs_settings_changed(const char *path,
enum ofono_gprs_context_type type,
const struct ofono_gprs_primary_context *settings)
@@ -813,6 +842,7 @@
struct ofono_watch *watch = &self->pub;
watch->reg_status = OFONO_NETREG_STATUS_NONE;
+ watch->reg_tech = OFONO_ACCESS_TECHNOLOGY_NONE;
}
static void ofono_watch_object_finalize(GObject *object)
@@ -847,6 +877,7 @@
NEW_SIGNAL(klass, REG_MCC);
NEW_SIGNAL(klass, REG_MNC);
NEW_SIGNAL(klass, REG_NAME);
+ NEW_SIGNAL(klass, REG_TECH);
NEW_SIGNAL(klass, GPRS);
ofono_watch_signals[SIGNAL_GPRS_SETTINGS_CHANGED] =
g_signal_new(SIGNAL_GPRS_SETTINGS_CHANGED_NAME,
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.29+git3.tar.bz2/ofono/src/watch_p.h
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony
*
- * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019-2022 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -18,7 +18,6 @@
#include <ofono/watch.h>
-void __ofono_watch_netreg_changed(const char *path);
void __ofono_watch_gprs_settings_changed(const char *path,
enum ofono_gprs_context_type type,
const struct ofono_gprs_primary_context *settings);
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.29+git3.tar.bz2/ofono/unit/test-dbus-access.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony
*
- * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2022 Jolla Ltd.
* Copyright (C) 2020 Open Mobile Platform LLC.
*
* This program is free software; you can redistribute it and/or modify
@@ -122,6 +122,9 @@
},{
OFONO_DBUS_ACCESS_INTF_OEMRAW,
OFONO_DBUS_ACCESS_OEMRAW_METHOD_COUNT
+ },{
+ OFONO_DBUS_ACCESS_INTF_IMS,
+ OFONO_DBUS_ACCESS_IMS_METHOD_COUNT
}
};
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.29+git3.tar.bz2/ofono/unit/test-watch.c
^
|
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony
*
- * Copyright (C) 2018-2019 Jolla Ltd.
+ * Copyright (C) 2018-2022 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
@@ -57,17 +57,25 @@
struct ofono_netreg {
struct ofono_atom atom;
+ struct ofono_watchlist *status_watches;
enum ofono_netreg_status status;
+ enum ofono_access_technology tech;
const char *mcc;
const char *mnc;
const char *name;
};
-int ofono_netreg_get_status(struct ofono_netreg *netreg)
+enum ofono_netreg_status ofono_netreg_get_status(struct ofono_netreg *netreg)
{
return netreg ? netreg->status : OFONO_NETREG_STATUS_NONE;
}
+enum ofono_access_technology
+ ofono_netreg_get_technology (struct ofono_netreg *netreg)
+{
+ return netreg ? netreg->tech : OFONO_ACCESS_TECHNOLOGY_NONE;
+}
+
const char *ofono_netreg_get_mcc(struct ofono_netreg *netreg)
{
return netreg ? netreg->mcc : NULL;
@@ -83,6 +91,44 @@
return netreg ? netreg->name : NULL;
}
+static void netreg_notify(struct ofono_netreg *netreg)
+{
+ GSList *l;
+
+ for (l = netreg->status_watches->items; l; l = l->next) {
+ struct ofono_watchlist_item *item = l->data;
+ ofono_netreg_status_notify_cb_t notify = item->notify;
+
+ notify(netreg->status, -1, -1, netreg->tech, netreg->mcc,
+ netreg->mnc, item->notify_data);
+ }
+}
+
+static unsigned int add_watch_item(struct ofono_watchlist *list,
+ void *notify, void *data, ofono_destroy_func destroy)
+{
+ struct ofono_watchlist_item *watch =
+ g_new0(struct ofono_watchlist_item, 1);
+
+ watch->notify = notify;
+ watch->destroy = destroy;
+ watch->notify_data = data;
+ return __ofono_watchlist_add_item(list, watch);
+}
+
+unsigned int __ofono_netreg_add_status_watch(struct ofono_netreg *netreg,
+ ofono_netreg_status_notify_cb_t notify,
+ void *data, ofono_destroy_func destroy)
+{
+ return add_watch_item(netreg->status_watches, notify, data, destroy);
+}
+
+gboolean __ofono_netreg_remove_status_watch(struct ofono_netreg *netreg,
+ unsigned int id)
+{
+ return __ofono_watchlist_remove_item(netreg->status_watches, id);
+}
+
/* Fake ofono_sim */
struct ofono_sim {
@@ -98,18 +144,6 @@
struct ofono_watchlist *state_watches;
};
-static unsigned int add_watch_item(struct ofono_watchlist *list,
- void *notify, void *data, ofono_destroy_func destroy)
-{
- struct ofono_watchlist_item *watch =
- g_new0(struct ofono_watchlist_item, 1);
-
- watch->notify = notify;
- watch->destroy = destroy;
- watch->notify_data = data;
- return __ofono_watchlist_add_item(list, watch);
-}
-
unsigned int ofono_sim_add_iccid_watch(struct ofono_sim *sim,
ofono_sim_iccid_event_cb_t cb, void *data,
ofono_destroy_func destroy)
@@ -342,7 +376,7 @@
return id;
}
-static void call_watches(struct ofono_atom *atom,
+static void atom_notify(struct ofono_atom *atom,
enum ofono_atom_watch_condition cond)
{
GSList *l;
@@ -400,7 +434,7 @@
if (!atom->registered) {
atom->registered = TRUE;
modem->atoms = g_slist_append(modem->atoms, atom);
- call_watches(atom, OFONO_ATOM_WATCH_CONDITION_REGISTERED);
+ atom_notify(atom, OFONO_ATOM_WATCH_CONDITION_REGISTERED);
}
}
@@ -409,7 +443,7 @@
{
if (atom->registered) {
atom->registered = FALSE;
- call_watches(atom, OFONO_ATOM_WATCH_CONDITION_UNREGISTERED);
+ atom_notify(atom, OFONO_ATOM_WATCH_CONDITION_UNREGISTERED);
modem->atoms = g_slist_remove(modem->atoms, atom);
}
}
@@ -428,6 +462,9 @@
netreg->atom.type = OFONO_ATOM_TYPE_NETREG;
netreg->atom.modem = modem;
netreg->atom.data = netreg;
+ netreg->status = OFONO_NETREG_STATUS_NOT_REGISTERED;
+ netreg->tech = OFONO_ACCESS_TECHNOLOGY_NONE;
+ netreg->status_watches = __ofono_watchlist_new(g_free);
gprs->atom.type = OFONO_ATOM_TYPE_GPRS;
gprs->atom.modem = modem;
@@ -455,15 +492,17 @@
static void test_modem_shutdown(struct ofono_modem *modem)
{
struct ofono_sim *sim = &modem->sim;
+ struct ofono_netreg *netreg = &modem->netreg;
call_modemwatches(modem, FALSE);
g_modem_list = g_slist_remove(g_modem_list, modem);
g_slist_free(modem->atoms);
+
__ofono_watchlist_free(sim->iccid_watches);
__ofono_watchlist_free(sim->imsi_watches);
__ofono_watchlist_free(sim->state_watches);
__ofono_watchlist_free(sim->spn_watches);
-
+ __ofono_watchlist_free(netreg->status_watches);
__ofono_watchlist_free(modem->atom_watches);
__ofono_watchlist_free(modem->online_watches);
}
@@ -504,8 +543,6 @@
NULL, NULL));
ofono_watch_remove_handler(NULL, 0);
ofono_watch_remove_handlers(NULL, NULL, 0);
- __ofono_watch_netreg_changed(NULL);
- __ofono_watch_netreg_changed(TEST_PATH);
__ofono_watch_gprs_settings_changed
(NULL, OFONO_GPRS_CONTEXT_TYPE_ANY, NULL);
__ofono_watch_gprs_settings_changed
@@ -623,7 +660,7 @@
struct ofono_watch *watch;
struct ofono_modem modem;
struct ofono_netreg *netreg = &modem.netreg;
- gulong id[5];
+ gulong id[6];
int n[G_N_ELEMENTS(id)];
#define NETREG 0
@@ -631,8 +668,7 @@
#define REG_MCC 2
#define REG_MNC 3
#define REG_NAME 4
-
- __ofono_watch_netreg_changed(TEST_PATH); /* No effect (yet) */
+#define REG_TECH 5
memset(&modem, 0, sizeof(modem));
__ofono_modemwatch_init();
@@ -652,16 +688,20 @@
(watch, test_inc_cb, n + REG_MNC);
id[REG_NAME] = ofono_watch_add_reg_name_changed_handler
(watch, test_inc_cb, n + REG_NAME);
+ id[REG_TECH] = ofono_watch_add_reg_tech_changed_handler
+ (watch, test_inc_cb, n + REG_TECH);
test_modem_register_atom(&modem, &netreg->atom);
g_assert(watch->netreg == netreg);
- g_assert(watch->reg_status == netreg->status);
- g_assert(n[NETREG] == 1);
- g_assert(n[REG_STATUS] == 1);
+ g_assert_cmpint(watch->reg_status, == ,netreg->status);
+ g_assert_cmpint(watch->reg_tech, == ,netreg->tech);
+ g_assert_cmpint(n[NETREG], == ,1);
+ g_assert_cmpint(n[REG_STATUS], == ,1);
+ g_assert_cmpint(n[REG_TECH], == ,0);
|