diff --git a/LICENSE b/LICENSE index 928d7af..f995b5d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,6 @@ Copyright (C) 2022 Jolla Ltd. Copyright (C) 2022 Slava Monich +Copyright (C) 2024 Marius Gripsgard You may use this file under the terms of the BSD license as follows: diff --git a/Makefile b/Makefile index 3b3c2d6..ac97fae 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ all: debug release # Library name # -NAME = samplebinderpluginext +NAME = qtibinderpluginext LIB_NAME = $(NAME) LIB_SONAME = $(LIB_NAME).so LIB = $(LIB_SONAME) @@ -33,10 +33,10 @@ STATIC_LIB = $(NAME).a # SRC = \ - sample_ext.c \ - sample_ims.c \ - sample_plugin.c \ - sample_slot.c + qti_ext.c \ + qti_ims.c \ + qti_plugin.c \ + qti_slot.c # # Directories diff --git a/README b/README index 06a7a12..724a9eb 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -Sample ofono binder plugin extension +Qti ofono binder plugin extension ==================================== It doesn't really do anything. It's just a demonstration of how @@ -7,21 +7,21 @@ 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" +1. ofono calls qti_plugin_init(). That function creates an + instance of QtiExt and registers it under the name "qti" 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 + from /etc/ofono/binder.d/qti.conf -3. ofono-binder-plugin calls sample_ext_new_slot() method of SampleExt - for each configured/detected slot. That creates per-slot SampleSlot +3. ofono-binder-plugin calls qti_ext_new_slot() method of QtiExt + for each configured/detected slot. That creates per-slot QtiSlot objects. -4. ofono-binder-plugin asks SampleSlot for particular interfaces by - calling its sample_slot_get_interface() method. SampleSlot only +4. ofono-binder-plugin asks QtiSlot for particular interfaces by + calling its qti_slot_get_interface() method. QtiSlot only reacts to BINDER_EXT_TYPE_IMS query and returns a pointer to - SampleIms object implementing BinderExtImsInterface + QtiIms object implementing BinderExtImsInterface 5. ofono-binder-plugin then goes on to call BinderExtImsInterface - methods of SampleIms object(s). + methods of QtiIms object(s). diff --git a/qti.conf b/qti.conf new file mode 100644 index 0000000..eb95eb9 --- /dev/null +++ b/qti.conf @@ -0,0 +1,2 @@ +[Settings] +extPlugin = qti diff --git a/rpm/ofono-binder-plugin-ext-sample.spec b/rpm/ofono-binder-plugin-ext-sample.spec deleted file mode 100644 index e22e8c1..0000000 --- a/rpm/ofono-binder-plugin-ext-sample.spec +++ /dev/null @@ -1,40 +0,0 @@ -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 diff --git a/sample.conf b/sample.conf deleted file mode 100644 index 714c9c9..0000000 --- a/sample.conf +++ /dev/null @@ -1,2 +0,0 @@ -[Settings] -extPlugin = sample diff --git a/src/sample_ext.c b/src/qti_ext.c similarity index 81% rename from src/sample_ext.c rename to src/qti_ext.c index f9e3e10..2a79daf 100644 --- a/src/sample_ext.c +++ b/src/qti_ext.c @@ -35,24 +35,24 @@ * any official policies, either expressed or implied. */ -#include "sample_ext.h" -#include "sample_slot.h" +#include "qti_ext.h" +#include "qti_slot.h" #include -typedef struct sample_ext { +typedef struct qti_ext { BinderExtPlugin parent; -} SampleExt; +} QtiExt; -typedef BinderExtPluginClass SampleExtClass; +typedef BinderExtPluginClass QtiExtClass; -GType sample_ext_get_type() G_GNUC_INTERNAL; -G_DEFINE_TYPE(SampleExt, sample_ext, BINDER_EXT_TYPE_PLUGIN) +GType qti_ext_get_type() G_GNUC_INTERNAL; +G_DEFINE_TYPE(QtiExt, qti_ext, BINDER_EXT_TYPE_PLUGIN) -#define THIS_TYPE sample_ext_get_type() -#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, SampleExt) +#define THIS_TYPE qti_ext_get_type() +#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, QtiExt) -const char sample_plugin_name[] = "sample"; +const char qti_plugin_name[] = "qti"; /*==========================================================================* * BinderExtPluginClass @@ -60,12 +60,12 @@ const char sample_plugin_name[] = "sample"; static BinderExtSlot* -sample_ext_new_slot( +qti_ext_new_slot( BinderExtPlugin* plugin, RadioInstance* radio, GHashTable* params) { - return sample_slot_new(radio, params); + return qti_slot_new(radio, params); } /*==========================================================================* @@ -73,7 +73,7 @@ sample_ext_new_slot( *==========================================================================*/ BinderExtPlugin* -sample_ext_new() +qti_ext_new() { return g_object_new(THIS_TYPE, NULL); } @@ -84,18 +84,18 @@ sample_ext_new() static void -sample_ext_init( - SampleExt* self) +qti_ext_init( + QtiExt* self) { } static void -sample_ext_class_init( - SampleExtClass* klass) +qti_ext_class_init( + QtiExtClass* klass) { - klass->plugin_name = sample_plugin_name; - klass->new_slot = sample_ext_new_slot; + klass->plugin_name = qti_plugin_name; + klass->new_slot = qti_ext_new_slot; } /* diff --git a/src/sample_ext.h b/src/qti_ext.h similarity index 93% rename from src/sample_ext.h rename to src/qti_ext.h index 9988a67..0918ee4 100644 --- a/src/sample_ext.h +++ b/src/qti_ext.h @@ -35,19 +35,19 @@ * any official policies, either expressed or implied. */ -#ifndef SAMPLE_EXT_H -#define SAMPLE_EXT_H +#ifndef QTI_EXT_H +#define QTI_EXT_H #include -extern const char sample_plugin_name[] G_GNUC_INTERNAL; +extern const char qti_plugin_name[] G_GNUC_INTERNAL; BinderExtPlugin* -sample_ext_new( +qti_ext_new( void) G_GNUC_INTERNAL; -#endif /* SAMPLE_EXT_H */ +#endif /* QTI_EXT_H */ /* * Local Variables: diff --git a/src/sample_ims.c b/src/qti_ims.c similarity index 75% rename from src/sample_ims.c rename to src/qti_ims.c index 8f99e77..13cf926 100644 --- a/src/sample_ims.c +++ b/src/qti_ims.c @@ -35,40 +35,40 @@ * any official policies, either expressed or implied. */ -#include "sample_ims.h" -#include "sample_slot.h" +#include "qti_ims.h" +#include "qti_slot.h" #include #include -typedef GObjectClass SampleImsClass; -typedef struct sample_ims { +typedef GObjectClass QtiImsClass; +typedef struct qti_ims { GObject parent; char* slot; -} SampleIms; +} QtiIms; static void -sample_ims_iface_init( +qti_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)) +GType qti_ims_get_type() G_GNUC_INTERNAL; +G_DEFINE_TYPE_WITH_CODE(QtiIms, qti_ims, G_TYPE_OBJECT, +G_IMPLEMENT_INTERFACE(BINDER_EXT_TYPE_IMS, qti_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 +#define THIS_TYPE qti_ims_get_type() +#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, QtiIms) +#define PARENT_CLASS qti_ims_parent_class -enum sample_ims_signal { +enum qti_ims_signal { SIGNAL_STATE_CHANGED, SIGNAL_COUNT }; -#define SIGNAL_STATE_CHANGED_NAME "sample-ims-state-changed" +#define SIGNAL_STATE_CHANGED_NAME "qti-ims-state-changed" -static guint sample_ims_signals[SIGNAL_COUNT] = { 0 }; +static guint qti_ims_signals[SIGNAL_COUNT] = { 0 }; /*==========================================================================* * BinderExtImsInterface @@ -76,10 +76,10 @@ static guint sample_ims_signals[SIGNAL_COUNT] = { 0 }; static BINDER_EXT_IMS_STATE -sample_ims_get_state( +qti_ims_get_state( BinderExtIms* ext) { - SampleIms* self = THIS(ext); + QtiIms* self = THIS(ext); DBG("%s", self->slot); #pragma message("TODO: return the actual state") @@ -88,14 +88,14 @@ sample_ims_get_state( static guint -sample_ims_set_registration( +qti_ims_set_registration( BinderExtIms* ext, BINDER_EXT_IMS_REGISTRATION registration, BinderExtImsResultFunc complete, GDestroyNotify destroy, void* user_data) { - SampleIms* self = THIS(ext); + QtiIms* self = THIS(ext); const gboolean on = (registration != BINDER_EXT_IMS_REGISTRATION_OFF); DBG("%s %s", self->slot, on ? "on" : "off"); @@ -109,27 +109,27 @@ sample_ims_set_registration( static void -sample_ims_cancel( +qti_ims_cancel( BinderExtIms* ext, guint id) { - SampleIms* self = THIS(ext); + QtiIms* self = THIS(ext); /* * Cancel a pending operation identified by the id returned by the - * above sample_ims_set_registration() call. + * above qti_ims_set_registration() call. */ DBG("%s %u", self->slot, id); } static gulong -sample_ims_add_state_handler( +qti_ims_add_state_handler( BinderExtIms* ext, BinderExtImsFunc handler, void* user_data) { - SampleIms* self = THIS(ext); + QtiIms* self = THIS(ext); DBG("%s", self->slot); return G_LIKELY(handler) ? g_signal_connect(self, @@ -138,14 +138,14 @@ sample_ims_add_state_handler( static void -sample_ims_iface_init( +qti_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; + iface->get_state = qti_ims_get_state; + iface->set_registration = qti_ims_set_registration; + iface->cancel = qti_ims_cancel; + iface->add_state_handler = qti_ims_add_state_handler; } /*==========================================================================* @@ -153,10 +153,10 @@ sample_ims_iface_init( *==========================================================================*/ BinderExtIms* -sample_ims_new( +qti_ims_new( const char* slot) { - SampleIms* self = g_object_new(THIS_TYPE, NULL); + QtiIms* self = g_object_new(THIS_TYPE, NULL); /* * This could be the place to register a listener that gets invoked @@ -172,10 +172,10 @@ sample_ims_new( static void -sample_ims_finalize( +qti_ims_finalize( GObject* object) { - SampleIms* self = THIS(object); + QtiIms* self = THIS(object); g_free(self->slot); G_OBJECT_CLASS(PARENT_CLASS)->finalize(object); @@ -183,18 +183,18 @@ sample_ims_finalize( static void -sample_ims_init( - SampleIms* self) +qti_ims_init( + QtiIms* self) { } static void -sample_ims_class_init( - SampleImsClass* klass) +qti_ims_class_init( + QtiImsClass* klass) { - G_OBJECT_CLASS(klass)->finalize = sample_ims_finalize; - sample_ims_signals[SIGNAL_STATE_CHANGED] = + G_OBJECT_CLASS(klass)->finalize = qti_ims_finalize; + qti_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); } diff --git a/src/sample_ims.h b/src/qti_ims.h similarity index 96% rename from src/sample_ims.h rename to src/qti_ims.h index e444c75..3422581 100644 --- a/src/sample_ims.h +++ b/src/qti_ims.h @@ -35,17 +35,17 @@ * any official policies, either expressed or implied. */ -#ifndef SAMPLE_IMS_H -#define SAMPLE_IMS_H +#ifndef QTI_IMS_H +#define QTI_IMS_H #include BinderExtIms* -sample_ims_new( +qti_ims_new( const char* slot) G_GNUC_INTERNAL; -#endif /* SAMPLE_IMS_H */ +#endif /* QTI_IMS_H */ /* * Local Variables: diff --git a/src/sample_plugin.c b/src/qti_plugin.c similarity index 88% rename from src/sample_plugin.c rename to src/qti_plugin.c index 99b20bf..a67e17e 100644 --- a/src/sample_plugin.c +++ b/src/qti_plugin.c @@ -35,7 +35,7 @@ * any official policies, either expressed or implied. */ -#include "sample_ext.h" +#include "qti_ext.h" #include @@ -44,12 +44,12 @@ static int -sample_plugin_init() +qti_plugin_init() { BinderExtPlugin* ext; DBG(""); - ext = sample_ext_new(); + ext = qti_ext_new(); binder_ext_plugin_register(ext); binder_ext_plugin_unref(ext); /* libofonobinderpluginext keeps the ref */ return 0; @@ -57,14 +57,14 @@ sample_plugin_init() static void -sample_plugin_exit() +qti_plugin_exit() { DBG(""); - binder_ext_plugin_unregister(sample_plugin_name); + binder_ext_plugin_unregister(qti_plugin_name); } -OFONO_PLUGIN_DEFINE(sample, "Sample binder plugin extension", OFONO_VERSION, - OFONO_PLUGIN_PRIORITY_DEFAULT, sample_plugin_init, sample_plugin_exit) +OFONO_PLUGIN_DEFINE(qti, "Qti binder plugin extension", OFONO_VERSION, + OFONO_PLUGIN_PRIORITY_DEFAULT, qti_plugin_init, qti_plugin_exit) /* * Local Variables: diff --git a/src/sample_slot.c b/src/qti_slot.c similarity index 76% rename from src/sample_slot.c rename to src/qti_slot.c index 6c62d5a..6b7a6cf 100644 --- a/src/sample_slot.c +++ b/src/qti_slot.c @@ -35,30 +35,30 @@ * any official policies, either expressed or implied. */ -#include "sample_slot.h" -#include "sample_ims.h" +#include "qti_slot.h" +#include "qti_ims.h" #include #include -typedef BinderExtSlotClass SampleSlotClass; -typedef struct sample_slot { +typedef BinderExtSlotClass QtiSlotClass; +typedef struct qti_slot { BinderExtSlot parent; BinderExtIms* ims; -} SampleSlot; +} QtiSlot; -GType sample_slot_get_type() G_GNUC_INTERNAL; -G_DEFINE_TYPE(SampleSlot, sample_slot, BINDER_EXT_TYPE_SLOT) +GType qti_slot_get_type() G_GNUC_INTERNAL; +G_DEFINE_TYPE(QtiSlot, qti_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 +#define THIS_TYPE qti_slot_get_type() +#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, QtiSlot) +#define PARENT_CLASS qti_slot_parent_class static void -sample_slot_terminate( - SampleSlot* self) +qti_slot_terminate( + QtiSlot* self) { if (self->ims) { binder_ext_ims_unref(self->ims); @@ -72,11 +72,11 @@ sample_slot_terminate( static gpointer -sample_slot_get_interface( +qti_slot_get_interface( BinderExtSlot* slot, GType iface) { - SampleSlot* self = THIS(slot); + QtiSlot* self = THIS(slot); if (iface == BINDER_EXT_TYPE_IMS) { return self->ims; @@ -87,10 +87,10 @@ sample_slot_get_interface( static void -sample_slot_shutdown( +qti_slot_shutdown( BinderExtSlot* slot) { - sample_slot_terminate(THIS(slot)); + qti_slot_terminate(THIS(slot)); BINDER_EXT_SLOT_CLASS(PARENT_CLASS)->shutdown(slot); } @@ -99,14 +99,14 @@ sample_slot_shutdown( *==========================================================================*/ BinderExtSlot* -sample_slot_new( +qti_slot_new( RadioInstance* radio, GHashTable* params) { - SampleSlot* self = g_object_new(THIS_TYPE, NULL); + QtiSlot* self = g_object_new(THIS_TYPE, NULL); BinderExtSlot* slot = &self->parent; - self->ims = sample_ims_new(radio->slot); + self->ims = qti_ims_new(radio->slot); return slot; } @@ -116,28 +116,28 @@ sample_slot_new( static void -sample_slot_finalize( +qti_slot_finalize( GObject* object) { - sample_slot_terminate(THIS(object)); + qti_slot_terminate(THIS(object)); G_OBJECT_CLASS(PARENT_CLASS)->finalize(object); } static void -sample_slot_init( - SampleSlot* self) +qti_slot_init( + QtiSlot* self) { } static void -sample_slot_class_init( - SampleSlotClass* klass) +qti_slot_class_init( + QtiSlotClass* klass) { - klass->get_interface = sample_slot_get_interface; - klass->shutdown = sample_slot_shutdown; - G_OBJECT_CLASS(klass)->finalize = sample_slot_finalize; + klass->get_interface = qti_slot_get_interface; + klass->shutdown = qti_slot_shutdown; + G_OBJECT_CLASS(klass)->finalize = qti_slot_finalize; } /* diff --git a/src/sample_slot.h b/src/qti_slot.h similarity index 96% rename from src/sample_slot.h rename to src/qti_slot.h index 2703d70..6cb16cc 100644 --- a/src/sample_slot.h +++ b/src/qti_slot.h @@ -35,20 +35,20 @@ * any official policies, either expressed or implied. */ -#ifndef SAMPLE_SLOT_H -#define SAMPLE_SLOT_H +#ifndef QTI_SLOT_H +#define QTI_SLOT_H #include #include BinderExtSlot* -sample_slot_new( +qti_slot_new( RadioInstance* radio, GHashTable* params) G_GNUC_INTERNAL; -#endif /* SAMPLE_SLOT_H */ +#endif /* QTI_SLOT_H */ /* * Local Variables: