[common] Add the definition of a legacy messaging interface 32/262332/1 accepted/tizen/unified/20210809.001403 submit/tizen/20210806.151755
authorPawel Wasowski <p.wasowski2@samsung.com>
Fri, 6 Aug 2021 15:00:22 +0000 (17:00 +0200)
committerPawel Wasowski <p.wasowski2@samsung.com>
Fri, 6 Aug 2021 15:00:22 +0000 (17:00 +0200)
This recent change that introduced new binary messaging interfaces,
replacing XW_MESSAGING_INTERFACE_1 with XW_MESSAGING_INTERFACE_2.
This chang broken the build of webapi-plugins-teec project, which depends
on the declaration of the legacy interface.
This commit fixes this problem, by adding the legacy interface back
to XW_Extension.h.

[Verification] webapi-plugins builds. webapi-plugins-teec builds,
when webapi-plugins built with this change is installed in GBS root.

Change-Id: Ia057a8e9ea9d51e06616a0ad16dc28b3ea342d8c

src/common/XW_Extension.h

index cc89536..37734dd 100644 (file)
@@ -138,6 +138,32 @@ struct XW_CoreInterface_1 {
 
 typedef struct XW_CoreInterface_1 XW_CoreInterface;
 
+/*
+ * XW_MESSAGING_INTERFACE_1 is no longer used in webapi-plugins
+ * but its declaration stays in this header, so that the dependencies
+ * of webapi-plugins-common can find the declaration in the XW_Extension.h
+ * they include.
+ */
+#define XW_MESSAGING_INTERFACE_1 "XW_MessagingInterface_1"
+
+typedef void (*XW_HandleMessageCallback)(XW_Instance instance, const char* message);
+
+struct XW_MessagingInterface_1 {
+  // Register a callback to be called when the JavaScript code associated
+  // with the extension posts a message. Note that the callback will be called
+  // with the XW_Instance that posted the message as well as the message
+  // contents.
+  void (*Register)(XW_Extension extension, XW_HandleMessageCallback handle_message);
+
+  // Post a message to the web content associated with the instance. To
+  // receive this message the extension's JavaScript code should set a
+  // listener using extension.setMessageListener() function.
+  //
+  // This function is thread-safe and can be called until the instance is
+  // destroyed.
+  void (*PostMessage)(XW_Instance instance, const char* message);
+};
+
 //
 // XW_MESSAGING_INTERFACE: Exchange asynchronous messages with JavaScript
 // code provided by extension.