From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH_v4 3/5] private-network: add request/release functions and new feature to Makefile.am
Date: Sun, 08 May 2011 23:52:46 -0500 [thread overview]
Message-ID: <4DC7731E.7040105@gmail.com> (raw)
In-Reply-To: <1304690513-3137-4-git-send-email-guillaume.zajac@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 4796 bytes --]
Hi Guillaume,
On 05/06/2011 09:01 AM, Guillaume Zajac wrote:
> ---
> Makefile.am | 7 ++--
> src/ofono.h | 6 +++
> src/private-network.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 99 insertions(+), 3 deletions(-)
> create mode 100644 src/private-network.c
>
> diff --git a/Makefile.am b/Makefile.am
> index a413a47..e1eaf15 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -16,8 +16,8 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \
> include/cdma-sms.h include/sim-auth.h \
> include/gprs-provision.h include/emulator.h \
> include/location-reporting.h \
> - include/cdma-connman.h \
> - include/gnss.h
> + include/cdma-connman.h include/gnss.h \
> + include/private-network.h
As mentioned previously, this one belongs in the previous commit.
>
> nodist_pkginclude_HEADERS = include/version.h
>
> @@ -387,7 +387,8 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) src/ofono.ver \
> src/message.h src/message.c src/gprs-provision.c \
> src/emulator.c src/location-reporting.c \
> src/cdma-connman.c src/gnss.c \
> - src/gnssagent.c src/gnssagent.h
> + src/gnssagent.c src/gnssagent.h \
> + src/private-network.c
>
> src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
>
> diff --git a/src/ofono.h b/src/ofono.h
> index 82d7e34..7353022 100644
> --- a/src/ofono.h
> +++ b/src/ofono.h
> @@ -468,3 +468,9 @@ void __ofono_gprs_provision_free_settings(
>
> #include <ofono/emulator.h>
> #include <ofono/gnss.h>
> +#include <ofono/private-network.h>
> +
> +void __ofono_private_network_release(int id);
> +ofono_bool_t __ofono_private_network_request(ofono_private_network_cb_t cb,
> + void *data, int *id);
> +
> diff --git a/src/private-network.c b/src/private-network.c
> new file mode 100644
> index 0000000..03204a5
> --- /dev/null
> +++ b/src/private-network.c
> @@ -0,0 +1,89 @@
> +/*
> + *
> + * oFono - Open Source Telephony
> + *
> + * Copyright (C) 2008-2011 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.h"
> +
> +static GSList *g_drivers = NULL;
> +
> +void __ofono_private_network_release(int id)
> +{
> + GSList *d;
> +
> + DBG("");
> +
> + for (d = g_drivers; d; d = d->next) {
> + const struct ofono_private_network_driver *driver = d->data;
> +
> + if (g_strcmp0(driver->name, "ConnMan Private Network"))
> + continue;
> +
What exactly is the purpose of the above statement? Also, for now I'd
just assume that you can only ever have a single private network driver
to make things simpler.
> + driver->release(id);
> +
> + break;
> + }
> +}
> +
> +ofono_bool_t __ofono_private_network_request(ofono_private_network_cb_t cb,
> + void *data, int *id)
> +{
> + GSList *d;
> +
> + DBG("");
> +
> + for (d = g_drivers; d; d = d->next) {
> + const struct ofono_private_network_driver *driver = d->data;
> +
> + if (g_strcmp0(driver->name, "ConnMan Private Network"))
> + continue;
> +
> + *id = driver->request(cb, data);
In general it is good form not to assign to an out variable unless the
function returns successfully.
> + if (*id < 0)
> + continue;
You might want to always return > 0 for successful cases, and leave 0 as
a sentinel value.
> +
> + return TRUE;
> + }
> +
> + return FALSE;
> +}
> +
> +int ofono_private_network_driver_register(
> + const struct ofono_private_network_driver *d)
> +{
> + DBG("driver: %p, name: %s", d, d->name);
> +
> + g_drivers = g_slist_prepend(g_drivers, (void *) d);
> +
> + return 0;
> +}
> +
> +void ofono_private_network_driver_unregister(
> + const struct ofono_private_network_driver *d)
> +{
> + DBG("driver: %p, name: %s", d, d->name);
> +
> + g_drivers = g_slist_remove(g_drivers, (void *) d);
> +}
Regards,
-Denis
next prev parent reply other threads:[~2011-05-09 4:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-06 14:01 [PATCH_v4 0/5] Private network request to ConnMan Guillaume Zajac
2011-05-06 14:01 ` [PATCH_v4 1/5] gatppp: Add new contructor to use external fd Guillaume Zajac
2011-05-09 4:44 ` Denis Kenzior
2011-05-06 14:01 ` [PATCH_v4 2/5] private-network: add callback typedef drivers and settings Guillaume Zajac
2011-05-09 4:48 ` Denis Kenzior
2011-05-06 14:01 ` [PATCH_v4 3/5] private-network: add request/release functions and new feature to Makefile.am Guillaume Zajac
2011-05-09 4:52 ` Denis Kenzior [this message]
2011-05-06 14:01 ` [PATCH_v4 4/5] emulator: add request/release private network calls Guillaume Zajac
2011-05-06 14:01 ` [PATCH_v4 5/5] connman: add plugin in oFono to request request/release private network Guillaume Zajac
2011-05-09 5:30 ` Denis Kenzior
2021-06-03 10:22 ` [PATCH_v4 0/5] Private network request to ConnMan adamsmith.87
2021-06-15 13:06 ` Jackson.com551
2021-07-21 19:49 ` Kaylee Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DC7731E.7040105@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox