summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeonghoon Park <jh1979.park@samsung.com>2017-11-07 16:35:26 +0900
committerJeonghoon Park <jh1979.park@samsung.com>2017-11-07 16:35:26 +0900
commitf769c46b3607660cbf579e2685664e10a2aca79d (patch)
tree0d4f9f900f79a3d1bb92f5b1208a5368e0dcd9aa
parent0fecff5b65c14959cf8ab130d1559e8c95b2cdbe (diff)
downloadrcc-f769c46b3607660cbf579e2685664e10a2aca79d.tar.gz
rcc-f769c46b3607660cbf579e2685664e10a2aca79d.tar.bz2
rcc-f769c46b3607660cbf579e2685664e10a2aca79d.zip
add remove functions for attributes notify
Change-Id: I59493283b84428424b7776f56bc19dd3dbb93741
-rw-r--r--inc/connectivity.h2
-rw-r--r--src/connectivity.c31
2 files changed, 31 insertions, 2 deletions
diff --git a/inc/connectivity.h b/inc/connectivity.h
index 5bb4ba3..9adfcb6 100644
--- a/inc/connectivity.h
+++ b/inc/connectivity.h
@@ -95,5 +95,7 @@ extern int connectivity_attributes_add_int(connectivity_resource_s *resource_inf
extern int connectivity_attributes_add_double(connectivity_resource_s *resource_info, const char *key, double value);
extern int connectivity_attributes_add_string(connectivity_resource_s *resource_info, const char *key, const char *value);
extern int connectivity_attributes_notify_all(connectivity_resource_s *resource_info);
+extern int connectivity_attributes_remove_value_by_key(connectivity_resource_s *resource_info, const char *key);
+extern int connectivity_attributes_remove_all(connectivity_resource_s *resource_info);
#endif /* __POSITION_FINDER_CONNECTIVITY_H__ */
diff --git a/src/connectivity.c b/src/connectivity.c
index 9cf3059..a9c695b 100644
--- a/src/connectivity.c
+++ b/src/connectivity.c
@@ -905,6 +905,29 @@ int connectivity_attributes_add_string(connectivity_resource_s *resource_info, c
return __add_value_to_hash(resource_info, key, data_value);
}
+int connectivity_attributes_remove_value_by_key(connectivity_resource_s *resource_info, const char *key)
+{
+ retv_if(!resource_info, -1);
+ retv_if(!key, -1);
+
+ if (resource_info->value_hash)
+ g_hash_table_remove(resource_info->value_hash, key);
+
+ return 0;
+}
+
+int connectivity_attributes_remove_all(connectivity_resource_s *resource_info)
+{
+ retv_if(!resource_info, -1);
+
+ if (resource_info->value_hash) {
+ g_hash_table_destroy(resource_info->value_hash);
+ resource_info->value_hash = NULL;
+ }
+
+ return 0;
+}
+
static void __json_add_data_iter_cb(gpointer key, gpointer value, gpointer user_data)
{
char *name = key;
@@ -1013,7 +1036,12 @@ int connectivity_attributes_notify_all(connectivity_resource_s *resource_info)
int ret = 0;
retv_if(!resource_info, -1);
- retv_if(!resource_info->value_hash, -1);
+
+ if (resource_info->value_hash == NULL) {
+ _W("You have nothing to notify now");
+ return 0;
+ }
+
switch (resource_info->protocol_type) {
case CONNECTIVITY_PROTOCOL_IOTIVITY:
@@ -1062,7 +1090,6 @@ int connectivity_attributes_notify_all(connectivity_resource_s *resource_info)
}
break;
case CONNECTIVITY_PROTOCOL_HTTP:
- /* TODO */
ret = web_util_json_init();
retv_if(ret, -1);