From 1325fac9188cff5109db8f59ab3e355fbfaf0c5c Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Thu, 9 Feb 2017 13:46:09 +0900 Subject: [PATCH] Remove capi-system-info package dependency Bluez is GPL license code, so we can't use the tizen specific library in the bluetoothd process. This patchset gets the profile information from model config file directly. Change-Id: I0541943b7bc30bd90b5c829b232ef58e5b2d2386 Signed-off-by: DoHyun Pyun --- Makefile.am | 4 +- Makefile.obexd | 4 +- Makefile.plugins | 4 +- Makefile.tools | 2 +- configure.ac | 10 +++-- packaging/bluez.spec | 3 +- profile.h | 123 ++++++++++++++++++++++++++++++++++++++++++++------- 7 files changed, 123 insertions(+), 27 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9c12a5e..e1a0328 100644 --- a/Makefile.am +++ b/Makefile.am @@ -191,7 +191,7 @@ src_bluetoothd_SOURCES = $(builtin_sources) \ src_bluetoothd_LDADD = lib/libbluetooth-internal.la \ gdbus/libgdbus-internal.la \ src/libshared-glib.la \ - @BACKTRACE_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ @CAPI_SYSTEM_INFO_LIBS@ -ldl -lrt + @BACKTRACE_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ @LIBXML_LIBS@ @INIPARSER_LIBS@ -ldl -lrt src_bluetoothd_LDFLAGS = $(AM_LDFLAGS) -Wl,--export-dynamic \ -Wl,--version-script=$(srcdir)/src/bluetooth.ver @@ -264,7 +264,7 @@ EXTRA_DIST += doc/pics-opp.txt doc/pixit-opp.txt \ EXTRA_DIST += tools/magic.btsnoop -AM_CFLAGS += @DBUS_CFLAGS@ @GLIB_CFLAGS@ @CAPI_SYSTEM_INFO_CFLAGS@ +AM_CFLAGS += @DBUS_CFLAGS@ @GLIB_CFLAGS@ @LIBXML_CFLAGS@ @INIPARSER_CFLAGS@ AM_CPPFLAGS = -I$(builddir)/lib diff --git a/Makefile.obexd b/Makefile.obexd index 83eb147..05a3b6b 100644 --- a/Makefile.obexd +++ b/Makefile.obexd @@ -83,12 +83,12 @@ obexd_src_obexd_SOURCES = $(btio_sources) $(gobex_sources) \ obexd_src_obexd_LDADD = lib/libbluetooth-internal.la \ gdbus/libgdbus-internal.la \ @ICAL_LIBS@ @DBUS_LIBS@ @GLIB_LIBS@ \ - @CAPI_SYSTEM_INFO_LIBS@ -ldl + @LIBXML_LIBS@ @INIPARSER_LIBS@ -ldl obexd_src_obexd_LDFLAGS = -Wl,--export-dynamic obexd_src_obexd_CFLAGS = $(AM_CFLAGS) @GLIB_CFLAGS@ @DBUS_CFLAGS@ \ - @CAPI_SYSTEM_INFO_CFLAGS@ \ + @LIBXML_CFLAGS@ @INIPARSER_CFLAGS@ \ @ICAL_CFLAGS@ -DOBEX_PLUGIN_BUILTIN \ -DPLUGINDIR=\""$(obex_plugindir)"\" \ -fPIC -D_FILE_OFFSET_BITS=64 -pie diff --git a/Makefile.plugins b/Makefile.plugins index 8514c8c..59dd332 100644 --- a/Makefile.plugins +++ b/Makefile.plugins @@ -157,6 +157,6 @@ if SIXAXIS plugin_LTLIBRARIES += plugins/sixaxis.la plugins_sixaxis_la_SOURCES = plugins/sixaxis.c plugins_sixaxis_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version \ - -no-undefined @UDEV_LIBS@ @CAPI_SYSTEM_INFO_LIBS@ -plugins_sixaxis_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden @UDEV_CFLAGS@ @CAPI_SYSTEM_INFO_CFLAGS@ + -no-undefined @UDEV_LIBS@ @LIBXML_LIBS@ @INIPARSER_LIBS@ +plugins_sixaxis_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden @UDEV_CFLAGS@ @LIBXML_CFLAGS@ @INIPARSER_CFLAGS@ endif diff --git a/Makefile.tools b/Makefile.tools index 45193d8..4d80fc7 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -166,7 +166,7 @@ tools_hciattach_SOURCES = tools/hciattach.c tools/hciattach.h \ tools/hciattach_sprd.c \ tools/pskey_get.c \ tools/hciattach_bcm43xx.c -tools_hciattach_LDADD = lib/libbluetooth-internal.la @CAPI_SYSTEM_INFO_LIBS@ +tools_hciattach_LDADD = lib/libbluetooth-internal.la @LIBXML_LIBS@ @INIPARSER_LIBS@ tools_hciconfig_SOURCES = tools/hciconfig.c tools/csr.h tools/csr.c tools_hciconfig_LDADD = lib/libbluetooth-internal.la diff --git a/configure.ac b/configure.ac index fa23e13..bceaa81 100644 --- a/configure.ac +++ b/configure.ac @@ -74,9 +74,13 @@ PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.6, dummy=yes, AC_SUBST(DBUS_CFLAGS) AC_SUBST(DBUS_LIBS) -PKG_CHECK_MODULES(CAPI_SYSTEM_INFO, capi-system-info) -AC_SUBST(CAPI_SYSTEM_INFO_CFLAGS) -AC_SUBST(CAPI_SYSTEM_INFO_LIBS) +PKG_CHECK_MODULES(LIBXML, libxml-2.0) +AC_SUBST(LIBXML_CFLAGS) +AC_SUBST(LIBXML_LIBS) + +PKG_CHECK_MODULES(INIPARSER, iniparser) +AC_SUBST(INIPARSER_CFLAGS) +AC_SUBST(INIPARSER_LIBS) AC_ARG_WITH([dbusconfdir], AC_HELP_STRING([--with-dbusconfdir=DIR], [path to D-Bus configuration directory]), diff --git a/packaging/bluez.spec b/packaging/bluez.spec index 95cb9a1..1786dc1 100644 --- a/packaging/bluez.spec +++ b/packaging/bluez.spec @@ -27,6 +27,8 @@ Source1001: bluez.manifest #Requires: dbus >= 0.60 #BuildRequires: pkgconfig(libudev) BuildRequires: pkgconfig(dbus-1) +BuildRequires: pkgconfig(iniparser) +BuildRequires: pkgconfig(libxml-2.0) #BuildRequires: pkgconfig(glib-2.0) #BuildRequires: pkgconfig(ncurses) #BuildRequires: flex @@ -49,7 +51,6 @@ BuildRequires: pkg-config BuildRequires: readline-devel BuildRequires: udev BuildRequires: pkgconfig(libtzplatform-config) -BuildRequires: pkgconfig(capi-system-info) Requires: %{name}-compat = %{version}-%{release} Recommends: %{name}-profile_common = %{version}-%{release} diff --git a/profile.h b/profile.h index a2019e2..697303d 100644 --- a/profile.h +++ b/profile.h @@ -1,24 +1,36 @@ /* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * 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. * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef __TIZEN_PROFILE_H__ #define __TIZEN_PROFILE_H__ #include -#include + +#include +#include +#include +#include + +#define MODEL_CONFIG_FILE "/etc/config/model-config.xml" +#define TYPE_FIELD "string" +#define FEATURE_TAG "platform" +#define MODEL_CONFIG_TAG "model-config" typedef enum { TIZEN_PROFILE_UNKNOWN = 0, @@ -30,15 +42,93 @@ typedef enum { } tizen_profile_t; static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN; -static inline tizen_profile_t _get_tizen_profile() + +static inline int __get_profile_from_model_config_xml(const char *field, char **value) +{ + char *node_name = NULL; + char *node_value = NULL; + xmlNode *cur_node = NULL; + xmlNodePtr cur_ptr = NULL; + xmlNodePtr model_ptr = NULL; + xmlDocPtr xml_doc = NULL; + + xml_doc = xmlParseFile(MODEL_CONFIG_FILE); + if (xml_doc == NULL) + return -1; + + cur_ptr = xmlDocGetRootElement(xml_doc); + if (cur_ptr == NULL) { + xmlFreeDoc(xml_doc); + return -1; + } + + for (cur_node = cur_ptr; cur_node; cur_node = cur_node->next) { + if (!xmlStrcmp(cur_ptr->name, (const xmlChar*)MODEL_CONFIG_TAG)) + break; + } + + if (cur_ptr == NULL) { + xmlFreeDoc(xml_doc); + return -1; + } + + cur_ptr = cur_ptr->xmlChildrenNode; + for (cur_node = cur_ptr; cur_node; cur_node = cur_node->next) { + if (!xmlStrcmp(cur_node->name, (const xmlChar*)FEATURE_TAG)) { + model_ptr = cur_node; + break; + } + } + + if (model_ptr == NULL) { + xmlFreeDoc(xml_doc); + return -1; + } + + if (model_ptr) { + cur_ptr = model_ptr->xmlChildrenNode; + + for (cur_node = cur_ptr; cur_node; cur_node = cur_node->next) { + if (cur_node->type == XML_ELEMENT_NODE) { + node_name = (char *)xmlGetProp(cur_node, (const xmlChar*)"name"); + + if (!strncmp(node_name, field, strlen(node_name))) { + node_value = (char *)xmlNodeListGetString(xml_doc, cur_node->xmlChildrenNode, 1); + if (node_value) { + *value = strdup(node_value); + free(node_name); + free(node_value); + break; + } + } + free(node_name); + } + } + } + + xmlFreeDoc(xml_doc); + return 0; +} + +static inline tizen_profile_t _get_tizen_profile(void) { - char *profileName; + char *profile_name = NULL; if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1)) return profile; - system_info_get_platform_string("http://tizen.org/feature/profile", &profileName); - switch (*profileName) { + if (__get_profile_from_model_config_xml("tizen.org/feature/profile", + &profile_name) < 0) { + profile = TIZEN_PROFILE_MOBILE; + return profile; + } + + if (profile_name == NULL) { + profile = TIZEN_PROFILE_MOBILE; + return profile; + } + + switch (*profile_name) { case 'm': case 'M': profile = TIZEN_PROFILE_MOBILE; @@ -55,13 +145,14 @@ static inline tizen_profile_t _get_tizen_profile() case 'I': profile = TIZEN_PROFILE_IVI; break; - default: // common or unknown ==> ALL ARE COMMON. + default: /* common or unknown ==> ALL ARE COMMON */ profile = TIZEN_PROFILE_COMMON; } - free(profileName); + free(profile_name); return profile; } + #define TIZEN_FEATURE_BLUEZ_BRCM_CHIP ((_get_tizen_profile()) == TIZEN_PROFILE_IVI) #define TIZEN_FEATURE_BLUEZ_SMS_ONLY ((_get_tizen_profile()) == TIZEN_PROFILE_WEARABLE) #define TIZEN_FEATURE_BLUEZ_BRCM_QOS ((_get_tizen_profile()) == TIZEN_PROFILE_WEARABLE) -- 2.7.4