tizen 2.4 release accepted/tizen_2.4_mobile tizen_2.4 accepted/tizen/2.4/mobile/20151029.030929 submit/tizen_2.4/20151028.065029 tizen_2.4_mobile_release
authorjk7744.park <jk7744.park@samsung.com>
Mon, 26 Oct 2015 07:01:44 +0000 (16:01 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Mon, 26 Oct 2015 07:01:44 +0000 (16:01 +0900)
34 files changed:
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
INSTALL [new file with mode: 0644]
Makefile.am [new file with mode: 0755]
NEWS [new file with mode: 0644]
NOTICE [new file with mode: 0755]
README [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0755]
doc/ui_eom_doc.h [new file with mode: 0644]
include/Makefile.am [new file with mode: 0755]
include/eom-connect.h [new file with mode: 0644]
include/eom.h [new file with mode: 0644]
include/eom.pc.in [new file with mode: 0644]
include/eom_internal.h [new file with mode: 0644]
packaging/libeom.manifest [new file with mode: 0644]
packaging/libeom.spec [new file with mode: 0644]
src/Makefile.am [new file with mode: 0755]
src/dbus/eom-connect.c [new file with mode: 0644]
src/dbus/eom-dbus.c [new file with mode: 0755]
src/dbus/eom-dbus.h [new file with mode: 0755]
src/eom-log.h [new file with mode: 0644]
src/eom-private.h [new file with mode: 0755]
src/eom.c [new file with mode: 0755]
src/wayland/eom-wayland.c [new file with mode: 0644]
src/wayland/eom-wayland.h [new file with mode: 0755]
src/wayland/protocol/eom-client-protocol.h [new file with mode: 0644]
src/wayland/protocol/eom-protocol.c [new file with mode: 0644]
src/wayland/protocol/eom.xml [new file with mode: 0644]
src/wayland/protocol/xdg-shell-client-protocol.h [new file with mode: 0644]
src/wayland/protocol/xdg-shell-protocol.c [new file with mode: 0644]
tests/Makefile.am [new file with mode: 0644]
tests/eom-test-output.c [new file with mode: 0755]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..817cb95
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,21 @@
+Copyright 2013 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/Makefile.am b/Makefile.am
new file mode 100755 (executable)
index 0000000..c7596e5
--- /dev/null
@@ -0,0 +1,28 @@
+# Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
+#
+# Contact:
+# SooChan Lim <sc1.lim@samsung.com>
+# Boram Park <boram1288.park@samsung.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+SUBDIRS = include src
+
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/NOTICE b/NOTICE
new file mode 100755 (executable)
index 0000000..dd669f8
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under MIT License.
+Please, see the LICENSE.MIT file for MIT License terms and conditions.
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..904cd67
--- /dev/null
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+
+autoreconf -v --install || exit 1
+cd $ORIGDIR || exit $?
+
+$srcdir/configure --enable-maintainer-mode "$@"
diff --git a/configure.ac b/configure.ac
new file mode 100755 (executable)
index 0000000..de40fd0
--- /dev/null
@@ -0,0 +1,143 @@
+# Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
+#
+# Contact:
+# SooChan Lim <sc1.lim@samsung.com>
+# Boram Park <boram1288.park@samsung.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+AC_PREREQ(2.60)
+AC_INIT(libeom, 1.0.0)
+AC_USE_SYSTEM_EXTENSIONS
+AC_CONFIG_SRCDIR([Makefile.am])
+AM_INIT_AUTOMAKE([dist-bzip2])
+
+AM_CONFIG_HEADER([config.h])
+AH_TOP([
+#ifndef __EOM_CONFIG_H__
+#define __EOM_CONFIG_H__
+])
+AH_BOTTOM([
+#endif /* __EOM_CONFIG_H__ */
+])
+
+AC_DISABLE_STATIC
+AC_PROG_LIBTOOL
+AC_PROG_CC
+
+AC_HEADER_STDC
+AC_SYS_LARGEFILE
+AC_FUNC_ALLOCA
+
+# Enable quiet compiles on automake 1.11.
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+# set the window system platform where the bufmgr initializes
+AC_ARG_WITH(eom-platform, AS_HELP_STRING([--with-eom-platform=WINSYS], [eom platform (default: X11)]),
+                               [ EOM_PLATFORM="$withval" ],
+                               [ EOM_PLATFORM="X11" ])
+AC_SUBST(EOM_PLATFORM)
+
+
+AC_ARG_WITH(tizen-version, AS_HELP_STRING([--with-tizen-version=T_VERSION], [eom platform (default: TIZEN_2_X)]),
+                               [ TIZEN_VERSION="$withval" ],
+                               [ TIZEN_VERSION="TIZEN_2_X" ])
+AC_SUBST(TIZEN_VERSION)
+
+
+
+# Checks for pkg-config packages
+PKG_CHECK_MODULES(DBUS, dbus-1)
+PKG_CHECK_MODULES(GLIB, glib-2.0 gobject-2.0)
+PKG_CHECK_MODULES(ELEMENTARY, elementary)
+
+LIBEOM_CFLAGS="$DBUS_CFLAGS $GLIB_CFLAGS $ELEMENTARY_CFLAGS"
+LIBEOM_LIBS="$DBUS_LIBS $GLIB_LIBS $ELEMENTARY_LIBS"
+
+if test "x$EOM_PLATFORM" = "xX11"; then
+    LIBEOM_CFLAGS="$LIBEOM_CFLAGS "
+    LIBEOM_LIBS="$LIBEOM_LIBS "
+fi
+
+if test "x$EOM_PLATFORM" = "xWAYLAND"; then
+    PKG_CHECK_MODULES(WAYLAND_CLIENT, wayland-client)
+    LIBEOM_CFLAGS="$LIBEOM_CFLAGS $WAYLAND_CLIENT_CFLAGS"
+    LIBEOM_LIBS="$LIBEOM_LIBS $WAYLAND_CLIENT_LIBS"
+
+    PKG_CHECK_MODULES(ECORE_WAYLAND, ecore-wayland)
+    LIBEOM_CFLAGS="$LIBEOM_CFLAGS $ECORE_WAYLAND_CFLAGS"
+    LIBEOM_LIBS="$LIBEOM_LIBS $ECORE_WAYLAND_LIBS"
+
+#      WAYLAND_PREFIX=`$PKG_CONFIG --variable=prefix wayland-client`
+#    AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner],,
+#                  [${WAYLAND_PREFIX}/bin$PATH_SEPARATOR$PATH])
+fi
+
+
+
+PKG_CHECK_MODULES(CAPI, [capi-base-common >= 0.1.1], [CAPI_VER="yes"], [CAPI_VER="no"])
+if test "x$CAPI_VER" = "xyes"; then
+    AC_DEFINE(HAVE_CAPI_0_1_1,1,[The version of capi-base-common is over 0.1.1])
+    LIBEOM_CFLAGS="$LIBEOM_CFLAGS $CAPI_CFLAGS"
+    LIBEOM_LIBS="$LIBEOM_LIBS $CAPI_LIBS"
+fi
+
+AC_CHECK_LIB(dlog, __dlog_print, [have_dlog="yes"], [have_dlog="no"])
+if test "x$have_dlog" = "xyes"; then
+       PKG_CHECK_MODULES(DLOG, dlog)
+       AC_DEFINE([HAVE_DLOG], 1, "Have dlog support")
+    LIBEOM_CFLAGS="$LIBEOM_CFLAGS $DLOG_CFLAGS"
+    LIBEOM_LIBS="$LIBEOM_LIBS $DLOG_LIBS"
+fi
+
+AC_SUBST([LIBEOM_CFLAGS])
+AC_SUBST([LIBEOM_LIBS])
+
+if test "x$EOM_PLATFORM" = "xX11"; then
+       AC_DEFINE(HAVE_X11,1,[The window system is X11.])
+else
+       AC_DEFINE(HAVE_WAYLAND,1,[The window system is WAYLAND.])
+fi
+
+AM_CONDITIONAL(HAVE_EOM_PLATFORM_X11, test "x$EOM_PLATFORM" = "xX11")
+AM_CONDITIONAL(HAVE_EOM_PLATFORM_WAYLAND, test "x$EOM_PLATFORM" = "xWAYLAND")
+
+if test "x$TIZEN_VERSION" = "xTIZEN_2_X"; then
+       AC_DEFINE(HAVE_TIZEN_2_X,1,[tizen version is 2.x.])
+fi
+
+AM_CONDITIONAL(HAVE_TIZEN_VERSION_2_X, test "x$TIZEN_VERSION" = "xTIZEN_2_X")
+
+
+
+# Checks for header files.
+AC_HEADER_STDC
+
+AC_OUTPUT([Makefile
+           src/Makefile
+           include/Makefile
+           include/eom.pc
+           tests/Makefile])
+
+echo "CFLAGS       : $CFLAGS"
+echo "LDFLAGS      : $LDFLAGS"
+echo "LIBEOM_CFLAGS: $LIBEOM_CFLAGS"
+echo "LIBEOM_LIBS  : $LIBEOM_LIBS"
diff --git a/doc/ui_eom_doc.h b/doc/ui_eom_doc.h
new file mode 100644 (file)
index 0000000..422f7f1
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef __UI_EOM_DOC_H__\r
+#define __UI_EOM_DOC_H__\r
+\r
+/**************************************************************************\r
+\r
+External Output Manager (EOM)\r
+\r
+Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.\r
+\r
+Contact:\r
+SooChan Lim <sc1.lim@samsung.com>\r
+Boram Park <boram1288.park@samsung.com>\r
+Changyeon Lee <cyeon.lee@samsung.com>\r
+JunKyeong Kim <jk0430.kim@samsung.com>\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a\r
+copy of this software and associated documentation files (the\r
+"Software"), to deal in the Software without restriction, including\r
+without limitation the rights to use, copy, modify, merge, publish,\r
+distribute, sub license, and/or sell copies of the Software, and to\r
+permit persons to whom the Software is furnished to do so, subject to\r
+the following conditions:\r
+\r
+The above copyright notice and this permission notice (including the\r
+next paragraph) shall be included in all copies or substantial portions\r
+of the Software.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.\r
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR\r
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\r
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\r
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+\r
+**************************************************************************/\r
+\r
+/**\r
+ * @ingroup CAPI_UI_FRAMEWORK\r
+ * @defgroup CAPI_UI_EOM_MODULE External Output Manager\r
+ * @brief The External Output Manager provides APIs for external outputs.\r
+ *\r
+ * @section CAPI_UI_EOM_MODULE_HEADER Required Header\r
+ *   #include <eom.h>\r
+ *\r
+ * @section CAPI_UI_EOM_MODULE_OVERVIEW Overview\r
+ * The External Output Manager (EOM) is for managing external outputs.\n\r
+ * User can get the information of external outputs and control them via\r
+ * eom API.\n\n\r
+ *\r
+ * Features :\n\r
+ *  - Get information.(output ID, type, resolution, physical size etc)\n\r
+ *  - Receive state changing informagtion by callback function. (add, remove, mode change, attribute change)\n\r
+ *  - Use external output device.(set attribute, set external window)\n\r
+ */\r
+ *\r
+ */\r
+\r
+#endif /* __UI_EOM_DOC_H__ */\r
diff --git a/include/Makefile.am b/include/Makefile.am
new file mode 100755 (executable)
index 0000000..d1a7d86
--- /dev/null
@@ -0,0 +1,34 @@
+# Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
+#
+# Contact:
+# SooChan Lim <sc1.lim@samsung.com>
+# Boram Park <boram1288.park@samsung.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+libeomincludedir = $(includedir)/eom
+libeominclude_HEADERS = \
+       eom.h \
+       eom_internal.h \
+       eom-connect.h
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = eom.pc
diff --git a/include/eom-connect.h b/include/eom-connect.h
new file mode 100644 (file)
index 0000000..c5b18f4
--- /dev/null
@@ -0,0 +1,75 @@
+/**************************************************************************
+
+eom (external output manager)
+
+Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+SooChan Lim <sc1.lim@samsung.com>
+Boram Park <boram1288.park@samsung.com>
+Changyeon Lee <cyeon.lee@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __EOM_CONNECT_H__
+#define __EOM_CONNECT_H__
+
+/**
+ * @ingroup
+ * @addtogroup CAPI_UI_EOM_MODULE
+ * @{
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <eom.h>
+
+/**
+ * @file eom-connect.h
+ */
+
+/**
+ * @brief Set mode to external output.
+ * @param[in] output : The pointer of external output instance
+ * @param[in] output_id : eom output id
+ * @return #EOM_ERROR_NONE if this function succeeds, otherwise error status value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #EOM_ERROR_SEND_MESSAGE_FAILE Message sending failure
+ * @retval #EOM_ERROR_OPERATE_MESSAGE_FAILE Message operation failure
+ * see #eom_output_mode_e
+ */
+int eom_output_set_mode(eom_output_id output_id, eom_output_mode_e mode);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+* @}
+*/
+
+#endif /* __EOM_CONNECT_H__ */
diff --git a/include/eom.h b/include/eom.h
new file mode 100644 (file)
index 0000000..98f467c
--- /dev/null
@@ -0,0 +1,500 @@
+/**************************************************************************
+
+External Output Manager (EOM)
+
+Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+SooChan Lim <sc1.lim@samsung.com>
+Boram Park <boram1288.park@samsung.com>
+Changyeon Lee <cyeon.lee@samsung.com>
+JunKyeong Kim <jk0430.kim@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __EOM_H__
+#define __EOM_H__
+
+/**
+ * @addtogroup CAPI_UI_EOM_MODULE
+ * @{
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include <stdbool.h>
+#include <string.h>
+#include <tizen.h>
+#include <Elementary.h>
+
+/**
+ * @file eom.h
+ */
+#ifndef TIZEN_ERROR_EOM
+#define TIZEN_ERROR_EOM                        -0x02F20000 | 0x00
+#endif
+/**
+ * @brief Enumeration of External Output Manager (EOM) error type
+ * @since_tizen 2.4
+ */
+typedef enum {
+       EOM_ERROR_NONE = TIZEN_ERROR_NONE,                            /**< Success */
+       EOM_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,          /**< Memory allocation failure */
+       EOM_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,  /**< Invalid input parameter */
+       EOM_ERROR_NO_SUCH_DEVICE = TIZEN_ERROR_NO_SUCH_DEVICE,        /**< Invalid external output instance */
+       EOM_ERROR_CONNECTION_FAILURE = TIZEN_ERROR_EOM | 0x01,        /**< Connection failure */
+       EOM_ERROR_MESSAGE_SENDING_FAILURE = TIZEN_ERROR_EOM | 0x02,   /**< Message sending failure */
+       EOM_ERROR_MESSAGE_OPERATION_FAILURE = TIZEN_ERROR_EOM | 0x03, /**< Message operation failure */
+} eom_error_e;
+
+/**
+ * @brief Enumeration of external output type
+ * @since_tizen 2.4
+ */
+typedef enum {
+       EOM_OUTPUT_TYPE_UNKNOWN,      /**< Unknown output type */
+       EOM_OUTPUT_TYPE_VGA,          /**< VGA output */
+       EOM_OUTPUT_TYPE_DVII,         /**< DVII output type */
+       EOM_OUTPUT_TYPE_DVID,         /**< DVID output type */
+       EOM_OUTPUT_TYPE_DVIA,         /**< DVIA output type */
+       EOM_OUTPUT_TYPE_COMPOSITE,    /**< Composite output type */
+       EOM_OUTPUT_TYPE_SVIDEO,       /**< SVIDEO output type */
+       EOM_OUTPUT_TYPE_LVDS,         /**< LVDS output type */
+       EOM_OUTPUT_TYPE_COMPONENT,    /**< Component output type */
+       EOM_OUTPUT_TYPE_9PINDIN,      /**< 9PinDIN output type */
+       EOM_OUTPUT_TYPE_DISPLAYPORT,  /**< DisplayPort output type */
+       EOM_OUTPUT_TYPE_HDMIA,        /**< HDMIA output type */
+       EOM_OUTPUT_TYPE_HDMIB,        /**< HDMIB output type */
+       EOM_OUTPUT_TYPE_TV,           /**< TV output type */
+       EOM_OUTPUT_TYPE_EDP,          /**< EDP output type */
+       EOM_OUTPUT_TYPE_VIRTUAL,      /**< VIRTUAL output type */
+       EOM_OUTPUT_TYPE_DSI,          /**< DSI output type */
+       EOM_OUTPUT_TYPE_MAX,
+} eom_output_type_e;
+
+/**
+ * @brief Enumeration of external output mode
+ * @since_tizen 2.4
+ */
+typedef enum {
+       EOM_OUTPUT_MODE_NONE,          /**< None */
+       EOM_OUTPUT_MODE_MIRROR,        /**< Mirror mode */
+       EOM_OUTPUT_MODE_PRESENTATION,  /**< Presentation mode */
+       EOM_OUTPUT_MODE_MAX,
+} eom_output_mode_e;
+
+/**
+ * @brief Enumeration of External Output Manager (EOM) attributes
+ * @since_tizen 2.4
+ */
+typedef enum {
+       EOM_OUTPUT_ATTRIBUTE_NONE,             /**< None */
+       EOM_OUTPUT_ATTRIBUTE_NORMAL,           /**< Normal presentation mode window showing on external output */
+       EOM_OUTPUT_ATTRIBUTE_EXCLUSIVE_SHARE,  /**< Exclusive share presentation mode window showing on external output */
+       EOM_OUTPUT_ATTRIBUTE_EXCLUSIVE,        /**< Exclusive presentation mode window showing on external output */
+       EOM_OUTPUT_ATTRIBUTE_MAX,
+} eom_output_attribute_e;
+
+/**
+ * @brief Enumeration of External Output Manager (EOM) attribute state
+ * @since_tizen 2.4
+ */
+typedef enum {
+       EOM_OUTPUT_ATTRIBUTE_STATE_NONE,      /**< None */
+       EOM_OUTPUT_ATTRIBUTE_STATE_ACTIVE,    /**< Output attribute is active */
+       EOM_OUTPUT_ATTRIBUTE_STATE_INACTIVE,  /**< Output attribute is inactive */
+       EOM_OUTPUT_ATTRIBUTE_STATE_LOST,      /**< Cannot use external output */
+       EOM_OUTPUT_ATTRIBUTE_STATE_MAX,
+} eom_output_attribute_state_e;
+
+/**
+ * @brief Definition for external output ID
+ * @since_tizen 2.4
+ */
+typedef unsigned int eom_output_id;
+
+/**
+ * @brief Called when External Output Manager (EOM) module sends output connection notification.
+ * @since_tizen 2.4
+ * @param[in] output_id  The output id which is connected output
+ * @param[in] user_data  The pointer of user data which is passed to eom_output_added_cb function
+ * @see eom_set_output_added_cb()
+ * @see eom_unset_output_added_cb()
+ */
+typedef void (*eom_output_added_cb)(eom_output_id output_id, void *user_data);
+
+/**
+ * @brief Called when External Output Manager (EOM) module sends output disconnection notification.
+ * @since_tizen 2.4
+ * @param[in] output_id  The output id which is connected output
+ * @param[in] user_data  The pointer of user data which is passed to eom_output_removed_cb function
+ * @see eom_set_output_removed_cb()
+ * @see eom_unset_output_removed_cb()
+ */
+typedef void (*eom_output_removed_cb)(eom_output_id output_id, void *user_data);
+
+/**
+ * @brief Called when External Output Manager (EOM) module sends output mode changing notification.
+ * @since_tizen 2.4
+ * @param[in] output_id  The output id which is connected output
+ * @param[in] user_data  The pointer of user data which is passed to eom_mode_changed_cb function
+ * @see eom_set_mode_changed_cb()
+ * @see eom_unset_mode_changed_cb()
+ */
+typedef void (*eom_mode_changed_cb)(eom_output_id output_id, void *user_data);
+
+/**
+ * @brief Called when External Output Manager (EOM) module sends output attribute changing notification.
+ * @since_tizen 2.4
+ * @param[in] output_id  The output id which is connected output
+ * @param[in] user_data  The pointer of user data which is passed to eom_attribute_changed_cb function
+ * @see eom_set_attribute_changed_cb()
+ * @see eom_unset_attribute_changed_cb()
+ */
+typedef void (*eom_attribute_changed_cb)(eom_output_id output_id, void *user_data);
+
+/**
+ * @brief Initializes External Output Manager (EOM).
+ * @details User should call this function previously for using EOM.
+ * @since_tizen 2.4
+ * @remarks After all using, call eom_deinit() function for resource returning.
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_CONNECTION_FAILURE The EOM connection failure
+ * @see eom_deinit()
+ * @see #eom_error_e
+ */
+int eom_init(void);
+
+/**
+ * @brief Finalizes External Output Manager (EOM).
+ * @details User should call this function after using EOM to release all resources of EOM.
+ * @since_tizen 2.4
+ * @see eom_init()
+ */
+void eom_deinit(void);
+
+/**
+ * @brief Registers a callback function to get output connection notification from External Output Manager (EOM) module.
+ * @since_tizen 2.4
+ * @param[in] callback  The function pointer of eom_output_added_cb callback function
+ * @param[in] user_data  The pointer of user data which is passed to eom_output_added_cb function
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_OUT_OF_MEMORY Memory allocation failure
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see eom_unset_output_added_cb()
+ * @see #eom_output_added_cb
+ */
+int eom_set_output_added_cb(eom_output_added_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.4
+ * @param[in] callback  The function pointer of eom_output_added_cb callback function
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see eom_set_output_added_cb()
+ * @see #eom_output_added_cb
+ */
+int eom_unset_output_added_cb(eom_output_added_cb callback);
+
+/**
+ * @brief Registers a callback function to get output disconnection notification from External Output Manager (EOM) module.
+ * @since_tizen 2.4
+ * @param[in] callback  The function pointer of eom_output_removed_cb callback function
+ * @param[in] user_data  The pointer of user data which is passed to eom_output_removed_cb function
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_OUT_OF_MEMORY Memory allocation failure
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see eom_unset_output_removed_cb()
+ * @see #eom_output_removed_cb
+ */
+int eom_set_output_removed_cb(eom_output_removed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.4
+ * @param[in] callback  The function pointer of eom_output_removed_cb callback function
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see eom_set_output_removed_cb()
+ * @see #eom_output_removed_cb
+ */
+int eom_unset_output_removed_cb(eom_output_removed_cb callback);
+
+/**
+ * @brief Registers a callback function to get output mode changing notification from External Output Manager (EOM) module.
+ * @since_tizen 2.4
+ * @param[in] callback  The function pointer of eom_mode_changed_cb callback function
+ * @param[in] user_data  The pointer of user data which is passed to eom_mode_changed_cb function
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_OUT_OF_MEMORY Memory allocation failure
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see eom_unset_mode_changed_cb()
+ * @see #eom_mode_changed_cb
+ */
+int eom_set_mode_changed_cb(eom_mode_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.4
+ * @param[in] callback  The function pointer of eom_mode_changed_cb callback function
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see eom_set_mode_changed_cb()
+ * @see #eom_mode_changed_cb
+ */
+int eom_unset_mode_changed_cb(eom_mode_changed_cb callback);
+
+/**
+ * @brief Registers a callback function to get output attribute changing notification from External Output Manager (EOM) module.
+ * @since_tizen 2.4
+ * @param[in] callback  The function pointer of eom_attribute_changed_cb callback function
+ * @param[in] user_data  The pointer of user data which is passed to eom_attribute_changed_cb function
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_OUT_OF_MEMORY Memory allocation failure
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see eom_unset_attribute_changed_cb()
+ * @see #eom_attribute_changed_cb
+ */
+int eom_set_attribute_changed_cb(eom_attribute_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.4
+ * @param[in] callback  The function pointer of eom_attribute_changed_cb callback function
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see eom_set_attribute_changed_cb()
+ * @see #eom_attribute_changed_cb
+ */
+int eom_unset_attribute_changed_cb(eom_attribute_changed_cb callback);
+
+/**
+ * @brief Gets the IDs and count of external output.
+ * @details This function returns the IDs of external output which are available to connect
+ * to target device, and the count of them also. User can get the id of external output
+ * which user want to watch.
+ * @since_tizen 2.4
+ * @remarks User should free return value by using free().\n
+ * The specific error code can be obtained using the get_last_result() method.
+ * Error codes are described in Exception section.
+ * @param[out] count  The count of the eom_output_id supported by system
+ * @return The array of the eom_output_id if this function succeeds, otherwise NULL
+ * @retval The pointer of #eom_output_id
+ * @exception #EOM_ERROR_NONE Successful
+ * @exception #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #EOM_ERROR_OUT_OF_MEMORY Memory allocation failure
+ * @pre eom_init()
+ * @see #eom_output_id
+ * @see #eom_error_e
+ */
+eom_output_id *eom_get_eom_output_ids(int *count);
+
+/**
+ * @brief Gets type of external output.
+ * @since_tizen 2.4
+ * @remarks The specific error code can be obtained using the get_last_result()
+ * method. Error codes are described in Exception section.
+ * @param[in] output_id  The id of external output device
+ * @param[out] type  The type of external output instance
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see #eom_output_id
+ * @see #eom_error_e
+ * @see #eom_output_type_e
+ */
+int eom_get_output_type(eom_output_id output_id, eom_output_type_e *type);
+
+/**
+ * @brief Gets mode of external output.
+ * @since_tizen 2.4
+ * @remarks The specific error code can be obtained using the get_last_result()
+ * method. Error codes are described in Exception section.
+ * @param[in] output_id  The id of external output device
+ * @param[out] mode  The mode of external output instance
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #EOM_ERROR_NO_SUCH_DEVICE Invalid external output instance
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see #eom_output_id
+ * @see #eom_error_e
+ * @see #eom_output_mode_e
+ */
+int eom_get_output_mode(eom_output_id output_id, eom_output_mode_e *mode);
+
+/**
+ * @brief Gets attribute of external output.
+ * @since_tizen 2.4
+ * @remarks The specific error code can be obtained using the get_last_result()
+ * method. Error codes are described in Exception section.
+ * @param[in] output_id  The id of external output device
+ * @param[out] attribute  The attribute of external output instance
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #EOM_ERROR_NO_SUCH_DEVICE Invalid external output instance
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see #eom_output_id
+ * @see #eom_error_e
+ * @see #eom_output_attribute_e
+ */
+int eom_get_output_attribute(eom_output_id output_id, eom_output_attribute_e *attribute);
+
+/**
+ * @brief Gets attribute state of external output.
+ * @since_tizen 2.4
+ * @remarks The specific error code can be obtained using the get_last_result()
+ * method. Error codes are described in Exception section.
+ * @param[in] output_id  The id of external output device
+ * @param[out] state  The attribute state of external output instance
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #EOM_ERROR_NO_SUCH_DEVICE Invalid external output instance
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see #eom_output_id
+ * @see #eom_error_e
+ * @see #eom_output_attribute_state_e
+ */
+int eom_get_output_attribute_state(eom_output_id output_id, eom_output_attribute_state_e *state);
+
+/**
+ * @brief Gets resolution of external output.
+ * @since_tizen 2.4
+ * @param[in] output_id  The id of external output device
+ * @param[out] width  The width of external output instance
+ * @param[out] height  The height of external output instance
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #EOM_ERROR_NO_SUCH_DEVICE Invalid external output instance
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see #eom_output_id
+ * @see #eom_error_e
+ */
+int eom_get_output_resolution(eom_output_id output_id, int *width, int *height);
+
+/**
+ * @brief Gets physical width/height (millimeters) of external output.
+ * @since_tizen 2.4
+ * @param[in] output_id  The id of external output device
+ * @param[out] phy_width  The physical mm width of external output instance
+ * @param[out] phy_height  The physical mm height of external output instance
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #EOM_ERROR_NO_SUCH_DEVICE Invalid external output instance
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see #eom_output_id
+ * @see #eom_error_e
+ */
+int eom_get_output_physical_size(eom_output_id output_id, int *phy_width, int *phy_height);
+
+/**
+ * @brief Sets the attribute of the external output ID.
+ * @details The application can set the External Output Manager (EOM) attribute to the external output ID.
+ * The EOM module manages the windows to display on external output and
+ * control the policy of external output. The application can recognize
+ * the attribute state and manage the resources when the application receives
+ * several notification callback from EOM module.
+ * @since_tizen 2.4
+ * @param[in] output_id  The id of external output device
+ * @param[in] attr  The attribute of the external output
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #EOM_ERROR_NO_SUCH_DEVICE Invalid external output instance
+ * @retval #EOM_ERROR_MESSAGE_SENDING_FAILURE Communication failure with EOM module
+ * @retval #EOM_ERROR_MESSAGE_OPERATION_FAILURE Operation failure
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see #eom_output_id
+ * @see #eom_error_e
+ */
+int eom_set_output_attribute(eom_output_id output_id, eom_output_attribute_e attr);
+
+/**
+ * @brief Sets window to the external output best resolution of external output device.
+ * @since_tizen 2.4
+ * @param[in] output_id  The id of external output device
+ * @param[in] win  The pointer of evas object
+ * @return 0 on success, otherwise a negative error value
+ * @retval #EOM_ERROR_NONE Successful
+ * @retval #EOM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #EOM_ERROR_NO_SUCH_DEVICE Invalid external output instance
+ * @retval #EOM_ERROR_MESSAGE_SENDING_FAILURE Communication failure with EOM module
+ * @retval #EOM_ERROR_MESSAGE_OPERATION_FAILURE Operation failure
+ * @pre eom_init()
+ * @pre eom_get_eom_output_ids()
+ * @see #eom_output_id
+ * @see #eom_error_e
+ */
+int eom_set_output_window(eom_output_id output_id, Evas_Object *win);
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+* @}
+*/
+
+#endif /* __EOM_H__ */
diff --git a/include/eom.pc.in b/include/eom.pc.in
new file mode 100644 (file)
index 0000000..b795246
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: eom
+Description: The External Output Manager debug Library
+Version: @PACKAGE_VERSION@
+Requires.private: dbus-1 gio-unix-2.0
+Requires: capi-base-common
+Cflags: -I${includedir}/eom
+Libs: -L${libdir} -leom
diff --git a/include/eom_internal.h b/include/eom_internal.h
new file mode 100644 (file)
index 0000000..df834cc
--- /dev/null
@@ -0,0 +1,51 @@
+/**************************************************************************
+
+eom (external output manager)
+
+Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+SooChan Lim <sc1.lim@samsung.com>
+Boram Park <boram1288.park@samsung.com>
+Changyeon Lee <cyeon.lee@samsung.com>
+JunKyeong Kim <jk0430.kim@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __EOM_INTERNAL_H__
+#define __EOM_INTERNAL_H__
+
+/**
+ * @brief Enumeration of eom notify type
+ * @since_tizen 2.4
+ */
+typedef enum {
+       EOM_OUTPUT_NOTIFY_NONE,               /**< None notify */
+       EOM_OUTPUT_NOTIFY_ADD,                /**< Output add notify */
+       EOM_OUTPUT_NOTIFY_REMOVE,             /**< Output remove notify */
+       EOM_OUTPUT_NOTIFY_MODE_CHANGED,       /**< Mode change notify */
+       EOM_OUTPUT_NOTIFY_ATTRIBUTE_CHANGED,  /**< Attribute change notify */
+       EOM_OUTPUT_NOTIFY_MAX,
+} eom_output_notify_type_e;
+
+#endif /* __EOM_INTERNAL_H__ */
diff --git a/packaging/libeom.manifest b/packaging/libeom.manifest
new file mode 100644 (file)
index 0000000..017d22d
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+    <domain name="_"/>
+ </request>
+</manifest>
diff --git a/packaging/libeom.spec b/packaging/libeom.spec
new file mode 100644 (file)
index 0000000..7e9e908
--- /dev/null
@@ -0,0 +1,75 @@
+%bcond_with x
+%bcond_with wayland
+
+Name: libeom
+Summary: External Output Manager Library
+Version: 1.0.2
+Release: 1
+Group: Graphics/X Window System
+License: MIT
+Source0: %{name}-%{version}.tar.gz
+Source1001:    libeom.manifest
+
+%if %{with wayland}
+BuildRequires:  pkgconfig(wayland-client)
+BuildRequires:  pkgconfig(ecore-wayland)
+%else
+%endif
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(dbus-1)
+BuildRequires:  pkgconfig(gio-unix-2.0)
+BuildRequires:  pkgconfig(capi-base-common)
+BuildRequires:  pkgconfig(elementary)
+
+%description
+This package provides the runtime library to manage eo(External Output)
+
+%package devel
+Summary: External Output Manager Library development package
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+Requires: pkgconfig(capi-base-common)
+
+%description devel
+External Output Manager Library development package
+
+%prep
+%setup -q
+cp %{SOURCE1001} .
+
+%build
+export CFLAGS="-g -O0 -Wall -Werror -Wno-error=deprecated-declarations"
+export LDFLAGS="$LDFLAGS -Wl,--hash-style=both -Wl,--as-needed"
+%if %{with wayland}
+%reconfigure --disable-dlog --disable-static --with-eom-platform=WAYLAND
+%else
+%if 0%{?tizen_version_major} == 2
+%reconfigure --disable-dlog --disable-static --with-eom-platform=X11 --with-tizen-version=TIZEN_2_X
+%else
+%reconfigure --disable-dlog --disable-static --with-eom-platform=X11 --with-tizen-version=TIZEN_3_X
+%endif
+%endif
+
+make %{?_smp_mflags}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp -af COPYING %{buildroot}/usr/share/license/%{name}
+%make_install
+
+%remove_docs
+
+%files
+%manifest %{name}.manifest
+%defattr(-,root,root,-)
+/usr/share/license/%{name}
+%{_libdir}/libeom.so.*
+
+%files devel
+%manifest %{name}.manifest
+%dir %{_includedir}/eom/
+%{_includedir}/eom/*.h
+%{_libdir}/libeom.so
+%{_libdir}/pkgconfig/eom.pc
+
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100755 (executable)
index 0000000..beada14
--- /dev/null
@@ -0,0 +1,60 @@
+# Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
+#
+# Contact:
+# SooChan Lim <sc1.lim@samsung.com>
+# Boram Park <boram1288.park@samsung.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+libeom_la_LTLIBRARIES = libeom.la
+libeom_ladir = $(libdir)
+libeom_la_LIBADD = @LIBEOM_LIBS@
+libeom_la_LDFLAGS = ${LDFLAGS}
+libeom_la_CFLAGS = \
+    ${CFLAGS} \
+    @LIBEOM_CFLAGS@ \
+    -I$(top_srcdir)/include \
+    -I$(top_srcdir)/src
+
+libeom_la_SOURCES = \
+       eom.c
+
+if HAVE_EOM_PLATFORM_X11
+libeom_la_CFLAGS += \
+       -I$(top_srcdir)/src/dbus
+
+libeom_la_SOURCES += \
+       dbus/eom-dbus.c
+endif
+
+if HAVE_EOM_PLATFORM_WAYLAND
+libeom_la_CFLAGS += \
+       -I$(top_srcdir)/src/wayland \
+       -I$(top_srcdir)/src/wayland/protocol
+
+libeom_la_SOURCES += \
+       wayland/protocol/xdg-shell-protocol.c \
+       wayland/protocol/eom-protocol.c \
+       wayland/eom-wayland.c
+endif
+
+
+
diff --git a/src/dbus/eom-connect.c b/src/dbus/eom-connect.c
new file mode 100644 (file)
index 0000000..d7f7041
--- /dev/null
@@ -0,0 +1,220 @@
+/**************************************************************************
+
+eom (external output manager)
+
+Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+SooChan Lim <sc1.lim@samsung.com>
+Boram Park <boram1288.park@samsung.com>
+Changyeon Lee <cyeon.lee@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <config.h>
+
+#include "eom.h"
+#include "eom-log.h"
+#include "eom-dbus.h"
+#include "eom-connect.h"
+#include "eom-private.h"
+
+API int
+eom_output_set_mode(eom_output_id output_id, eom_output_mode_e mode)
+{
+       bool ret = false;
+       GValueArray *msg_array;
+       GValueArray *ret_array;
+       GValue v = G_VALUE_INIT;
+
+       RETV_IF_FAIL(mode < EOM_OUTPUT_MODE_MAX, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       INFO("mode: %d\n", mode);
+
+       msg_array = g_value_array_new(0);
+
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, output_id);
+       msg_array = g_value_array_append(msg_array, &v);
+       g_value_set_int(&v, mode);
+       msg_array = g_value_array_append(msg_array, &v);
+
+       ret_array = eom_dbus_client_send_message("SetMode", msg_array);
+       g_value_array_free(msg_array);
+       if (!ret_array) {
+               _eom_mutex_unlock();
+               return EOM_ERROR_MESSAGE_SENDING_FAILURE;
+       }
+
+       ret = g_value_get_int(g_value_array_get_nth(ret_array, 0));
+
+       g_value_array_free(ret_array);
+
+       INFO("SetMode: %s", (ret) ? "success" : "failed");
+
+       _eom_mutex_unlock();
+
+       return (ret) ? EOM_ERROR_NONE : EOM_ERROR_MESSAGE_OPERATION_FAILURE;
+}
+
+static int
+_eom_dbus_convert_gvalue_to_message_temp(GArray *array, DBusMessage *msg)
+{
+       DBusMessageIter iter;
+       GValue *v = NULL;
+       GType type;
+       int i;
+
+       if (!array)
+               return 1;
+
+       if (array->len <= 0)
+               return 1;
+
+       dbus_message_iter_init_append(msg, &iter);
+
+       INFO("[EOM_CLIENT:%s] len(%d)", client_info.name, array->len);
+
+       for (i = 0; i < array->len; i++) {
+               v = &g_array_index(array, GValue, i);
+               type = v->g_type;
+
+               INFO("[EOM_CLIENT:%s] type(%d)", client_info.name, (int)type);
+
+               switch (type) {
+               case G_TYPE_INT:
+                       {
+                               int integer = g_value_get_int(v);
+
+                               if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &integer)) {
+                                       ERR("[EOM_CLIENT:%s] failed: int append", client_info.name);
+                                       return 0;
+                               }
+                       }
+                       break;
+               case G_TYPE_UINT:
+                       {
+                               unsigned int uinteger = g_value_get_uint(v);
+
+                               if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &uinteger)) {
+                                       ERR("[EOM_CLIENT:%s] failed: uint append", client_info.name);
+                                       return 0;
+                               }
+                       }
+                       break;
+               case G_TYPE_STRING:
+                       {
+                               char *string = (char *)g_value_get_string(v);
+
+                               if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, (void *)&string)) {
+                                       ERR("[EOM_CLIENT:%s] failed: uint append", client_info.name);
+                                       return 0;
+                               }
+                       }
+                       break;
+               case G_TYPE_VARIANT:
+                       {
+                               GVariant *variant = g_value_get_variant(v);
+                               int data_size = g_variant_get_size(variant);
+                               void *data = (void *)g_variant_get_data(variant);
+                               DBusMessageIter sub;
+
+                               RETV_IF_FAIL(data != NULL, 0);
+                               RETV_IF_FAIL(data_size > 0, 0);
+
+                               dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "y", &sub);
+                               if (!dbus_message_iter_append_fixed_array(&sub, DBUS_TYPE_BYTE, (void *)&data, data_size)) {
+                                       ERR("[EOM_CLIENT:%s] failed: uint append", client_info.name);
+                                       return 0;
+                               }
+                               dbus_message_iter_close_container(&iter, &sub);
+                       }
+                       break;
+               default:
+                       return 0;
+               }
+       }
+
+       return 1;
+}
+
+static GArray*
+_eom_dbus_convert_message_to_gvalue_temp(DBusMessage *msg)
+{
+       GArray *array;
+       DBusMessageIter iter;
+
+       if (!dbus_message_iter_init(msg, &iter))
+               return NULL;
+
+       array = g_array_new(FALSE, FALSE, sizeof(GValue));
+
+       do {
+               int type = dbus_message_iter_get_arg_type(&iter);
+               GValue v = G_VALUE_INIT;
+
+               INFO("[EOM_CLIENT:%s] type(%c(%d))", client_info.name, (char)type, type);
+
+               switch (type) {
+               case DBUS_TYPE_INT32:
+                       {
+                               int integer = 0;
+                               dbus_message_iter_get_basic(&iter, &integer);
+                               g_value_init(&v, G_TYPE_INT);
+                               g_value_set_int(&v, integer);
+                               array = g_array_append_val(array, v);
+                               g_value_unset(&v);
+                       }
+                       break;
+               case DBUS_TYPE_UINT32:
+                       {
+                               unsigned int uinteger = 0;
+                               dbus_message_iter_get_basic(&iter, &uinteger);
+                               g_value_init(&v, G_TYPE_UINT);
+                               g_value_set_uint(&v, uinteger);
+                               array = g_array_append_val(array, v);
+                               g_value_unset(&v);
+                       }
+                       break;
+               case DBUS_TYPE_STRING:
+                       {
+                               char *string = NULL;
+                               dbus_message_iter_get_basic(&iter, &string);
+                               g_value_init(&v, G_TYPE_STRING);
+                               g_value_set_string(&v, string);
+                               array = g_array_append_val(array, v);
+                               g_value_unset(&v);
+                       }
+                       break;
+               default:
+                       NEVER_GET_HERE();
+                       g_array_free(array, FALSE);
+                       return NULL;
+               }
+       } while (dbus_message_iter_has_next(&iter) && dbus_message_iter_next(&iter));
+
+       return array;
+}
+
diff --git a/src/dbus/eom-dbus.c b/src/dbus/eom-dbus.c
new file mode 100755 (executable)
index 0000000..9967cf4
--- /dev/null
@@ -0,0 +1,635 @@
+/**************************************************************************
+
+eom (external output manager)
+
+Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+SooChan Lim <sc1.lim@samsung.com>
+Boram Park <boram1288.park@samsung.com>
+Changyeon Lee <cyeon.lee@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <config.h>
+#include <dbus/dbus.h>
+#include <string.h>
+#include "eom.h"
+#include "eom-log.h"
+#include "eom-dbus.h"
+#include "eom-private.h"
+
+#define EOM_DBUS_SERVER     "org.eom.server"
+#define EOM_DBUS_CLIENT     "org.eom.client"
+#define EOM_DBUS_INTERFACE  "org.eom.interface"
+#define EOM_DBUS_PATH       "/org/eom/path"
+
+#define STR_LEN 128
+
+#define REPLY_TIME  1000
+#define ARGV_NUM    64
+
+typedef struct _EomDBusClientMethod {
+       char name[STR_LEN];
+       notify_func func;
+       void *data;
+       struct _EomDBusClientMethod *next;
+} EomDBusClientMethod;
+
+typedef struct _EomDBusClientInfo {
+       DBusConnection *conn;
+       char name[STR_LEN];
+       char rule[STR_LEN];
+       GSource *src;
+       EomDBusClientMethod *methods;
+       int fd;
+} EomDBusClientInfo;
+
+static EomDBusClientInfo client_info;
+
+static bool dbus_initialized;
+static EomDBusClientMethod dbus_method;
+
+static void _eom_dbus_client_deinitialize(EomDBusClientInfo *info);
+
+static int
+_eom_dbus_need_private_conn(void)
+{
+       char *env = getenv("EOM_PRIVATE_CONN");
+
+       if (env) {
+               return (atoi(env) > 0) ? 1 : 0;
+               INFO("EOM_PRIVATE_CONN = %s", env);
+       }
+
+       return 0;
+}
+
+static int
+_eom_dbus_convert_gvalue_to_message(GArray *array, DBusMessage *msg)
+{
+       DBusMessageIter iter;
+       GValue *v = NULL;
+       GType type;
+       int i;
+
+       if (!array)
+               return 1;
+
+       if (array->len <= 0)
+               return 1;
+
+       dbus_message_iter_init_append(msg, &iter);
+
+       INFO("[EOM_CLIENT:%s] len(%d)", client_info.name, array->len);
+
+       for (i = 0; i < array->len; i++) {
+               v = &g_array_index(array, GValue, i);
+               type = v->g_type;
+
+               INFO("[EOM_CLIENT:%s] type(%d)", client_info.name, (int)type);
+
+               switch (type) {
+               case G_TYPE_INT:
+                       {
+                               int integer = g_value_get_int(v);
+
+                               if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &integer)) {
+                                       ERR("[EOM_CLIENT:%s] failed: int append", client_info.name);
+                                       return 0;
+                               }
+                       }
+                       break;
+               default:
+                       return 0;
+               }
+       }
+
+       return 1;
+}
+
+static GArray*
+_eom_dbus_convert_message_to_gvalue(DBusMessage *msg)
+{
+       GArray *array;
+       DBusMessageIter iter;
+
+       if (!dbus_message_iter_init(msg, &iter))
+               return NULL;
+
+       array = g_array_new(FALSE, FALSE, sizeof(GValue));
+
+       do {
+               int type = dbus_message_iter_get_arg_type(&iter);
+               GValue v = G_VALUE_INIT;
+
+               INFO("[EOM_CLIENT:%s] type(%c(%d))", client_info.name, (char)type, type);
+
+               switch (type) {
+               case DBUS_TYPE_INT32:
+                       {
+                               int integer = 0;
+                               dbus_message_iter_get_basic(&iter, &integer);
+                               g_value_init(&v, G_TYPE_INT);
+                               g_value_set_int(&v, integer);
+                               array = g_array_append_val(array, v);
+                               g_value_unset(&v);
+                       }
+                       break;
+               default:
+                       NEVER_GET_HERE();
+                       g_array_free(array, FALSE);
+                       return NULL;
+               }
+       } while (dbus_message_iter_has_next(&iter) && dbus_message_iter_next(&iter));
+
+       return array;
+}
+
+static void
+_eom_dbus_client_process_message(EomDBusClientInfo *info, DBusMessage *msg)
+{
+       EomDBusClientMethod **prev;
+       DBusError err;
+
+       dbus_error_init(&err);
+
+       INFO("[CLIENT] Process a message (%s.%s)",
+               dbus_message_get_interface(msg), dbus_message_get_member(msg));
+
+       RET_IF_FAIL(info->conn != NULL);
+
+       for (prev = &info->methods; *prev; prev = &(*prev)->next) {
+               EomDBusClientMethod *method = *prev;
+
+               if (!strcmp(dbus_message_get_member(msg), method->name)) {
+                       GArray *array = _eom_dbus_convert_message_to_gvalue(msg);
+
+                       if (method->func)
+                               method->func(method->data, array);
+
+                       if (array)
+                               g_array_free(array, FALSE);
+
+                       dbus_error_free(&err);
+
+                       return;
+               }
+       }
+}
+
+
+gboolean
+_eom_dbus_client_cb(GIOChannel *src, GIOCondition cond, gpointer data)
+{
+       EomDBusClientInfo *info = (EomDBusClientInfo *)data;
+
+       if (!info || !info->conn || info->fd < 0)
+               return false;
+
+       do {
+               if (info->conn)
+                       dbus_connection_read_write_dispatch(info->conn, 0);
+       } while (info->conn &&
+                       dbus_connection_get_is_connected(info->conn) &&
+                       dbus_connection_get_dispatch_status(info->conn) ==
+                       DBUS_DISPATCH_DATA_REMAINS);
+
+       return true;
+}
+
+
+static DBusHandlerResult
+_eom_dbus_client_msg_handler(DBusConnection *connection, DBusMessage *msg, void *data)
+{
+       EomDBusClientInfo *info = (EomDBusClientInfo *)data;
+
+       if (!info || !info->conn || !msg)
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+       INFO("[Client] Got a message (%s.%s)",
+               dbus_message_get_interface(msg), dbus_message_get_member(msg));
+
+       _eom_dbus_client_process_message(info, msg);
+
+       return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+static DBusHandlerResult
+_eom_dbus_client_msg_filter(DBusConnection *conn, DBusMessage *msg, void *data)
+{
+       EomDBusClientInfo *info = (EomDBusClientInfo *)data;
+
+       if (!info)
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+       if (dbus_message_is_signal(msg, DBUS_INTERFACE_LOCAL, "Disconnected")) {
+               INFO("[EOM] disconnected by signal");
+               _eom_dbus_client_deinitialize(info);
+
+               return DBUS_HANDLER_RESULT_HANDLED;
+       }
+
+       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static int
+_eom_dbus_client_initialize(EomDBusClientInfo *info)
+{
+       DBusError err;
+       int ret;
+       DBusObjectPathVTable vtable = {.message_function = _eom_dbus_client_msg_handler, };
+       GIOChannel *channel;
+
+       dbus_error_init(&err);
+
+       if (_eom_dbus_need_private_conn())
+               info->conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
+       else
+               info->conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+
+       if (dbus_error_is_set(&err)) {
+               ERR("[EOM] failed: connection (%s)", err.message);
+               goto free_err;
+       }
+       if (!info->conn) {
+               ERR("[EOM] failed: connection NULL");
+               goto free_err;
+       }
+
+       ret = dbus_bus_request_name(info->conn, info->name, DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
+       if (dbus_error_is_set(&err)) {
+               ERR("[EOM] failed: request name (%s)", err.message);
+               goto free_conn;
+       }
+       if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+               ERR("[EOM] failed: Not Primary Owner (%d)", ret);
+               goto free_conn;
+       }
+
+       snprintf(info->rule, sizeof(info->rule), "interface='%s'", EOM_DBUS_INTERFACE);
+
+       dbus_bus_add_match(info->conn, info->rule, &err);
+       dbus_connection_flush(info->conn);
+       if (dbus_error_is_set(&err)) {
+               ERR("[EOM] failed: add match (%s)", err.message);
+               goto free_name;
+       }
+
+       if (!dbus_connection_register_object_path(info->conn, EOM_DBUS_PATH, &vtable, info)) {
+               ERR("[EOM] failed: register object path");
+               goto free_match;
+       }
+
+       dbus_connection_set_exit_on_disconnect(info->conn, FALSE);
+
+       if (!dbus_connection_add_filter(info->conn, _eom_dbus_client_msg_filter, info, NULL)) {
+               ERR("[EOM] failed: add filter (%s)", err.message);
+               goto free_register;
+       }
+
+       if (!dbus_connection_get_unix_fd(info->conn, &info->fd) || info->fd < 0) {
+               ERR("[EOM] failed: get fd");
+               goto free_filter;
+       }
+
+       dbus_error_free(&err);
+
+       channel = g_io_channel_unix_new(info->fd);
+       g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL);
+
+       info->src = g_io_create_watch(channel, G_IO_IN);
+       g_source_set_callback(info->src, (GSourceFunc)_eom_dbus_client_cb, (gpointer)info, NULL);
+       g_source_attach(info->src, NULL);
+
+       g_io_channel_unref(channel);
+
+       INFO("[EOM_CLIENT] connected");
+
+       return 1;
+
+free_filter:
+       dbus_connection_remove_filter(info->conn, _eom_dbus_client_msg_filter, info);
+free_register:
+       dbus_connection_unregister_object_path(info->conn, EOM_DBUS_PATH);
+free_match:
+       dbus_bus_remove_match(info->conn, info->rule, &err);
+       dbus_error_free(&err);
+free_name:
+       dbus_bus_release_name(info->conn, info->name, &err);
+       dbus_error_free(&err);
+free_conn:
+       dbus_connection_close(info->conn);
+free_err:
+       dbus_error_free(&err);
+       info->conn = NULL;
+       info->fd = -1;
+
+       return 0;
+}
+
+static void
+_eom_dbus_client_deinitialize(EomDBusClientInfo *info)
+{
+       DBusError err;
+
+       if (!info->conn)
+               return;
+
+       if (info->src) {
+               g_source_destroy(info->src);
+               g_source_unref(info->src);
+       }
+
+       if (info->conn) {
+               dbus_error_init(&err);
+               dbus_bus_remove_match(info->conn, info->rule, &err);
+               dbus_error_free(&err);
+               dbus_bus_release_name(info->conn, info->name, &err);
+               dbus_error_free(&err);
+               dbus_connection_unref(info->conn);
+       }
+
+       memset(info, 0, sizeof(EomDBusClientInfo));
+       info->fd = -1;
+
+       INFO("[EOM] disconnected");
+}
+
+
+static bool
+_eom_dbus_client_connect(void)
+{
+       if (client_info.conn)
+               return true;
+
+       snprintf(client_info.name, STR_LEN, "org.eom.client%d", getpid());
+
+       client_info.fd = -1;
+
+       if (!_eom_dbus_client_initialize(&client_info))
+               return false;
+
+       return true;
+}
+
+static void
+_eom_dbus_client_disconnect(void)
+{
+       _eom_dbus_client_deinitialize(&client_info);
+}
+
+static bool
+_eom_dbus_client_add_method(EomDBusClientMethod *method)
+{
+       EomDBusClientMethod **prev;
+
+       for (prev = &client_info.methods; *prev; prev = &(*prev)->next);
+
+       method->next = NULL;
+       *prev = method;
+
+       return true;
+}
+
+static void
+_eom_dbus_client_remove_method(EomDBusClientMethod *method)
+{
+       EomDBusClientMethod **prev;
+
+       for (prev = &client_info.methods; *prev; prev = &(*prev)->next)
+               if (*prev == method) {
+                       *prev = method->next;
+                       method->next = NULL;
+                       break;
+               }
+}
+
+bool
+eom_dbus_client_init(notify_func func)
+{
+       if (dbus_initialized)
+               return true;
+
+       if (!_eom_dbus_client_connect())
+               return false;
+
+       snprintf(dbus_method.name, sizeof(dbus_method.name), "%s", "Notify");
+       dbus_method.func = func;
+       dbus_method.data = NULL;
+       _eom_dbus_client_add_method(&dbus_method);
+
+       dbus_initialized = true;
+
+       INFO("dbus init");
+
+       return true;
+}
+
+void
+eom_dbus_client_deinit(GList *cb_info_list)
+{
+       if (!dbus_initialized)
+               return;
+
+       /* An output instance and a callback can be created and be added only by user.
+        * If there is cb_info_list, it means that user is still
+        * watching and interested with eom dbus message.
+        */
+       if (cb_info_list)
+               return;
+
+       _eom_dbus_client_remove_method(&dbus_method);
+       _eom_dbus_client_disconnect();
+
+       dbus_initialized = false;
+}
+
+GArray*
+eom_dbus_client_send_message(char *method, GArray *array)
+{
+       DBusMessage *msg = NULL;
+       DBusMessage *reply_msg = NULL;
+       GArray *ret_array = NULL;
+       DBusError err;
+
+       RETV_IF_FAIL(client_info.conn != NULL, NULL);
+
+       dbus_error_init(&err);
+
+       msg = dbus_message_new_method_call(EOM_DBUS_SERVER, EOM_DBUS_PATH, EOM_DBUS_INTERFACE, method);
+       GOTO_IF_FAIL(msg != NULL, err_send);
+
+       INFO("[EOM_CLIENT:%s] Send message(%s)", client_info.name, method);
+
+       if (!_eom_dbus_convert_gvalue_to_message(array, msg)) {
+               ERR("[EOM_CLIENT:%s] failed: gvalue_to_message", client_info.name);
+               goto err_send;
+       }
+
+       reply_msg = dbus_connection_send_with_reply_and_block(client_info.conn, msg, REPLY_TIME, &err);
+       if (dbus_error_is_set(&err)) {
+               ERR("[EOM_CLIENT:%s] failed: send (%s)", client_info.name, err.message);
+               goto err_send;
+       }
+       GOTO_IF_FAIL(reply_msg != NULL, err_send);
+
+       INFO("[EOM_CLIENT:%s] Got reply", client_info.name);
+
+       ret_array = _eom_dbus_convert_message_to_gvalue(reply_msg);
+
+       dbus_message_unref(msg);
+       dbus_message_unref(reply_msg);
+       dbus_error_free(&err);
+
+       return ret_array;
+err_send:
+       if (msg)
+               dbus_message_unref(msg);
+       if (reply_msg)
+               dbus_message_unref(reply_msg);
+
+       dbus_error_free(&err);
+
+       return NULL;
+}
+
+
+GArray *
+eom_dbus_client_get_output_ids(void)
+{
+       GArray *array = NULL;
+
+       array = eom_dbus_client_send_message("GetOutputIDs", NULL);
+       RETV_IF_FAIL(array != NULL, NULL);
+
+       return array;
+}
+
+GArray *
+eom_dbus_client_get_output_info(eom_output_id output_id)
+{
+       GArray *array = NULL;
+       GArray *msg_array;
+       GValue v = G_VALUE_INIT;
+
+       msg_array = g_array_new(FALSE, FALSE, sizeof(GValue));
+
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, output_id);
+       msg_array = g_array_append_val(msg_array, v);
+
+       array = eom_dbus_client_send_message("GetOutputInfo", msg_array);
+       GOTO_IF_FAIL(array != NULL, fail);
+
+       g_array_free(msg_array, FALSE);
+
+       return array;
+fail:
+       g_array_free(msg_array, FALSE);
+
+       return NULL;
+}
+
+GArray *
+eom_dbus_client_set_attribute(eom_output_id output_id, eom_output_attribute_e attr)
+{
+       GArray *array = NULL;
+       GArray *msg_array;
+       GValue v = G_VALUE_INIT;
+       int pid = 0;
+
+       pid = getpid();
+
+       INFO("output_id: %d, pid: %d, attr: %d\n", output_id, pid, attr);
+
+       msg_array = g_array_new(FALSE, FALSE, sizeof(GValue));
+
+       /* 0:output_id, 1:pid, 2:eom_attribuete_e */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, output_id);
+       msg_array = g_array_append_val(msg_array, v);
+       g_value_set_int(&v, pid);
+       msg_array = g_array_append_val(msg_array, v);
+       g_value_set_int(&v, attr);
+       msg_array = g_array_append_val(msg_array, v);
+
+       array = eom_dbus_client_send_message("SetOutputAttribute", msg_array);
+       GOTO_IF_FAIL(array != NULL, fail);
+
+       g_array_free(msg_array, FALSE);
+
+       return array;
+fail:
+       g_array_free(msg_array, FALSE);
+
+       return NULL;
+}
+
+GArray *
+eom_dbus_client_set_window(eom_output_id output_id, Evas_Object *win)
+{
+       GArray *array = NULL;
+       GArray *msg_array;
+       GValue v = G_VALUE_INIT;
+       int pid = 0;
+       Ecore_X_Window xwin;
+       int ret = 0;
+
+       pid = getpid();
+       xwin = elm_win_xwindow_get(win);
+
+       INFO("output_id: %d, pid: %d, xwin: %d\n", output_id, pid, xwin);
+
+       msg_array = g_array_new(FALSE, FALSE, sizeof(GValue));
+
+       /* 0:output_id, 1:pid, 2:eom_attribuete_e */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, output_id);
+       msg_array = g_array_append_val(msg_array, v);
+       g_value_set_int(&v, pid);
+       msg_array = g_array_append_val(msg_array, v);
+       g_value_set_int(&v, xwin);
+       msg_array = g_array_append_val(msg_array, v);
+
+       array = eom_dbus_client_send_message("SetWindow", msg_array);
+       RETV_IF_FAIL(array != NULL, NULL);
+
+       g_array_free(msg_array, FALSE);
+
+       ret = g_value_get_int(&g_array_index(array, GValue, 0));
+       GOTO_IF_FAIL(ret != 0, fail);
+
+#ifdef HAVE_TIZEN_2_X
+       const char *profile = "desktop";
+       elm_win_profiles_set(win, &profile, 1);
+#endif
+       elm_win_fullscreen_set(win, EINA_TRUE);
+
+       return array;
+fail:
+       g_array_free(msg_array, FALSE);
+
+       return NULL;
+}
+
diff --git a/src/dbus/eom-dbus.h b/src/dbus/eom-dbus.h
new file mode 100755 (executable)
index 0000000..6f4697c
--- /dev/null
@@ -0,0 +1,53 @@
+/**************************************************************************
+
+eom (external output manager)
+
+Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+SooChan Lim <sc1.lim@samsung.com>
+Boram Park <boram1288.park@samsung.com>
+Changyeon Lee <cyeon.lee@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __EOM_DBUS_H__
+#define __EOM_DBUS_H__
+
+#include <stdbool.h>
+#include <glib.h>
+#include <glib-object.h>
+#include "eom.h"
+#include "eom-private.h"
+
+bool eom_dbus_client_init(notify_func func);
+void eom_dbus_client_deinit(GList *cb_info_list);
+
+GArray *eom_dbus_client_get_output_ids(void);
+GArray *eom_dbus_client_get_output_info(eom_output_id output_id);
+GArray *eom_dbus_client_set_attribute(eom_output_id output_id, eom_output_attribute_e attry);
+GArray *eom_dbus_client_set_window(eom_output_id output_id, Evas_Object *win);
+
+GArray *eom_dbus_client_send_message(char *method, GArray *array);
+
+#endif /* __EOM_DBUS_H__ */
diff --git a/src/eom-log.h b/src/eom-log.h
new file mode 100644 (file)
index 0000000..7ea830b
--- /dev/null
@@ -0,0 +1,79 @@
+/**************************************************************************
+
+eom (external output manager)
+
+Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+SooChan Lim <sc1.lim@samsung.com>
+Boram Park <boram1288.park@samsung.com>
+Changyeon Lee <cyeon.lee@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __EOM_LOG_H__
+#define __EOM_LOG_H__
+
+#include <config.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#undef HAVE_DLOG
+
+extern bool eom_debug_on;
+
+#ifndef HAVE_CAPI_0_1_1
+static inline void set_last_result(int i) {; }
+#endif
+
+#ifdef HAVE_DLOG
+#define LOG_TAG        "EOM"
+#include <dlog.h>
+#define INFO(fmt, arg...)  \
+       if (eom_debug_on) SECURE_SLOGI(fmt, ##arg)
+#define WARN(fmt, arg...)  \
+       if (eom_debug_on) SECURE_SLOGW(fmt, ##arg)
+#define ERR(fmt, arg...)   SECURE_SLOGE(fmt, ##arg)
+#define FATAL(fmt, arg...) SECURE_SLOGF(fmt, ##arg)
+#else  /* HAVE_DLOG */
+#include <stdlib.h>
+#define INFO(fmt, arg...)  \
+       if (eom_debug_on) fprintf(stdout, "[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
+#define WARN(fmt, arg...)  \
+       if (eom_debug_on) fprintf(stderr, "[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
+#define ERR(fmt, arg...)   fprintf(stderr, "[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
+#define FATAL(fmt, arg...) fprintf(stderr, "[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
+#endif  /* HAVE_DLOG */
+
+#define WARN_IF_FAIL(cond)                             if (!(cond)) ERR("'%s' failed", #cond);
+#define RET_IF_FAIL(cond)                              {if (!(cond)) { ERR("'%s' failed", #cond); return; } }
+#define RETV_IF_FAIL(cond, val)                        {if (!(cond)) { ERR("'%s' failed", #cond); return val; } }
+#define GOTO_IF_FAIL(cond, dst)                        {if (!(cond)) { ERR("'%s' failed", #cond); goto dst; } }
+#define NEVER_GET_HERE()                               ERR("** NEVER GET HERE **\n")
+
+#endif /* __EOM_LOG_H__ */
diff --git a/src/eom-private.h b/src/eom-private.h
new file mode 100755 (executable)
index 0000000..64cae84
--- /dev/null
@@ -0,0 +1,58 @@
+/**************************************************************************
+
+eom (external output manager)
+
+Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+SooChan Lim <sc1.lim@samsung.com>
+Boram Park <boram1288.park@samsung.com>
+Changyeon Lee <cyeon.lee@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __EOM_PRIVATE_H__
+#define __EOM_PRIVATE_H__
+
+#include "eom.h"
+
+typedef struct {
+       eom_output_id id;
+       eom_output_type_e type;
+       eom_output_mode_e output_mode;
+       eom_output_attribute_e attribute;
+       eom_output_attribute_state_e state;
+
+       int width;
+       int height;
+       int mm_width;
+       int mm_height;
+} eom_output_info;
+
+/* notify callback function prototype */
+typedef void (*notify_func) (void *data, GArray *array);
+
+void _eom_mutex_lock(void);
+void _eom_mutex_unlock(void);
+
+#endif /* __EOM_PRIVATE_H__ */
diff --git a/src/eom.c b/src/eom.c
new file mode 100755 (executable)
index 0000000..078f203
--- /dev/null
+++ b/src/eom.c
@@ -0,0 +1,1147 @@
+/**************************************************************************
+
+eom (external output manager)
+
+Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+SooChan Lim <sc1.lim@samsung.com>
+Boram Park <boram1288.park@samsung.com>
+Changyeon Lee <cyeon.lee@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <config.h>
+
+#include <glib.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+
+#include "eom.h"
+#include "eom_internal.h"
+#include "eom-log.h"
+#ifdef HAVE_WAYLAND
+#include "eom-wayland.h"
+#else
+#include "eom-dbus.h"
+#endif
+#include "eom-private.h"
+
+typedef struct {
+       eom_output_notify_type_e type;       /**< External output type */
+       eom_output_id            output_id;  /**< External output id */
+} eom_output_notify_base_s;
+
+typedef struct {
+       eom_output_notify_type_e type;       /**< External output type */
+       eom_output_id            output_id;  /**< External output id */
+} eom_output_notify_add_s;
+
+typedef struct {
+       eom_output_notify_type_e type;       /**< External output type */
+       eom_output_id            output_id;  /**< External output id */
+} eom_output_notify_remove_s;
+
+typedef struct {
+       eom_output_notify_type_e type;       /**< External output type */
+       eom_output_id            output_id;  /**< External output id */
+       eom_output_mode_e        old_mode;   /**< External output mode */
+       eom_output_mode_e        new_mode;   /**< External output mode */
+} eom_output_notify_mode_change_s;
+
+typedef struct {
+       eom_output_notify_type_e     type;        /**< External output type */
+       eom_output_id                output_id;   /**< External output id */
+       eom_output_attribute_e       attribute;   /**< External output attribute */
+       eom_output_attribute_state_e attr_state;  /**< External output attribute state */
+} eom_output_notify_attribute_change_s;
+
+typedef union {
+       eom_output_notify_base_s             base;           /**< Base structure for eom notify */
+       eom_output_notify_add_s              output_add;     /**< #EOM_OUTPUT_NOTIFY_ADD notify */
+       eom_output_notify_remove_s           output_remove;  /**< #EOM_OUTPUT_NOTIFY_REMOVE notify */
+       eom_output_notify_mode_change_s      mode_change;    /**< #EOM_OUTPUT_NOTIFY_MODE_CHANGED notify */
+       eom_output_notify_attribute_change_s attr_change;    /**< #EOM_OUTPUT_NOTIFY_ATTRIBUTE_CHANGED notify */
+} eom_output_notify_s;
+
+typedef struct {
+       eom_output_notify_type_e type;
+       eom_output_added_cb add_func;
+       eom_output_removed_cb remove_func;
+       eom_mode_changed_cb mode_change_func;
+       eom_attribute_changed_cb attribute_change_func;
+       void *user_data;
+} eom_output_notify_cb_info;
+
+bool eom_debug_on;
+
+static pthread_mutex_t eom_lock;
+
+static GList *cb_info_list;
+static GList *output_info_list;
+
+static void _eom_output_process_notify_cb(void *data, GArray *array);
+static eom_output_info *_eom_find_output_info(eom_output_id output_id);
+static eom_output_info *_eom_alloc_output_info(int output_id, int output_type);
+static const char*
+TYPE(eom_output_type_e output_type)
+{
+       switch (output_type) {
+       case EOM_OUTPUT_TYPE_VGA:
+               return "VGA";
+       case EOM_OUTPUT_TYPE_DVII:
+               return "DVII";
+       case EOM_OUTPUT_TYPE_DVID:
+               return "DVID";
+       case EOM_OUTPUT_TYPE_DVIA:
+               return "DVIA";
+       case EOM_OUTPUT_TYPE_COMPOSITE:
+               return "COMPOSITE";
+       case EOM_OUTPUT_TYPE_SVIDEO:
+               return "SVIDEO";
+       case EOM_OUTPUT_TYPE_LVDS:
+               return "LVDS";
+       case EOM_OUTPUT_TYPE_COMPONENT:
+               return "COMPONENT";
+       case EOM_OUTPUT_TYPE_9PINDIN:
+               return "9PINDIN";
+       case EOM_OUTPUT_TYPE_DISPLAYPORT:
+               return "DISPLAYPORT";
+       case EOM_OUTPUT_TYPE_HDMIA:
+               return "HDMIA";
+       case EOM_OUTPUT_TYPE_HDMIB:
+               return "HDMIB";
+       case EOM_OUTPUT_TYPE_TV:
+               return "TV";
+       case EOM_OUTPUT_TYPE_EDP:
+               return "EDP";
+       case EOM_OUTPUT_TYPE_VIRTUAL:
+               return "VIRTUAL";
+       case EOM_OUTPUT_TYPE_DSI:
+               return "DSI";
+       default:
+               return "UNKNOWN";
+       }
+}
+
+static void
+_eom_get_debug_evn(void)
+{
+       char *env = getenv("EOM_DEBUG");
+
+       if (env) {
+               eom_debug_on = (atoi(env) > 0) ? true : false;
+#ifdef HAVE_DLOG
+               fprintf(stderr, "eom dlog on\n");
+#else
+               fprintf(stderr, "eom dlog off\n");
+#endif
+               INFO("EOM_DEBUG = %s", env);
+       } else
+               eom_debug_on = 0;
+}
+
+static bool
+_eom_mutex_init(void)
+{
+       static bool init = false;
+       char eom_error_buf[256] = {0, };
+
+       if (init)
+               return true;
+
+       if (pthread_mutex_init(&eom_lock, NULL)) {
+               ERR("(err=%s(%d)) fail: mutex init", strerror_r(errno, eom_error_buf, 256), errno);
+               return false;
+       }
+
+       init = true;
+
+       return true;
+}
+
+void
+_eom_mutex_lock(void)
+{
+       if (!_eom_mutex_init())
+               return;
+
+       pthread_mutex_lock(&eom_lock);
+}
+
+void
+_eom_mutex_unlock(void)
+{
+       pthread_mutex_unlock(&eom_lock);
+}
+
+static void
+_eom_set_output_info_mode(eom_output_info *output_info, int output_mode)
+{
+       RET_IF_FAIL(output_info != NULL);
+
+       if (output_info->output_mode == output_mode)
+               return;
+
+       output_info->output_mode = output_mode;
+}
+
+static void
+_eom_set_output_attribute(eom_output_info *output_info, eom_output_attribute_e attribute)
+{
+       RET_IF_FAIL(output_info != NULL);
+
+       output_info->attribute = attribute;
+}
+
+static void
+_eom_set_output_attribute_state(eom_output_info *output_info, eom_output_attribute_state_e state)
+{
+       RET_IF_FAIL(output_info != NULL);
+
+       output_info->state = state;
+}
+
+static void
+_eom_set_output_info_size(eom_output_info *output_info, int w, int h)
+{
+       RET_IF_FAIL(output_info != NULL);
+
+       output_info->width = w;
+       output_info->height = h;
+}
+
+static void
+_eom_set_output_info_phy_size(eom_output_info *output_info, int w_mm, int h_mm)
+{
+       RET_IF_FAIL(output_info != NULL);
+
+       output_info->mm_width = w_mm;
+       output_info->mm_height = h_mm;
+}
+
+static void
+_eom_reset_output_info(eom_output_info *output_info)
+{
+       RET_IF_FAIL(output_info != NULL);
+
+       output_info->output_mode = EOM_OUTPUT_MODE_NONE;
+       output_info->width = 0;
+       output_info->height = 0;
+       output_info->mm_width = 0;
+       output_info->mm_height = 0;
+}
+
+static void
+_eom_output_call_notify_cb(eom_output_notify_s *notify)
+{
+       GList *l;
+
+       for (l = cb_info_list; l; l = g_list_next(l)) {
+               eom_output_notify_cb_info *cb_info = (eom_output_notify_cb_info *)l->data;
+
+               if (!cb_info || cb_info->type != notify->base.type)
+                       continue;
+
+               if (notify->base.type == EOM_OUTPUT_NOTIFY_ADD) {
+                       if (cb_info->add_func == NULL)
+                               continue;
+
+                       INFO("cb_info: type(%d) output_id(%d)", notify->base.type, notify->base.output_id);
+
+                       cb_info->add_func(notify->base.output_id, cb_info->user_data);
+               } else if (notify->base.type == EOM_OUTPUT_NOTIFY_REMOVE) {
+                       if (cb_info->remove_func == NULL)
+                               continue;
+
+                       INFO("cb_info: type(%d) output_id(%d)", notify->base.type, notify->base.output_id);
+
+                       cb_info->remove_func(notify->base.output_id, cb_info->user_data);
+               } else if (notify->base.type == EOM_OUTPUT_NOTIFY_MODE_CHANGED) {
+                       if (cb_info->mode_change_func == NULL)
+                               continue;
+
+                       INFO("cb_info: type(%d) output_id(%d)", notify->base.type, notify->base.output_id);
+
+                       cb_info->mode_change_func(notify->base.output_id, cb_info->user_data);
+               } else if (notify->base.type == EOM_OUTPUT_NOTIFY_ATTRIBUTE_CHANGED) {
+                       if (cb_info->attribute_change_func == NULL)
+                               continue;
+
+                       INFO("cb_info: type(%d) output_id(%d)", notify->base.type, notify->base.output_id);
+
+                       cb_info->attribute_change_func(notify->base.output_id, cb_info->user_data);
+               } else {
+                       INFO("cb_info: type(%d) output_id(%d)", notify->base.type, notify->base.output_id);
+                       continue;
+               }
+       }
+}
+
+static void
+_eom_output_process_notify_cb(void *data, GArray *array)
+{
+       eom_output_notify_s notify;
+       eom_output_info *output_info;
+       int notify_type, output_id, output_type, output_mode, w, h, w_mm, h_mm, pid, attr, state;
+       GValue *v;
+
+       RET_IF_FAIL(array != NULL);
+       RET_IF_FAIL(array->len == 11);
+
+       /* 11 args 0: notify_type 1:output_id, 2:output_type, 3:output_mode, 4:w, 5:h, 6:w_mm, 7:h_mm, 8:pid, 9:attr, 10:state */
+       v = &g_array_index(array, GValue, 0);
+       notify_type = g_value_get_int(v);
+       v = &g_array_index(array, GValue, 1);
+       output_id = g_value_get_int(v);
+       v = &g_array_index(array, GValue, 2);
+       output_type = g_value_get_int(v);
+       v = &g_array_index(array, GValue, 3);
+       output_mode = g_value_get_int(v);
+       v = &g_array_index(array, GValue, 4);
+       w = g_value_get_int(v);
+       v = &g_array_index(array, GValue, 5);
+       h = g_value_get_int(v);
+       v = &g_array_index(array, GValue, 6);
+       w_mm = g_value_get_int(v);
+       v = &g_array_index(array, GValue, 7);
+       h_mm = g_value_get_int(v);
+       v = &g_array_index(array, GValue, 8);
+       pid = g_value_get_int(v);
+       v = &g_array_index(array, GValue, 9);
+       attr = g_value_get_int(v);
+       v = &g_array_index(array, GValue, 10);
+       state = g_value_get_int(v);
+
+       INFO("notify: %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
+               notify_type, output_id, output_type, output_mode, w, h, w_mm, h_mm, pid, attr, state);
+
+       memset(&notify, 0, sizeof(eom_output_notify_s));
+       notify.base.type = notify_type;
+       notify.base.output_id = output_id;
+
+       _eom_mutex_lock();
+
+       output_info = _eom_find_output_info(output_id);
+       GOTO_IF_FAIL(output_info != NULL, exit);
+
+       switch (notify_type) {
+       case EOM_OUTPUT_NOTIFY_ADD:
+               {
+                       INFO("'%s(%d)' added", TYPE(output_type), output_id);
+
+                       _eom_set_output_info_mode(output_info, output_mode);
+                       _eom_set_output_info_size(output_info, w, h);
+                       _eom_set_output_info_phy_size(output_info, w_mm, h_mm);
+
+                       _eom_mutex_unlock();
+                       _eom_output_call_notify_cb(&notify);
+                       _eom_mutex_lock();
+               }
+               break;
+
+       case EOM_OUTPUT_NOTIFY_REMOVE:
+               {
+                       INFO("'%s(%d)' removed", TYPE(output_type), output_id);
+
+                       _eom_reset_output_info(output_info);
+
+                       _eom_mutex_unlock();
+                       _eom_output_call_notify_cb(&notify);
+                       _eom_mutex_lock();
+               }
+               break;
+
+       case EOM_OUTPUT_NOTIFY_MODE_CHANGED:
+               {
+                       eom_output_mode_e old_mode;
+
+                       old_mode = output_info->output_mode;
+                       output_info->output_mode = output_mode;
+
+                       INFO("'%s(%d)' mode changed(%d=>%d)",
+                                       TYPE(output_type), output_id, old_mode, output_info->output_mode);
+
+                       notify.mode_change.old_mode = old_mode;
+                       notify.mode_change.new_mode = output_info->output_mode;
+
+                       _eom_mutex_unlock();
+                       _eom_output_call_notify_cb(&notify);
+                       _eom_mutex_lock();
+               }
+               break;
+
+       case EOM_OUTPUT_NOTIFY_ATTRIBUTE_CHANGED:
+               {
+                       int current_pid = getpid();
+
+                       if (current_pid == pid) {
+                               INFO("'%s(%d)'pid(%d)", TYPE(output_type), output_id, pid);
+                               _eom_set_output_attribute(output_info, attr);
+                               _eom_set_output_attribute_state(output_info, state);
+                               notify.attr_change.output_id = output_id;
+                               notify.attr_change.attribute = attr;
+                               notify.attr_change.attr_state = state;
+
+                               _eom_mutex_unlock();
+                               _eom_output_call_notify_cb(&notify);
+                               _eom_mutex_lock();
+
+                               if (state == EOM_OUTPUT_ATTRIBUTE_STATE_LOST)
+                                       _eom_set_output_attribute_state(output_info, EOM_OUTPUT_ATTRIBUTE_STATE_NONE);
+                       }
+               }
+               break;
+
+       default:
+               INFO("'unknown(%d)' notified", notify.base.type);
+
+               _eom_mutex_unlock();
+               _eom_output_call_notify_cb(&notify);
+               _eom_mutex_lock();
+               break;
+       }
+
+exit:
+       _eom_mutex_unlock();
+}
+
+
+static eom_output_info*
+_eom_find_output_info(eom_output_id output_id)
+{
+       GList *l;
+
+       for (l = output_info_list; l; l = g_list_next(l)) {
+               eom_output_info *output_info = (eom_output_info *)l->data;
+
+               if (output_info && (output_id == output_info->id))
+                       return output_info;
+       }
+
+       return NULL;
+}
+
+static void
+_eom_free_output_info(eom_output_info **output_info)
+{
+       if (output_info && *output_info) {
+               free(*output_info);
+               *output_info = NULL;
+       }
+}
+
+static eom_output_info*
+_eom_alloc_output_info(int output_id, int output_type)
+{
+       eom_output_info *output_info = NULL;
+
+       output_info = calloc(1, sizeof(eom_output_info));
+       GOTO_IF_FAIL(output_info != NULL, fail);
+
+       output_info->id = output_id;
+       output_info->type = output_type;
+       output_info->output_mode = EOM_OUTPUT_MODE_NONE;
+       output_info->attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
+       output_info->state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
+       output_info->width = 0;
+       output_info->height = 0;
+       output_info->mm_width = 0;
+       output_info->mm_height = 0;
+
+       INFO("alloc '%s(%d)''s info", TYPE(output_type), output_id);
+
+       return output_info;
+
+fail:
+       ERR("fail: alloc '%s(%d)''s info", TYPE(output_type), output_id);
+
+       return NULL;
+}
+
+API int
+eom_init(void)
+{
+       bool ret;
+
+       _eom_get_debug_evn();
+
+       _eom_mutex_lock();
+
+#ifdef HAVE_WAYLAND
+       ret = eom_wayland_client_init(_eom_output_process_notify_cb);
+#else
+       ret = eom_dbus_client_init(_eom_output_process_notify_cb);
+#endif
+
+       _eom_mutex_unlock();
+
+       INFO("eom init %s", (ret) ? "success" : "failed");
+
+       return (ret) ? EOM_ERROR_NONE : EOM_ERROR_CONNECTION_FAILURE;
+}
+
+API void
+eom_deinit(void)
+{
+       GList *l;
+
+       _eom_mutex_lock();
+#ifdef HAVE_WAYLAND
+       eom_wayland_client_deinit(cb_info_list);
+#else
+       eom_dbus_client_deinit(cb_info_list);
+#endif
+
+       /* TODO: redesign the life-cycle of output_infos */
+       /* destory output_info. */
+       for (l = output_info_list; l; l = g_list_next(l)) {
+               eom_output_info *output_info = (eom_output_info *)l->data;
+               output_info_list = g_list_remove(output_info_list, output_info);
+
+               _eom_free_output_info(&output_info);
+       }
+
+       _eom_mutex_unlock();
+
+       INFO("eom deinit");
+}
+
+API eom_output_id*
+eom_get_eom_output_ids(int *count)
+{
+       GArray *ret_array = NULL;
+       eom_output_id *output_ids = NULL;
+       int i;
+
+       if (!count) {
+               set_last_result(EOM_ERROR_INVALID_PARAMETER);
+               return NULL;
+       }
+
+       _eom_mutex_lock();
+
+#ifdef HAVE_WAYLAND
+       ret_array = eom_wayland_client_get_output_ids();
+#else
+       ret_array = eom_dbus_client_get_output_ids();
+#endif
+       if (!ret_array) {
+               *count = 0;
+               _eom_mutex_unlock();
+               set_last_result(EOM_ERROR_NONE);
+               return NULL;
+       }
+
+       if (ret_array->len == 0) {
+               g_array_free(ret_array, FALSE);
+               *count = 0;
+               _eom_mutex_unlock();
+               set_last_result(EOM_ERROR_NONE);
+               return NULL;
+       }
+
+       output_ids = calloc(ret_array->len, sizeof(eom_output_id));
+       GOTO_IF_FAIL(output_ids != NULL, fail);
+
+       *count = ret_array->len;
+       for (i = 0; i < ret_array->len; i++) {
+               GValue *v = &g_array_index(ret_array, GValue, i);
+               output_ids[i] = g_value_get_int(v);
+               INFO("output_ids: %d", output_ids[i]);
+       }
+
+       g_array_free(ret_array, FALSE);
+       ret_array = NULL;
+
+       /* TODO: redesign the life-cycle of output_infos */
+       for (i = 0; i < *count; i++) {
+               /* add output_info to output_info_list */
+               eom_output_info *output_info;
+               eom_output_id output_id = output_ids[i];
+
+               output_info = _eom_find_output_info(output_id);
+               if (output_info)
+                       continue;
+
+#ifdef HAVE_WAYLAND
+               ret_array = eom_wayland_client_get_output_info(output_id);
+#else
+               ret_array = eom_dbus_client_get_output_info(output_id);
+#endif
+               if (ret_array) {
+                       /* 0:output_id, 1:output_type, 2:output_mode, 3:w, 4:h, 5:w_mm, 6:h_mm, 7:attribute */
+                       output_info = _eom_alloc_output_info(g_value_get_int(&g_array_index(ret_array, GValue, 0)),
+                                                                                                 g_value_get_int(&g_array_index(ret_array, GValue, 1)));
+                       if (output_info) {
+                               output_info_list = g_list_append(output_info_list, output_info);
+                               _eom_set_output_info_mode(output_info, g_value_get_int(&g_array_index(ret_array, GValue, 2)));
+                               _eom_set_output_info_size(output_info, g_value_get_int(&g_array_index(ret_array, GValue, 3)),
+                                                                                                               g_value_get_int(&g_array_index(ret_array, GValue, 4)));
+                               _eom_set_output_info_phy_size(output_info, g_value_get_int(&g_array_index(ret_array, GValue, 5)),
+                                                                                                                       g_value_get_int(&g_array_index(ret_array, GValue, 6)));
+                               _eom_set_output_attribute(output_info, g_value_get_int(&g_array_index(ret_array, GValue, 7)));
+                               INFO("GetOutputInfo: %s(%d)", TYPE(output_info->type), output_info->id);
+                       }
+
+                       g_array_free(ret_array, FALSE);
+                       ret_array = NULL;
+               } else
+                       ERR("fail: get id(%d)'s information", output_id);
+       }
+
+       _eom_mutex_unlock();
+
+       set_last_result(EOM_ERROR_NONE);
+
+       return output_ids;
+
+fail:
+       if (ret_array)
+               g_array_free(ret_array, FALSE);
+
+       *count = 0;
+
+       _eom_mutex_unlock();
+
+       set_last_result(EOM_ERROR_OUT_OF_MEMORY);
+
+       return NULL;
+}
+
+API int
+eom_set_output_added_cb(eom_output_added_cb callback, void *user_data)
+{
+       eom_output_notify_cb_info *cb_info;
+       GList *l;
+
+       RETV_IF_FAIL(callback != NULL, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       for (l = cb_info_list; l; l = g_list_next(l)) {
+               eom_output_notify_cb_info *cb_info = (eom_output_notify_cb_info *)l->data;
+
+               if (cb_info && (cb_info->add_func != NULL) && (cb_info->add_func == callback)) {
+                       _eom_mutex_unlock();
+                       return EOM_ERROR_NONE;
+               }
+       }
+
+       cb_info = calloc(1, sizeof(eom_output_notify_cb_info));
+       GOTO_IF_FAIL(cb_info != NULL, fail);
+
+       cb_info->type = EOM_OUTPUT_NOTIFY_ADD;
+       cb_info->add_func = callback;
+       cb_info->user_data = user_data;
+
+       cb_info_list = g_list_append(cb_info_list, cb_info);
+
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_NONE;
+
+fail:
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_OUT_OF_MEMORY;
+}
+
+API int
+eom_unset_output_added_cb(eom_output_added_cb callback)
+{
+       GList *l;
+
+       RETV_IF_FAIL(callback != NULL, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       for (l = cb_info_list; l; l = g_list_next(l)) {
+               eom_output_notify_cb_info *cb_info = (eom_output_notify_cb_info *)l->data;
+
+               if (!cb_info || (cb_info->add_func == NULL) || (cb_info->add_func != callback))
+                       continue;
+
+               cb_info_list = g_list_remove(cb_info_list, cb_info);
+               free(cb_info);
+
+               _eom_mutex_unlock();
+
+               return EOM_ERROR_NONE;
+       }
+
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_INVALID_PARAMETER;
+}
+
+API int
+eom_set_output_removed_cb(eom_output_removed_cb callback, void *user_data)
+{
+       eom_output_notify_cb_info *cb_info;
+       GList *l;
+
+       RETV_IF_FAIL(callback != NULL, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       for (l = cb_info_list; l; l = g_list_next(l)) {
+               eom_output_notify_cb_info *cb_info = (eom_output_notify_cb_info *)l->data;
+
+               if (cb_info && (cb_info->remove_func != NULL) && (cb_info->remove_func == callback)) {
+                       _eom_mutex_unlock();
+                       return EOM_ERROR_NONE;
+               }
+       }
+
+       cb_info = calloc(1, sizeof(eom_output_notify_cb_info));
+       GOTO_IF_FAIL(cb_info != NULL, fail);
+
+       cb_info->type = EOM_OUTPUT_NOTIFY_REMOVE;
+       cb_info->remove_func = callback;
+       cb_info->user_data = user_data;
+
+       cb_info_list = g_list_append(cb_info_list, cb_info);
+
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_NONE;
+
+fail:
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_OUT_OF_MEMORY;
+}
+
+API int
+eom_unset_output_removed_cb(eom_output_removed_cb callback)
+{
+       GList *l;
+
+       RETV_IF_FAIL(callback != NULL, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       for (l = cb_info_list; l; l = g_list_next(l)) {
+               eom_output_notify_cb_info *cb_info = (eom_output_notify_cb_info *)l->data;
+
+               if (!cb_info || (cb_info->remove_func == NULL) || (cb_info->remove_func != callback))
+                       continue;
+
+               cb_info_list = g_list_remove(cb_info_list, cb_info);
+               free(cb_info);
+
+               _eom_mutex_unlock();
+
+               return EOM_ERROR_NONE;
+       }
+
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_INVALID_PARAMETER;
+}
+
+API int
+eom_set_mode_changed_cb(eom_mode_changed_cb callback, void *user_data)
+{
+       eom_output_notify_cb_info *cb_info;
+       GList *l;
+
+       RETV_IF_FAIL(callback != NULL, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       for (l = cb_info_list; l; l = g_list_next(l)) {
+               eom_output_notify_cb_info *cb_info = (eom_output_notify_cb_info *)l->data;
+
+               if (cb_info && (cb_info->mode_change_func != NULL) && (cb_info->mode_change_func == callback)) {
+                       _eom_mutex_unlock();
+                       return EOM_ERROR_NONE;
+               }
+       }
+
+       cb_info = calloc(1, sizeof(eom_output_notify_cb_info));
+       GOTO_IF_FAIL(cb_info != NULL, fail);
+
+       cb_info->type = EOM_OUTPUT_NOTIFY_MODE_CHANGED;
+       cb_info->mode_change_func = callback;
+       cb_info->user_data = user_data;
+
+       cb_info_list = g_list_append(cb_info_list, cb_info);
+
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_NONE;
+
+fail:
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_OUT_OF_MEMORY;
+}
+
+API int
+eom_unset_mode_changed_cb(eom_mode_changed_cb callback)
+{
+       GList *l;
+
+       RETV_IF_FAIL(callback != NULL, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       for (l = cb_info_list; l; l = g_list_next(l)) {
+               eom_output_notify_cb_info *cb_info = (eom_output_notify_cb_info *)l->data;
+
+               if (!cb_info || (cb_info->mode_change_func == NULL) || (cb_info->mode_change_func != callback))
+                       continue;
+
+               cb_info_list = g_list_remove(cb_info_list, cb_info);
+               free(cb_info);
+
+               _eom_mutex_unlock();
+
+               return EOM_ERROR_NONE;
+       }
+
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_INVALID_PARAMETER;
+}
+
+API int
+eom_set_attribute_changed_cb(eom_attribute_changed_cb callback, void *user_data)
+{
+       eom_output_notify_cb_info *cb_info;
+       GList *l;
+
+       RETV_IF_FAIL(callback != NULL, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       for (l = cb_info_list; l; l = g_list_next(l)) {
+               eom_output_notify_cb_info *cb_info = (eom_output_notify_cb_info *)l->data;
+
+               if (cb_info && (cb_info->attribute_change_func != NULL) && (cb_info->attribute_change_func == callback)) {
+                       _eom_mutex_unlock();
+                       return EOM_ERROR_NONE;
+               }
+       }
+
+       cb_info = calloc(1, sizeof(eom_output_notify_cb_info));
+       GOTO_IF_FAIL(cb_info != NULL, fail);
+
+       cb_info->type = EOM_OUTPUT_NOTIFY_ATTRIBUTE_CHANGED;
+       cb_info->attribute_change_func = callback;
+       cb_info->user_data = user_data;
+
+       cb_info_list = g_list_append(cb_info_list, cb_info);
+
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_NONE;
+
+fail:
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_OUT_OF_MEMORY;
+}
+
+API int
+eom_unset_attribute_changed_cb(eom_attribute_changed_cb callback)
+{
+       GList *l;
+
+       RETV_IF_FAIL(callback != NULL, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       for (l = cb_info_list; l; l = g_list_next(l)) {
+               eom_output_notify_cb_info *cb_info = (eom_output_notify_cb_info *)l->data;
+
+               if (!cb_info || (cb_info->attribute_change_func == NULL) || (cb_info->attribute_change_func != callback))
+                       continue;
+
+               cb_info_list = g_list_remove(cb_info_list, cb_info);
+               free(cb_info);
+
+               _eom_mutex_unlock();
+
+               return EOM_ERROR_NONE;
+       }
+
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_INVALID_PARAMETER;
+}
+
+API int
+eom_set_output_attribute(eom_output_id output_id, eom_output_attribute_e attr)
+{
+       eom_output_info *output_info = NULL;
+       bool ret = false;
+       GArray *ret_array;
+
+       RETV_IF_FAIL(output_id != 0, EOM_ERROR_INVALID_PARAMETER);
+       RETV_IF_FAIL(attr > EOM_OUTPUT_ATTRIBUTE_NONE, EOM_ERROR_INVALID_PARAMETER);
+       RETV_IF_FAIL(attr < EOM_OUTPUT_ATTRIBUTE_MAX, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       output_info = _eom_find_output_info(output_id);
+       if (!output_info) {
+               set_last_result(EOM_ERROR_NO_SUCH_DEVICE);
+               _eom_mutex_unlock();
+               return EOM_ERROR_NO_SUCH_DEVICE;
+       }
+
+       INFO("output_id: %d, attr: %d\n", output_id, attr);
+
+#ifdef HAVE_WAYLAND
+       ret_array = eom_wayland_client_set_attribute(output_id, attr);
+#else
+       ret_array = eom_dbus_client_set_attribute(output_id, attr);
+#endif
+       if (!ret_array) {
+               _eom_mutex_unlock();
+               return EOM_ERROR_MESSAGE_SENDING_FAILURE;
+       }
+
+       ret = g_value_get_int(&g_array_index(ret_array, GValue, 0));
+
+       g_array_free(ret_array, FALSE);
+
+       INFO("SetOutputAttribute: %s", (ret) ? "success" : "failed");
+
+       if (ret)
+               _eom_set_output_attribute(output_info, attr);
+
+       _eom_mutex_unlock();
+
+       return (ret) ? EOM_ERROR_NONE : EOM_ERROR_MESSAGE_OPERATION_FAILURE;
+}
+
+
+API int
+eom_get_output_type(eom_output_id output_id, eom_output_type_e *type)
+{
+       eom_output_info *output_info = NULL;
+
+       RETV_IF_FAIL(output_id != 0, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       output_info = _eom_find_output_info(output_id);
+       if (!output_info) {
+               *type = EOM_OUTPUT_TYPE_UNKNOWN;
+               _eom_mutex_unlock();
+               set_last_result(EOM_ERROR_NO_SUCH_DEVICE);
+               return EOM_ERROR_NO_SUCH_DEVICE;
+       }
+       *type = output_info->type;
+
+       _eom_mutex_unlock();
+
+       set_last_result(EOM_ERROR_NONE);
+       return EOM_ERROR_NONE;
+}
+
+API int
+eom_get_output_mode(eom_output_id output_id, eom_output_mode_e *mode)
+{
+       eom_output_info *output_info = NULL;
+
+       RETV_IF_FAIL(output_id != 0, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       output_info = _eom_find_output_info(output_id);
+       if (!output_info) {
+               *mode = EOM_OUTPUT_MODE_NONE;
+               _eom_mutex_unlock();
+               set_last_result(EOM_ERROR_NO_SUCH_DEVICE);
+               return EOM_ERROR_NO_SUCH_DEVICE;
+       }
+       *mode = output_info->output_mode;
+
+       _eom_mutex_unlock();
+
+       set_last_result(EOM_ERROR_NONE);
+       return EOM_ERROR_NONE;
+}
+
+API int
+eom_get_output_attribute(eom_output_id output_id, eom_output_attribute_e *attribute)
+{
+       eom_output_info *output_info = NULL;
+
+       RETV_IF_FAIL(output_id != 0, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       output_info = _eom_find_output_info(output_id);
+       if (!output_info) {
+               *attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
+               _eom_mutex_unlock();
+               set_last_result(EOM_ERROR_NO_SUCH_DEVICE);
+               return EOM_ERROR_NO_SUCH_DEVICE;
+       }
+       *attribute = output_info->attribute;
+
+       _eom_mutex_unlock();
+
+       set_last_result(EOM_ERROR_NONE);
+       return EOM_ERROR_NONE;
+}
+
+API int
+eom_get_output_attribute_state(eom_output_id output_id, eom_output_attribute_state_e *state)
+{
+       eom_output_info *output_info = NULL;
+
+       RETV_IF_FAIL(output_id != 0, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       output_info = _eom_find_output_info(output_id);
+       if (!output_info) {
+               *state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
+               _eom_mutex_unlock();
+               set_last_result(EOM_ERROR_NO_SUCH_DEVICE);
+               return EOM_ERROR_NO_SUCH_DEVICE;
+       }
+       *state = output_info->state;
+
+       _eom_mutex_unlock();
+
+       set_last_result(EOM_ERROR_NONE);
+       return EOM_ERROR_NONE;
+}
+
+API int
+eom_get_output_resolution(eom_output_id output_id, int *width, int *height)
+{
+       eom_output_info *output_info = NULL;
+
+       RETV_IF_FAIL(output_id != 0, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       output_info = _eom_find_output_info(output_id);
+       if (!output_info) {
+               if (width)
+                       *width = 0;
+               if (height)
+                       *height = 0;
+
+               set_last_result(EOM_ERROR_NO_SUCH_DEVICE);
+               _eom_mutex_unlock();
+               return EOM_ERROR_NO_SUCH_DEVICE;
+       }
+
+       if (width)
+               *width = output_info->width;
+       if (height)
+               *height = output_info->height;
+
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_NONE;
+}
+
+API int
+eom_get_output_physical_size(eom_output_id output_id, int *phy_width, int *phy_height)
+{
+       eom_output_info *output_info = NULL;
+
+       RETV_IF_FAIL(output_id != 0, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       output_info = _eom_find_output_info(output_id);
+       if (!output_info) {
+               if (phy_width)
+                       *phy_width = 0;
+               if (phy_height)
+                       *phy_height = 0;
+
+               _eom_mutex_unlock();
+               set_last_result(EOM_ERROR_NO_SUCH_DEVICE);
+               return EOM_ERROR_NO_SUCH_DEVICE;
+       }
+
+       if (phy_width)
+               *phy_width = output_info->mm_width;
+       if (phy_height)
+               *phy_height = output_info->mm_height;
+
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_NONE;
+}
+
+API int
+eom_set_output_window(eom_output_id output_id, Evas_Object *win)
+{
+       eom_output_info *output_info = NULL;
+       bool ret = false;
+       GArray *ret_array;
+
+       RETV_IF_FAIL(output_id != 0, EOM_ERROR_INVALID_PARAMETER);
+       RETV_IF_FAIL(win != NULL, EOM_ERROR_INVALID_PARAMETER);
+
+       _eom_mutex_lock();
+
+       output_info = _eom_find_output_info(output_id);
+       if (!output_info) {
+               set_last_result(EOM_ERROR_NO_SUCH_DEVICE);
+               _eom_mutex_unlock();
+               return EOM_ERROR_NO_SUCH_DEVICE;
+       }
+
+       INFO("output_id: %d, evas_win: %p\n", output_id, win);
+
+#ifdef HAVE_WAYLAND
+       ret_array = eom_wayland_client_set_window(output_id, win);
+#else
+       ret_array = eom_dbus_client_set_window(output_id, win);
+#endif
+       if (!ret_array) {
+               _eom_mutex_unlock();
+               return EOM_ERROR_MESSAGE_SENDING_FAILURE;
+       }
+
+       ret = g_value_get_int(&g_array_index(ret_array, GValue, 0));
+       g_array_free(ret_array, FALSE);
+       if (ret == 0) {
+               ERR("SetWindow: failed\n");
+               _eom_mutex_unlock();
+               return EOM_ERROR_MESSAGE_OPERATION_FAILURE;
+       }
+
+       INFO("SetWindow: success\n");
+
+       _eom_mutex_unlock();
+
+       return EOM_ERROR_NONE;
+}
+
diff --git a/src/wayland/eom-wayland.c b/src/wayland/eom-wayland.c
new file mode 100644 (file)
index 0000000..31bc2aa
--- /dev/null
@@ -0,0 +1,870 @@
+/**************************************************************************
+
+eom (external output manager)
+
+Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+SooChan Lim <sc1.lim@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <config.h>
+#include "eom.h"
+#include "eom_internal.h"
+#include "eom-log.h"
+#include "eom-wayland.h"
+#include "eom-private.h"
+#include "eom-client-protocol.h"
+#include "xdg-shell-client-protocol.h"
+#include <Ecore_Wayland.h>
+
+typedef struct _EomWaylandClientInfo {
+       /* wl */
+       struct wl_display *display;
+       struct wl_registry *registry;
+
+       struct wl_eom *eom;
+
+       /* eom wayland output list */
+       struct wl_list eom_wl_output_list;
+       int num_outputs;
+
+       notify_func func;
+} EomWaylandClientInfo;
+
+typedef struct _EomWaylandOutput {
+       eom_output_id id;
+       struct wl_output *output;
+
+       /* current output data */
+       int32_t x;
+       int32_t y;
+       int32_t physical_width;
+       int32_t physical_height;
+       enum wl_output_subpixel subpixel;
+       const char *make;
+       const char *model;
+       enum wl_output_transform transform;
+
+       uint32_t flags;
+       int32_t width;
+       int32_t height;
+       int32_t refresh;
+
+       int32_t factor;
+
+       /* current eom data */
+       enum wl_eom_type eom_type;
+       enum wl_eom_status eom_status;
+       enum wl_eom_mode eom_mode;
+       enum wl_eom_attribute eom_attribute;
+       enum wl_eom_attribute_state eom_attribute_state;
+
+       /* client info */
+       EomWaylandClientInfo *client_info;
+
+       struct wl_list link;
+} EomWaylandOutput;
+
+static EomWaylandClientInfo wl_client_info;
+static int eom_wayland_init = 0;
+
+static eom_output_type_e
+_convert_to_eom_output_type(enum wl_eom_type eom_type)
+{
+       eom_output_type_e output_type = EOM_OUTPUT_TYPE_UNKNOWN;
+       switch (eom_type) {
+       case WL_EOM_TYPE_NONE:
+               output_type = EOM_OUTPUT_TYPE_UNKNOWN;
+               break;
+       case WL_EOM_TYPE_VGA:
+               output_type = EOM_OUTPUT_TYPE_VGA;
+               break;
+       case WL_EOM_TYPE_DIVI:
+               output_type = EOM_OUTPUT_TYPE_DVII;;
+               break;
+       case WL_EOM_TYPE_DIVD:
+               output_type = EOM_OUTPUT_TYPE_DVID;
+               break;
+       case WL_EOM_TYPE_DIVA:
+               output_type = EOM_OUTPUT_TYPE_DVIA;
+               break;
+       case WL_EOM_TYPE_COMPOSITE:
+               output_type = EOM_OUTPUT_TYPE_COMPOSITE;
+               break;
+       case WL_EOM_TYPE_SVIDEO:
+               output_type = EOM_OUTPUT_TYPE_SVIDEO;
+               break;
+       case WL_EOM_TYPE_LVDS:
+               output_type = EOM_OUTPUT_TYPE_LVDS;
+               break;
+       case WL_EOM_TYPE_COMPONENT:
+               output_type = EOM_OUTPUT_TYPE_COMPONENT;
+               break;
+       case WL_EOM_TYPE_9PINDIN:
+               output_type = EOM_OUTPUT_TYPE_9PINDIN;
+               break;
+       case WL_EOM_TYPE_DISPLAYPORT:
+               output_type = EOM_OUTPUT_TYPE_DISPLAYPORT;
+               break;
+       case WL_EOM_TYPE_HDMIA:
+               output_type = EOM_OUTPUT_TYPE_HDMIA;
+               break;
+       case WL_EOM_TYPE_HDMIB:
+               output_type = EOM_OUTPUT_TYPE_HDMIB;
+               break;
+       case WL_EOM_TYPE_TV:
+               output_type = EOM_OUTPUT_TYPE_TV;
+               break;
+       case WL_EOM_TYPE_EDP:
+               output_type = EOM_OUTPUT_TYPE_EDP;
+               break;
+       case WL_EOM_TYPE_VIRTUAL:
+               output_type = EOM_OUTPUT_TYPE_VIRTUAL;
+               break;
+       case WL_EOM_TYPE_DSI:
+               output_type = EOM_OUTPUT_TYPE_DSI;
+               break;
+       default:
+               ERR("no type.");
+               break;
+       }
+
+       return output_type;
+}
+
+static eom_output_mode_e
+_convert_to_eom_output_mode(enum wl_eom_mode eom_mode)
+{
+       eom_output_mode_e output_mode = EOM_OUTPUT_MODE_NONE;
+       switch (eom_mode) {
+       case WL_EOM_MODE_NONE:
+               output_mode = EOM_OUTPUT_MODE_NONE;
+               break;
+       case WL_EOM_MODE_MIRROR:
+               output_mode = EOM_OUTPUT_MODE_MIRROR;
+               break;
+       case WL_EOM_MODE_PRESENTATION:
+               output_mode = EOM_OUTPUT_MODE_PRESENTATION;
+               break;
+       default:
+               ERR("no mode.");
+               break;
+       }
+
+       return output_mode;
+}
+
+static eom_output_attribute_e
+_convert_to_eom_output_attribute(enum wl_eom_attribute eom_attribute)
+{
+       eom_output_attribute_e output_attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
+       switch (eom_attribute) {
+       case WL_EOM_ATTRIBUTE_NONE:
+               output_attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
+               break;
+       case WL_EOM_ATTRIBUTE_NORMAL:
+               output_attribute = EOM_OUTPUT_ATTRIBUTE_NORMAL;
+               break;
+       case WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARED:
+               output_attribute = EOM_OUTPUT_ATTRIBUTE_EXCLUSIVE_SHARE;
+               break;
+       case WL_EOM_ATTRIBUTE_EXCLUSIVE:
+               output_attribute = EOM_OUTPUT_ATTRIBUTE_EXCLUSIVE;
+               break;
+       default:
+               ERR("no attribute.");
+               break;
+       }
+
+       return output_attribute;
+}
+
+static eom_output_attribute_state_e
+_convert_to_eom_output_attribute_state(enum wl_eom_attribute_state eom_attribute_state)
+{
+       eom_output_attribute_state_e output_attribute_state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
+       switch (eom_attribute_state) {
+       case WL_EOM_ATTRIBUTE_STATE_NONE:
+               output_attribute_state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
+               break;
+       case WL_EOM_ATTRIBUTE_STATE_ACTIVE:
+               output_attribute_state = EOM_OUTPUT_ATTRIBUTE_STATE_ACTIVE;
+               break;
+       case WL_EOM_ATTRIBUTE_STATE_INACTIVE:
+               output_attribute_state = EOM_OUTPUT_ATTRIBUTE_STATE_INACTIVE;
+               break;
+       case WL_EOM_ATTRIBUTE_STATE_LOST:
+               output_attribute_state = EOM_OUTPUT_ATTRIBUTE_STATE_LOST;
+               break;
+       default:
+               ERR("no attribute state.");
+               break;
+       }
+
+       return output_attribute_state;
+}
+
+static enum wl_eom_attribute
+_convert_to_wl_eom_attribute(eom_output_attribute_e attr)
+{
+       enum wl_eom_attribute eom_attribute = WL_EOM_ATTRIBUTE_NONE;
+       switch (attr) {
+       case EOM_OUTPUT_ATTRIBUTE_NONE:
+               eom_attribute = WL_EOM_ATTRIBUTE_NONE;
+               break;
+       case EOM_OUTPUT_ATTRIBUTE_NORMAL:
+               eom_attribute = WL_EOM_ATTRIBUTE_NORMAL;
+               break;
+       case EOM_OUTPUT_ATTRIBUTE_EXCLUSIVE_SHARE:
+               eom_attribute = WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARED;
+               break;
+       case EOM_OUTPUT_ATTRIBUTE_EXCLUSIVE:
+               eom_attribute = WL_EOM_ATTRIBUTE_EXCLUSIVE;
+               break;
+       default:
+               ERR("no wl attribute.");
+               break;
+       }
+
+       return eom_attribute;
+}
+
+
+static void
+_eom_wayland_client_call_notify(EomWaylandOutput *eom_wl_output, eom_output_notify_type_e type)
+{
+       GArray *array = NULL;
+       GValue v = G_VALUE_INIT;
+
+       array = g_array_new(FALSE, FALSE, sizeof(GValue));
+
+       /* 11 args 0: notify_type 1:output_id, 2:output_type, 3:output_mode, 4:w, 5:h, 6:w_mm, 7:h_mm, 8:pid, 9:attri, 10:state */
+       /* 0: notify_type */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, type);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 1:output_id */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->id);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 2:output_type */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, _convert_to_eom_output_type(eom_wl_output->eom_type));
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 3:output_mode */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, _convert_to_eom_output_mode(eom_wl_output->eom_mode));
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 4:w */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->width);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 5:h */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->height);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 6:w_mm */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->physical_width);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 7:h_mm */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->physical_height);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 8:pid */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->physical_width);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 9:attri */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, _convert_to_eom_output_attribute(eom_wl_output->eom_attribute));
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 10:state */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, _convert_to_eom_output_attribute_state(eom_wl_output->eom_attribute_state));
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       if (eom_wl_output->client_info->func)
+               eom_wl_output->client_info->func(NULL, array);
+
+       if (array)
+               g_array_free(array, FALSE);
+
+}
+
+
+static EomWaylandOutput *
+_eom_wayland_client_find_output_from_wl_output(struct wl_list *eom_wl_output_list, struct wl_output *output)
+{
+       EomWaylandOutput *eom_wl_output = NULL;
+       EomWaylandOutput *tmp = NULL;
+       EomWaylandOutput *ret = NULL;
+
+       /* remove all eom_wl_outputs */
+       if (!wl_list_empty(eom_wl_output_list)) {
+               wl_list_for_each_safe(eom_wl_output, tmp, eom_wl_output_list, link) {
+                       if (eom_wl_output->output == output) {
+                               ret = eom_wl_output;
+                               break;
+                       }
+               }
+       }
+
+       return ret;
+}
+
+static EomWaylandOutput *
+_eom_wayland_client_find_output_from_eom_output(struct wl_list *eom_wl_output_list, eom_output_id id)
+{
+       EomWaylandOutput *eom_wl_output = NULL;
+       EomWaylandOutput *tmp = NULL;
+       EomWaylandOutput *ret = NULL;
+
+       /* remove all eom_wl_outputs */
+       if (!wl_list_empty(eom_wl_output_list)) {
+               wl_list_for_each_safe(eom_wl_output, tmp, eom_wl_output_list, link) {
+                       if (eom_wl_output->id == id) {
+                               ret = eom_wl_output;
+                               break;
+                       }
+               }
+       }
+
+       return ret;
+}
+
+
+static void
+_eom_wl_output_handle_geometry(void *data,
+                       struct wl_output *wl_output,
+                       int32_t x,
+                       int32_t y,
+                       int32_t physical_width,
+                       int32_t physical_height,
+                       int32_t subpixel,
+                       const char *make,
+                       const char *model,
+                       int32_t transform)
+{
+       EomWaylandOutput *eom_wl_output = (EomWaylandOutput *) data;
+
+       INFO("wl_output:%p x:%d y:%d phy_w:%d phy_h:%d subpixel:%d make:%s model:%s transform:%d\n",
+               wl_output, x, y, physical_width, physical_height, subpixel, make, model, transform);
+
+       /* save vaules if it is different before */
+       if (eom_wl_output->x != x)
+               eom_wl_output->x = x;
+       if (eom_wl_output->y != y)
+               eom_wl_output->y = y;
+       if (eom_wl_output->physical_height)
+               eom_wl_output->physical_height = physical_height;
+       if (eom_wl_output->physical_width)
+               eom_wl_output->physical_width = physical_width;
+       if (eom_wl_output->subpixel)
+               eom_wl_output->subpixel = subpixel;
+       if (eom_wl_output->transform)
+               eom_wl_output->transform = transform;
+
+}
+
+
+static void
+_eom_wl_output_handle_mode(void *data,
+                       struct wl_output *wl_output,
+                       uint32_t flags,
+                       int32_t width,
+                       int32_t height,
+                       int32_t refresh)
+{
+       EomWaylandOutput *eom_wl_output = (EomWaylandOutput *) data;
+
+       INFO("wl_output:%p flags:%d width:%d height:%d refresh:%d\n",
+               wl_output, flags, width, height, refresh);
+
+       /* save vaules if it is different before */
+       if (eom_wl_output->flags != flags)
+               eom_wl_output->flags = flags;
+       if (eom_wl_output->width != width)
+               eom_wl_output->width = width;
+       if (eom_wl_output->height != height)
+               eom_wl_output->height = height;
+       if (eom_wl_output->refresh != refresh)
+               eom_wl_output->refresh = refresh;
+}
+
+static void
+_eom_wl_output_handle_done(void *data,
+                       struct wl_output *wl_output)
+{
+       INFO("wl_output:%p\n", wl_output);
+}
+
+static void
+_eom_wl_output_handle_scale(void *data,
+                       struct wl_output *wl_output,
+                       int32_t factor)
+{
+       EomWaylandOutput *eom_wl_output = (EomWaylandOutput *) data;
+
+       INFO("wl_output:%p factor:%d\n", wl_output, factor);
+
+       /* save vaules if it is different before */
+       if (eom_wl_output->factor != factor)
+               eom_wl_output->factor = factor;
+}
+
+static const struct wl_output_listener eom_wl_output_listener = {
+       _eom_wl_output_handle_geometry,
+       _eom_wl_output_handle_mode,
+       _eom_wl_output_handle_done,
+       _eom_wl_output_handle_scale,
+};
+
+static void
+_eom_wl_eom_output_type(void *data,
+                       struct wl_eom *wl_eom,
+                       struct wl_output *output,
+                       uint32_t type,
+                       uint32_t status)
+{
+       EomWaylandClientInfo *eom_client_info = (EomWaylandClientInfo *) data;
+       EomWaylandOutput *eom_wl_output = NULL;
+
+       eom_wl_output = _eom_wayland_client_find_output_from_wl_output(&eom_client_info->eom_wl_output_list, output);
+       RET_IF_FAIL(eom_wl_output != NULL);
+
+       /* save the output type */
+       if (eom_wl_output->eom_type != type)
+               eom_wl_output->eom_type = type;
+
+       /* check the connection status and call the notify */
+       if (eom_wl_output->eom_status != status) {
+               eom_wl_output->eom_status = status;
+
+               if (status == WL_EOM_STATUS_CONNECTION)
+                       _eom_wayland_client_call_notify(eom_wl_output, EOM_OUTPUT_NOTIFY_ADD);
+               else if (status == WL_EOM_STATUS_DISCONNECTION)
+                       _eom_wayland_client_call_notify(eom_wl_output, EOM_OUTPUT_NOTIFY_REMOVE);
+       }
+}
+
+static void
+_eom_wl_eom_output_mode(void *data,
+                       struct wl_eom *wl_eom,
+                       struct wl_output *output,
+                       uint32_t mode)
+{
+       EomWaylandClientInfo *eom_client_info = (EomWaylandClientInfo *) data;
+       EomWaylandOutput *eom_wl_output = NULL;
+
+       eom_wl_output = _eom_wayland_client_find_output_from_wl_output(&eom_client_info->eom_wl_output_list, output);
+       RET_IF_FAIL(eom_wl_output != NULL);
+
+       /* check the eom mode and call the notify */
+       if (eom_wl_output->eom_mode != mode) {
+               eom_wl_output->eom_mode = mode;
+
+               _eom_wayland_client_call_notify(eom_wl_output, EOM_OUTPUT_NOTIFY_MODE_CHANGED);
+       }
+}
+
+static void
+_eom_wl_eom_output_attribute(void *data,
+                        struct wl_eom *wl_eom,
+                        struct wl_output *output,
+                        uint32_t attribute,
+                        uint32_t attribute_state,
+                        uint32_t error)
+{
+       EomWaylandClientInfo *eom_client_info = (EomWaylandClientInfo *) data;
+       EomWaylandOutput *eom_wl_output = NULL;
+
+       eom_wl_output = _eom_wayland_client_find_output_from_wl_output(&eom_client_info->eom_wl_output_list, output);
+       RET_IF_FAIL(eom_wl_output != NULL);
+
+       /* check the eom attribute and call the notify */
+       if (eom_wl_output->eom_attribute != attribute || eom_wl_output->eom_attribute_state != attribute_state) {
+               eom_wl_output->eom_attribute = attribute;
+               eom_wl_output->eom_attribute_state = attribute_state;
+
+               _eom_wayland_client_call_notify(eom_wl_output, EOM_OUTPUT_NOTIFY_ATTRIBUTE_CHANGED);
+       }
+}
+
+
+static const struct wl_eom_listener eom_wl_eom_listener = {
+       _eom_wl_eom_output_type,
+       _eom_wl_eom_output_mode,
+       _eom_wl_eom_output_attribute,
+};
+
+
+static void
+_eom_wl_registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
+{
+       EomWaylandClientInfo *ci = (EomWaylandClientInfo *)data;
+       EomWaylandOutput *eom_wl_output = NULL;
+       struct wl_output *output = NULL;
+       struct wl_eom *eom = NULL;
+
+       if (strcmp(interface, "wl_output") == 0) {
+               output = wl_registry_bind(registry, name, &wl_output_interface, 1);
+               if (!output)
+                       ERR("Error. fail to bind  %s.\n", interface);
+               else {
+                       INFO("bind %s.\n", interface);
+
+                       /* create the eom_wl_output */
+                       eom_wl_output = calloc(1, sizeof(EomWaylandOutput));
+                       if (!eom_wl_output) {
+                               ERR("error. fail to allocate the eom_output.\n");
+                               return;
+                       }
+                       ci->num_outputs++;
+                       eom_wl_output->id = ci->num_outputs;
+                       eom_wl_output->output = output;
+                       wl_list_insert(&ci->eom_wl_output_list, &eom_wl_output->link);
+
+                       /* add listener */
+                       wl_output_add_listener(eom_wl_output->output, &eom_wl_output_listener, eom_wl_output);
+               }
+       } else if (strcmp(interface, "wl_eom") == 0) {
+               eom = wl_registry_bind(registry, name, &wl_eom_interface, 1);
+               if (!eom)
+                       ERR("Error. fail to bind  %s.\n", interface);
+               else {
+                       INFO("bind %s.\n", interface);
+
+                       ci->eom = eom;
+
+                       /* add listener */
+                       wl_eom_add_listener(ci->eom, &eom_wl_eom_listener, ci);
+               }
+       } else
+               INFO("Not bind %s.\n", interface);
+}
+
+static void
+_eom_wl_registry_handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
+{
+
+}
+
+static const struct wl_registry_listener eom_registry_listener = {
+       _eom_wl_registry_handle_global,
+       _eom_wl_registry_handle_global_remove
+};
+
+static bool
+_eom_wayland_client_initialize()
+{
+       int ecore_count = -1;
+
+       ecore_count = ecore_wl_init(NULL);
+       GOTO_IF_FAIL(ecore_count > 0, fail);
+
+       wl_list_init(&wl_client_info.eom_wl_output_list);
+
+       wl_client_info.display = ecore_wl_display_get();
+       GOTO_IF_FAIL(wl_client_info.display != NULL, fail);
+
+       /* get the registry */
+       wl_client_info.registry = wl_display_get_registry(wl_client_info.display);
+       GOTO_IF_FAIL(wl_client_info.registry != NULL, fail);
+
+       /* get the global objects */
+       wl_registry_add_listener(wl_client_info.registry, &eom_registry_listener, &wl_client_info);
+       wl_display_dispatch(wl_client_info.display);
+       wl_display_roundtrip(wl_client_info.display);
+
+       /* remove type none eom_wl_outputs */
+       if (!wl_list_empty(&wl_client_info.eom_wl_output_list)) {
+               EomWaylandOutput *eom_wl_output = NULL;
+               EomWaylandOutput *tmp = NULL;
+
+               wl_list_for_each_safe(eom_wl_output, tmp, &wl_client_info.eom_wl_output_list, link) {
+                       if (eom_wl_output->eom_type == WL_EOM_TYPE_NONE) {
+                               WARN("[EOM_CLIENT] eom_type is NONE. remove.\n");
+                               wl_output_destroy(eom_wl_output->output);
+                               wl_list_remove(&eom_wl_output->link);
+                               free(eom_wl_output);
+                               eom_wl_output = NULL;
+                       }
+               }
+       }
+
+       /* output list */
+       if (wl_list_empty(&wl_client_info.eom_wl_output_list))
+               WARN("[EOM_CLIENT] no wl output at this device.\n");
+
+       INFO("[EOM_CLIENT] wayland client init.");
+
+       return true;
+fail:
+       return false;
+}
+
+static void
+_eom_wayland_client_deinitialize()
+{
+       EomWaylandOutput *eom_wl_output = NULL;
+       EomWaylandOutput *tmp = NULL;
+
+       /* remove all eom_wl_outputs */
+       if (!wl_list_empty(&wl_client_info.eom_wl_output_list)) {
+               wl_list_for_each_safe(eom_wl_output, tmp, &wl_client_info.eom_wl_output_list, link) {
+                       if (eom_wl_output->output)
+                               wl_output_destroy(eom_wl_output->output);
+                       free(eom_wl_output);
+                       eom_wl_output = NULL;
+               }
+       }
+
+       ecore_wl_shutdown();
+
+       INFO("[EOM_CLIENT] wayland client deinit.");
+}
+
+bool
+eom_wayland_client_init(notify_func func)
+{
+       bool ret = false;
+
+       if (eom_wayland_init) return true;
+
+       ret = _eom_wayland_client_initialize();
+       GOTO_IF_FAIL(ret != false, fail);
+
+       wl_client_info.func = func;
+
+       eom_wayland_init = 1;
+
+       return ret;
+fail:
+       return false;
+}
+
+void
+eom_wayland_client_deinit(GList *cb_info_list)
+{
+       if (!eom_wayland_init)
+               return;
+
+       _eom_wayland_client_deinitialize();
+
+       eom_wayland_init = 0;
+
+       memset(&wl_client_info, 0x0, sizeof(EomWaylandClientInfo));
+}
+
+GArray *
+eom_wayland_client_get_output_ids(void)
+{
+       GArray *array = NULL;
+       GValue v = G_VALUE_INIT;
+       EomWaylandOutput *eom_wl_output = NULL;
+       EomWaylandOutput *tmp = NULL;
+
+       if (wl_list_empty(&wl_client_info.eom_wl_output_list)) {
+               ERR("error. no outputs.\n");
+               return NULL;
+       }
+
+       array = g_array_new(FALSE, FALSE, sizeof(GValue));
+
+       /* remove all eom_wl_outputs */
+       wl_list_for_each_safe(eom_wl_output, tmp, &wl_client_info.eom_wl_output_list, link) {
+               if (eom_wl_output->output) {
+                       g_value_init(&v, G_TYPE_INT);
+                       g_value_set_int(&v, eom_wl_output->id);
+                       array = g_array_append_val(array, v);
+                       g_value_unset(&v);
+               }
+       }
+
+       /* returned array will be freed by caller */
+       return array;
+}
+
+GArray *
+eom_wayland_client_get_output_info(eom_output_id output_id)
+{
+       GArray *array = NULL;
+       GValue v = G_VALUE_INIT;
+       EomWaylandOutput *eom_wl_output = NULL;
+
+       eom_wl_output = _eom_wayland_client_find_output_from_eom_output(&wl_client_info.eom_wl_output_list, output_id);
+       RETV_IF_FAIL(eom_wl_output != NULL, NULL);
+
+       array = g_array_new(FALSE, FALSE, sizeof(GValue));
+
+       /* 0:output_id, 1:output_type, 2:output_mode, 3:w, 4:h, 5:w_mm, 6:h_mm */
+       /* 0:output_id */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->id);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 1:output_type */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->eom_type);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 2:output_mode */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->eom_mode);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 3:w */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->width);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 4:h */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->height);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 5:w_mm */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->physical_width);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* 6:h_mm */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->physical_height);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* returned array will be freed by caller */
+       return array;
+}
+
+GArray *
+eom_wayland_client_set_attribute(eom_output_id output_id, eom_output_attribute_e attr)
+{
+       GArray *array = NULL;
+       GValue v = G_VALUE_INIT;
+       EomWaylandOutput *eom_wl_output = NULL;
+       int ret = 0;
+
+       eom_wl_output = _eom_wayland_client_find_output_from_eom_output(&wl_client_info.eom_wl_output_list, output_id);
+       GOTO_IF_FAIL(eom_wl_output != NULL, fail);
+
+       wl_eom_set_attribute(wl_client_info.eom, eom_wl_output->output, _convert_to_wl_eom_attribute(attr));
+
+       /* TODO: wait for the result of set_attribute. this should be the blocking call. */
+       wl_display_dispatch(wl_client_info.display);
+       wl_display_roundtrip(wl_client_info.display);
+
+       ret = 1;
+
+       array = g_array_new(FALSE, FALSE, sizeof(GValue));
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, ret);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* returned array will be freed by caller */
+       return array;
+fail:
+
+       return NULL;
+}
+
+GArray *
+eom_wayland_client_set_window(eom_output_id output_id, Evas_Object *win)
+{
+       GArray *array = NULL;
+       GValue v = G_VALUE_INIT;
+       Ecore_Wl_Window *e_wl_win = NULL;
+       EomWaylandOutput *eom_wl_output = NULL;
+       struct wl_shell_surface *shell_surface = NULL;
+       struct xdg_surface *xdg_shell_surface = NULL;
+       int ret = 0;
+
+       e_wl_win = elm_win_wl_window_get(win);
+       GOTO_IF_FAIL(e_wl_win != NULL, fail);
+
+       eom_wl_output = _eom_wayland_client_find_output_from_eom_output(&wl_client_info.eom_wl_output_list, output_id);
+       GOTO_IF_FAIL(eom_wl_output != NULL, fail);
+
+       /* set full screen at output */
+       xdg_shell_surface = ecore_wl_window_xdg_surface_get(e_wl_win);
+       if (xdg_shell_surface) {
+               xdg_surface_set_fullscreen(xdg_shell_surface, eom_wl_output->output);
+       } else {
+               shell_surface = ecore_wl_window_shell_surface_get(e_wl_win);
+               if (shell_surface) {
+                       wl_shell_surface_set_fullscreen(shell_surface,
+                                                                                 WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
+                                                                                 0, eom_wl_output->output);
+               } else {
+                       ERR("no wl surface.\n");
+                       goto fail;
+               }
+       }
+
+       ret = 1;
+
+       array = g_array_new(FALSE, FALSE, sizeof(GValue));
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, ret);
+       array = g_array_append_val(array, v);
+       g_value_unset(&v);
+
+       /* returned array will be freed by caller */
+       return array;
+fail:
+
+       return NULL;
+}
+
diff --git a/src/wayland/eom-wayland.h b/src/wayland/eom-wayland.h
new file mode 100755 (executable)
index 0000000..1c3d617
--- /dev/null
@@ -0,0 +1,51 @@
+/**************************************************************************
+
+eom (external output manager)
+
+Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+SooChan Lim <sc1.lim@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __EOM_WAYLAND_H__
+#define __EOM_WAYLAND_H__
+
+#include <stdbool.h>
+#include <glib.h>
+#include <glib-object.h>
+#include "eom.h"
+#include "eom-private.h"
+
+bool eom_wayland_client_init(notify_func func);
+void eom_wayland_client_deinit(GList *cb_info_list);
+
+GArray *eom_wayland_client_get_output_ids(void);
+GArray *eom_wayland_client_get_output_info(eom_output_id output_id);
+GArray *eom_wayland_client_set_attribute(eom_output_id output_id, eom_output_attribute_e attry);
+GArray *eom_wayland_client_set_window(eom_output_id output_id, Evas_Object *win);
+
+
+#endif /* __EOM_WAYLAND_H__ */
+
diff --git a/src/wayland/protocol/eom-client-protocol.h b/src/wayland/protocol/eom-client-protocol.h
new file mode 100644 (file)
index 0000000..9f91c45
--- /dev/null
@@ -0,0 +1,229 @@
+#ifndef WL_EOM_CLIENT_PROTOCOL_H
+#define WL_EOM_CLIENT_PROTOCOL_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-client.h"
+
+struct wl_client;
+struct wl_resource;
+
+struct wl_eom;
+
+extern const struct wl_interface wl_eom_interface;
+
+#ifndef WL_EOM_ERROR_ENUM
+#define WL_EOM_ERROR_ENUM
+enum wl_eom_error {
+       WL_EOM_ERROR_NONE = 0,
+       WL_EOM_ERROR_NO_OUTPUT = 1,
+       WL_EOM_ERROR_NO_ATTRIBUTE = 2,
+       WL_EOM_ERROR_OUTPUT_OCCUPIED = 3,
+};
+#endif /* WL_EOM_ERROR_ENUM */
+
+#ifndef WL_EOM_TYPE_ENUM
+#define WL_EOM_TYPE_ENUM
+/**
+ * wl_eom_type - connector type of the external output
+ * @WL_EOM_TYPE_NONE: none
+ * @WL_EOM_TYPE_VGA: VGA output connector type
+ * @WL_EOM_TYPE_DIVI: VGA output connector type
+ * @WL_EOM_TYPE_DIVD: VGA output connector type
+ * @WL_EOM_TYPE_DIVA: VGA output connector type
+ * @WL_EOM_TYPE_COMPOSITE: VGA output connector type
+ * @WL_EOM_TYPE_SVIDEO: VGA output connector type
+ * @WL_EOM_TYPE_LVDS: VGA output connector type
+ * @WL_EOM_TYPE_COMPONENT: VGA output connector type
+ * @WL_EOM_TYPE_9PINDIN: VGA output connector type
+ * @WL_EOM_TYPE_DISPLAYPORT: VGA output connector type
+ * @WL_EOM_TYPE_HDMIA: VGA output connector type
+ * @WL_EOM_TYPE_HDMIB: VGA output connector type
+ * @WL_EOM_TYPE_TV: VGA output connector type
+ * @WL_EOM_TYPE_EDP: VGA output connector type
+ * @WL_EOM_TYPE_VIRTUAL: VGA output connector type
+ * @WL_EOM_TYPE_DSI: VGA output connector type
+ *
+ * ***** TODO ******
+ */
+enum wl_eom_type {
+       WL_EOM_TYPE_NONE = 0,
+       WL_EOM_TYPE_VGA = 1,
+       WL_EOM_TYPE_DIVI = 2,
+       WL_EOM_TYPE_DIVD = 3,
+       WL_EOM_TYPE_DIVA = 4,
+       WL_EOM_TYPE_COMPOSITE = 5,
+       WL_EOM_TYPE_SVIDEO = 6,
+       WL_EOM_TYPE_LVDS = 7,
+       WL_EOM_TYPE_COMPONENT = 8,
+       WL_EOM_TYPE_9PINDIN = 9,
+       WL_EOM_TYPE_DISPLAYPORT = 10,
+       WL_EOM_TYPE_HDMIA = 11,
+       WL_EOM_TYPE_HDMIB = 12,
+       WL_EOM_TYPE_TV = 13,
+       WL_EOM_TYPE_EDP = 14,
+       WL_EOM_TYPE_VIRTUAL = 15,
+       WL_EOM_TYPE_DSI = 16,
+};
+#endif /* WL_EOM_TYPE_ENUM */
+
+#ifndef WL_EOM_STATUS_ENUM
+#define WL_EOM_STATUS_ENUM
+/**
+ * wl_eom_status - connection status of the external output
+ * @WL_EOM_STATUS_NONE: none
+ * @WL_EOM_STATUS_CONNECTION: output connected
+ * @WL_EOM_STATUS_DISCONNECTION: output disconnected
+ *
+ * ***** TODO ******
+ */
+enum wl_eom_status {
+       WL_EOM_STATUS_NONE = 0,
+       WL_EOM_STATUS_CONNECTION = 1,
+       WL_EOM_STATUS_DISCONNECTION = 2,
+};
+#endif /* WL_EOM_STATUS_ENUM */
+
+#ifndef WL_EOM_MODE_ENUM
+#define WL_EOM_MODE_ENUM
+/**
+ * wl_eom_mode - mode of the external output
+ * @WL_EOM_MODE_NONE: none
+ * @WL_EOM_MODE_MIRROR: mirror mode
+ * @WL_EOM_MODE_PRESENTATION: presentation mode
+ *
+ * ***** TODO ******
+ */
+enum wl_eom_mode {
+       WL_EOM_MODE_NONE = 0,
+       WL_EOM_MODE_MIRROR = 1,
+       WL_EOM_MODE_PRESENTATION = 2,
+};
+#endif /* WL_EOM_MODE_ENUM */
+
+#ifndef WL_EOM_ATTRIBUTE_ENUM
+#define WL_EOM_ATTRIBUTE_ENUM
+/**
+ * wl_eom_attribute - attribute of the external output
+ * @WL_EOM_ATTRIBUTE_NONE: none
+ * @WL_EOM_ATTRIBUTE_NORMAL: nomal attribute
+ * @WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARED: exclusive shared attribute
+ * @WL_EOM_ATTRIBUTE_EXCLUSIVE: exclusive attribute
+ *
+ * ***** TODO ******
+ */
+enum wl_eom_attribute {
+       WL_EOM_ATTRIBUTE_NONE = 0,
+       WL_EOM_ATTRIBUTE_NORMAL = 1,
+       WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARED = 2,
+       WL_EOM_ATTRIBUTE_EXCLUSIVE = 3,
+};
+#endif /* WL_EOM_ATTRIBUTE_ENUM */
+
+#ifndef WL_EOM_ATTRIBUTE_STATE_ENUM
+#define WL_EOM_ATTRIBUTE_STATE_ENUM
+/**
+ * wl_eom_attribute_state - state of the external output attribute
+ * @WL_EOM_ATTRIBUTE_STATE_NONE: none
+ * @WL_EOM_ATTRIBUTE_STATE_ACTIVE: attribute is active on the output
+ * @WL_EOM_ATTRIBUTE_STATE_INACTIVE: attribute is inactive on the output
+ * @WL_EOM_ATTRIBUTE_STATE_LOST: the connection of output is lost
+ *
+ * ***** TODO ******
+ */
+enum wl_eom_attribute_state {
+       WL_EOM_ATTRIBUTE_STATE_NONE = 0,
+       WL_EOM_ATTRIBUTE_STATE_ACTIVE = 1,
+       WL_EOM_ATTRIBUTE_STATE_INACTIVE = 2,
+       WL_EOM_ATTRIBUTE_STATE_LOST = 3,
+};
+#endif /* WL_EOM_ATTRIBUTE_STATE_ENUM */
+
+/**
+ * wl_eom - an interface to get the information of the external outputs
+ * @output_type: (none)
+ * @output_mode: (none)
+ * @output_attribute: (none)
+ *
+ * ***** TODO ******
+ */
+struct wl_eom_listener {
+       /**
+        * output_type - (none)
+        * @output: (none)
+        * @type: (none)
+        * @status: (none)
+        */
+       void (*output_type)(void *data,
+                           struct wl_eom *wl_eom,
+                           struct wl_output *output,
+                           uint32_t type,
+                           uint32_t status);
+       /**
+        * output_mode - (none)
+        * @output: (none)
+        * @mode: (none)
+        */
+       void (*output_mode)(void *data,
+                           struct wl_eom *wl_eom,
+                           struct wl_output *output,
+                           uint32_t mode);
+       /**
+        * output_attribute - (none)
+        * @output: (none)
+        * @attribute: (none)
+        * @attribute_state: (none)
+        * @error: (none)
+        */
+       void (*output_attribute)(void *data,
+                                struct wl_eom *wl_eom,
+                                struct wl_output *output,
+                                uint32_t attribute,
+                                uint32_t attribute_state,
+                                uint32_t error);
+};
+
+static inline int
+wl_eom_add_listener(struct wl_eom *wl_eom,
+                   const struct wl_eom_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) wl_eom,
+                                    (void (**)(void)) listener, data);
+}
+
+#define WL_EOM_SET_ATTRIBUTE   0
+
+static inline void
+wl_eom_set_user_data(struct wl_eom *wl_eom, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) wl_eom, user_data);
+}
+
+static inline void *
+wl_eom_get_user_data(struct wl_eom *wl_eom)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) wl_eom);
+}
+
+static inline void
+wl_eom_destroy(struct wl_eom *wl_eom)
+{
+       wl_proxy_destroy((struct wl_proxy *) wl_eom);
+}
+
+static inline void
+wl_eom_set_attribute(struct wl_eom *wl_eom, struct wl_output *output, uint32_t attribute)
+{
+       wl_proxy_marshal((struct wl_proxy *) wl_eom,
+                        WL_EOM_SET_ATTRIBUTE, output, attribute);
+}
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/wayland/protocol/eom-protocol.c b/src/wayland/protocol/eom-protocol.c
new file mode 100644 (file)
index 0000000..fc7ccc7
--- /dev/null
@@ -0,0 +1,36 @@
+#include <stdlib.h>
+#include <stdint.h>
+#include "wayland-util.h"
+
+extern const struct wl_interface wl_output_interface;
+
+static const struct wl_interface *types[] = {
+       &wl_output_interface,
+       NULL,
+       &wl_output_interface,
+       NULL,
+       NULL,
+       &wl_output_interface,
+       NULL,
+       &wl_output_interface,
+       NULL,
+       NULL,
+       NULL,
+};
+
+static const struct wl_message wl_eom_requests[] = {
+       { "set_attribute", "ou", types + 0 },
+};
+
+static const struct wl_message wl_eom_events[] = {
+       { "output_type", "ouu", types + 2 },
+       { "output_mode", "ou", types + 5 },
+       { "output_attribute", "ouuu", types + 7 },
+};
+
+WL_EXPORT const struct wl_interface wl_eom_interface = {
+       "wl_eom", 1,
+       1, wl_eom_requests,
+       3, wl_eom_events,
+};
+
diff --git a/src/wayland/protocol/eom.xml b/src/wayland/protocol/eom.xml
new file mode 100644 (file)
index 0000000..ed162a9
--- /dev/null
@@ -0,0 +1,102 @@
+<protocol name="wl_eom">
+  <interface name="wl_eom" version="1">
+    <description summary="an interface to get the information of the external outputs">
+      ***** TODO ******
+    </description>
+
+    <enum name="error">
+      <entry name="none" value="0" summary="no error"/>
+      <entry name="no_output" value="1" summary="Given output is invalid."/>
+      <entry name="no_attribute" value="2" summary="Given attribute is invalid."/>
+      <entry name="output_occupied" value="3" summary="The key has been grabbed already."/>
+    </enum>
+
+    <enum name="type">
+      <description summary="connector type of the external output">
+      ***** TODO ******
+      </description>
+      <entry name="none" value="0" summary="none"/>
+      <entry name="vga" value="1" summary="VGA output connector type"/>
+      <entry name="divi" value="2" summary="VGA output connector type"/>
+      <entry name="divd" value="3" summary="VGA output connector type"/>
+      <entry name="diva" value="4" summary="VGA output connector type"/>
+      <entry name="composite" value="5" summary="VGA output connector type"/>
+      <entry name="svideo" value="6" summary="VGA output connector type"/>
+      <entry name="lvds" value="7" summary="VGA output connector type"/>
+      <entry name="component" value="8" summary="VGA output connector type"/>
+      <entry name="9pindin" value="9" summary="VGA output connector type"/>
+      <entry name="displayport" value="10" summary="VGA output connector type"/>
+      <entry name="hdmia" value="11" summary="VGA output connector type"/>
+      <entry name="hdmib" value="12" summary="VGA output connector type"/>
+      <entry name="tv" value="13" summary="VGA output connector type"/>
+      <entry name="edp" value="14" summary="VGA output connector type"/>
+      <entry name="virtual" value="15" summary="VGA output connector type"/>
+      <entry name="dsi" value="16" summary="VGA output connector type"/>
+    </enum>
+
+   <enum name="status">
+      <description summary="connection status of the external output">
+      ***** TODO ******
+      </description>
+      <entry name="none" value="0" summary="none"/>
+      <entry name="connection" value="1" summary="output connected"/>
+      <entry name="disconnection" value="2" summary="output disconnected"/>
+    </enum>
+
+   <enum name="mode">
+      <description summary="mode of the external output">
+      ***** TODO ******
+      </description>
+      <entry name="none" value="0" summary="none"/>
+      <entry name="mirror" value="1" summary="mirror mode"/>
+      <entry name="presentation" value="2" summary="presentation mode"/>
+    </enum>
+
+   <enum name="attribute">
+      <description summary="attribute of the external output">
+      ***** TODO ******
+      </description>
+      <entry name="none" value="0" summary="none"/>
+      <entry name="normal" value="1" summary="nomal attribute"/>
+      <entry name="exclusive_shared" value="2" summary="exclusive shared attribute"/>
+      <entry name="exclusive" value="3" summary="exclusive attribute"/>
+    </enum>
+
+   <enum name="attribute_state">
+      <description summary="state of the external output attribute">
+      ***** TODO ******
+      </description>
+      <entry name="none" value="0" summary="none"/>
+      <entry name="active" value="1" summary="attribute is active on the output"/>
+      <entry name="inactive" value="2" summary="attribute is inactive on the output"/>
+      <entry name="lost" value="3" summary="the connection of output is lost"/>
+    </enum>
+
+    <request name="set_attribute">
+      <arg name="output" type="object" interface="wl_output"/>
+      <arg name="attribute" type="uint"/>
+    </request>
+
+    <event name="output_type">
+      <arg name="output" type="object" interface="wl_output"/>
+      <arg name="type" type="uint"/>
+      <arg name="status" type="uint"/>
+      <arg name="error" type="uint"/>
+    </event>
+
+    <event name="output_mode">
+      <arg name="output" type="object" interface="wl_output"/>
+      <arg name="mode" type="uint"/>
+      <arg name="error" type="uint"/>
+    </event>
+
+    <event name="output_attribute">
+      <arg name="output" type="object" interface="wl_output"/>
+      <arg name="attribute" type="uint"/>
+      <arg name="attribute_state" type="uint"/>
+      <arg name="error" type="uint"/>
+    </event>
+
+  </interface>
+</protocol>
+
diff --git a/src/wayland/protocol/xdg-shell-client-protocol.h b/src/wayland/protocol/xdg-shell-client-protocol.h
new file mode 100644 (file)
index 0000000..ed743fd
--- /dev/null
@@ -0,0 +1,496 @@
+/*
+ * Copyright © 2008-2013 Kristian Høgsberg
+ * Copyright © 2013      Rafael Antognolli
+ * Copyright © 2013      Jasper St. Pierre
+ * Copyright © 2010-2013 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this
+ * software and its documentation for any purpose is hereby granted
+ * without fee, provided that the above copyright notice appear in
+ * all copies and that both that copyright notice and this permission
+ * notice appear in supporting documentation, and that the name of
+ * the copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+
+#ifndef XDG_SHELL_CLIENT_PROTOCOL_H
+#define XDG_SHELL_CLIENT_PROTOCOL_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-client.h"
+
+struct wl_client;
+struct wl_resource;
+
+struct xdg_shell;
+struct xdg_surface;
+struct xdg_popup;
+
+extern const struct wl_interface xdg_shell_interface;
+extern const struct wl_interface xdg_surface_interface;
+extern const struct wl_interface xdg_popup_interface;
+
+#ifndef XDG_SHELL_VERSION_ENUM
+#define XDG_SHELL_VERSION_ENUM
+/**
+ * xdg_shell_version - latest protocol version
+ * @XDG_SHELL_VERSION_CURRENT: Always the latest version
+ *
+ * The 'current' member of this enum gives the version of the protocol.
+ * Implementations can compare this to the version they implement using
+ * static_assert to ensure the protocol and implementation versions match.
+ */
+enum xdg_shell_version {
+       XDG_SHELL_VERSION_CURRENT = 4,
+};
+#endif /* XDG_SHELL_VERSION_ENUM */
+
+/**
+ * xdg_shell - create desktop-style surfaces
+ * @ping: check if the client is alive
+ *
+ * This interface is implemented by servers that provide desktop-style
+ * user interfaces.
+ *
+ * It allows clients to associate a xdg_surface with a basic surface.
+ */
+struct xdg_shell_listener {
+       /**
+        * ping - check if the client is alive
+        * @serial: pass this to the callback
+        *
+        * The ping event asks the client if it's still alive. Pass the
+        * serial specified in the event back to the compositor by sending
+        * a "pong" request back with the specified serial.
+        *
+        * Compositors can use this to determine if the client is still
+        * alive. It's unspecified what will happen if the client doesn't
+        * respond to the ping request, or in what timeframe. Clients
+        * should try to respond in a reasonable amount of time.
+        */
+       void (*ping)(void *data,
+                    struct xdg_shell *xdg_shell,
+                    uint32_t serial);
+};
+
+static inline int
+xdg_shell_add_listener(struct xdg_shell *xdg_shell,
+                      const struct xdg_shell_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) xdg_shell,
+                                    (void (**)(void)) listener, data);
+}
+
+#define XDG_SHELL_USE_UNSTABLE_VERSION 0
+#define XDG_SHELL_GET_XDG_SURFACE      1
+#define XDG_SHELL_GET_XDG_POPUP        2
+#define XDG_SHELL_PONG 3
+
+static inline void
+xdg_shell_set_user_data(struct xdg_shell *xdg_shell, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) xdg_shell, user_data);
+}
+
+static inline void *
+xdg_shell_get_user_data(struct xdg_shell *xdg_shell)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) xdg_shell);
+}
+
+static inline void
+xdg_shell_destroy(struct xdg_shell *xdg_shell)
+{
+       wl_proxy_destroy((struct wl_proxy *) xdg_shell);
+}
+
+static inline void
+xdg_shell_use_unstable_version(struct xdg_shell *xdg_shell, int32_t version)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_shell,
+                        XDG_SHELL_USE_UNSTABLE_VERSION, version);
+}
+
+static inline struct xdg_surface *
+xdg_shell_get_xdg_surface(struct xdg_shell *xdg_shell, struct wl_surface *surface)
+{
+       struct wl_proxy *id;
+
+       id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_shell,
+                        XDG_SHELL_GET_XDG_SURFACE, &xdg_surface_interface, NULL, surface);
+
+       return (struct xdg_surface *) id;
+}
+
+static inline struct xdg_popup *
+xdg_shell_get_xdg_popup(struct xdg_shell *xdg_shell, struct wl_surface *surface, struct wl_surface *parent, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y, uint32_t flags)
+{
+       struct wl_proxy *id;
+
+       id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_shell,
+                        XDG_SHELL_GET_XDG_POPUP, &xdg_popup_interface, NULL, surface, parent, seat, serial, x, y, flags);
+
+       return (struct xdg_popup *) id;
+}
+
+static inline void
+xdg_shell_pong(struct xdg_shell *xdg_shell, uint32_t serial)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_shell,
+                        XDG_SHELL_PONG, serial);
+}
+
+#ifndef XDG_SURFACE_RESIZE_EDGE_ENUM
+#define XDG_SURFACE_RESIZE_EDGE_ENUM
+/**
+ * xdg_surface_resize_edge - edge values for resizing
+ * @XDG_SURFACE_RESIZE_EDGE_NONE: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_TOP: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_BOTTOM: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_LEFT: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_TOP_LEFT: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_RIGHT: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT: (none)
+ *
+ * These values are used to indicate which edge of a surface is being
+ * dragged in a resize operation. The server may use this information to
+ * adapt its behavior, e.g. choose an appropriate cursor image.
+ */
+enum xdg_surface_resize_edge {
+       XDG_SURFACE_RESIZE_EDGE_NONE = 0,
+       XDG_SURFACE_RESIZE_EDGE_TOP = 1,
+       XDG_SURFACE_RESIZE_EDGE_BOTTOM = 2,
+       XDG_SURFACE_RESIZE_EDGE_LEFT = 4,
+       XDG_SURFACE_RESIZE_EDGE_TOP_LEFT = 5,
+       XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT = 6,
+       XDG_SURFACE_RESIZE_EDGE_RIGHT = 8,
+       XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT = 9,
+       XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT = 10,
+};
+#endif /* XDG_SURFACE_RESIZE_EDGE_ENUM */
+
+#ifndef XDG_SURFACE_STATE_ENUM
+#define XDG_SURFACE_STATE_ENUM
+/**
+ * xdg_surface_state - types of state on the surface
+ * @XDG_SURFACE_STATE_MAXIMIZED: the surface is maximized
+ * @XDG_SURFACE_STATE_FULLSCREEN: the surface is fullscreen
+ * @XDG_SURFACE_STATE_RESIZING: (none)
+ * @XDG_SURFACE_STATE_ACTIVATED: (none)
+ *
+ * The different state values used on the surface. This is designed for
+ * state values like maximized, fullscreen. It is paired with the configure
+ * event to ensure that both the client and the compositor setting the
+ * state can be synchronized.
+ *
+ * States set in this way are double-buffered. They will get applied on the
+ * next commit.
+ *
+ * Desktop environments may extend this enum by taking up a range of values
+ * and documenting the range they chose in this description. They are not
+ * required to document the values for the range that they chose. Ideally,
+ * any good extensions from a desktop environment should make its way into
+ * standardization into this enum.
+ *
+ * The current reserved ranges are:
+ *
+ * 0x0000 - 0x0FFF: xdg-shell core values, documented below. 0x1000 -
+ * 0x1FFF: GNOME
+ */
+enum xdg_surface_state {
+       XDG_SURFACE_STATE_MAXIMIZED = 1,
+       XDG_SURFACE_STATE_FULLSCREEN = 2,
+       XDG_SURFACE_STATE_RESIZING = 3,
+       XDG_SURFACE_STATE_ACTIVATED = 4,
+};
+#endif /* XDG_SURFACE_STATE_ENUM */
+
+/**
+ * xdg_surface - desktop-style metadata interface
+ * @configure: suggest a surface change
+ * @close: surface wants to be closed
+ *
+ * An interface that may be implemented by a wl_surface, for
+ * implementations that provide a desktop-style user interface.
+ *
+ * It provides requests to treat surfaces like windows, allowing to set
+ * properties like maximized, fullscreen, minimized, and to move and resize
+ * them, and associate metadata like title and app id.
+ *
+ * On the server side the object is automatically destroyed when the
+ * related wl_surface is destroyed. On client side, xdg_surface.destroy()
+ * must be called before destroying the wl_surface object.
+ */
+struct xdg_surface_listener {
+       /**
+        * configure - suggest a surface change
+        * @width: (none)
+        * @height: (none)
+        * @states: (none)
+        * @serial: (none)
+        *
+        * The configure event asks the client to resize its surface.
+        *
+        * The width and height arguments specify a hint to the window
+        * about how its surface should be resized in window geometry
+        * coordinates. The states listed in the event specify how the
+        * width/height arguments should be interpreted.
+        *
+        * A client should arrange a new surface, and then send a
+        * ack_configure request with the serial sent in this configure
+        * event before attaching a new surface.
+        *
+        * If the client receives multiple configure events before it can
+        * respond to one, it is free to discard all but the last event it
+        * received.
+        */
+       void (*configure)(void *data,
+                         struct xdg_surface *xdg_surface,
+                         int32_t width,
+                         int32_t height,
+                         struct wl_array *states,
+                         uint32_t serial);
+       /**
+        * close - surface wants to be closed
+        *
+        * The close event is sent by the compositor when the user wants
+        * the surface to be closed. This should be equivalent to the user
+        * clicking the close button in client-side decorations, if your
+        * application has any...
+        *
+        * This is only a request that the user intends to close your
+        * window. The client may choose to ignore this request, or show a
+        * dialog to ask the user to save their data...
+        */
+       void (*close)(void *data,
+                     struct xdg_surface *xdg_surface);
+};
+
+static inline int
+xdg_surface_add_listener(struct xdg_surface *xdg_surface,
+                        const struct xdg_surface_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) xdg_surface,
+                                    (void (**)(void)) listener, data);
+}
+
+#define XDG_SURFACE_DESTROY    0
+#define XDG_SURFACE_SET_PARENT 1
+#define XDG_SURFACE_SET_TITLE  2
+#define XDG_SURFACE_SET_APP_ID 3
+#define XDG_SURFACE_SHOW_WINDOW_MENU   4
+#define XDG_SURFACE_MOVE       5
+#define XDG_SURFACE_RESIZE     6
+#define XDG_SURFACE_ACK_CONFIGURE      7
+#define XDG_SURFACE_SET_WINDOW_GEOMETRY        8
+#define XDG_SURFACE_SET_MAXIMIZED      9
+#define XDG_SURFACE_UNSET_MAXIMIZED    10
+#define XDG_SURFACE_SET_FULLSCREEN     11
+#define XDG_SURFACE_UNSET_FULLSCREEN   12
+#define XDG_SURFACE_SET_MINIMIZED      13
+
+static inline void
+xdg_surface_set_user_data(struct xdg_surface *xdg_surface, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) xdg_surface, user_data);
+}
+
+static inline void *
+xdg_surface_get_user_data(struct xdg_surface *xdg_surface)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) xdg_surface);
+}
+
+static inline void
+xdg_surface_destroy(struct xdg_surface *xdg_surface)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_DESTROY);
+
+       wl_proxy_destroy((struct wl_proxy *) xdg_surface);
+}
+
+static inline void
+xdg_surface_set_parent(struct xdg_surface *xdg_surface, struct wl_surface *parent)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_PARENT, parent);
+}
+
+static inline void
+xdg_surface_set_title(struct xdg_surface *xdg_surface, const char *title)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_TITLE, title);
+}
+
+static inline void
+xdg_surface_set_app_id(struct xdg_surface *xdg_surface, const char *app_id)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_APP_ID, app_id);
+}
+
+static inline void
+xdg_surface_show_window_menu(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SHOW_WINDOW_MENU, seat, serial, x, y);
+}
+
+static inline void
+xdg_surface_move(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_MOVE, seat, serial);
+}
+
+static inline void
+xdg_surface_resize(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial, uint32_t edges)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_RESIZE, seat, serial, edges);
+}
+
+static inline void
+xdg_surface_ack_configure(struct xdg_surface *xdg_surface, uint32_t serial)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_ACK_CONFIGURE, serial);
+}
+
+static inline void
+xdg_surface_set_window_geometry(struct xdg_surface *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_WINDOW_GEOMETRY, x, y, width, height);
+}
+
+static inline void
+xdg_surface_set_maximized(struct xdg_surface *xdg_surface)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_MAXIMIZED);
+}
+
+static inline void
+xdg_surface_unset_maximized(struct xdg_surface *xdg_surface)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_UNSET_MAXIMIZED);
+}
+
+static inline void
+xdg_surface_set_fullscreen(struct xdg_surface *xdg_surface, struct wl_output *output)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_FULLSCREEN, output);
+}
+
+static inline void
+xdg_surface_unset_fullscreen(struct xdg_surface *xdg_surface)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_UNSET_FULLSCREEN);
+}
+
+static inline void
+xdg_surface_set_minimized(struct xdg_surface *xdg_surface)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_MINIMIZED);
+}
+
+/**
+ * xdg_popup - desktop-style metadata interface
+ * @popup_done: popup interaction is done
+ *
+ * An interface that may be implemented by a wl_surface, for
+ * implementations that provide a desktop-style popups/menus. A popup
+ * surface is a transient surface with an added pointer grab.
+ *
+ * An existing implicit grab will be changed to owner-events mode, and the
+ * popup grab will continue after the implicit grab ends (i.e. releasing
+ * the mouse button does not cause the popup to be unmapped).
+ *
+ * The popup grab continues until the window is destroyed or a mouse button
+ * is pressed in any other clients window. A click in any of the clients
+ * surfaces is reported as normal, however, clicks in other clients
+ * surfaces will be discarded and trigger the callback.
+ *
+ * The x and y arguments specify the locations of the upper left corner of
+ * the surface relative to the upper left corner of the parent surface, in
+ * surface local coordinates.
+ *
+ * xdg_popup surfaces are always transient for another surface.
+ */
+struct xdg_popup_listener {
+       /**
+        * popup_done - popup interaction is done
+        * @serial: serial of the implicit grab on the pointer
+        *
+        * The popup_done event is sent out when a popup grab is broken,
+        * that is, when the users clicks a surface that doesn't belong to
+        * the client owning the popup surface.
+        */
+       void (*popup_done)(void *data,
+                          struct xdg_popup *xdg_popup,
+                          uint32_t serial);
+};
+
+static inline int
+xdg_popup_add_listener(struct xdg_popup *xdg_popup,
+                      const struct xdg_popup_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) xdg_popup,
+                                    (void (**)(void)) listener, data);
+}
+
+#define XDG_POPUP_DESTROY      0
+
+static inline void
+xdg_popup_set_user_data(struct xdg_popup *xdg_popup, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) xdg_popup, user_data);
+}
+
+static inline void *
+xdg_popup_get_user_data(struct xdg_popup *xdg_popup)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) xdg_popup);
+}
+
+static inline void
+xdg_popup_destroy(struct xdg_popup *xdg_popup)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_popup,
+                        XDG_POPUP_DESTROY);
+
+       wl_proxy_destroy((struct wl_proxy *) xdg_popup);
+}
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/wayland/protocol/xdg-shell-protocol.c b/src/wayland/protocol/xdg-shell-protocol.c
new file mode 100644 (file)
index 0000000..e078651
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright © 2008-2013 Kristian Høgsberg
+ * Copyright © 2013      Rafael Antognolli
+ * Copyright © 2013      Jasper St. Pierre
+ * Copyright © 2010-2013 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this
+ * software and its documentation for any purpose is hereby granted
+ * without fee, provided that the above copyright notice appear in
+ * all copies and that both that copyright notice and this permission
+ * notice appear in supporting documentation, and that the name of
+ * the copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include "wayland-util.h"
+
+extern const struct wl_interface wl_output_interface;
+extern const struct wl_interface wl_seat_interface;
+extern const struct wl_interface wl_surface_interface;
+extern const struct wl_interface xdg_popup_interface;
+extern const struct wl_interface xdg_surface_interface;
+
+static const struct wl_interface *types[] = {
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       &xdg_surface_interface,
+       &wl_surface_interface,
+       &xdg_popup_interface,
+       &wl_surface_interface,
+       &wl_surface_interface,
+       &wl_seat_interface,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       &wl_surface_interface,
+       &wl_seat_interface,
+       NULL,
+       NULL,
+       NULL,
+       &wl_seat_interface,
+       NULL,
+       &wl_seat_interface,
+       NULL,
+       NULL,
+       &wl_output_interface,
+};
+
+static const struct wl_message xdg_shell_requests[] = {
+       { "use_unstable_version", "i", types + 0 },
+       { "get_xdg_surface", "no", types + 4 },
+       { "get_xdg_popup", "nooouiiu", types + 6 },
+       { "pong", "u", types + 0 },
+};
+
+static const struct wl_message xdg_shell_events[] = {
+       { "ping", "u", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface xdg_shell_interface = {
+       "xdg_shell", 1,
+       4, xdg_shell_requests,
+       1, xdg_shell_events,
+};
+
+static const struct wl_message xdg_surface_requests[] = {
+       { "destroy", "", types + 0 },
+       { "set_parent", "?o", types + 14 },
+       { "set_title", "s", types + 0 },
+       { "set_app_id", "s", types + 0 },
+       { "show_window_menu", "ouii", types + 15 },
+       { "move", "ou", types + 19 },
+       { "resize", "ouu", types + 21 },
+       { "ack_configure", "u", types + 0 },
+       { "set_window_geometry", "iiii", types + 0 },
+       { "set_maximized", "", types + 0 },
+       { "unset_maximized", "", types + 0 },
+       { "set_fullscreen", "?o", types + 24 },
+       { "unset_fullscreen", "", types + 0 },
+       { "set_minimized", "", types + 0 },
+};
+
+static const struct wl_message xdg_surface_events[] = {
+       { "configure", "iiau", types + 0 },
+       { "close", "", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface xdg_surface_interface = {
+       "xdg_surface", 1,
+       14, xdg_surface_requests,
+       2, xdg_surface_events,
+};
+
+static const struct wl_message xdg_popup_requests[] = {
+       { "destroy", "", types + 0 },
+};
+
+static const struct wl_message xdg_popup_events[] = {
+       { "popup_done", "u", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface xdg_popup_interface = {
+       "xdg_popup", 1,
+       1, xdg_popup_requests,
+       1, xdg_popup_events,
+};
+
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644 (file)
index 0000000..1829456
--- /dev/null
@@ -0,0 +1,12 @@
+AM_CFLAGS = \
+       $(LIBEOM_CFLAGS) \
+       -I$(top_srcdir)/include
+
+AM_LDFLAGS = \
+       $(LIBEOM_LIBS) \
+       $(top_builddir)/src/libeom.la
+
+noinst_PROGRAMS = \
+       eom-test-output
+
+eom_test_output_SOURCES = eom-test-output.c
diff --git a/tests/eom-test-output.c b/tests/eom-test-output.c
new file mode 100755 (executable)
index 0000000..f48554d
--- /dev/null
@@ -0,0 +1,88 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <gio/gio.h>
+#include <eom.h>
+
+/* This test application consider only one output */
+
+static void
+test_eom_output_notify_cb_output_add (eom_output_notify_s *notify, void *user_data)
+{
+    eom_output_notify_add_s *add_notify = (eom_output_notify_add_s*)notify;
+    printf ("output(%d) connected\n", add_notify->output_id);
+
+    /* already has one connected output */
+    if (output)
+        return;
+
+    output = eom_output_create (add_notify->output_id);
+    if (!output)
+        printf ("fail: creating output\n");
+}
+
+static void
+test_eom_output_notify_cb_output_remove (eom_output_notify_s *notify, void *user_data)
+{
+    eom_output_notify_remove_s *rm_notify = (eom_output_notify_remove_s*)notify;
+    printf ("output(%d) disconnected\n", rm_notify->output_id);
+
+    /* no connected output */
+    if (!output)
+        return;
+
+    if (eom_output_get_output_id (output) != rm_notify->output_id)
+    {
+        printf ("I'm not interested in this output(%d,%d)\n", eom_output_get_output_id (output), rm_notify->output_id);
+        return;
+    }
+
+    eom_output_destroy (output);
+    output = NULL;
+}
+
+static void
+test_eom_check_connected_output (void)
+{
+    int output_cnt;
+    eom_output_id *output_ids;
+
+    output_ids = eom_get_eom_output_ids (&output_cnt);
+    if (!output_ids)
+        goto done;
+
+    printf ("output(%d) connected\n", output_ids[0]);
+
+done:
+    if (output_ids)
+        free (output_ids);
+}
+
+int
+main(int argc, char *argv[])
+{
+    GMainLoop *event_loop;
+
+    g_type_init();
+
+    if (eom_init ())
+        return 0;
+
+    eom_output_add_notify_cb (EOM_OUTPUT_NOTIFY_ADD, test_eom_output_notify_cb_output_add, NULL);
+    eom_output_add_notify_cb (EOM_OUTPUT_NOTIFY_REMOVE, test_eom_output_notify_cb_output_remove, NULL);
+
+    test_eom_check_connected_output ();
+
+    /* run event loop */
+    event_loop = g_main_loop_new (NULL, FALSE);
+    g_main_loop_run (event_loop);
+
+    if (output)
+        eom_output_destroy (output);
+
+    eom_output_remove_notify_cb (test_eom_output_notify_cb_output_add);
+    eom_output_remove_notify_cb (test_eom_output_notify_cb_output_remove);
+
+    eom_deinit ();
+
+    return 0;
+}
\ No newline at end of file