mirror of git://git.sysmocom.de/ofono
parent
2fea7be017
commit
ca95c87dae
|
@ -32,6 +32,18 @@
|
||||||
|
|
||||||
static GSList *history_drivers = NULL;
|
static GSList *history_drivers = NULL;
|
||||||
|
|
||||||
|
struct history_foreach_data {
|
||||||
|
const struct ofono_call *call;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
time_t start;
|
||||||
|
time_t end;
|
||||||
|
};
|
||||||
|
|
||||||
|
time_t when;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
static struct ofono_history_context *history_context_create(
|
static struct ofono_history_context *history_context_create(
|
||||||
struct ofono_modem *modem,
|
struct ofono_modem *modem,
|
||||||
struct ofono_history_driver *driver)
|
struct ofono_history_driver *driver)
|
||||||
|
@ -57,11 +69,21 @@ static struct ofono_history_context *history_context_create(
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void context_remove(struct ofono_atom *atom)
|
||||||
|
{
|
||||||
|
struct ofono_history_context *context = __ofono_atom_get_data(atom);
|
||||||
|
|
||||||
|
if (context->driver->remove)
|
||||||
|
context->driver->remove(context);
|
||||||
|
|
||||||
|
g_free(context);
|
||||||
|
}
|
||||||
|
|
||||||
void __ofono_history_probe_drivers(struct ofono_modem *modem)
|
void __ofono_history_probe_drivers(struct ofono_modem *modem)
|
||||||
{
|
{
|
||||||
GSList *l;
|
|
||||||
struct ofono_history_context *context;
|
|
||||||
struct ofono_history_driver *driver;
|
struct ofono_history_driver *driver;
|
||||||
|
struct ofono_history_context *context;
|
||||||
|
GSList *l;
|
||||||
|
|
||||||
for (l = history_drivers; l; l = l->next) {
|
for (l = history_drivers; l; l = l->next) {
|
||||||
driver = l->data;
|
driver = l->data;
|
||||||
|
@ -71,56 +93,57 @@ void __ofono_history_probe_drivers(struct ofono_modem *modem)
|
||||||
if (!context)
|
if (!context)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
modem->history_contexts =
|
__ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_HISTORY,
|
||||||
g_slist_prepend(modem->history_contexts, context);
|
context_remove, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void __ofono_history_remove_drivers(struct ofono_modem *modem)
|
static void history_call_ended(struct ofono_atom *atom, void *data)
|
||||||
{
|
{
|
||||||
GSList *l;
|
struct ofono_history_context *context = __ofono_atom_get_data(atom);
|
||||||
struct ofono_history_context *context;
|
struct history_foreach_data *hfd = data;
|
||||||
|
|
||||||
for (l = modem->history_contexts; l; l = l->next) {
|
if (context->driver->call_ended == NULL)
|
||||||
context = l->data;
|
return;
|
||||||
|
|
||||||
if (context->driver->remove)
|
context->driver->call_ended(context, hfd->call, hfd->start, hfd->end);
|
||||||
context->driver->remove(context);
|
|
||||||
|
|
||||||
g_free(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_slist_free(modem->history_contexts);
|
|
||||||
modem->history_contexts = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __ofono_history_call_ended(struct ofono_modem *modem,
|
void __ofono_history_call_ended(struct ofono_modem *modem,
|
||||||
const struct ofono_call *call,
|
const struct ofono_call *call,
|
||||||
time_t start, time_t end)
|
time_t start, time_t end)
|
||||||
{
|
{
|
||||||
struct ofono_history_context *context;
|
struct history_foreach_data hfd;
|
||||||
GSList *l;
|
|
||||||
|
|
||||||
for (l = modem->history_contexts; l; l = l->next) {
|
hfd.call = call;
|
||||||
context = l->data;
|
hfd.start = start;
|
||||||
|
hfd.end = end;
|
||||||
|
|
||||||
if (context->driver->call_ended)
|
__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_HISTORY,
|
||||||
context->driver->call_ended(context, call, start, end);
|
history_call_ended, &hfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void history_call_missed(struct ofono_atom *atom, void *data)
|
||||||
|
{
|
||||||
|
struct ofono_history_context *context = __ofono_atom_get_data(atom);
|
||||||
|
struct history_foreach_data *hfd = data;
|
||||||
|
|
||||||
|
if (context->driver->call_missed == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
context->driver->call_missed(context, hfd->call, hfd->when);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __ofono_history_call_missed(struct ofono_modem *modem,
|
void __ofono_history_call_missed(struct ofono_modem *modem,
|
||||||
const struct ofono_call *call, time_t when)
|
const struct ofono_call *call, time_t when)
|
||||||
{
|
{
|
||||||
struct ofono_history_context *context;
|
struct history_foreach_data hfd;
|
||||||
GSList *l;
|
|
||||||
|
|
||||||
for (l = modem->history_contexts; l; l = l->next) {
|
hfd.call = call;
|
||||||
context = l->data;
|
hfd.when = when;
|
||||||
|
|
||||||
if (context->driver->call_missed)
|
__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_HISTORY,
|
||||||
context->driver->call_missed(context, call, when);
|
history_call_missed, &hfd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ofono_history_driver_register(const struct ofono_history_driver *driver)
|
int ofono_history_driver_register(const struct ofono_history_driver *driver)
|
||||||
|
|
|
@ -834,7 +834,6 @@ int ofono_modem_unregister(struct ofono_modem *m)
|
||||||
if (modem == NULL)
|
if (modem == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
__ofono_history_remove_drivers(modem);
|
|
||||||
modem_remove(modem);
|
modem_remove(modem);
|
||||||
|
|
||||||
g_modem_list = g_slist_remove(g_modem_list, modem);
|
g_modem_list = g_slist_remove(g_modem_list, modem);
|
||||||
|
|
|
@ -71,7 +71,6 @@ struct ofono_modem {
|
||||||
int next_atom_watch_id;
|
int next_atom_watch_id;
|
||||||
|
|
||||||
struct ofono_modem_data *modem_info;
|
struct ofono_modem_data *modem_info;
|
||||||
GSList *history_contexts;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <ofono/modem.h>
|
#include <ofono/modem.h>
|
||||||
|
@ -193,7 +192,6 @@ void __ofono_ussd_passwd_unregister(struct ofono_ussd *ussd, const char *sc);
|
||||||
#include <ofono/history.h>
|
#include <ofono/history.h>
|
||||||
|
|
||||||
void __ofono_history_probe_drivers(struct ofono_modem *modem);
|
void __ofono_history_probe_drivers(struct ofono_modem *modem);
|
||||||
void __ofono_history_remove_drivers(struct ofono_modem *modem);
|
|
||||||
|
|
||||||
void __ofono_history_call_ended(struct ofono_modem *modem,
|
void __ofono_history_call_ended(struct ofono_modem *modem,
|
||||||
const struct ofono_call *call,
|
const struct ofono_call *call,
|
||||||
|
|
Loading…
Reference in New Issue