[-]
[+]
|
Changed |
_service:tar_git:libgbinder.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -6,7 +6,7 @@
<service name="tar_git">
<param name="url">https://github.com/mer-hybris/libgbinder.git</param>
<param name="branch">master</param>
- <param name="revision">ccf3e1237c670c939f91308e411f936eba8b88b5</param>
+ <param name="revision">6d2f2efe310d0aaabc5c8e7eeabd8aa73d5be18e</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.0.42.tar.bz2/Makefile
^
|
@@ -16,7 +16,7 @@
VERSION_MAJOR = 1
VERSION_MINOR = 0
-VERSION_RELEASE = 41
+VERSION_RELEASE = 42
# Version for pkg-config
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.0.42.tar.bz2/debian/changelog
^
|
@@ -1,3 +1,9 @@
+libgbinder (1.0.42) unstable; urgency=low
+
+ * Allow GBinderClient to use multiple interfaces
+
+ -- Slava Monich <slava.monich@jolla.com> Tue, 05 May 2020 19:56:39 +0300
+
libgbinder (1.0.41) unstable; urgency=low
* Stop using GUtilIdlePool
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.0.42.tar.bz2/include/gbinder_client.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2020 Jolla Ltd.
+ * Copyright (C) 2018-2020 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -37,6 +37,11 @@
G_BEGIN_DECLS
+typedef struct gbinder_client_iface_info {
+ const char* iface;
+ guint32 last_code;
+} GBinderClientIfaceInfo;
+
typedef
void
(*GBinderClientReplyFunc)(
@@ -51,6 +56,12 @@
const char* iface);
GBinderClient*
+gbinder_client_new2(
+ GBinderRemoteObject* object,
+ const GBinderClientIfaceInfo* ifaces,
+ gsize count); /* since 1.0.42 */
+
+GBinderClient*
gbinder_client_ref(
GBinderClient* client);
@@ -62,10 +73,20 @@
gbinder_client_interface(
GBinderClient* client); /* since 1.0.22 */
+const char*
+gbinder_client_interface2(
+ GBinderClient* client,
+ guint32 code); /* since 1.0.42 */
+
GBinderLocalRequest*
gbinder_client_new_request(
GBinderClient* client);
+GBinderLocalRequest*
+gbinder_client_new_request2(
+ GBinderClient* client,
+ guint32 code); /* since 1.0.42 */
+
GBinderRemoteReply*
gbinder_client_transact_sync_reply(
GBinderClient* client,
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.0.42.tar.bz2/src/gbinder_client.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2020 Jolla Ltd.
+ * Copyright (C) 2018-2020 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -41,14 +41,22 @@
#include <gutil_macros.h>
+#include <stdlib.h>
#include <errno.h>
+#include <limits.h>
-typedef struct gbinder_client_priv {
- GBinderClient pub;
- guint32 refcount;
+typedef struct gbinder_client_iface_range {
char* iface;
GBytes* rpc_header;
GBinderLocalRequest* basic_req;
+ guint32 last_code;
+} GBinderClientIfaceRange;
+
+typedef struct gbinder_client_priv {
+ GBinderClient pub;
+ guint32 refcount;
+ GBinderClientIfaceRange* ranges;
+ guint nr;
} GBinderClientPriv;
typedef struct gbinder_client_tx {
@@ -66,18 +74,78 @@
*==========================================================================*/
static
+const GBinderClientIfaceRange*
+gbinder_client_find_range(
+ GBinderClientPriv* priv,
+ guint32 code)
+{
+ guint i;
+
+ for (i = 0; i < priv->nr; i++) {
+ const GBinderClientIfaceRange* r = priv->ranges + i;
+
+ if (r->last_code >= code) {
+ return r;
+ }
+ }
+ return NULL;
+}
+
+/*
+ * Generates basic request (without additional parameters) for the
+ * specified interface and pulls header data out of it. The basic
+ * request can be reused for those transactions which have no
+ * additional parameters. The header data are needed for building
+ * non-trivial requests.
+ */
+static
+void
+gbinder_client_init_range(
+ GBinderClientIfaceRange* r,
+ GBinderDriver* driver,
+ const GBinderClientIfaceInfo* info)
+{
+ GBinderOutputData* hdr;
+
+ r->basic_req = gbinder_driver_local_request_new(driver, info->iface);
+ hdr = gbinder_local_request_data(r->basic_req);
+ r->rpc_header = g_bytes_new(hdr->bytes->data, hdr->bytes->len);
+ r->iface = g_strdup(info->iface);
+ r->last_code = info->last_code;
+}
+
+static
+int
+gbinder_client_sort_ranges(
+ const void* p1,
+ const void* p2)
+{
+ const GBinderClientIfaceRange* r1 = p1;
+ const GBinderClientIfaceRange* r2 = p2;
+
+ return (r1->last_code < r2->last_code) ? (-1) :
+ (r1->last_code > r2->last_code) ? 1 : 0;
+}
+
+static
void
gbinder_client_free(
GBinderClientPriv* priv)
{
GBinderClient* self = &priv->pub;
+ guint i;
- gbinder_remote_object_unref(self->remote);
- gbinder_local_request_unref(priv->basic_req);
- g_free(priv->iface);
- if (priv->rpc_header) {
- g_bytes_unref(priv->rpc_header);
+ for (i = 0; i < priv->nr; i++) {
+ GBinderClientIfaceRange* r = priv->ranges + i;
+
+ gbinder_local_request_unref(r->basic_req);
+ g_free(r->iface);
+ if (r->rpc_header) {
+ g_bytes_unref(r->rpc_header);
+ }
}
+ g_free(priv->ranges);
+ gbinder_remote_object_unref(self->remote);
g_slice_free(GBinderClientPriv, priv);
}
@@ -115,9 +183,10 @@
*==========================================================================*/
GBinderClient*
-gbinder_client_new(
+gbinder_client_new2(
GBinderRemoteObject* remote,
- const char* iface)
+ const GBinderClientIfaceInfo* ifaces,
+ gsize count)
{
if (G_LIKELY(remote)) {
GBinderClientPriv* priv = g_slice_new0(GBinderClientPriv);
@@ -126,22 +195,22 @@
g_atomic_int_set(&priv->refcount, 1);
self->remote = gbinder_remote_object_ref(remote);
+ if (count > 0) {
+ gsize i;
- /*
- * Generate basic request (without additional parameters) and pull
- * header data out of it. The basic request can be reused for those
- * transactions which has no additional parameters. The header data
- * are needed for building non-trivial requests.
- */
- if (iface) {
- GBinderOutputData* hdr;
-
- priv->basic_req = gbinder_driver_local_request_new(driver, iface);
- hdr = gbinder_local_request_data(priv->basic_req);
- priv->rpc_header = g_bytes_new(hdr->bytes->data, hdr->bytes->len);
- self->iface = priv->iface = g_strdup(iface);
+ priv->nr = count;
+ priv->ranges = g_new(GBinderClientIfaceRange, priv->nr);
+ for (i = 0; i < count; i++) {
+ gbinder_client_init_range(priv->ranges + i, driver, ifaces + i);
+ }
+ qsort(priv->ranges, count, sizeof(GBinderClientIfaceRange),
+ gbinder_client_sort_ranges);
} else {
- priv->basic_req = gbinder_local_request_new
+ /* No interface info */
+ priv->nr = 1;
+ priv->ranges = g_new0(GBinderClientIfaceRange, 1);
+ priv->ranges[0].last_code = UINT_MAX;
+ priv->ranges[0].basic_req = gbinder_local_request_new
(gbinder_driver_io(driver), NULL);
}
return self;
@@ -150,6 +219,18 @@
}
GBinderClient*
+gbinder_client_new(
+ GBinderRemoteObject* remote,
+ const char* iface)
+{
+ GBinderClientIfaceInfo info;
+
+ info.iface = iface;
+ info.last_code = UINT_MAX;
+ return gbinder_client_new2(remote, &info, 1);
+}
+
+GBinderClient*
gbinder_client_ref(
GBinderClient* self)
{
@@ -180,7 +261,23 @@
gbinder_client_interface(
GBinderClient* self) /* since 1.0.22 */
{
- return G_LIKELY(self) ? gbinder_client_cast(self)->iface : NULL;
+ return G_LIKELY(self) ? gbinder_client_cast(self)->ranges->iface : NULL;
+}
+
+const char*
+gbinder_client_interface2(
+ GBinderClient* self,
+ guint32 code) /* since 1.0.42 */
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.0.42.tar.bz2/src/gbinder_client_p.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2020 Jolla Ltd.
+ * Copyright (C) 2018-2020 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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 name of Jolla Ltd nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * 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
@@ -38,7 +38,6 @@
#include "gbinder_types_p.h"
struct gbinder_client {
- const char* iface;
GBinderRemoteObject* remote;
};
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.0.42.tar.bz2/unit/unit_client/unit_client.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2020 Jolla Ltd.
+ * Copyright (C) 2018-2020 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -75,10 +75,13 @@
void)
{
g_assert(!gbinder_client_new(NULL, NULL));
+ g_assert(!gbinder_client_new2(NULL, NULL, 0));
g_assert(!gbinder_client_ref(NULL));
g_assert(!gbinder_client_interface(NULL));
+ g_assert(!gbinder_client_interface2(NULL, 0));
gbinder_client_unref(NULL);
g_assert(!gbinder_client_new_request(NULL));
+ g_assert(!gbinder_client_new_request2(NULL, 0));
g_assert(!gbinder_client_transact_sync_reply(NULL, 0, NULL, NULL));
g_assert(gbinder_client_transact_sync_oneway(NULL, 0, NULL) == (-EINVAL));
g_assert(!gbinder_client_transact(NULL, 0, 0, NULL, NULL, NULL, NULL));
@@ -102,7 +105,7 @@
g_assert(client);
g_assert(gbinder_client_ref(client) == client);
- g_assert(!g_strcmp0(gbinder_client_interface(client), iface));
+ g_assert_cmpstr(gbinder_client_interface(client), == ,iface);
gbinder_client_unref(client);
gbinder_client_cancel(client, 0); /* does nothing */
@@ -112,6 +115,44 @@
}
/*==========================================================================*
+ * interfaces
+ *==========================================================================*/
+
+static
+void
+test_interfaces(
+ void)
+{
+ GBinderIpc* ipc = gbinder_ipc_new(GBINDER_DEFAULT_BINDER, NULL);
+ GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
+ GBinderRemoteObject* obj = gbinder_object_registry_get_remote(reg, 0);
+ static const GBinderClientIfaceInfo ifaces[] = {
+ {"33", 33 }, { "11", 11 }, { "22", 22 }
+ };
+ GBinderClient* client = gbinder_client_new2(obj, ifaces,
+ G_N_ELEMENTS(ifaces));
+
+ g_assert(client);
+ g_assert_cmpstr(gbinder_client_interface(client), == ,"11");
+ g_assert_cmpstr(gbinder_client_interface2(client, 11), == ,"11");
+ g_assert_cmpstr(gbinder_client_interface2(client, 22), == ,"22");
+ g_assert_cmpstr(gbinder_client_interface2(client, 33), == ,"33");
+ g_assert(!gbinder_client_interface2(client, 34));
+ g_assert(!gbinder_client_new_request2(client, 34));
+ gbinder_client_unref(client);
+
+ /* Client with no interface info */
+ client = gbinder_client_new2(obj, NULL, 0);
+ g_assert(client);
+ g_assert(!gbinder_client_interface(client));
+ g_assert(!gbinder_client_interface2(client, 1));
+ gbinder_client_unref(client);
+
+ gbinder_remote_object_unref(obj);
+ gbinder_ipc_unref(ipc);
+}
+
+/*==========================================================================*
* no_header
*==========================================================================*/
@@ -344,8 +385,9 @@
GDestroyNotify destroy)
{
GBinderClient* client = test_client_new(0, TEST_INTERFACE);
- GBinderLocalRequest* req = gbinder_client_new_request(client);
+ GBinderLocalRequest* req = gbinder_client_new_request2(client, 0);
+ g_assert(req);
test_reply_tx(client, req, done, destroy);
gbinder_local_request_unref(req);
@@ -391,6 +433,7 @@
g_test_init(&argc, &argv, NULL);
g_test_add_func(TEST_("null"), test_null);
g_test_add_func(TEST_("basic"), test_basic);
+ g_test_add_func(TEST_("interfaces"), test_interfaces);
g_test_add_func(TEST_("dead"), test_dead);
g_test_add_func(TEST_("no_header"), test_no_header);
g_test_add_func(TEST_("sync_oneway"), test_sync_oneway);
|