summaryrefslogtreecommitdiffstats
path: root/src/history.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-11-05 16:46:43 -0600
committerDenis Kenzior <denkenz@gmail.com>2009-11-05 16:46:43 -0600
commit9afdf1a35bbf298c1881fc57688199c8eb3ec116 (patch)
treeecd56d527f7e6237e7567ca09e5973a5c5074f37 /src/history.c
parent61260c298fc7814f06d589029c2cef5f8a3d218c (diff)
downloadofono-9afdf1a35bbf298c1881fc57688199c8eb3ec116.tar.bz2
Add SMS history capability
Diffstat (limited to 'src/history.c')
-rw-r--r--src/history.c113
1 files changed, 108 insertions, 5 deletions
diff --git a/src/history.c b/src/history.c
index ee7a492e..1b95b49a 100644
--- a/src/history.c
+++ b/src/history.c
@@ -32,7 +32,7 @@
static GSList *history_drivers = NULL;
-struct history_foreach_data {
+struct history_call_foreach_data {
const struct ofono_call *call;
union {
struct {
@@ -44,6 +44,22 @@ struct history_foreach_data {
};
};
+struct history_sms_foreach_data {
+ unsigned int msg_id;
+ const char *address;
+ const char *text;
+ union {
+ struct {
+ const struct tm *remote;
+ const struct tm *local;
+ };
+ struct {
+ time_t when;
+ enum ofono_history_sms_status status;
+ };
+ };
+};
+
static struct ofono_history_context *history_context_create(
struct ofono_modem *modem,
struct ofono_history_driver *driver)
@@ -101,7 +117,7 @@ void __ofono_history_probe_drivers(struct ofono_modem *modem)
static void history_call_ended(struct ofono_atom *atom, void *data)
{
struct ofono_history_context *context = __ofono_atom_get_data(atom);
- struct history_foreach_data *hfd = data;
+ struct history_call_foreach_data *hfd = data;
if (context->driver->call_ended == NULL)
return;
@@ -113,7 +129,7 @@ void __ofono_history_call_ended(struct ofono_modem *modem,
const struct ofono_call *call,
time_t start, time_t end)
{
- struct history_foreach_data hfd;
+ struct history_call_foreach_data hfd;
hfd.call = call;
hfd.start = start;
@@ -126,7 +142,7 @@ void __ofono_history_call_ended(struct ofono_modem *modem,
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;
+ struct history_call_foreach_data *hfd = data;
if (context->driver->call_missed == NULL)
return;
@@ -137,7 +153,7 @@ static void history_call_missed(struct ofono_atom *atom, void *data)
void __ofono_history_call_missed(struct ofono_modem *modem,
const struct ofono_call *call, time_t when)
{
- struct history_foreach_data hfd;
+ struct history_call_foreach_data hfd;
hfd.call = call;
hfd.when = when;
@@ -146,6 +162,93 @@ void __ofono_history_call_missed(struct ofono_modem *modem,
history_call_missed, &hfd);
}
+static void history_sms_received(struct ofono_atom *atom, void *data)
+{
+ struct ofono_history_context *context = __ofono_atom_get_data(atom);
+ struct history_sms_foreach_data *hfd = data;
+
+ if (context->driver->sms_received == NULL)
+ return;
+
+ context->driver->sms_received(context, hfd->msg_id, hfd->address,
+ hfd->remote, hfd->local, hfd->text);
+}
+
+void __ofono_history_sms_received(struct ofono_modem *modem,
+ unsigned int msg_id,
+ const char *from,
+ const struct tm *remote,
+ const struct tm *local,
+ const char *text)
+{
+ struct history_sms_foreach_data hfd;
+
+ hfd.msg_id = msg_id;
+ hfd.address = from;
+ hfd.remote = remote;
+ hfd.local = local;
+ hfd.text = text;
+
+ __ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_HISTORY,
+ history_sms_received, &hfd);
+}
+
+static void history_sms_send_pending(struct ofono_atom *atom, void *data)
+{
+ struct ofono_history_context *context = __ofono_atom_get_data(atom);
+ struct history_sms_foreach_data *hfd = data;
+
+ if (context->driver->sms_send_pending == NULL)
+ return;
+
+ context->driver->sms_send_pending(context, hfd->msg_id, hfd->address,
+ hfd->when, hfd->text);
+}
+
+void __ofono_history_sms_send_pending(struct ofono_modem *modem,
+ unsigned int msg_id, const char *to,
+ time_t when, const char *text)
+{
+ struct history_sms_foreach_data hfd;
+
+ hfd.msg_id = msg_id;
+ hfd.address = to;
+ hfd.text = text;
+ hfd.when = when;
+ hfd.status = OFONO_HISTORY_SMS_STATUS_PENDING;
+
+ __ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_HISTORY,
+ history_sms_send_pending, &hfd);
+}
+
+static void history_sms_send_status(struct ofono_atom *atom, void *data)
+{
+ struct ofono_history_context *context = __ofono_atom_get_data(atom);
+ struct history_sms_foreach_data *hfd = data;
+
+ if (context->driver->sms_send_status == NULL)
+ return;
+
+ context->driver->sms_send_status(context, hfd->msg_id,
+ hfd->when, hfd->status);
+}
+
+void __ofono_history_sms_send_status(struct ofono_modem *modem,
+ unsigned int msg_id, time_t when,
+ enum ofono_history_sms_status status)
+{
+ struct history_sms_foreach_data hfd;
+
+ hfd.msg_id = msg_id;
+ hfd.address = NULL;
+ hfd.text = NULL;
+ hfd.when = when;
+ hfd.status = status;
+
+ __ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_HISTORY,
+ history_sms_send_status, &hfd);
+}
+
int ofono_history_driver_register(const struct ofono_history_driver *driver)
{
DBG("driver: %p name: %s", driver, driver->name);