summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-12-18 17:54:03 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2012-12-18 17:54:43 +0200
commit91c50f7fa1f676ceb12f9465ebd695aa3093ae53 (patch)
treee618d60e580dcf7754879fc562d2ae8a91494fe0
parent093d96a57d1ec118f2d0e8f35e110c3d9aae158b (diff)
downloadbluez-91c50f7fa1f676ceb12f9465ebd695aa3093ae53.tar.gz
obexd: Merge obex-client into obexd daemon
-rw-r--r--.gitignore1
-rw-r--r--Makefile.obexd20
-rw-r--r--obexd/client/main.c186
-rw-r--r--obexd/src/main.c9
4 files changed, 10 insertions, 206 deletions
diff --git a/.gitignore b/.gitignore
index a3a0f7225..ad85ff53b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -83,7 +83,6 @@ src/bluetooth.service
obexd/src/builtin.h
obexd/src/obexd
-obexd/client/obex-client
tools/obex-client-tool
tools/obex-server-tool
unit/test-gobex
diff --git a/Makefile.obexd b/Makefile.obexd
index e6536bc8b..dd2c41998 100644
--- a/Makefile.obexd
+++ b/Makefile.obexd
@@ -84,13 +84,7 @@ CLEANFILES += obexd/src/builtin.h $(builtin_files)
EXTRA_DIST += obexd/src/genbuiltin
-
-libexec_PROGRAMS += obexd/client/obex-client
-
-obexd_client_obex_client_SOURCES = $(gdbus_sources) $(gobex_sources) \
- $(btio_sources) \
- obexd/client/main.c obexd/src/log.h obexd/src/log.c \
- obexd/client/manager.h obexd/client/manager.c \
+obexd_src_obexd_SOURCES += obexd/client/manager.h obexd/client/manager.c \
obexd/client/session.h obexd/client/session.c \
obexd/client/bluetooth.h obexd/client/bluetooth.c \
obexd/client/sync.h obexd/client/sync.c \
@@ -103,15 +97,3 @@ obexd_client_obex_client_SOURCES = $(gdbus_sources) $(gobex_sources) \
obexd/client/dbus.h obexd/client/dbus.c \
obexd/client/driver.h obexd/client/driver.c \
obexd/src/map_ap.h
-
-obexd_client_obex_client_LDADD = lib/libbluetooth-private.la \
- @GLIB_LIBS@ @DBUS_LIBS@
-
-obexd_client_obex_client_CFLAGS = @GLIB_CFLAGS@ @DBUS_CFLAGS@ \
- -fPIC -D_FILE_OFFSET_BITS=64
-
-obexd_client_obex_client_CPPFLAGS = -I$(builddir)/lib -I$(srcdir)/obexd/src \
- -I$(srcdir)/btio -I$(srcdir)/gobex \
- -I$(srcdir)/gdbus
-
-obexd_client_obex_client_SHORTNAME = obex-client
diff --git a/obexd/client/main.c b/obexd/client/main.c
deleted file mode 100644
index 255ee37d0..000000000
--- a/obexd/client/main.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- *
- * OBEX Client
- *
- * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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 <syslog.h>
-#include <unistd.h>
-#include <sys/signalfd.h>
-
-#include <glib.h>
-#include <gdbus/gdbus.h>
-
-#include "log.h"
-#include "manager.h"
-
-static GMainLoop *event_loop = NULL;
-
-static unsigned int __terminated = 0;
-
-static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
- gpointer user_data)
-{
- struct signalfd_siginfo si;
- ssize_t result;
- int fd;
-
- if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
- return FALSE;
-
- fd = g_io_channel_unix_get_fd(channel);
-
- result = read(fd, &si, sizeof(si));
- if (result != sizeof(si))
- return FALSE;
-
- switch (si.ssi_signo) {
- case SIGINT:
- case SIGTERM:
- if (__terminated == 0) {
- info("Terminating");
- g_main_loop_quit(event_loop);
- }
-
- __terminated = 1;
- break;
- case SIGUSR2:
- __obex_log_enable_debug();
- break;
- case SIGPIPE:
- /* ignore */
- break;
- }
-
- return TRUE;
-}
-
-static guint setup_signalfd(void)
-{
- GIOChannel *channel;
- guint source;
- sigset_t mask;
- int fd;
-
- sigemptyset(&mask);
- sigaddset(&mask, SIGINT);
- sigaddset(&mask, SIGTERM);
- sigaddset(&mask, SIGUSR2);
- sigaddset(&mask, SIGPIPE);
-
- if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) {
- perror("Failed to set signal mask");
- return 0;
- }
-
- fd = signalfd(-1, &mask, 0);
- if (fd < 0) {
- perror("Failed to create signal descriptor");
- return 0;
- }
-
- channel = g_io_channel_unix_new(fd);
-
- g_io_channel_set_close_on_unref(channel, TRUE);
- g_io_channel_set_encoding(channel, NULL, NULL);
- g_io_channel_set_buffered(channel, FALSE);
-
- source = g_io_add_watch(channel,
- G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
- signal_handler, NULL);
-
- g_io_channel_unref(channel);
-
- return source;
-}
-
-static char *option_debug = NULL;
-static gboolean option_stderr = FALSE;
-
-static gboolean parse_debug(const char *key, const char *value,
- gpointer user_data, GError **error)
-{
- if (value)
- option_debug = g_strdup(value);
- else
- option_debug = g_strdup("*");
-
- return TRUE;
-}
-
-static GOptionEntry options[] = {
- { "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG,
- G_OPTION_ARG_CALLBACK, parse_debug,
- "Enable debug information output", "DEBUG" },
- { "stderr", 's', 0, G_OPTION_ARG_NONE, &option_stderr,
- "Write log information to stderr" },
- { NULL },
-};
-
-
-int main(int argc, char *argv[])
-{
- GOptionContext *context;
- GError *gerr = NULL;
- guint signal;
-
- context = g_option_context_new(NULL);
- g_option_context_add_main_entries(context, options, NULL);
-
- g_option_context_parse(context, &argc, &argv, &gerr);
- if (gerr != NULL) {
- g_printerr("%s\n", gerr->message);
- g_error_free(gerr);
- exit(EXIT_FAILURE);
- }
-
- g_option_context_free(context);
-
- event_loop = g_main_loop_new(NULL, FALSE);
-
- signal = setup_signalfd();
-
- __obex_log_init("obex-client", option_debug, !option_stderr);
-
- if (client_manager_init() < 0)
- exit(EXIT_FAILURE);
-
- DBG("Entering main loop");
-
- g_main_loop_run(event_loop);
-
- g_source_remove(signal);
-
- client_manager_exit();
-
- g_main_loop_unref(event_loop);
-
- __obex_log_cleanup();
-
- return 0;
-}
diff --git a/obexd/src/main.c b/obexd/src/main.c
index af317369c..5d037173d 100644
--- a/obexd/src/main.c
+++ b/obexd/src/main.c
@@ -44,6 +44,8 @@
#include <gdbus/gdbus.h>
+#include "../client/manager.h"
+
#include "log.h"
#include "obexd.h"
#include "server.h"
@@ -314,10 +316,17 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
+ if (client_manager_init() < 0) {
+ error("client_manager_init failed");
+ exit(EXIT_FAILURE);
+ }
+
g_main_loop_run(main_loop);
g_source_remove(signal);
+ client_manager_exit();
+
obex_server_exit();
plugin_cleanup();