summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorRegis Merlino <regis.merlino@intel.com>2013-02-22 15:52:55 +0100
committerMark Ryan <mark.d.ryan@intel.com>2013-02-25 16:23:27 +0100
commit3f332f2c5d8d991a0ea657086b0cff2dfd787206 (patch)
treeed4539b12422e667600db9743a181b52f9294fbe /server
parentb01091c46738d801903c00d1e072fa4e51ad9804 (diff)
downloaddleyna-server-3f332f2c5d8d991a0ea657086b0cff2dfd787206.tar.gz
[Init] Add initial source code
Signed-off-by: Regis Merlino <regis.merlino@intel.com>
Diffstat (limited to 'server')
-rw-r--r--server/Makefile.am36
-rw-r--r--server/com.intel.dleyna-server.service.in4
-rw-r--r--server/daemon.c101
-rw-r--r--server/dleyna-server-service-1.0.pc.in8
4 files changed, 149 insertions, 0 deletions
diff --git a/server/Makefile.am b/server/Makefile.am
new file mode 100644
index 0000000..135c62d
--- /dev/null
+++ b/server/Makefile.am
@@ -0,0 +1,36 @@
+AM_CFLAGS = $(GLIB_CFLAGS) \
+ $(GIO_CFLAGS) \
+ $(DLEYNA_CORE_CFLAGS) \
+ -I$(top_builddir)/lib \
+ -include config.h
+
+ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
+
+libexec_PROGRAMS = dleyna-server-service
+
+dleyna_server_service_SOURCES = daemon.c
+
+dleyna_server_service_LDADD = $(GLIB_LIBS) \
+ $(GIO_LIBS) \
+ $(DLEYNA_CORE_LIBS) \
+ $(top_builddir)/lib/libdleyna-server-1.0.la
+
+dms_info_sources = ../test/dbus/dms-info.c
+
+noinst_PROGRAMS = dms-info
+dms_info_SOURCES = $(dms_info_sources)
+
+dms_info_CFLAGS = $(GLIB_CFLAGS) \
+ $(GIO_CFLAGS)
+
+dms_info_LDADD = $(GLIB_LIBS) \
+ $(GIO_LIBS)
+
+dbussessiondir = @DBUS_SESSION_DIR@
+dbussession_DATA = com.intel.dleyna-server.service
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = dleyna-server-service-1.0.pc
+
+CLEANFILES = $(dbussession_DATA) $(pkgconfig_DATA)
+DISTCLEANFILES = $(dbussession_DATA) $(pkgconfig_DATA)
diff --git a/server/com.intel.dleyna-server.service.in b/server/com.intel.dleyna-server.service.in
new file mode 100644
index 0000000..b81e6cd
--- /dev/null
+++ b/server/com.intel.dleyna-server.service.in
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name=com.intel.dleyna-server
+Exec=@prefix@/libexec/dleyna-server-service
+
diff --git a/server/daemon.c b/server/daemon.c
new file mode 100644
index 0000000..aced018
--- /dev/null
+++ b/server/daemon.c
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ *
+ * Mark Ryan <mark.d.ryan@intel.com>
+ * Regis Merlino <regis.merlino@intel.com>
+ *
+ */
+
+#include <glib.h>
+#include <sys/signalfd.h>
+
+#include <libdleyna/core/main-loop.h>
+#include <lib/control-point-server.h>
+
+static guint g_sig_id;
+
+static gboolean prv_quit_handler(GIOChannel *source, GIOCondition condition,
+ gpointer user_data)
+{
+ dleyna_main_loop_quit();
+ g_sig_id = 0;
+
+ return FALSE;
+}
+
+static gboolean prv_init_signal_handler(sigset_t mask)
+{
+ gboolean retval = FALSE;
+ int fd = -1;
+ GIOChannel *channel = NULL;
+
+ fd = signalfd(-1, &mask, SFD_NONBLOCK);
+ if (fd == -1)
+ goto on_error;
+
+ channel = g_io_channel_unix_new(fd);
+ g_io_channel_set_close_on_unref(channel, TRUE);
+
+ if (g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL) !=
+ G_IO_STATUS_NORMAL)
+ goto on_error;
+
+ if (g_io_channel_set_encoding(channel, NULL, NULL) !=
+ G_IO_STATUS_NORMAL)
+ goto on_error;
+
+ g_sig_id = g_io_add_watch(channel, G_IO_IN | G_IO_PRI,
+ prv_quit_handler,
+ NULL);
+
+ retval = TRUE;
+
+on_error:
+
+ if (channel)
+ g_io_channel_unref(channel);
+
+ return retval;
+}
+
+int main(int argc, char *argv[])
+{
+ sigset_t mask;
+ int retval = 1;
+
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGTERM);
+ sigaddset(&mask, SIGINT);
+
+ if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1)
+ goto out;
+
+ if (!prv_init_signal_handler(mask))
+ goto out;
+
+ retval = dleyna_main_loop_start(argv[0],
+ dleyna_control_point_get_server(),
+ NULL);
+
+out:
+
+ if (g_sig_id)
+ (void) g_source_remove(g_sig_id);
+
+ return retval;
+}
diff --git a/server/dleyna-server-service-1.0.pc.in b/server/dleyna-server-service-1.0.pc.in
new file mode 100644
index 0000000..d6e9af7
--- /dev/null
+++ b/server/dleyna-server-service-1.0.pc.in
@@ -0,0 +1,8 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libexecdir=@libexecdir@
+
+Name: @PACKAGE@-service
+Description: UPnP & DLNA media content management
+Requires.private: glib-2.0 gio-2.0 dleyna-core-1.0 dleyna-server-1.0
+Version: @VERSION@ \ No newline at end of file