From ffd2b546e5eea2b361791bbe9062f1baf8530c35 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 13 Nov 2010 07:40:43 +0900 Subject: [PATCH] Use a proper technology callback to report Tethering status --- Makefile.am | 2 +- include/technology.h | 3 +++ include/tethering.h | 28 ---------------------------- plugins/bluetooth.c | 5 ++--- src/connman.h | 6 ++++-- src/technology.c | 11 +++++++++++ src/tethering.c | 6 ++---- 7 files changed, 23 insertions(+), 38 deletions(-) delete mode 100644 include/tethering.h diff --git a/Makefile.am b/Makefile.am index 651eede..badab1c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,7 +8,7 @@ include_HEADERS = include/types.h include/log.h include/plugin.h \ include/storage.h include/service.h \ include/resolver.h include/ipconfig.h \ include/device.h include/network.h include/inet.h \ - include/ondemand.h include/tethering.h + include/ondemand.h nodist_include_HEADERS = include/version.h diff --git a/include/technology.h b/include/technology.h index dcab267..7471a53 100644 --- a/include/technology.h +++ b/include/technology.h @@ -36,6 +36,9 @@ extern "C" { struct connman_technology; +void connman_technology_tethering_notify(struct connman_technology *technology, + connman_bool_t enabled); + struct connman_technology_driver { const char *name; enum connman_service_type type; diff --git a/include/tethering.h b/include/tethering.h deleted file mode 100644 index 63f4f68..0000000 --- a/include/tethering.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Connection Manager - * - * Copyright (C) 2007-2010 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 - * - */ - -#ifndef __CONNMAN_TETHERING_H -#define __CONNMAN_TETHERING_H - -void connman_tethering_enabled(void); -void connman_tethering_disabled(void); - -#endif diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c index 984a647..03a01dc 100644 --- a/plugins/bluetooth.c +++ b/plugins/bluetooth.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -969,7 +968,7 @@ static void server_register_reply(DBusPendingCall *call, void *user_data) dbus_message_unref(reply); dbus_pending_call_unref(call); - connman_tethering_enabled(); + connman_technology_tethering_notify(NULL, TRUE); } static void server_unregister_reply(DBusPendingCall *call, void *user_data) @@ -994,7 +993,7 @@ static void server_unregister_reply(DBusPendingCall *call, void *user_data) dbus_message_unref(reply); dbus_pending_call_unref(call); - connman_tethering_disabled(); + connman_technology_tethering_notify(NULL, FALSE); } diff --git a/src/connman.h b/src/connman.h index 8cb4754..7dbd707 100644 --- a/src/connman.h +++ b/src/connman.h @@ -420,6 +420,8 @@ void __connman_tethering_cleanup(void); connman_bool_t __connman_tethering_get_status(void); int __connman_tethering_set_status(connman_bool_t status); void __connman_tethering_update_interface(const char *interface); +void __connman_tethering_set_enabled(void); +void __connman_tethering_set_disabled(void); #include @@ -428,9 +430,9 @@ void __connman_provider_list(DBusMessageIter *iter, void *user_data); int __connman_provider_create_and_connect(DBusMessage *msg); const char * __connman_provider_get_ident(struct connman_provider *provider); int __connman_provider_indicate_state(struct connman_provider *provider, - enum connman_provider_state state); + enum connman_provider_state state); int __connman_provider_indicate_error(struct connman_provider *provider, - enum connman_provider_error error); + enum connman_provider_error error); int __connman_provider_connect(struct connman_provider *provider); int __connman_provider_disconnect(struct connman_provider *provider); int __connman_provider_remove(const char *path); diff --git a/src/technology.c b/src/technology.c index b0810f2..b315e95 100644 --- a/src/technology.c +++ b/src/technology.c @@ -177,6 +177,17 @@ void __connman_technology_remove_interface(enum connman_service_type type, } } +void connman_technology_tethering_notify(struct connman_technology *technology, + connman_bool_t enabled) +{ + DBG("technology %p enabled %u", technology, enabled); + + if (enabled == TRUE) + __connman_tethering_set_enabled(); + else + __connman_tethering_set_disabled(); +} + static int set_tethering(const char *bridge, connman_bool_t enabled) { GSList *list; diff --git a/src/tethering.c b/src/tethering.c index 154efe9..04f3409 100644 --- a/src/tethering.c +++ b/src/tethering.c @@ -31,8 +31,6 @@ #include "connman.h" -#include - #define BRIDGE_NAME "tether" static connman_bool_t tethering_status = FALSE; @@ -128,7 +126,7 @@ static void disable_nat(const char *interface) /* TODO: Flush nat POSTROUTING chain */ } -void connman_tethering_enabled(void) +void __connman_tethering_set_enabled(void) { if (tethering_status == FALSE) return; @@ -143,7 +141,7 @@ void connman_tethering_enabled(void) } } -void connman_tethering_disabled(void) +void __connman_tethering_set_disabled(void) { if (tethering_status == FALSE) return; -- 2.7.4