summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-12-22 20:49:15 +0100
committerMarcel Holtmann <marcel@holtmann.org>2007-12-22 20:49:15 +0100
commite8f7754e312aeac4aaca74d304ed6e36ed2f6a0d (patch)
treee13fb14e8878f7e48cfd0827ff7ce2f9534487ec
parentba189b000c4c5ab4d15c6b155a7dbf8bd46c42d4 (diff)
downloadconnman-e8f7754e312aeac4aaca74d304ed6e36ed2f6a0d.tar.gz
connman-e8f7754e312aeac4aaca74d304ed6e36ed2f6a0d.tar.bz2
connman-e8f7754e312aeac4aaca74d304ed6e36ed2f6a0d.zip
Add skeleton for daemon and D-Bus registration
-rw-r--r--Makefile.am2
-rw-r--r--configure.in7
-rw-r--r--src/Makefile.am16
-rw-r--r--src/connman.conf11
-rw-r--r--src/connman.h25
-rw-r--r--src/main.c71
6 files changed, 131 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 4a0cec8e..baa76129 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,6 @@
+SUBDIRS = src
+
MAINTAINERCLEANFILES = Makefile.in \
aclocal.m4 configure config.h.in config.sub config.guess \
ltmain.sh depcomp missing install-sh mkinstalldirs
diff --git a/configure.in b/configure.in
index 645032c2..7cddb933 100644
--- a/configure.in
+++ b/configure.in
@@ -18,4 +18,9 @@ AC_PROG_CC
AC_PROG_CC_PIE
AC_PROG_INSTALL
-AC_OUTPUT(Makefile)
+PKG_CHECK_MODULES(GDBUS, gdbus, dummy=yes,
+ AC_MSG_ERROR(libgdbus is required))
+AC_SUBST(GDBUS_CFLAGS)
+AC_SUBST(GDBUS_LIBS)
+
+AC_OUTPUT(Makefile src/Makefile)
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 00000000..87a6e78a
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,16 @@
+
+dbusdir = $(sysconfdir)/dbus-1/system.d
+
+dbus_DATA = connman.conf
+
+sbin_PROGRAMS = connmand
+
+connmand_SOURCES = main.c connman.h
+
+connmand_LDADD = @GDBUS_LIBS@
+
+AM_CFLAGS = @GDBUS_CFLAGS@
+
+EXTRA_DIST = $(dbus_DATA)
+
+MAINTAINERCLEANFILES = Makefile.in
diff --git a/src/connman.conf b/src/connman.conf
new file mode 100644
index 00000000..4e83980e
--- /dev/null
+++ b/src/connman.conf
@@ -0,0 +1,11 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <policy user="root">
+ <allow own="org.freedesktop.connman"/>
+ </policy>
+ <policy at_console="true">
+ <allow send_interface="org.freedesktop.connman"/>
+ <allow send_destination="org.freedesktop.connman"/>
+ </policy>
+</busconfig>
diff --git a/src/connman.h b/src/connman.h
new file mode 100644
index 00000000..5282d144
--- /dev/null
+++ b/src/connman.h
@@ -0,0 +1,25 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2007 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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
+ *
+ */
+
+#define CONNMAN_SERVICE "org.freedesktop.connman"
+
+#define CONNMAN_MANAGER_PATH "/"
+#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 00000000..76af50a6
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,71 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2007 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include <gdbus.h>
+
+#include "connman.h"
+
+static GMainLoop *main_loop = NULL;
+
+static void sig_term(int sig)
+{
+ g_main_loop_quit(main_loop);
+}
+
+int main(int argc, char *argv[])
+{
+ DBusConnection *conn;
+ struct sigaction sa;
+
+ main_loop = g_main_loop_new(NULL, FALSE);
+
+ conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, CONNMAN_SERVICE);
+ if (conn == NULL) {
+ fprintf(stderr, "Can't register with system bus\n");
+ exit(1);
+ }
+
+ g_dbus_register_object(conn, CONNMAN_MANAGER_PATH, NULL, NULL);
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = sig_term;
+ sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
+
+ g_main_loop_run(main_loop);
+
+ g_dbus_unregister_object(conn, CONNMAN_MANAGER_PATH);
+
+ g_dbus_cleanup_connection(conn);
+
+ g_main_loop_unref(main_loop);
+
+ return 0;
+}