From ecedf91d68b97b5876ac75e5bfa3365dd8e70e1e Mon Sep 17 00:00:00 2001 From: Jin Yoon Date: Mon, 24 Jul 2017 11:43:09 +0900 Subject: [PATCH] Encapsulate pre-defined functions into controller_internal.c Change-Id: I5801569003f9331fd8e7a7bd4fb9c96e237ae9f0 --- CMakeLists.txt | 1 + inc/controller.h | 2 ++ inc/controller_internal.h | 28 ++++++++++++++++++++++++++++ src/controller.c | 20 ++------------------ src/controller_internal.c | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 inc/controller_internal.h create mode 100644 src/controller_internal.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d4f9c9..91e1717 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ INCLUDE_DIRECTORIES(${PROJECT_ROOT_DIR}/inc) ADD_EXECUTABLE(${PROJECT_NAME} ${PROJECT_ROOT_DIR}/src/controller.c + ${PROJECT_ROOT_DIR}/src/controller_internal.c ${PROJECT_ROOT_DIR}/src/connectivity.c ${PROJECT_ROOT_DIR}/src/resource.c ${PROJECT_ROOT_DIR}/src/resource/resource_illuminance_sensor.c diff --git a/inc/controller.h b/inc/controller.h index 8920022..154bb76 100644 --- a/inc/controller.h +++ b/inc/controller.h @@ -22,4 +22,6 @@ #ifndef __POSITION_FINDER_CONTROLLER_H__ #define __POSITION_FINDER_CONTROLLER_H__ +#include "controller_internal.h" + #endif /* __POSITION_FINDER_CONTROLLER_H__ */ diff --git a/inc/controller_internal.h b/inc/controller_internal.h new file mode 100644 index 0000000..73c6a23 --- /dev/null +++ b/inc/controller_internal.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: Jin Yoon + * Geunsun Lee + * Eunyoung Lee + * Junkyu Han + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 __POSITION_FINDER_CONTROLLER_INTERNAL_H__ +#define __POSITION_FINDER_CONTROLLER_INTERNAL_H__ + +extern void controller_init_internal_functions(void); +extern void controller_fini_internal_functions(void); + +#endif /* __POSITION_FINDER_CONTROLLER_INTERNAL_H__ */ diff --git a/src/controller.c b/src/controller.c index cee20d9..06cb7b7 100644 --- a/src/controller.c +++ b/src/controller.c @@ -42,9 +42,6 @@ #define USE_MULTIPLE_SENSOR 0 #define MULTIPLE_SENSOR_NUMBER 5 -static void _start_internal_function(void); -static void _stop_internal_function(void); - typedef struct app_data_s { Ecore_Timer *getter_timer[PIN_MAX]; connectivity_resource_s *resource_info; @@ -111,7 +108,7 @@ static bool service_app_create(void *data) app_data *ad = data; int ret = -1; - _start_internal_function(); + controller_init_internal_functions(); ret = connectivity_set_resource("/door/1", "org.tizen.door", &ad->resource_info); if (ret == -1) _E("Cannot broadcast resource"); @@ -159,7 +156,7 @@ static void service_app_terminate(void *data) } connectivity_unset_resource(ad->resource_info); - _stop_internal_function(); + controller_fini_internal_functions(); free(ad); } @@ -211,16 +208,3 @@ int main(int argc, char* argv[]) return ret; } - -/* Do not modify codes under this comment */ -static void _start_internal_function(void) -{ - connectivity_init(); -} - -static void _stop_internal_function(void) -{ - _I("Terminating..."); - resource_close_all(); - connectivity_fini(); -} diff --git a/src/controller_internal.c b/src/controller_internal.c new file mode 100644 index 0000000..9deb732 --- /dev/null +++ b/src/controller_internal.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: Jin Yoon + * Geunsun Lee + * Eunyoung Lee + * Junkyu Han + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + +#include + +#include "log.h" +#include "connectivity.h" +#include "resource.h" + +void controller_init_internal_functions(void) +{ + connectivity_init(); +} + +void controller_fini_internal_functions(void) +{ + _I("Terminating..."); + resource_close_all(); + connectivity_fini(); +} -- 2.34.1