Remove unused code and function.
authorHeejin Kim <hj_elena.kim@samsung.com>
Sat, 23 Sep 2017 14:55:35 +0000 (23:55 +0900)
committerHeejin Kim <hj_elena.kim@samsung.com>
Sat, 23 Sep 2017 14:55:35 +0000 (23:55 +0900)
Reflect davidfather's comment

framework/src/st_things/st_things.c
framework/src/st_things/things_stack/inc/things_api.h
framework/src/st_things/things_stack/src/common/easy-setup/easysetup_manager.c
framework/src/st_things/things_stack/src/common/framework/things_data_manager.c
framework/src/st_things/things_stack/src/common/framework/things_req_handler.c
framework/src/st_things/things_stack/src/common/framework/things_resource.c
framework/src/st_things/things_stack/src/common/framework/things_security_manager.c
framework/src/st_things/things_stack/src/common/framework/things_server_builder.c
framework/src/st_things/things_stack/src/common/utils/things_ping.c
framework/src/st_things/things_stack/src/common/utils/things_string_util.c
framework/src/st_things/things_stack/src/stack/things_stack.c

index 9be054a..25c0329 100644 (file)
@@ -385,46 +385,6 @@ int st_things_start(void)
        return ST_THINGS_ERROR_OPERATION_FAILED;
 }
 
-int st_things_stop(void)
-{
-       ST_LOG_ENTRY(ST_INFO);
-
-       if (STACK_STARTED != g_stack_status) {
-               int ret_val = ST_THINGS_ERROR_OPERATION_FAILED;
-               switch (g_stack_status) {
-               case STACK_NOT_INITIALIZED:
-                       ST_LOG(ST_ERROR, "Stack is not initialized.");
-                       ret_val = ST_THINGS_ERROR_STACK_NOT_INITIALIZED;
-                       break;
-               case STACK_INITIALIZED:
-                       ST_LOG(ST_ERROR, "Stack is not started.");
-                       ret_val = ST_THINGS_ERROR_STACK_NOT_STARTED;
-                       break;
-               default:
-                       ST_LOG_V(ST_ERROR, "Invalid stack state: %d.", g_stack_status);
-                       break;
-               }
-
-               ST_LOG_EXIT(ST_INFO);
-               return ret_val;
-       }
-
-       int result = 0;
-
-       // Terminate DA Stack.
-       if (1 != (result = things_stop())) {
-               ST_LOG_V(ST_ERROR, "things_stop failed (result:%d)", result);
-               ST_LOG_EXIT(ST_INFO);
-               return ST_THINGS_ERROR_OPERATION_FAILED;
-       }
-
-       g_stack_status = STACK_INITIALIZED;
-
-       ST_LOG_EXIT(ST_INFO);
-       ST_LOG_DEINIT();
-       return ST_THINGS_ERROR_NONE;
-}
-
 int st_things_register_request_cb(st_things_get_request_cb get_cb, st_things_set_request_cb set_cb)
 {
        ST_LOG_ENTRY(ST_INFO);
index 53f2911..f68c4f6 100644 (file)
@@ -54,8 +54,6 @@ int things_return_user_opinion_for_reset(int b_reset_start);
 
 int things_reset(void *remote_owner, things_es_enrollee_reset_e reset_type);
 
-int things_stop(void);
-
 typedef int (*things_handle_request_func_type)(struct things_resource_s *p_resource);
 int things_register_handle_request_func(things_handle_request_func_type get_func, things_handle_request_func_type set_func);
 
index 0b9310b..e535e4e 100644 (file)
@@ -291,9 +291,6 @@ esm_result_e esm_init_easysetup(int restart_flag, things_server_builder_s *serve
                THINGS_LOG_V_ERROR(THINGS_ERROR, TAG, "Easy Setup Memory allocation is failed.");
                return ESM_ERROR;
        }
-//    es_device_property device_property = {
-//        {{WiFi_11G, WiFi_11N, WiFi_11AC, WiFi_EOF}, WiFi_5G}, {"Test Device"}
-//    };
 
        if (server_builder != NULL) {
                g_server_builder = server_builder;
@@ -632,7 +629,6 @@ static void *wifi_prov_timeout_handler(timeout_s *param)
 
        if (ESM_OK != esm_init_easysetup(1, NULL)) {
                THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Easy-Setup Module Initialization failed");
-               things_stop();
                return NULL;
        }
 
@@ -896,8 +892,6 @@ void cloud_data_prov_cb_in_app(es_cloud_prov_data_s *event_data)
 
 bool esm_get_network_status(void)
 {
-       //THINGS_LOG_D(THINGS_DEBUG, TAG, "Enter.");
-
        bool is_ok = false;
 
        if (things_is_net_initialize() != 1) {
@@ -924,7 +918,6 @@ bool esm_get_network_status(void)
                es_set_state(ES_STATE_INIT);
        }
 
-       //THINGS_LOG_D(THINGS_DEBUG, TAG, "Exit.");
        return is_ok;
 }
 
@@ -945,7 +938,6 @@ int esm_register_pin_generated_cb(pin_generated_func_type func)
 {
        if (func) {
                g_pin_generated_cb = func;
-               // SetGeneratePinCB(generate_pin_cb);
                return 1;
        } else {
                THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Invalid PINGeneratedCB function");
@@ -957,7 +949,6 @@ int esm_register_pin_close_cb(pin_close_func_type func)
 {
        if (func) {
                g_pin_close_cb = func;
-               // SetGeneratePinCB(generate_pin_cb);
                return 1;
        } else {
                THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Invalid PINGeneratedCB function");
@@ -969,8 +960,6 @@ int esm_register_user_confirm_cb(user_confirm_result_func_type func)
 {
        if (func) {
                g_user_confirm_cb = func;
-
-               // SetUserConfirmCB(NULL, get_user_confirmation);
                return 1;
        } else {
                THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Invalid UserConformCB function");
index 3b753fd..c041d05 100644 (file)
@@ -1545,7 +1545,6 @@ static things_resource_s *register_resource(things_server_builder_s *p_builder,
                THINGS_LOG_D(THINGS_DEBUG, TAG, "RESOURCE TO REGISTER : %s", resource->uri);
 
                memset(res_uri, 0, (size_t) MAX_URI_LENGTH);
-               /*SVACE warning fix */
                strncat(res_uri, resource->uri, MAX_URI_LENGTH);
 
                ret = p_builder->create_resource(p_builder, res_uri, resource->resource_types[0], resource->interface_types[0], CHECK_DISCOVERABLE(resource->policy), CHECK_OBSERVABLE(resource->policy), CHECK_SECURE(resource->policy));
@@ -1803,7 +1802,6 @@ int dm_register_resource(things_server_builder_s *p_builder)
                device = (st_device_s *) hashmap_get(g_device_hmap, (unsigned long)device_num);
 
                if (NULL != device) {
-                       /*SVACE warning fix */
                        snprintf(id, sizeof(id), "%d", device->no);
                        THINGS_LOG_D(THINGS_DEBUG, TAG, "==================== Device (%s) ====================", id);
 
@@ -2260,8 +2258,6 @@ int dm_init_module(const char *devJsonPath)
        return Parse_things_files(devJsonPath);
 }
 
-//
-
 int dm_termiate_module()
 {
        //  Need to backup all the keys in order to delete from the map.
index b12583f..20cc6f5 100644 (file)
@@ -115,12 +115,6 @@ static int verify_request(OCEntityHandlerRequest *eh_request, const char *uri, i
                // the result of additional verification
                result = 0;
 
-               // if(gValidator == NULL )
-               // {s
-               //     THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Validator not registered");
-               //     goto EXIT_VALIDATION;
-               // }
-
                //  If the given resource does not have sensor nor read interface type..
                if (!(resource->things_is_supporting_interface_type(resource, OIC_INTERFACE_SENSOR))
                        && !(resource->things_is_supporting_interface_type(resource, OC_RSRVD_INTERFACE_READ))) {
@@ -1117,12 +1111,6 @@ void init_handler()
 {
        g_quit_flag = false;
 
-//#ifdef __ST_THINGS_RTOS__
-//    pthread_create_rtos(&g_req_handle, NULL, message_handling_loop, (void *)NULL, THINGS_STACK_MESSAGE_HANDLING_THREAD);
-//#else
-//   things_thread_create (&g_req_handle, NULL, message_handling_loop, (void *)NULL);
-//#endif
-
 }
 
 void deinit_handler()
index 9cd5445..d531e43 100644 (file)
@@ -823,7 +823,6 @@ things_resource_s *things_create_resource_inst(OCRequestHandle requesthd, OCReso
        return res;
 }
 
-// BTD
 things_resource_s *clone_resource_inst(things_resource_s *pori)
 {
        if (pori == NULL) {
index ad8a93e..fd43e31 100644 (file)
@@ -445,7 +445,7 @@ static int get_mac_addr(unsigned char *p_id_buf, size_t p_id_buf_size, unsigned
        return OIC_SEC_OK;
 }
 
-// ++ Added by Chul Lee : To support MAC based UUID
+// To support MAC based UUID
 int sm_generate_mac_based_device_id(bool is_forced)
 {
        THINGS_LOG_D(THINGS_DEBUG, TAG, "In %s", __func__);
@@ -492,7 +492,7 @@ int sm_generate_mac_based_device_id(bool is_forced)
        return res;
 }
 
-// ++ Added by Chul Lee : To support MAC based UUID
+// To support MAC based UUID
 //
 
 int sm_init_things_security(int auth_type, const char *db_path)
@@ -591,7 +591,7 @@ int sm_reset_svrdb()
 }
 
 //
-// ++ Added by Chul Lee : to test certificate based (D)TLS connection for  D2D & D2S
+// To test certificate based (D)TLS connection for  D2D & D2S
 
 #ifndef _EXCLUDE_TEST_KEY_
 static OicSecKey_t primary_cert;
index f888f54..0174f68 100644 (file)
@@ -77,21 +77,7 @@ void *presence_noti_loop(void *param)
        THINGS_LOG_D(THINGS_DEBUG, TAG, THINGS_FUNC_ENTRY);
 
        if (OCStartPresence(0) == OC_STACK_OK) {
-               /*        while (!g_quit_flag)
-                  {
-                  g_presence_flag++;
-                  //THINGS_LOG_D(THINGS_DEBUG, TAG, "COUNT : %d", g_presence_flag);
-                  if (g_presence_flag > g_presence_duration)
-                  {
-                  g_presence_flag = 0;
-                  OCStopPresence();
-                  THINGS_LOG(THINGS_INFO, TAG, "Stop Sending Presence Packet");
-                  is_presence = false;
-                  break;
-                  }
-                  sleep(1);
-                  }
-                */
+               THINGS_LOG_D(THINGS_DEBUG, TAG, "OC Stack is available");
        } else {
                THINGS_LOG_ERROR(THINGS_ERROR, TAG, "OCStartPresence Error");
        }
@@ -128,8 +114,7 @@ struct things_resource_s *create_resource(struct things_server_builder_s *builde
        if (1 == isObserable) {
                rsc_properties |= OC_OBSERVABLE;
        }
-       // if( strstr(uri, URI_ACCESSPOINTLIST) == 0
-       //     && strstr(uri, URI_PROVINFO) == 0 )
+
        if (1 == isSecure) {
 #ifdef __SECURED__
                rsc_properties |= OC_SECURE;
@@ -321,8 +306,6 @@ int broadcast_presence(things_server_builder_s *builder, int max_cnt)
 
 void init_builder(struct things_server_builder_s *builder, request_handler_cb cb)
 {
-       //if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
-       //if(OC_STACK_OK != OCInit1 (OC_CLIENT_SERVER,OC_IP_USE_V4, OC_IP_USE_V4) )
        OCTransportAdapter m_transport = (OC_ADAPTER_IP | OC_ADAPTER_TCP);
        if (OC_STACK_OK != OCInit2(OC_CLIENT_SERVER, OC_IP_USE_V4, OC_IP_USE_V4, m_transport)) {
                THINGS_LOG_ERROR(THINGS_ERROR, TAG, "RESOURCE SERVER START FAILED");
index f0b0ef6..d15af76 100644 (file)
@@ -69,7 +69,6 @@ typedef struct things_ping_s {
 static list_s *list = NULL;
 static const char INTERVAL_ARRAY[] = "inarray";
 static const char INTERVAL[] = "in";
-things_ping_s *pPing = NULL;   //SKKIM for ping command
 
 static void *thd_ping_loop(things_ping_s *ping);
 static OCStackApplicationResult discover_ping_resource_handler(void *ctx, OCDoHandle handle, OCClientResponse *client_response);
@@ -114,7 +113,6 @@ bool oic_ping_init(void)
                res = true;
        }
 
-       pPing = NULL;
        THINGS_LOG(THINGS_DEBUG, TAG, "Exit.");
        return res;
 }
@@ -291,7 +289,6 @@ static void *__attribute__((optimize("O0"))) thd_ping_loop(things_ping_s *ping)
                sleep(sleepTime);
        } while (!ping->continue_thread);
 
-       pPing = ping;
        int sleepDelay = 10;
 
        THINGS_LOG_D(THINGS_DEBUG, TAG, "Start common-Ping request for /oic/ping to Cloud(%s)", ping->addr);
@@ -337,18 +334,10 @@ static void *__attribute__((optimize("O0"))) thd_ping_loop(things_ping_s *ping)
        unset_mask(ping, PING_ST_STARTTHREAD | PING_ST_DISCOVERY | PING_ST_REQUEST | PING_ST_INTUPDATE | PING_ST_TIMEOUT);
        ping->continue_thread = false;
        set_def_interval(ping);
-       pPing = NULL;
        THINGS_LOG(THINGS_DEBUG, TAG, "Exit.");
        return (void *)1;
 }
 
-//void CommandPing()                //SKKIM for ping command
-//{
-//  if (pPing != NULL) {
-//      send_things_ping_request(pPing);
-//  }
-//}
-
 static OCStackApplicationResult discover_ping_resource_handler(void *ctx, OCDoHandle handle, OCClientResponse *client_response)
 {
        THINGS_LOG(THINGS_DEBUG, TAG, "Enter.");
index d792dae..32918dd 100644 (file)
@@ -110,7 +110,6 @@ int get_id_value_from_query(char idvalue[], char *inputQuery, int size)
                return 0;
        }
 
-       /*[Jaehong] (Need to consider trim to remove space in query) */
        // Remove empty space
        char queries[MAX_INPUT_QUERY_LEN + 1] = { 0, };
        int index = 0;
index 70d1c98..cd06df8 100644 (file)
@@ -498,7 +498,6 @@ int things_start_stack()
 
        if (0 != sm_init_things_security(auty_type, dm_get_svrdb_file_path())) {
                THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Failed to initialize OICSecurity features");
-               things_stop();
                return 0;
        }
        sm_set_otm_event_handler(otm_event_cb);
@@ -506,7 +505,6 @@ int things_start_stack()
        g_req_handler = get_handler_instance();
        if (NULL == g_req_handler) {
                THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Failed to initialize Request Handler");
-               things_stop();
                return 0;
        }
        // Will be refactored to received callbacks for GET/PUT/POST/DELETE/OBSERVE ..
@@ -516,7 +514,6 @@ int things_start_stack()
        g_server_builder = get_builder_instance();
        if (NULL == g_server_builder) {
                THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Failed to initialize Resource Server");
-               things_stop();
                return 0;
        }
 
@@ -526,7 +523,6 @@ int things_start_stack()
        //5. Generate MAC based device UUID
        if (0 != sm_generate_mac_based_device_id(false)) {
                THINGS_LOG(THINGS_WARNING, TAG, "Failed to generate MAC based device_id");
-               things_stop();
                return 0;
        }
 #endif
@@ -534,19 +530,16 @@ int things_start_stack()
        // 6. Register Device-ID & Resources
        if (dm_register_device_id() == false) {
                THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Failed to register Device ID");
-               things_stop();
                return 0;
        }
 
        if (!dm_register_resource(g_server_builder)) {
                THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Failed to register Resource");
-               things_stop();
                return 0;
        }
        // 7. Initiate Easy-Setup & Login to Cloud
        if (ESM_OK != esm_init_easysetup(0, g_server_builder)) {
                THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Failed to initialize Easy-Setup Module");
-               things_stop();
                return 0;
        }
        // Register Callback
@@ -554,7 +547,6 @@ int things_start_stack()
 
        if (es_cloud_init(g_server_builder) == NULL) {
                THINGS_LOG_ERROR(THINGS_ERROR, TAG, "Failed to initialize Cloud");
-               things_stop();
                return 0;
        }
 
@@ -634,45 +626,6 @@ GOTO_OUT:
        return res;
 }
 
-int things_stop(void)
-{
-       pthread_mutex_lock(&g_things_stop_mutex);
-
-       THINGS_LOG_D(THINGS_DEBUG, TAG, THINGS_FUNC_ENTRY);
-       g_quit_flag = 1;
-       is_things_module_inited = 0;
-
-       pthread_mutex_lock(&m_thread_oic_reset);
-       if (b_thread_things_reset == true) {
-               b_reset_continue_flag = false;
-               h_thread_things_reset = 0;
-               b_thread_things_reset = false;
-       }
-       pthread_mutex_unlock(&m_thread_oic_reset);
-
-       THINGS_LOG_D(THINGS_DEBUG, TAG, "Terminate Cloud Session Managing");
-       es_cloud_terminate();
-
-       THINGS_LOG_D(THINGS_DEBUG, TAG, "Terminate EasySetup");
-       esm_terminate_easysetup();
-
-       if (g_server_builder != NULL) {
-               g_server_builder->deinit_module(g_server_builder);
-               release_builder_instance(g_server_builder);
-               g_server_builder = NULL;
-       }
-       if (g_req_handler != NULL) {
-               g_req_handler->deinit_module();
-               release_handler_instance(g_req_handler);
-               g_req_handler = NULL;
-       }
-       // Need to add memory release for the Queue..
-       THINGS_LOG_D(THINGS_DEBUG, TAG, THINGS_FUNC_EXIT);
-
-       pthread_mutex_unlock(&g_things_stop_mutex);
-       return 1;
-}
-
 int things_register_confirm_reset_start_func(things_reset_confirm_func_type func)
 {
        if (func != NULL) {