From: Marcel Holtmann Date: Sat, 22 Dec 2007 19:49:15 +0000 (+0100) Subject: Add skeleton for daemon and D-Bus registration X-Git-Tag: 0.1~483 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e8f7754e312aeac4aaca74d304ed6e36ed2f6a0d;p=platform%2Fupstream%2Fconnman.git Add skeleton for daemon and D-Bus registration --- diff --git a/Makefile.am b/Makefile.am index 4a0cec8..baa7612 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 645032c..7cddb93 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 0000000..87a6e78 --- /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 0000000..4e83980 --- /dev/null +++ b/src/connman.conf @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/src/connman.h b/src/connman.h new file mode 100644 index 0000000..5282d14 --- /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 0000000..76af50a --- /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 +#endif + +#include +#include +#include +#include + +#include + +#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; +}