To support Tizen 2.3 native application, add tizen native api to message port library.
Change-Id: I90928fc241639273a629cc171f847b03af641afb
Signed-off-by: Hurnjoo Lee <hurnjoo.lee@samsung.com>
AC_SUBST(DLOG_CFLAGS)
AC_SUBST(DLOG_LIBS)
+PKG_CHECK_MODULES([CAPIBASECOMMON], [capi-base-common])
+AC_SUBST(CAPIBASECOMMON_CFLAGS)
+AC_SUBST(CAPIBASECOMMON_LIBS)
+
AC_DEFINE(MESSAGEPORT_BUS_ADDRESS,
["unix:path=%s/.message-port", "/tmp"],
[messageport daemon server socket address])
msgport-manager.c \
msgport-factory.h \
msgport-factory.c \
+ compatibility/message_port_wrapper.c \
$(NULL)
libmessage_port_la_LDFLAGS = -version-info $(subst .,:,$(VERSION))
libmessage_port_la_includedir = $(includedir)/
libmessage_port_la_include_HEADERS = \
message-port.h \
+ compatibility/message_port.h \
$(NULL)
libmessage_port_la_CPPFLAGS = \
-I . \
-I $(top_builddir) \
-DLOG_TAG=\"MESSAGEPORT/LIB\" \
- $(GLIB_CFLAGS) $(GIO_CFLAGS) $(BUNDLE_CFLAGS) $(DLOG_CFLAGS) \
+ $(GLIB_CFLAGS) $(GIO_CFLAGS) $(BUNDLE_CFLAGS) $(DLOG_CFLAGS) $(CAPIBASECOMMON_CFLAGS) \
-Wall -error
$(NULL)
libmessage_port_la_LIBADD = \
../common/libmessageport-common.la \
- $(GLIB_LIBS) $(GIO_LIBS) $(BUNDLE_LIBS) $(DLOG_LIBS) \
+ $(GLIB_LIBS) $(GIO_LIBS) $(BUNDLE_LIBS) $(DLOG_LIBS) $(CAPIBASECOMMON_LIBS) \
$(NULL)
pkgconfigdir = $(libdir)/pkgconfig
--- /dev/null
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of message-port.
+ *
+ * Copyright (c) 2015 Samsung Electronics
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __TIZEN_APPFW_MESSAGE_PORT_H__
+#define __TIZEN_APPFW_MESSAGE_PORT_H__
+
+#ifdef __GNUC__
+# ifndef EXPORT_API
+# define EXPORT_API __attribute__((visibility("default")))
+# endif
+#else
+# define EXPORT_API
+#endif
+
+#include <stdbool.h>
+#include <bundle.h>
+#include <message-port.h>
+#include <tizen_error.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* For Tizen 2.3 Native API compatibility*/
+typedef enum
+{
+ MESSAGE_PORT_ERROR_NONE = MESSAGEPORT_ERROR_NONE, /**< Successful */
+ MESSAGE_PORT_ERROR_IO_ERROR = MESSAGEPORT_ERROR_IO_ERROR, /**< Internal I/O error */
+ MESSAGE_PORT_ERROR_OUT_OF_MEMORY = MESSAGEPORT_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ MESSAGE_PORT_ERROR_INVALID_PARAMETER = MESSAGEPORT_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ MESSAGE_PORT_ERROR_PORT_NOT_FOUND = MESSAGEPORT_ERROR_MESSAGEPORT_NOT_FOUND, /**< The message port of the remote application is not found */
+ MESSAGE_PORT_ERROR_CERTIFICATE_NOT_MATCH = MESSAGEPORT_ERROR_CERTIFICATE_NOT_MATCH, /**< The remote application is not signed with the same certificate */
+ MESSAGE_PORT_ERROR_MAX_EXCEEDED = MESSAGEPORT_ERROR_MAX_EXCEEDED, /**< The size of the message has exceeded the maximum limit */
+ MESSAGE_PORT_ERROR_RESOURCE_UNAVAILABLE = MESSAGEPORT_ERROR_RESOURCE_UNAVAILABLE /**< Resource is temporarily unavailable */
+} message_port_error_e;
+
+typedef void (*message_port_message_cb)(int local_port_id, const char *remote_app_id, const char *remote_port, bool trusted_remote_port, bundle *messagem, void *user_data);
+typedef void (*message_port_trusted_message_cb)(int trusted_local_port_id, const char *remote_app_id, const char *remote_port, bool trusted_remote_port, bundle *message, void *user_data);
+
+EXPORT_API int
+message_port_register_local_port (const char *local_port, message_port_message_cb callback, void *user_data);
+
+EXPORT_API int
+message_port_register_trusted_local_port (const char *trusted_local_port, message_port_trusted_message_cb callback, void *user_data);
+
+EXPORT_API int
+message_port_unregister_local_port (int local_port_id);
+
+EXPORT_API int
+message_port_unregister_trusted_local_port (int trusted_local_port_id);
+
+EXPORT_API int
+message_port_check_remote_port (const char *remote_app_id, const char *remote_port, bool *exist);
+
+EXPORT_API int
+message_port_check_trusted_remote_port (const char *remote_app_id, const char *remote_port, bool *exist);
+
+EXPORT_API int
+message_port_send_message (const char *remote_app_id, const char *remote_port, bundle *message);
+
+EXPORT_API int
+message_port_send_trusted_message (const char *remote_app_id, const char *remote_port, bundle *message);
+
+EXPORT_API int
+message_port_send_message_with_local_port (const char *remote_app_id, const char *remote_port, bundle *message, int local_port_id);
+
+EXPORT_API int
+message_port_send_trusted_message_with_local_port (const char *remote_app_id, const char *remote_port, bundle *message, int local_port_id);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_APPFW_MESSAGE_PORT_H__ */
--- /dev/null
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of message-port.
+ *
+ * Copyright (c) 2015 Samsung Electronics
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include "message_port.h"
+
+EXPORT_API int
+message_port_register_local_port (const char *local_port, message_port_message_cb callback, void *user_data)
+{
+ return messageport_register_local_port_full (local_port, callback, user_data);
+}
+
+EXPORT_API int
+message_port_register_trusted_local_port (const char *trusted_local_port, message_port_trusted_message_cb callback, void *user_data)
+{
+ return messageport_register_trusted_local_port_full (trusted_local_port, callback, user_data);
+}
+
+EXPORT_API int
+message_port_unregister_local_port (int local_port_id)
+{
+ return messageport_unregister_local_port (local_port_id);
+}
+
+EXPORT_API int
+message_port_unregister_trusted_local_port (int trusted_local_port_id)
+{
+ return messageport_unregister_trusted_local_port (trusted_local_port_id);
+}
+
+EXPORT_API int
+message_port_check_remote_port (const char *remote_app_id, const char *remote_port, bool *exist)
+{
+ return messageport_check_remote_port (remote_app_id, remote_port, exist);
+}
+
+EXPORT_API int
+message_port_check_trusted_remote_port (const char *remote_app_id, const char *remote_port, bool *exist)
+{
+ return messageport_check_trusted_remote_port (remote_app_id, remote_port, exist);
+}
+
+EXPORT_API int
+message_port_send_message (const char *remote_app_id, const char *remote_port, bundle *message)
+{
+ return messageport_send_message (remote_app_id, remote_port, message);
+}
+
+EXPORT_API int
+message_port_send_trusted_message( const char *remote_app_id, const char *remote_port, bundle *message)
+{
+ return messageport_send_trusted_message (remote_app_id, remote_port, message);
+}
+
+EXPORT_API int
+message_port_send_message_with_local_port (const char *remote_app_id, const char *remote_port, bundle *message, int local_port_id)
+{
+ return messageport_send_bidirectional_message (local_port_id, remote_app_id, remote_port, message);
+}
+
+EXPORT_API int
+message_port_send_trusted_message_with_local_port (const char *remote_app_id, const char *remote_port, bundle *message, int local_port_id)
+{
+ return messageport_send_bidirectional_trusted_message (local_port_id, remote_app_id, remote_port, message);
+}
+
+
return port_id > 0 ? port_id : (int)res;
}
+static int
+_messageport_unregister_port (int local_port_id, gboolean is_trusted)
+{
+ messageport_error_e res, res_check_trust;
+ gboolean is_trusted_out = FALSE;
+ MsgPortManager *manager = msgport_factory_get_manager ();
+ if (!manager) return MESSAGEPORT_ERROR_IO_ERROR;
+
+ res_check_trust = msgport_manager_get_service_is_trusted (manager, local_port_id, &is_trusted_out);
+ if (res_check_trust != MESSAGEPORT_ERROR_NONE)
+ return (int)res_check_trust;
+
+ if (is_trusted_out == is_trusted)
+ return MESSAGEPORT_ERROR_MESSAGEPORT_NOT_FOUND;
+
+ res = msgport_manager_unregister_service (manager, local_port_id);
+
+ return (int)res;
+}
+
static messageport_error_e
_messageport_check_remote_port (const char *app_id, const char *port, gboolean is_trusted, bool *exists)
{
MsgPortManager *manager = msgport_factory_get_manager ();
if (!manager) return MESSAGEPORT_ERROR_IO_ERROR;
+ if (!message) return MESSAGEPORT_ERROR_INVALID_PARAMETER;
GVariant *v_data = bundle_to_variant_map (message);
MsgPortManager *manager = msgport_factory_get_manager ();
if (!manager) return MESSAGEPORT_ERROR_IO_ERROR;
+ if (!message) return MESSAGEPORT_ERROR_INVALID_PARAMETER;
GVariant *v_data = bundle_to_variant_map (message);
return _messageport_register_port (local_port, TRUE, callback, userdata);
}
+int
+messageport_unregister_local_port (int local_port_id)
+{
+ return _messageport_unregister_port (local_port_id, FALSE);
+}
+
+int
+messageport_unregister_trusted_local_port (int trusted_local_port_id)
+{
+ return _messageport_unregister_port (trusted_local_port_id, TRUE);
+}
+
messageport_error_e
messageport_check_remote_port (const char *remote_app_id, const char *port_name, bool *exists)
{
return res;
}
+
#include <bundle.h>
#include <glib.h>
-
-#ifndef __cplusplus
-typedef guint8 bool;
-#endif
+#include <stdbool.h>
+#include <tizen_error.h>
G_BEGIN_DECLS
*/
typedef enum _messageport_error_e
{
- MESSAGEPORT_ERROR_NONE = 0,
- MESSAGEPORT_ERROR_IO_ERROR = -1,
- MESSAGEPORT_ERROR_OUT_OF_MEMORY = -2,
- MESSAGEPORT_ERROR_INVALID_PARAMETER = -3,
- MESSAGEPORT_ERROR_MESSAGEPORT_NOT_FOUND = -4,
- MESSAGEPORT_ERROR_CERTIFICATE_NOT_MATCH = -5,
- MESSAGEPORT_ERROR_MAX_EXCEEDED = -6,
+ MESSAGEPORT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ MESSAGEPORT_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Internal I/O error */
+ MESSAGEPORT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ MESSAGEPORT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ MESSAGEPORT_ERROR_MESSAGEPORT_NOT_FOUND = TIZEN_ERROR_MESSAGE_PORT | 0x01, /**< The message port of the remote application is not found */
+ MESSAGEPORT_ERROR_CERTIFICATE_NOT_MATCH = TIZEN_ERROR_MESSAGE_PORT | 0x02, /**< The remote application is not signed with the same certificate */
+ MESSAGEPORT_ERROR_MAX_EXCEEDED = TIZEN_ERROR_MESSAGE_PORT | 0x03, /**< The size of the message has exceeded the maximum limit */
+ MESSAGEPORT_ERROR_RESOURCE_UNAVAILABLE = TIZEN_ERROR_MESSAGE_PORT | 0x04 /**< Resource is temporarily unavailable */
} messageport_error_e;
/**
messageport_register_trusted_local_port_full(const char* local_port, messageport_message_cb_full callback, void *userdata);
/**
+ * messageport_unregister_local_port:
+ * @local_port_id: The local message port ID
+ *
+ * Unregisters the local message port.
+ * This method unregisters the callback function with the specified local port ID.
+ *
+ * Returns: 0 on success, otherwise a negative error value.
+ * #MESSAGEPORT_ERROR_NONE Successful
+ * #MESSAGEPORT_ERROR_INVALID_PARAMETER The specified @a local_port_id is not positive
+ * #MESSAGEPORT_ERROR_MESSAGEPORT_NOT_FOUND The specified @a local_port_id cannot be found
+ * #MESSAGEPORT_ERROR_OUT_OF_MEMORY Out of memory
+ * #MESSAGEPORT_ERROR_IO_ERROR Internal I/O error
+ */
+EXPORT_API int
+messageport_unregister_local_port(int local_port_id);
+
+/**
+ * messageport_unregister_trusted_local_port:
+ * @trusted_local_port_id: The trusted local message port ID
+ *
+ * Unregisters the trusted local message port.
+ * This method unregisters the callback function with the specified trusted local port ID.
+ *
+ * Returns: 0 on success, otherwise a negative error value.
+ * #MESSAGEPORT_ERROR_NONE Successful
+ * #MESSAGEPORT_ERROR_INVALID_PARAMETER The specified @a local_port_id is not positive
+ * #MESSAGEPORT_ERROR_MESSAGEPORT_NOT_FOUND The specified @a local_port_id cannot be found
+ * #MESSAGEPORT_ERROR_OUT_OF_MEMORY Out of memory
+ * #MESSAGEPORT_ERROR_IO_ERROR Internal I/O error
+ */
+EXPORT_API int
+messageport_unregister_trusted_local_port(int trusted_local_port_id);
+
+/**
* messageport_check_remote_port:
* @remote_app_id: The ID of the remote application
* @remote_port: the name of the remote message port to check for.
Description: Message port client library for WRT plugin
Version: @PACKAGE_VERSION@
URL: @PACKAGE_URL@
-Requires: glib-2.0 >= 2.30 gio-2.0 gio-unix-2.0 bundle dlog
+Requires: glib-2.0 >= 2.30 gio-2.0 gio-unix-2.0 bundle dlog capi-base-common
Libs: -L${libdir} -lmessage-port
Cflags: -I${includedir}
#include "msgport-manager.h"
#include "msgport-service.h"
#include "msgport-utils.h" /* msgport_daemon_error_to_error */
-#include "message-port.h" /* messageport_error_e */
#include "common/dbus-manager-glue.h"
#ifdef USE_SESSION_BUS
#include "common/dbus-server-glue.h"
}
messageport_error_e
-msgport_manager_unregister_servcie (MsgPortManager *manager, int service_id)
+msgport_manager_unregister_service (MsgPortManager *manager, int service_id)
{
const gchar *object_path = NULL;
MsgPortService *service = NULL;
MsgPortService *service = NULL;
g_return_val_if_fail (manager && MSGPORT_IS_MANAGER (manager), MESSAGEPORT_ERROR_IO_ERROR);
g_return_val_if_fail (manager->proxy, MESSAGEPORT_ERROR_IO_ERROR);
- g_return_val_if_fail (service_id && is_trusted_out, MESSAGEPORT_ERROR_INVALID_PARAMETER);
+ g_return_val_if_fail (service_id > 0 && is_trusted_out, MESSAGEPORT_ERROR_INVALID_PARAMETER);
service = _get_local_port (manager, service_id);
if (!service) return MESSAGEPORT_ERROR_MESSAGEPORT_NOT_FOUND;
BuildRequires: pkgconfig(glib-2.0) >= 2.30
BuildRequires: pkgconfig(gobject-2.0)
BuildRequires: pkgconfig(pkgmgr-info)
+BuildRequires: pkgconfig(capi-base-common)
%description
This daemon allows the webapplications to communicates using
%manifest %{name}.manifest
%defattr(-,root,root,-)
%doc AUTHORS COPYING.LIB
-%{_libdir}/lib%{name}.so*
+%{_libdir}/lib%{name}.so.*
#libmessage-port-devel
%files -n lib%{name}-devel
%defattr(-,root,root,-)
%manifest %{name}.manifest
%{_libdir}/pkgconfig/%{name}.pc
+%{_libdir}/lib%{name}.so
%{_includedir}/*.h
%if %{build_tests} == 1