diff options
author | Denis Kenzior <denkenz@gmail.com> | 2009-06-17 07:03:21 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-06-17 18:20:20 -0500 |
commit | 1dbfc02d6cfa2666caa56382158c579197f5b114 (patch) | |
tree | d0b88a7c99a19ba03f16a7b40327a5413728e1e6 /plugins | |
parent | c892f36dc285a7713fd6d48e50f0f926cbe6ee83 (diff) | |
download | ofono-1dbfc02d6cfa2666caa56382158c579197f5b114.tar.bz2 |
Add call-history driver type
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Makefile.am | 12 | ||||
-rw-r--r-- | plugins/example_history.c | 123 |
2 files changed, 134 insertions, 1 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index b65bc731..310ad459 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -3,16 +3,26 @@ builtin_modules = builtin_sources = builtin_cflags = +if MAINTAINER_MODE +builtin_modules += example_history +builtin_sources += example_history.c +endif + noinst_LTLIBRARIES = libbuiltin.la libbuiltin_la_SOURCES = $(builtin_sources) libbuiltin_la_LDFLAGS = -libbuiltin_la_CFLAGS = $(AM_CFLAGS) $(builtin_cflags) -DOFONO_PLUGIN_BUILTIN +libbuiltin_la_CFLAGS = $(AM_CFLAGS) $(builtin_cflags) -DOFONO_PLUGIN_BUILTIN \ + -DOFONO_API_SUBJECT_TO_CHANGE BUILT_SOURCES = builtin.h nodist_libbuiltin_la_SOURCES = $(BUILT_SOURCES) +AM_CFLAGS = -fvisibility=hidden @GLIB_CFLAGS@ @GDBUS_CFLAGS@ + +INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/src + CLEANFILES = $(BUILT_SOURCES) MAINTAINERCLEANFILES = Makefile.in diff --git a/plugins/example_history.c b/plugins/example_history.c new file mode 100644 index 00000000..3ebf7434 --- /dev/null +++ b/plugins/example_history.c @@ -0,0 +1,123 @@ +/* + * + * oFono - Open Source Telephony + * + * Copyright (C) 2008-2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <string.h> +#include <glib.h> + +#include <ofono/plugin.h> +#include <ofono/log.h> +#include <ofono/history.h> + +#include "driver.h" +#include "common.h" + +static int example_history_probe(struct ofono_history_context *context) +{ + ofono_debug("Example History Probe for modem: %p", context->modem); + return 0; +} + +static void example_history_remove(struct ofono_history_context *context) +{ + ofono_debug("Example History Remove for modem: %p", context->modem); +} + +static void example_history_call_ended(struct ofono_history_context *context, + const struct ofono_call *call, + time_t start, time_t end) +{ + const char *from = "Unknown"; + char buf[128]; + + ofono_debug("Call Ended on modem: %p", context->modem); + + if (call->type != 0) + return; + + ofono_debug("Voice Call, %s", + call->direction ? "Incoming" : "Outgoing"); + + if (call->clip_validity == 0) + from = phone_number_to_string(&call->phone_number); + + if (call->direction == 0) + ofono_debug("To: %s", from); + else + ofono_debug("From: %s", from); + + strftime(buf, 127, "%a, %d %b %Y %H:%M:%S %z", localtime(&start)); + buf[127] = '\0'; + ofono_debug("StartTime: %s", buf); + + strftime(buf, 127, "%a, %d %b %Y %H:%M:%S %z", localtime(&end)); + buf[127] = '\0'; + ofono_debug("EndTime: %s", buf); +} + +static void example_history_call_missed(struct ofono_history_context *context, + const struct ofono_call *call, + time_t when) +{ + const char *from = "Unknown"; + char buf[128]; + + ofono_debug("Call Missed on modem: %p", context->modem); + + if (call->type != 0) + return; + + ofono_debug("Voice Call, %s", + call->direction ? "Incoming" : "Outgoing"); + + if (call->clip_validity == 0) + from = phone_number_to_string(&call->phone_number); + + ofono_debug("From: %s", from); + strftime(buf, 127, "%a, %d %b %Y %H:%M:%S %z", localtime(&when)); + buf[127] = '\0'; + ofono_debug("When: %s", buf); +} + +static struct ofono_history_driver example_driver = { + .name = "Example Call History", + .probe = example_history_probe, + .remove = example_history_remove, + .call_ended = example_history_call_ended, + .call_missed = example_history_call_missed, +}; + +static int example_history_init(void) +{ + return ofono_history_driver_register(&example_driver); +} + +static void example_history_exit(void) +{ + ofono_history_driver_unregister(&example_driver); +} + +OFONO_PLUGIN_DEFINE(example_history, "Example Call History Plugin", + VERSION, OFONO_PLUGIN_PRIORITY_DEFAULT, + example_history_init, example_history_exit) |