[sample] Initial commit

This commit is contained in:
Slava Monich
2022-05-19 17:35:18 +03:00
commit 012681a1af
13 changed files with 963 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*~
build

34
LICENSE Normal file
View File

@@ -0,0 +1,34 @@
Copyright (C) 2022 Jolla Ltd.
Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of the BSD license as follows:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the names of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation
are those of the authors and should not be interpreted as representing
any official policies, either expressed or implied.

146
Makefile Normal file
View File

@@ -0,0 +1,146 @@
# -*- Mode: makefile-gmake -*-
.PHONY: clean all debug release
#
# Required packages
#
# ofono.pc adds -export-symbols-regex linker option which doesn't work
# on all platforms.
#
LDPKGS = libofonobinderpluginext libgbinder-radio libgbinder libglibutil gobject-2.0 glib-2.0
PKGS = ofono $(LDPKGS)
#
# Default target
#
all: debug release
#
# Library name
#
NAME = samplebinderpluginext
LIB_NAME = $(NAME)
LIB_SONAME = $(LIB_NAME).so
LIB = $(LIB_SONAME)
STATIC_LIB = $(NAME).a
#
# Sources
#
SRC = \
sample_ext.c \
sample_ims.c \
sample_plugin.c \
sample_slot.c
#
# Directories
#
SRC_DIR = src
BUILD_DIR = build
DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
RELEASE_BUILD_DIR = $(BUILD_DIR)/release
#
# Tools and flags
#
CC = $(CROSS_COMPILE)gcc
LD = $(CC)
WARNINGS = -Wall
BASE_FLAGS = -fPIC -fvisibility=hidden
FULL_CFLAGS = $(BASE_FLAGS) $(CFLAGS) $(DEFINES) $(WARNINGS) -MMD -MP \
$(shell pkg-config --cflags $(PKGS))
FULL_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS) -shared \
$(shell pkg-config --libs $(LDPKGS))
DEBUG_FLAGS = -g
RELEASE_FLAGS =
KEEP_SYMBOLS ?= 0
ifneq ($(KEEP_SYMBOLS),0)
RELEASE_FLAGS += -g
endif
DEBUG_LDFLAGS = $(FULL_LDFLAGS) $(DEBUG_FLAGS)
RELEASE_LDFLAGS = $(FULL_LDFLAGS) $(RELEASE_FLAGS)
DEBUG_CFLAGS = $(FULL_CFLAGS) $(DEBUG_FLAGS) -DDEBUG
RELEASE_CFLAGS = $(FULL_CFLAGS) $(RELEASE_FLAGS) -O2
#
# Files
#
DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
DEBUG_SO = $(DEBUG_BUILD_DIR)/$(LIB)
RELEASE_SO = $(RELEASE_BUILD_DIR)/$(LIB)
#
# Dependencies
#
DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(DEPS)),)
-include $(DEPS)
endif
endif
$(DEBUG_OBJS) $(DEBUG_SO): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS) $(RELEASE_SO): | $(RELEASE_BUILD_DIR)
#
# Rules
#
debug: $(DEBUG_SO)
release: $(RELEASE_SO)
clean:
rm -f $(SRC_DIR)/*~ rpm/*~ *~
rm -fr $(BUILD_DIR)
$(DEBUG_BUILD_DIR):
mkdir -p $@
$(RELEASE_BUILD_DIR):
mkdir -p $@
$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
$(DEBUG_SO): $(DEBUG_OBJS)
$(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) $(DEBUG_LIBS) -o $@
$(RELEASE_SO): $(RELEASE_OBJS)
$(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) $(RELEASE_LIBS) -o $@
ifeq ($(KEEP_SYMBOLS),0)
$(STRIP) $@
endif
#
# Install
#
PLUGINDIR ?= $$(pkg-config ofono --variable=plugindir)
ABS_PLUGINDIR := $(shell echo /$(PLUGINDIR) | sed -r 's|/+|/|g')
INSTALL = install
INSTALL_PLUGIN_DIR = $(DESTDIR)$(ABS_PLUGINDIR)
install: $(INSTALL_PLUGIN_DIR)
$(INSTALL) -m 755 $(RELEASE_SO) $(INSTALL_PLUGIN_DIR)
$(INSTALL_PLUGIN_DIR):
$(INSTALL) -d $@

27
README Normal file
View File

@@ -0,0 +1,27 @@
Sample ofono binder plugin extension
====================================
It doesn't really do anything. It's just a demonstration of how
the extension interfaces (BINDER_EXT_TYPE_IMS being used as an
example) are supposed to be implemented.
Here is what happens when this extension gets loaded.
1. ofono calls sample_plugin_init(). That function creates an
instance of SampleExt and registers it under the name "sample"
by calling binder_ext_plugin_register()
2. ofono-binder-plugin finds the extension by name which it reads
from /etc/ofono/binder.d/sample.conf
3. ofono-binder-plugin calls sample_ext_new_slot() method of SampleExt
for each configured/detected slot. That creates per-slot SampleSlot
objects.
4. ofono-binder-plugin asks SampleSlot for particular interfaces by
calling its sample_slot_get_interface() method. SampleSlot only
reacts to BINDER_EXT_TYPE_IMS query and returns a pointer to
SampleIms object implementing BinderExtImsInterface
5. ofono-binder-plugin then goes on to call BinderExtImsInterface
methods of SampleIms object(s).

View File

@@ -0,0 +1,40 @@
Name: ofono-binder-plugin-ext-sample
Version: 1.0.0
Release: 1
Summary: Sample extension for ofono binder plugin
License: BSD
URL: https://github.com/monich/ofono-binder-plugin-ext-sample
Source: %{name}-%{version}.tar.bz2
BuildRequires: ofono-devel
BuildRequires: pkgconfig
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(libglibutil)
BuildRequires: pkgconfig(libgbinder-radio)
BuildRequires: pkgconfig(libofonobinderpluginext)
%define plugin_dir %(pkg-config ofono --variable=plugindir)
%define config_dir /etc/ofono/binder.d/
%description
Sample extension for ofono binder plugin
%prep
%setup -q -n %{name}-%{version}
%build
make %{_smp_mflags} PLUGINDIR=%{plugin_dir} KEEP_SYMBOLS=1 release
%install
rm -rf %{buildroot}
make DESTDIR=%{buildroot} PLUGINDIR=%{plugin_dir} install
mkdir -p %{buildroot}%{config_dir}
install -m 644 sample.conf %{buildroot}%{config_dir}
%files
%dir %{plugin_dir}
%dir %{config_dir}
%defattr(-,root,root,-)
%config %{config_dir}/sample.conf
%{plugin_dir}/samplebinderpluginext.so

2
sample.conf Normal file
View File

@@ -0,0 +1,2 @@
[Settings]
extPlugin = sample

107
src/sample_ext.c Normal file
View File

@@ -0,0 +1,107 @@
/*
* Copyright (C) 2022 Jolla Ltd.
* Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/
#include "sample_ext.h"
#include "sample_slot.h"
#include <binder_ext_plugin_impl.h>
typedef struct sample_ext {
BinderExtPlugin parent;
} SampleExt;
typedef BinderExtPluginClass SampleExtClass;
GType sample_ext_get_type() G_GNUC_INTERNAL;
G_DEFINE_TYPE(SampleExt, sample_ext, BINDER_EXT_TYPE_PLUGIN)
#define THIS_TYPE sample_ext_get_type()
#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, SampleExt)
const char sample_plugin_name[] = "sample";
/*==========================================================================*
* BinderExtPluginClass
*==========================================================================*/
static
BinderExtSlot*
sample_ext_new_slot(
BinderExtPlugin* plugin,
RadioInstance* radio,
GHashTable* params)
{
return sample_slot_new(radio, params);
}
/*==========================================================================*
* API
*==========================================================================*/
BinderExtPlugin*
sample_ext_new()
{
return g_object_new(THIS_TYPE, NULL);
}
/*==========================================================================*
* Internals
*==========================================================================*/
static
void
sample_ext_init(
SampleExt* self)
{
}
static
void
sample_ext_class_init(
SampleExtClass* klass)
{
klass->plugin_name = sample_plugin_name;
klass->new_slot = sample_ext_new_slot;
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/

58
src/sample_ext.h Normal file
View File

@@ -0,0 +1,58 @@
/*
* Copyright (C) 2022 Jolla Ltd.
* Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/
#ifndef SAMPLE_EXT_H
#define SAMPLE_EXT_H
#include <binder_ext_types.h>
extern const char sample_plugin_name[] G_GNUC_INTERNAL;
BinderExtPlugin*
sample_ext_new(
void)
G_GNUC_INTERNAL;
#endif /* SAMPLE_EXT_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/

208
src/sample_ims.c Normal file
View File

@@ -0,0 +1,208 @@
/*
* Copyright (C) 2022 Jolla Ltd.
* Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/
#include "sample_ims.h"
#include "sample_slot.h"
#include <binder_ext_ims_impl.h>
#include <ofono/log.h>
typedef GObjectClass SampleImsClass;
typedef struct sample_ims {
GObject parent;
char* slot;
} SampleIms;
static
void
sample_ims_iface_init(
BinderExtImsInterface* iface);
GType sample_ims_get_type() G_GNUC_INTERNAL;
G_DEFINE_TYPE_WITH_CODE(SampleIms, sample_ims, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE(BINDER_EXT_TYPE_IMS, sample_ims_iface_init))
#define THIS_TYPE sample_ims_get_type()
#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, SampleIms)
#define PARENT_CLASS sample_ims_parent_class
enum sample_ims_signal {
SIGNAL_STATE_CHANGED,
SIGNAL_COUNT
};
#define SIGNAL_STATE_CHANGED_NAME "sample-ims-state-changed"
static guint sample_ims_signals[SIGNAL_COUNT] = { 0 };
/*==========================================================================*
* BinderExtImsInterface
*==========================================================================*/
static
BINDER_EXT_IMS_STATE
sample_ims_get_state(
BinderExtIms* ext)
{
SampleIms* self = THIS(ext);
DBG("%s", self->slot);
#pragma message("TODO: return the actual state")
return BINDER_EXT_IMS_STATE_UNKNOWN;
}
static
guint
sample_ims_set_registration(
BinderExtIms* ext,
BINDER_EXT_IMS_REGISTRATION registration,
BinderExtImsResultFunc complete,
GDestroyNotify destroy,
void* user_data)
{
SampleIms* self = THIS(ext);
const gboolean on = (registration != BINDER_EXT_IMS_REGISTRATION_OFF);
DBG("%s %s", self->slot, on ? "on" : "off");
if (on) {
#pragma message("TODO: turn IMS registration on")
} else {
#pragma message("TODO: turn IMS registration off")
}
return 0;
}
static
void
sample_ims_cancel(
BinderExtIms* ext,
guint id)
{
SampleIms* self = THIS(ext);
/*
* Cancel a pending operation identified by the id returned by the
* above sample_ims_set_registration() call.
*/
DBG("%s %u", self->slot, id);
}
static
gulong
sample_ims_add_state_handler(
BinderExtIms* ext,
BinderExtImsFunc handler,
void* user_data)
{
SampleIms* self = THIS(ext);
DBG("%s", self->slot);
return G_LIKELY(handler) ? g_signal_connect(self,
SIGNAL_STATE_CHANGED_NAME, G_CALLBACK(handler), user_data) : 0;
}
static
void
sample_ims_iface_init(
BinderExtImsInterface* iface)
{
iface->version = BINDER_EXT_IMS_INTERFACE_VERSION;
iface->get_state = sample_ims_get_state;
iface->set_registration = sample_ims_set_registration;
iface->cancel = sample_ims_cancel;
iface->add_state_handler = sample_ims_add_state_handler;
}
/*==========================================================================*
* API
*==========================================================================*/
BinderExtIms*
sample_ims_new(
const char* slot)
{
SampleIms* self = g_object_new(THIS_TYPE, NULL);
/*
* This could be the place to register a listener that gets invoked
* on registration state change and emits SIGNAL_STATE_CHANGED.
*/
self->slot = g_strdup(slot);
return BINDER_EXT_IMS(self);
}
/*==========================================================================*
* Internals
*==========================================================================*/
static
void
sample_ims_finalize(
GObject* object)
{
SampleIms* self = THIS(object);
g_free(self->slot);
G_OBJECT_CLASS(PARENT_CLASS)->finalize(object);
}
static
void
sample_ims_init(
SampleIms* self)
{
}
static
void
sample_ims_class_init(
SampleImsClass* klass)
{
G_OBJECT_CLASS(klass)->finalize = sample_ims_finalize;
sample_ims_signals[SIGNAL_STATE_CHANGED] =
g_signal_new(SIGNAL_STATE_CHANGED_NAME, G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/

56
src/sample_ims.h Normal file
View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2022 Jolla Ltd.
* Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/
#ifndef SAMPLE_IMS_H
#define SAMPLE_IMS_H
#include <binder_ext_ims.h>
BinderExtIms*
sample_ims_new(
const char* slot)
G_GNUC_INTERNAL;
#endif /* SAMPLE_IMS_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/

75
src/sample_plugin.c Normal file
View File

@@ -0,0 +1,75 @@
/*
* Copyright (C) 2022 Jolla Ltd.
* Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/
#include "sample_ext.h"
#include <binder_ext_plugin.h>
#include <ofono/log.h>
#include <ofono/plugin.h>
static
int
sample_plugin_init()
{
BinderExtPlugin* ext;
DBG("");
ext = sample_ext_new();
binder_ext_plugin_register(ext);
binder_ext_plugin_unref(ext); /* libofonobinderpluginext keeps the ref */
return 0;
}
static
void
sample_plugin_exit()
{
DBG("");
binder_ext_plugin_unregister(sample_plugin_name);
}
OFONO_PLUGIN_DEFINE(sample, "Sample binder plugin extension", OFONO_VERSION,
OFONO_PLUGIN_PRIORITY_DEFAULT, sample_plugin_init, sample_plugin_exit)
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/

149
src/sample_slot.c Normal file
View File

@@ -0,0 +1,149 @@
/*
* Copyright (C) 2022 Jolla Ltd.
* Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/
#include "sample_slot.h"
#include "sample_ims.h"
#include <binder_ext_slot_impl.h>
#include <radio_instance.h>
typedef BinderExtSlotClass SampleSlotClass;
typedef struct sample_slot {
BinderExtSlot parent;
BinderExtIms* ims;
} SampleSlot;
GType sample_slot_get_type() G_GNUC_INTERNAL;
G_DEFINE_TYPE(SampleSlot, sample_slot, BINDER_EXT_TYPE_SLOT)
#define THIS_TYPE sample_slot_get_type()
#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, SampleSlot)
#define PARENT_CLASS sample_slot_parent_class
static
void
sample_slot_terminate(
SampleSlot* self)
{
if (self->ims) {
binder_ext_ims_unref(self->ims);
self->ims = NULL;
}
}
/*==========================================================================*
* BinderExtSlot
*==========================================================================*/
static
gpointer
sample_slot_get_interface(
BinderExtSlot* slot,
GType iface)
{
SampleSlot* self = THIS(slot);
if (iface == BINDER_EXT_TYPE_IMS) {
return self->ims;
} else {
return BINDER_EXT_SLOT_CLASS(PARENT_CLASS)->get_interface(slot, iface);
}
}
static
void
sample_slot_shutdown(
BinderExtSlot* slot)
{
sample_slot_terminate(THIS(slot));
BINDER_EXT_SLOT_CLASS(PARENT_CLASS)->shutdown(slot);
}
/*==========================================================================*
* API
*==========================================================================*/
BinderExtSlot*
sample_slot_new(
RadioInstance* radio,
GHashTable* params)
{
SampleSlot* self = g_object_new(THIS_TYPE, NULL);
BinderExtSlot* slot = &self->parent;
self->ims = sample_ims_new(radio->slot);
return slot;
}
/*==========================================================================*
* Internals
*==========================================================================*/
static
void
sample_slot_finalize(
GObject* object)
{
sample_slot_terminate(THIS(object));
G_OBJECT_CLASS(PARENT_CLASS)->finalize(object);
}
static
void
sample_slot_init(
SampleSlot* self)
{
}
static
void
sample_slot_class_init(
SampleSlotClass* klass)
{
klass->get_interface = sample_slot_get_interface;
klass->shutdown = sample_slot_shutdown;
G_OBJECT_CLASS(klass)->finalize = sample_slot_finalize;
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/

59
src/sample_slot.h Normal file
View File

@@ -0,0 +1,59 @@
/*
* Copyright (C) 2022 Jolla Ltd.
* Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/
#ifndef SAMPLE_SLOT_H
#define SAMPLE_SLOT_H
#include <binder_ext_slot.h>
#include <radio_types.h>
BinderExtSlot*
sample_slot_new(
RadioInstance* radio,
GHashTable* params)
G_GNUC_INTERNAL;
#endif /* SAMPLE_SLOT_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/