Commit 6719a69a authored by Regis Merlino's avatar Regis Merlino

[Init] Add initial source files

Signed-off-by: default avatarRegis Merlino <regis.merlino@intel.com>
parent 99aa98ae
*.o
*.lo
*~
*.la
*.pc
*.tgz
*.gz
.dirstamp
Makefile
Makefile.in
aclocal.m4
autom4te.cache/
compile
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
missing
.deps/
.libs/
stamp-h1
INSTALL
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
This diff is collapsed.
version 0.0.1
- Initial version of dleyna-connector-dbus
connectordir = $(libdir)/dleyna-1.0/connectors
AM_CFLAGS = $(GLIB_CFLAGS) \
$(GIO_CFLAGS) \
$(DLEYNA_CORE_CFLAGS) \
-include config.h
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
connector_LTLIBRARIES = libdleyna-connector-dbus.la
libdleyna_connector_dbus_la_LDFLAGS = -avoid-version \
-no-undefined \
-module
libdleyna_connector_dbus_la_SOURCES = src/connector-dbus.c
libdleyna_connector_dbus_la_LIBADD = $(GLIB_LIBS) \
$(GIO_LIBS) \
$(DLEYNA_CORE_LIBS)
MAINTAINERCLEANFILES = Makefile.in \
aclocal.m4 \
configure \
config.h.in \
config.h.in~ \
build-aux/depcomp \
build-aux/compile \
build-aux/missing \
build-aux/install-sh
maintainer-clean-local:
rm -rf build-aux
Introduction:
-------------
TODO
Compilation
------------
TODO
Working with the source code repository
---------------------------------------
dleyna-connector-dbus can be downloaded, compiled and installed as
follows:
Clone repository
# git clone git://github.com/01org/dleyna-ipc-dbus.git
# cd dleyna-connector-dbus
Configure and build
# ./autoreconf -i
# ./configure
# make
Final installation
# sudo make install
These instructions are suitable for users who simply want to install
dleyna-connector-dbus. However, developers wishing to contribute
to the project should follow a separate "Configure and build" step.
Configure and build
# ./bootstrap-configure
# make
The script "bootstrap-configure" cleans the repository, calls
autreconf and then invokes configure with proper settings for
development. These settings include the enabling of
maintainer mode and debugging.
Developers can remove autogenerated files with the following command
# make maintainer-clean
Configure Options:
------------------
--enable-werror
This option is disabled by default. To enable use --enable-werror.
When enabled, all warnings are treated as errors during compilation.
Should be enabled during development to ensure that errors do not
creep into the code base. This option is enabled by
bootstrap-configure.
--enable-debug
This option is disabled by default. To enable use
--enable-debug. When enabled, the make files produce debug builds.
This option is enabled by bootstrap-configure.
--enable-optimization
This option is enabled by default. To disable use
--disable-optimization. When enabled it turns on compiler
optimizations. Disable = -O0, enable = -O2.
--with-log-level
See logging.txt for more information about logging.
#!/bin/sh
if [ -f config.status ]; then
make maintainer-clean
fi
autoreconf -if && \
./configure --enable-maintainer-mode \
--enable-silent-rules \
--disable-optimization \
--enable-debug \
--with-log-level=8 $*
\ No newline at end of file
AC_PREREQ([2.66])
AC_INIT([dleyna-connector-dbus],
[0.0.1],
[https://github.com/01org/dleyna-ipc-dbus/issues/new],
,
[https://01.org/dleyna/])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([src/connector-dbus.c])
AC_PREFIX_DEFAULT(/usr/local)
AM_INIT_AUTOMAKE([subdir-objects])
AM_MAINTAINER_MODE
AM_SILENT_RULES([yes])
DLEYNA_CONNECTOR_DBUS_COMPILER_FLAGS
# Checks for languages.
AC_LANG_C
# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_MKDIR_P
# Initialize libtool
# Disable generation of static libraries
LT_PREREQ([2.2.6])
LT_INIT([dlopen disable-static])
LT_LANG([C])
# Checks for libraries.
PKG_PROG_PKG_CONFIG(0.16)
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.28])
PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.28])
PKG_CHECK_MODULES([DBUS], [dbus-1])
PKG_CHECK_MODULES([DLEYNA_CORE], [dleyna-core-1.0 >= 0.0.1])
# Checks for header files.
AC_CHECK_HEADERS([stdlib.h string.h syslog.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_UINT8_T
AC_HEADER_STDBOOL
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([memset strchr strrchr strstr])
# Define Log Level values
LOG_LEVEL_0=0x00
LOG_LEVEL_1=0x01
LOG_LEVEL_2=0x02
LOG_LEVEL_3=0x04
LOG_LEVEL_4=0x08
LOG_LEVEL_5=0x10
LOG_LEVEL_6=0x20
LOG_LEVEL_7=0x13
LOG_LEVEL_8=0x3F
AC_DEFINE_UNQUOTED([DLEYNA_LOG_LEVEL_DISABLED], [${LOG_LEVEL_0}], [Log level flag for disabled messages])
AC_DEFINE_UNQUOTED([DLEYNA_LOG_LEVEL_ERROR], [${LOG_LEVEL_1}], [Log level flag for errors])
AC_DEFINE_UNQUOTED([DLEYNA_LOG_LEVEL_CRITICAL], [${LOG_LEVEL_2}], [Log level flag for critical messages])
AC_DEFINE_UNQUOTED([DLEYNA_LOG_LEVEL_WARNING], [${LOG_LEVEL_3}], [Log level flag for warnings])
AC_DEFINE_UNQUOTED([DLEYNA_LOG_LEVEL_MESSAGE], [${LOG_LEVEL_4}], [Log level flag for messages])
AC_DEFINE_UNQUOTED([DLEYNA_LOG_LEVEL_INFO], [${LOG_LEVEL_5}], [Log level flag for informational messages])
AC_DEFINE_UNQUOTED([DLEYNA_LOG_LEVEL_DEBUG], [${LOG_LEVEL_6}], [Log level flag for debug messages])
AC_DEFINE_UNQUOTED([DLEYNA_LOG_LEVEL_DEFAULT], [${LOG_LEVEL_7}], [Log level flag to display default level messages])
AC_DEFINE_UNQUOTED([DLEYNA_LOG_LEVEL_ALL], [${LOG_LEVEL_8}], [Log level flag for all messages])
AC_ARG_ENABLE(debug,
AS_HELP_STRING(
[--enable-debug],
[enable compiling with debugging information]),
[],
[enable_debug=no])
AS_CASE("${enable_debug}",
[yes], [CFLAGS="$CFLAGS -g";
AC_DEFINE_UNQUOTED([DLEYNA_DEBUG_ENABLED],[1], [Compiling with debugging information enabled])
],
[no], [],
[AC_MSG_ERROR([bad value ${enable_debug} for --enable-debug])])
AC_ARG_ENABLE(werror,
AS_HELP_STRING(
[--enable-werror],
[warnings are treated as errors]),
[],
[enable_werror=no])
AS_CASE("${enable_werror}",
[yes], [CFLAGS="$CFLAGS -Werror"],
[no], [],
[AC_MSG_ERROR([bad value ${enable_werror} for --enable-werror])])
AC_ARG_ENABLE(optimization,
AS_HELP_STRING(
[--disable-optimization],
[disable code optimization through compiler]),
[],
[enable_optimization=yes])
AS_CASE("${enable_optimization}",
[yes], [disable_optimization=no],
[no], [CFLAGS="$CFLAGS -O0"; disable_optimization=yes],
[AC_MSG_ERROR([bad value ${enable_optimization} for --enable-werror])])
AC_ARG_WITH(log-level,
AS_HELP_STRING(
[--with-log-level],
[enable logging information (0,1..6,7,8)\
0=disabled \
7=default (=1,2,5) \
8=all (=1,2,3,4,5,6) \
1,..,6=a comma separated list of log level\
]),
[],
[with_log_level=7])
DLEYNA_LOG_LEVEL_CHECK([${with_log_level}])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
AS_ECHO(["-------------------------------------------------
${PACKAGE_NAME} Version ${PACKAGE_VERSION}
Prefix : '${prefix}'
Compiler : '${CC}'
CFLAGS : '${CFLAGS}'
-Package features:
- enable-werror : ${enable_werror}
- enable-debug : ${enable_debug}
- disable-optimization: ${disable_optimization}
- with-log-level : ${with_log_level}
--------------------------------------------------"])
dnl
dnl dleyna-connector-dbus
dnl
dnl Copyright (C) 2013 Intel Corporation. All rights reserved.
dnl
dnl This program is free software; you can redistribute it and/or modify it
dnl under the terms and conditions of the GNU Lesser General Public License,
dnl version 2.1, as published by the Free Software Foundation.
dnl
dnl This program is distributed in the hope it will be useful, but WITHOUT
dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dnl FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
dnl for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with this program; if not, write to the Free Software Foundation, Inc.,
dnl 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
dnl
dnl Regis Merlino <regis.merlino@intel.com>
dnl
AC_DEFUN_ONCE([DLEYNA_CONNECTOR_DBUS_COMPILER_FLAGS], [
if (test x"${CFLAGS}" = x""); then
CFLAGS="-Wall"
CFLAGS+=" -O2"
CFLAGS+=" -D_FORTIFY_SOURCE=2"
fi
if (test x"$USE_MAINTAINER_MODE" = x"yes"); then
CFLAGS+=" -Wextra"
CFLAGS+=" -Wno-unused-parameter"
CFLAGS+=" -Wno-missing-field-initializers"
CFLAGS+=" -Wdeclaration-after-statement"
CFLAGS+=" -Wmissing-declarations"
CFLAGS+=" -Wredundant-decls"
CFLAGS+=" -Wcast-align"
CFLAGS+=" -Wstrict-prototypes"
CFLAGS+=" -Wmissing-prototypes"
CFLAGS+=" -Wnested-externs"
CFLAGS+=" -Wshadow"
CFLAGS+=" -Wformat=2"
CFLAGS+=" -Winit-self"
CFLAGS+=" -std=gnu99"
CFLAGS+=" -pedantic"
CFLAGS+=" -Wno-overlength-strings"
CFLAGS+=" -DG_DISABLE_DEPRECATED"
CFLAGS+=" -DGLIB_DISABLE_DEPRECATION_WARNINGS"
fi
CFLAGS+=" -Wno-format-extra-args"
])
dnl
dnl dLeyna
dnl
dnl Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
dnl
dnl This program is free software; you can redistribute it and/or modify it
dnl under the terms and conditions of the GNU Lesser General Public License,
dnl version 2.1, as published by the Free Software Foundation.
dnl
dnl This program is distributed in the hope it will be useful, but WITHOUT
dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dnl FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
dnl for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with this program; if not, write to the Free Software Foundation, Inc.,
dnl 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
dnl
dnl Ludovic Ferrandis <ludovic.ferrandis@intel.com>
dnl
AC_DEFUN([_DLEYNA_LOG_LEVEL_CHECK_VALUE],
[
AS_CASE($1,
[[[1-6]]], [AS_IF([test ${log_array[[${log_level}]]} -ne 0],
[
AC_MSG_ERROR(["$1 should be set once"], 1)
],
[test "x${log_single}" = xyes],
[
AC_MSG_ERROR(["Unique value element already set"], 1)
])
],
[0|7|8], [AS_IF([test ${log_level_count} -ne 0],
[
AC_MSG_ERROR(["$1 should be a unique value element"], 1)
])
log_single=yes
],
[AC_MSG_ERROR(["$1 is not a valid value"], 1)]
)
log_name=LOG_LEVEL_${log_level}
eval log_value=\$${log_name}
let "LOG_LEVEL |= ${log_value}"
]
)
AC_DEFUN([DLEYNA_LOG_LEVEL_CHECK],
[
AC_MSG_CHECKING([for --with-log-level=$1])
old_IFS=${IFS}
IFS=","
log_ok=yes
log_single=no
log_level_count=0
LOG_LEVEL=0
log_array=(0 0 0 0 0 0 0 0 0)
for log_level in $1
do
IFS=${old_IFS}
_DLEYNA_LOG_LEVEL_CHECK_VALUE([$log_level])
IFS=","
let log_level_count++
let log_array[[${log_level}]]++
done
IFS=${old_IFS}
AC_DEFINE_UNQUOTED([DLEYNA_LOG_LEVEL], [${LOG_LEVEL}], [Log level flag for debug messages])
AC_MSG_RESULT([ok])
]
)
/*
* dLeyna
*
* Copyright (C) 2013 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
* version 2.1, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
* Regis Merlino <regis.merlino@intel.com>
*
*/
#include <gio/gio.h>
#include <string.h>
#include <libdleyna/core/connector.h>
#include <libdleyna/core/error.h>
#include <libdleyna/core/log.h>
typedef struct dleyna_dbus_object_t_ dleyna_dbus_object_t;
struct dleyna_dbus_object_t_ {
guint id;
gchar *root_path;
const dleyna_connector_dispatch_cb_t *dispatch_table;
guint dispatch_table_size;
dleyna_connector_interface_filter_cb_t filter_cb;
};
typedef struct dleyna_dbus_call_info_t_ dleyna_dbus_call_info_t;
struct dleyna_dbus_call_info_t_ {
dleyna_dbus_object_t *object;
guint interface_index;
};
typedef struct dleyna_dbus_context_t_ dleyna_dbus_context_t;
struct dleyna_dbus_context_t_ {
GHashTable *objects;
GHashTable *clients;
GDBusNodeInfo *root_node_info;
GDBusNodeInfo *server_node_info;
guint owner_id;
GDBusConnection *connection;
dleyna_connector_connected_cb_t connected_cb;
dleyna_connector_disconnected_cb_t disconnected_cb;
dleyna_connector_client_lost_cb_t client_lost_cb;
};
static dleyna_dbus_context_t g_context;
#define DLEYNA_SERVICE "com.intel.dleyna"
static const GDBusErrorEntry g_error_entries[] = {
{ DLEYNA_ERROR_BAD_PATH, DLEYNA_SERVICE".BadPath" },
{ DLEYNA_ERROR_OBJECT_NOT_FOUND, DLEYNA_SERVICE".ObjectNotFound" },
{ DLEYNA_ERROR_BAD_QUERY, DLEYNA_SERVICE".BadQuery" },
{ DLEYNA_ERROR_OPERATION_FAILED, DLEYNA_SERVICE".OperationFailed" },
{ DLEYNA_ERROR_BAD_RESULT, DLEYNA_SERVICE".BadResult" },
{ DLEYNA_ERROR_UNKNOWN_INTERFACE, DLEYNA_SERVICE".UnknownInterface" },
{ DLEYNA_ERROR_UNKNOWN_PROPERTY, DLEYNA_SERVICE".UnknownProperty" },
{ DLEYNA_ERROR_DEVICE_NOT_FOUND, DLEYNA_SERVICE".DeviceNotFound" },
{ DLEYNA_ERROR_DIED, DLEYNA_SERVICE".Died" },
{ DLEYNA_ERROR_CANCELLED, DLEYNA_SERVICE".Cancelled" },
{ DLEYNA_ERROR_NOT_SUPPORTED, DLEYNA_SERVICE".NotSupported" },
{ DLEYNA_ERROR_LOST_OBJECT, DLEYNA_SERVICE".LostObject" },
{ DLEYNA_ERROR_BAD_MIME, DLEYNA_SERVICE".BadMime" },
{ DLEYNA_ERROR_HOST_FAILED, DLEYNA_SERVICE".HostFailed" },
{ DLEYNA_ERROR_IO, DLEYNA_SERVICE".IO" }
};
const dleyna_connector_t *dleyna_connector_get_interface(void);
static void prv_object_method_call(GDBusConnection *conn,
const gchar *sender,
const gchar *object,
const gchar *interface,
const gchar *method,
GVariant *parameters,
GDBusMethodInvocation *invocation,
gpointer user_data);
static const GDBusInterfaceVTable g_object_vtable = {
prv_object_method_call,
NULL,
NULL
};
static gchar **prv_subtree_enumerate(GDBusConnection *connection,
const gchar *sender,
const gchar *object_path,
gpointer user_data);
static GDBusInterfaceInfo **prv_subtree_introspect(
GDBusConnection *connection,
const gchar *sender,
const gchar *object_path,
const gchar *node,
gpointer user_data);
static const GDBusInterfaceVTable *prv_subtree_dispatch(
GDBusConnection *connection,
const gchar *sender,
const gchar *object_path,
const gchar *interface_name,
const gchar *node,
gpointer *out_user_data,
gpointer user_data);
static const GDBusSubtreeVTable g_subtree_vtable = {
prv_subtree_enumerate,
prv_subtree_introspect,
prv_subtree_dispatch
};
static void prv_subtree_method_call(GDBusConnection *conn,
const gchar *sender,
const gchar *object_path,
const gchar *interface,
const gchar *method,
GVariant *parameters,
GDBusMethodInvocation *invocation,
gpointer user_data);
static const GDBusInterfaceVTable g_subtree_interface_vtable = {
prv_subtree_method_call,
NULL,
NULL
};
static void prv_connector_init_error_domain(GQuark error_quark)
{
guint index = sizeof(g_error_entries) / sizeof(const GDBusErrorEntry);
while (index) {
index--;
g_dbus_error_register_error(
error_quark,
g_error_entries[index].error_code,
g_error_entries[index].dbus_error_name);
}
}
static void prv_free_dbus_object(gpointer data)
{
dleyna_dbus_object_t *object = data;
g_free(object->root_path);
g_free(object);
}
static gboolean prv_connector_initialize(const gchar *server_info,
const gchar *root_info,
GQuark error_quark,
gpointer user_data)
{
gboolean success = TRUE;
DLEYNA_LOG_DEBUG("Enter");
memset(&g_context, 0, sizeof(g_context));
g_context.objects = g_hash_table_new_full(g_direct_hash, g_direct_equal,
g_free, prv_free_dbus_object);
g_context.clients = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_free);
g_context.root_node_info = g_dbus_node_info_new_for_xml(root_info,
NULL);
if (!g_context.root_node_info) {
success = FALSE;
goto out;
}
g_context.server_node_info = g_dbus_node_info_new_for_xml(server_info,
NULL);
if (!g_context.server_node_info) {
success = FALSE;
goto out;
}
prv_connector_init_error_domain(error_quark);
out:
DLEYNA_LOG_DEBUG("Exit");
return success;
}
static void prv_connector_shutdown(void)
{
DLEYNA_LOG_DEBUG("Enter");
if (g_context.objects)
g_hash_table_unref(g_context.objects);
if (g_context.clients)
g_hash_table_unref(g_context.clients);
if (g_context.owner_id)
g_bus_unown_name(g_context.owner_id);
if (g_context.connection)
g_object_unref(g_context.connection);
if (g_context.server_node_info)
g_dbus_node_info_unref(g_context.server_node_info);
if (g_context.root_node_info)
g_dbus_node_info_unref(g_context.root_node_info);
DLEYNA_LOG_DEBUG("Exit");
}