Add the double-precision attribute retrieving function context_history_record_get_dou... 88/86788/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Mon, 5 Sep 2016 02:03:02 +0000 (11:03 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Mon, 5 Sep 2016 02:03:02 +0000 (11:03 +0900)
Change-Id: Ia3ce8a5b8fa649263b1c6515ac48590e2be39b18
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
include/context_history.h
src/context_history.cpp

index 3bc2b86..39e8327 100644 (file)
@@ -407,6 +407,7 @@ int context_history_list_destroy(context_history_list_h list);
  * @retval             #CONTEXT_HISTORY_ERROR_INVALID_PARAMETER        Invalid parameter
  *
  * @pre                context_history_list_get_current()
+ * @see                context_history_record_get_double()
  * @see                context_history_record_get_string()
  */
 int context_history_record_get_int(context_history_record_h record,  const char* key, int* value);
@@ -426,10 +427,29 @@ int context_history_record_get_int(context_history_record_h record,  const char*
  *
  * @pre                context_history_list_get_current()
  * @see                context_history_record_get_int()
+ * @see                context_history_record_get_double()
  */
 int context_history_record_get_string(context_history_record_h record, const char* key, char** value);
 
 /**
+ * @brief              Gets a double-precision value from a record.
+ * @since_tizen 3.0
+ *
+ * @param[in]  record          The record handle
+ * @param[in]  key                     The key of attribute to get
+ * @param[out] value           The result value
+ *
+ * @return             0 on success, otherwise a negative error value
+ * @retval             #CONTEXT_HISTORY_ERROR_NONE                                     Successful
+ * @retval             #CONTEXT_HISTORY_ERROR_INVALID_PARAMETER        Invalid parameter
+ *
+ * @pre                context_history_list_get_current()
+ * @see                context_history_record_get_int()
+ * @see                context_history_record_get_string()
+ */
+int context_history_record_get_double(context_history_record_h record,  const char* key, double* value);
+
+/**
  * @brief              Destroys a record handle and releases all its resources.
  * @since_tizen 2.4
  *
index ff04836..535c9ce 100644 (file)
@@ -21,7 +21,7 @@
 #include <ProviderTypes.h>
 #include <context_history.h>
 
-#define TYPE_INT 0
+#define TYPE_NUMERIC 0
 #define TYPE_STRING 1
 #define FILTER_KEY_LIMIT 10
 
@@ -231,7 +231,24 @@ SO_EXPORT int context_history_record_get_int(context_history_record_h record, co
        ASSERT_NOT_NULL(record && val && key);
 
        // Check key and data type
-       IF_FAIL_RETURN_TAG(check_record_key_data_type(TYPE_INT, key), CONTEXT_HISTORY_ERROR_INVALID_PARAMETER, _E, "Data type mismatched");
+       IF_FAIL_RETURN_TAG(check_record_key_data_type(TYPE_NUMERIC, key), CONTEXT_HISTORY_ERROR_INVALID_PARAMETER, _E, "Data type mismatched");
+
+       std::list<std::string> key_list;
+       record->jrecord.getKeys(&key_list);
+       IF_FAIL_RETURN_TAG(key_list.size() > 0, CONTEXT_HISTORY_ERROR_NO_DATA, _E, "No data");
+
+       // Check invalid record key
+       IF_FAIL_RETURN_TAG(record->jrecord.get(NULL, key, val), CONTEXT_HISTORY_ERROR_INVALID_PARAMETER, _E, "Invalid record key");
+
+       return CONTEXT_HISTORY_ERROR_NONE;
+}
+
+SO_EXPORT int context_history_record_get_double(context_history_record_h record, const char* key, double* val)
+{
+       ASSERT_NOT_NULL(record && val && key);
+
+       // Check key and data type
+       IF_FAIL_RETURN_TAG(check_record_key_data_type(TYPE_NUMERIC, key), CONTEXT_HISTORY_ERROR_INVALID_PARAMETER, _E, "Data type mismatched");
 
        std::list<std::string> key_list;
        record->jrecord.getKeys(&key_list);
@@ -363,7 +380,7 @@ bool check_record_key_data_type(int type, std::string key)
                        key.compare(CONTEXT_HISTORY_AUDIO_JACK) == 0 ||
                        key.compare(CONTEXT_HISTORY_SYSTEM_VOLUME) == 0 ||
                        key.compare(CONTEXT_HISTORY_MEDIA_VOLUME) == 0) {
-               return (type == TYPE_INT);
+               return (type == TYPE_NUMERIC);
        }
 
        return false;