diff options
Diffstat (limited to 'src/libcharon/plugins/android')
-rw-r--r-- | src/libcharon/plugins/android/Makefile.am | 1 | ||||
-rw-r--r-- | src/libcharon/plugins/android/android_logger.c | 108 | ||||
-rw-r--r-- | src/libcharon/plugins/android/android_logger.h | 52 | ||||
-rw-r--r-- | src/libcharon/plugins/android/android_plugin.c | 10 |
4 files changed, 0 insertions, 171 deletions
diff --git a/src/libcharon/plugins/android/Makefile.am b/src/libcharon/plugins/android/Makefile.am index b922ef4af..b10cd9527 100644 --- a/src/libcharon/plugins/android/Makefile.am +++ b/src/libcharon/plugins/android/Makefile.am @@ -14,7 +14,6 @@ libstrongswan_android_la_SOURCES = \ android_plugin.c android_plugin.h \ android_service.c android_service.h \ android_handler.c android_handler.h \ - android_logger.c android_logger.h \ android_creds.c android_creds.h libstrongswan_android_la_LDFLAGS = -module -avoid-version diff --git a/src/libcharon/plugins/android/android_logger.c b/src/libcharon/plugins/android/android_logger.c deleted file mode 100644 index 0c5f609f7..000000000 --- a/src/libcharon/plugins/android/android_logger.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2010-2012 Tobias Brunner - * Hochschule fuer Technik Rapperswil - * - * 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. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * 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. - */ - -#include <string.h> -#include <android/log.h> - -#include "android_logger.h" - -#include <library.h> -#include <daemon.h> -#include <threading/mutex.h> - -typedef struct private_android_logger_t private_android_logger_t; - -/** - * Private data of an android_logger_t object - */ -struct private_android_logger_t { - - /** - * Public interface - */ - android_logger_t public; - - /** - * logging level - */ - int level; - - /** - * Mutex to ensure multi-line log messages are not torn apart - */ - mutex_t *mutex; -}; - -METHOD(logger_t, log_, void, - private_android_logger_t *this, debug_t group, level_t level, - int thread, ike_sa_t* ike_sa, const char *message) -{ - int prio = level > 1 ? ANDROID_LOG_DEBUG : ANDROID_LOG_INFO; - char sgroup[16]; - const char *current = message, *next; - snprintf(sgroup, sizeof(sgroup), "%N", debug_names, group); - this->mutex->lock(this->mutex); - while (TRUE) - { /* log each line separately */ - next = strchr(current, '\n'); - if (next == NULL) - { - __android_log_print(prio, "charon", "%.2d[%s] %s\n", - thread, sgroup, current); - break; - } - __android_log_print(prio, "charon", "%.2d[%s] %.*s\n", - thread, sgroup, (int)(next - current), current); - current = next + 1; - } - this->mutex->unlock(this->mutex); -} - -METHOD(logger_t, get_level, level_t, - private_android_logger_t *this, debug_t group) -{ - return this->level; -} - -METHOD(android_logger_t, destroy, void, - private_android_logger_t *this) -{ - this->mutex->destroy(this->mutex); - free(this); -} - -/** - * Described in header. - */ -android_logger_t *android_logger_create() -{ - private_android_logger_t *this; - - INIT(this, - .public = { - .logger = { - .log = _log_, - .get_level = _get_level, - }, - .destroy = _destroy, - }, - .mutex = mutex_create(MUTEX_TYPE_DEFAULT), - .level = lib->settings->get_int(lib->settings, - "%s.plugins.android.loglevel", 1, charon->name), - ); - - return &this->public; -} - diff --git a/src/libcharon/plugins/android/android_logger.h b/src/libcharon/plugins/android/android_logger.h deleted file mode 100644 index 15abbb43f..000000000 --- a/src/libcharon/plugins/android/android_logger.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2010 Tobias Brunner - * Hochschule fuer Technik Rapperswil - * - * 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. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * 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. - */ - -/** - * @defgroup android_logger android_logger - * @{ @ingroup android - */ - -#ifndef ANDROID_LOGGER_H_ -#define ANDROID_LOGGER_H_ - -#include <bus/bus.h> - -typedef struct android_logger_t android_logger_t; - -/** - * Android specific logger. - */ -struct android_logger_t { - - /** - * Implements logger_t interface - */ - logger_t logger; - - /** - * Destroy the logger. - */ - void (*destroy)(android_logger_t *this); - -}; - -/** - * Create an Android specific logger instance. - * - * @return logger instance - */ -android_logger_t *android_logger_create(); - -#endif /** ANDROID_LOGGER_H_ @}*/ diff --git a/src/libcharon/plugins/android/android_plugin.c b/src/libcharon/plugins/android/android_plugin.c index bad8bc042..c0f58e9b4 100644 --- a/src/libcharon/plugins/android/android_plugin.c +++ b/src/libcharon/plugins/android/android_plugin.c @@ -15,7 +15,6 @@ */ #include "android_plugin.h" -#include "android_logger.h" #include "android_handler.h" #include "android_creds.h" #include "android_service.h" @@ -36,11 +35,6 @@ struct private_android_plugin_t { android_plugin_t public; /** - * Android specific logger - */ - android_logger_t *logger; - - /** * Android specific DNS handler */ android_handler_t *handler; @@ -68,10 +62,8 @@ METHOD(plugin_t, destroy, void, hydra->attributes->remove_handler(hydra->attributes, &this->handler->handler); lib->credmgr->remove_set(lib->credmgr, &this->creds->set); - charon->bus->remove_logger(charon->bus, &this->logger->logger); this->creds->destroy(this->creds); this->handler->destroy(this->handler); - this->logger->destroy(this->logger); DESTROY_IF(this->service); free(this); } @@ -91,14 +83,12 @@ plugin_t *android_plugin_create() .destroy = _destroy, }, }, - .logger = android_logger_create(), .creds = android_creds_create(), ); this->service = android_service_create(this->creds); this->handler = android_handler_create(this->service != NULL); - charon->bus->add_logger(charon->bus, &this->logger->logger); lib->credmgr->add_set(lib->credmgr, &this->creds->set); hydra->attributes->add_handler(hydra->attributes, &this->handler->handler); |