add remove functions for attributes notify
[apps/native/position-finder-server.git] / inc / connectivity.h
index ca1aa2f..9adfcb6 100644 (file)
 #ifndef __POSITION_FINDER_CONNECTIVITY_H__
 #define __POSITION_FINDER_CONNECTIVITY_H__
 
-#include "connectivity_internal.h"
+typedef struct _connectivity_resource connectivity_resource_s;
 
-struct connectivity_resource {
-       iotcon_resource_h res;
-       iotcon_observers_h observers;
-       char *path;
-};
-
-typedef struct connectivity_resource connectivity_resource_s;
+typedef enum {
+       CONNECTIVITY_PROTOCOL_DEFAULT = 0,
+       CONNECTIVITY_PROTOCOL_IOTIVITY,
+       CONNECTIVITY_PROTOCOL_HTTP,
+       CONNECTIVITY_PROTOCOL_MAX
+   } connectivity_protocol_e;
 
 /**
  * @brief Create connectivity resource and registers the resource in server.
@@ -50,33 +49,53 @@ extern int connectivity_set_resource(const char *path, const char *type, connect
 extern void connectivity_unset_resource(connectivity_resource_s *resource);
 
 /**
- * @brief Notifies specific clients that resource's attributes have changed with boolean vaule.
+ * @brief Notifies a resource's value to observed clients.
  * @param[in] resource_info A structure containing information about connectivity resource
- * @param[in] key A new key to be added into attributes
- * @param[in] value A boolean value to be added into attributes
+ * @param[in] key A key to be sended.
+ * @param[in] value A value to be sended.
  * @return 0 on success, otherwise a negative error value
  * @see If key is already exists, current value will be replaced with new value.
  */
 extern int connectivity_notify_bool(connectivity_resource_s *resource_info, const char *key, bool value);
 
 /**
- * @brief Notifies specific clients that resource's attributes have changed with int vaule.
+ * @brief Notifies a resource's value to observed clients.
  * @param[in] resource_info A structure containing information about connectivity resource
- * @param[in] key A new key to be added into attributes
- * @param[in] value A int value to be added into attributes
+ * @param[in] key A key to be sended.
+ * @param[in] value A value to be sended.
  * @return 0 on success, otherwise a negative error value
  * @see If key is already exists, current value will be replaced with new value.
  */
 extern int connectivity_notify_int(connectivity_resource_s *resource_info, const char *key, int value);
 
 /**
- * @brief Notifies specific clients that resource's attributes have changed with double vaule.
+ * @brief Notifies a resource's value to observed clients.
  * @param[in] resource_info A structure containing information about connectivity resource
- * @param[in] key A new key to be added into attributes
- * @param[in] value A double value to be added into attributes
+ * @param[in] key A key to be sended.
+ * @param[in] value A value to be sended.
  * @return 0 on success, otherwise a negative error value
  * @see If key is already exists, current value will be replaced with new value.
  */
 extern int connectivity_notify_double(connectivity_resource_s *resource_info, const char *key, double value);
 
+/**
+ * @brief Notifies a resource's value to observed clients.
+ * @param[in] resource_info A structure containing information about connectivity resource
+ * @param[in] key A key to be sended.
+ * @param[in] value A value to be sended.
+ * @return 0 on success, otherwise a negative error value
+ * @see If key is already exists, current value will be replaced with new value.
+ */
+extern int connectivity_notify_string(connectivity_resource_s *resource_info, const char *key, const char *value);
+
+/* TODO : add comments for these functions */
+extern int connectivity_set_protocol(connectivity_protocol_e protocol_type);
+extern int connectivity_attributes_add_bool(connectivity_resource_s *resource_info, const char *key, bool value);
+extern int connectivity_attributes_add_int(connectivity_resource_s *resource_info, const char *key, int value);
+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__ */