*/
int watchface_complication_provider_setup_get_context(app_control_h handle,
bundle **context);
-int watchface_complication_provider_set_short_text_data(bundle *shared_data,
- char *text, char *icon, char *title);
-int watchface_complication_provider_set_long_text_data(bundle *shared_data,
- char *text, char *icon, char *title);
-int watchface_complication_provider_set_ranged_value_data(bundle *shared_data,
- int current, int min, int max, char *text, char *icon, char *title);
-int watchface_complication_provider_set_time_value_data(bundle *shared_data,
- char *time_str, char *icon, char *title);
-int watchface_complication_provider_set_icon_value_data(bundle *shared_data,
- char *icon);
-int watchface_complication_provider_set_image_value_data(bundle *shared_data,
- char *image);
+
+/**
+ * @brief Sets shared data type.
+ * @details Developer can set different set of data for shared data depends on data type.
+ * COMPLICATION_SHORT_TEXT : short text, icon, title, extra
+ * COMPLICATION_LONG_TEXT : long text, icon, title, extra
+ * COMPLICATION_RANGED_VALUE : short text, icon, title, current, min, max, extra
+ * COMPLICATION_TIME : time, short text, icon, extra
+ * COMPLICATION_ICON : icon_path, extra
+ * COMPLICATION_IMAGE : image_path, extra
+ * @since_tizen 5.0
+ * @param[in] shared_data The data which will be shared with watch application
+ * @param[in] type The data type of shared_data
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+int __on_update_request(const char *provider_id, const char *req_appid,
+ complication_type type, const bundle *context, bundle *shared_data,
+{
+ watchface_complication_provider_data_set_type(shared_data, COMPLICATION_SHORT_TEXT);
+ // Sets short text type data.
+}
+ * @endcode
+ */
+int watchface_complication_provider_data_set_type(bundle *shared_data,
+ complication_type type);
+
+/**
+ * @brief Sets short text data for shared data.
+ * @since_tizen 5.0
+ * @remarks Short text data can be added only for COMPLICATION_SHORT_TEXT,
+ * COMPLICATION_RANGED_VALUE, COMPLICATION_TIME type shared data.
+ * @param[in] shared_data The data which will be shared with watch application
+ * @param[in] short_text The short text data
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #watchface_complication_provider_data_set_type
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+int __on_update_request(const char *provider_id, const char *req_appid,
+ complication_type type, const bundle *context, bundle *shared_data,
+{
+ watchface_complication_provider_data_set_type(shared_data, COMPLICATION_SHORT_TEXT);
+ watchface_complication_provider_data_set_short_text(shared_data, "text data");
+}
+ * @endcode
+ */
+int watchface_complication_provider_data_set_short_text(bundle *shared_data,
+ const char *short_text);
+
+/**
+ * @brief Sets long text data for shared data.
+ * @since_tizen 5.0
+ * @remarks Long text data can be added only for COMPLICATION_LONG_TEXT type shared data.
+ * @param[in] shared_data The data which will be shared with watch application
+ * @param[in] long_text The long text data
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #watchface_complication_provider_data_set_type
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+int __on_update_request(const char *provider_id, const char *req_appid,
+ complication_type type, const bundle *context, bundle *shared_data,
+{
+ watchface_complication_provider_data_set_type(shared_data, COMPLICATION_LONG_TEXT);
+ watchface_complication_provider_data_set_long_text(shared_data, "long text data");
+}
+ * @endcode
+ */
+int watchface_complication_provider_data_set_long_text(bundle *shared_data,
+ const char *long_text);
+
+/**
+ * @brief Sets title data for shared data.
+ * @since_tizen 5.0
+ * @remarks Long text data can be added only for COMPLICATION_SHORT_TEXT, COMPLICATION_LONG_TEXT, COMPLICATION_RANGED_VALUE type shared data.
+ * @param[in] shared_data The data which will be shared with watch application
+ * @param[in] title The title text data
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #watchface_complication_provider_data_set_type
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+int __on_update_request(const char *provider_id, const char *req_appid,
+ complication_type type, const bundle *context, bundle *shared_data,
+{
+ watchface_complication_provider_data_set_type(shared_data, COMPLICATION_LONG_TEXT);
+ watchface_complication_provider_data_set_title(shared_data, "title");
+}
+ * @endcode
+ */
+int watchface_complication_provider_data_set_title(bundle *shared_data,
+ const char *title);
+
+/**
+ * @brief Sets timestamp data for shared data.
+ * @since_tizen 5.0
+ * @remarks timestamp data can be added only for COMPLICATION_TIME type shared data.
+ * @param[in] shared_data The data which will be shared with watch application
+ * @param[in] timestamp The timestamp data
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #watchface_complication_provider_data_set_type
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+int __on_update_request(const char *provider_id, const char *req_appid,
+ complication_type type, const bundle *context, bundle *shared_data,
+{
+ time_t seconds;
+
+ seconds = time(NULL);
+ watchface_complication_provider_data_set_type(shared_data, COMPLICATION_TIME);
+ watchface_complication_provider_data_set_timestamp(shared_data, seconds);
+}
+ * @endcode
+ */
+int watchface_complication_provider_data_set_timestamp(bundle *shared_data,
+ long timestamp);
+
+/**
+ * @brief Sets image path data for shared data.
+ * @since_tizen 5.0
+ * @remarks timestamp data can be added only for COMPLICATION_IMAGE type shared data.
+ * @param[in] shared_data The data which will be shared with watch application
+ * @param[in] image_path The image path data
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #watchface_complication_provider_data_set_type
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+int __on_update_request(const char *provider_id, const char *req_appid,
+ complication_type type, const bundle *context, bundle *shared_data,
+{
+ watchface_complication_provider_data_set_type(shared_data, COMPLICATION_TIME);
+ watchface_complication_provider_data_set_image_path(shared_data, "path");
+}
+ * @endcode
+ */
+int watchface_complication_provider_data_set_image_path(bundle *shared_data,
+ const char *image_path);
+
+/**
+ * @brief Sets ranged value ata for shared data.
+ * @since_tizen 5.0
+ * @remarks timestamp data can be added only for COMPLICATION_IMAGE type shared data.
+ * @param[in] shared_data The data which will be shared with watch application
+ * @param[in] current_value The current value
+ * @param[in] min_value The minimum value
+ * @param[in] max_value The max value
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #watchface_complication_provider_data_set_type
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+int __on_update_request(const char *provider_id, const char *req_appid,
+ complication_type type, const bundle *context, bundle *shared_data,
+{
+ watchface_complication_provider_data_set_type(shared_data, COMPLICATION_TIME);
+ watchface_complication_provider_data_set_ranged_value(shared_data, 50.0, 0.0, 100.0);
+}
+ * @endcode
+ */
+int watchface_complication_provider_data_set_ranged_value(bundle *shared_data,
+ double current_value, double min_value, double max_value);
+
+/**
+ * @brief Sets icon path data for shared data.
+ * @since_tizen 5.0
+ * @remarks timestamp data can be added only for COMPLICATION_SHORT_TEXT,
+ * COMPLICATION_LONG_TEXT, COMPLICATION_TIME, COMPLICATION_ICON type shared data.
+ * @param[in] shared_data The data which will be shared with watch application
+ * @param[in] icon_path The icon path data
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #watchface_complication_provider_data_set_type
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+int __on_update_request(const char *provider_id, const char *req_appid,
+ complication_type type, const bundle *context, bundle *shared_data,
+{
+ watchface_complication_provider_data_set_type(shared_data, COMPLICATION_TIME);
+ watchface_complication_provider_data_set_icon_path(shared_data, "path");
+}
+ * @endcode
+ */
+int watchface_complication_provider_data_set_icon_path(bundle *shared_data,
+ const char *icon_path);
+
+/**
+ * @brief Sets extra data for shared data.
+ * @since_tizen 5.0
+ * @remarks timestamp data can be added to every type of shared data.
+ * @param[in] shared_data The data which will be shared with watch application
+ * @param[in] extra_data The extra data
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #watchface_complication_provider_data_set_type
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+int __on_update_request(const char *provider_id, const char *req_appid,
+ complication_type type, const bundle *context, bundle *shared_data,
+{
+ watchface_complication_provider_data_set_type(shared_data, COMPLICATION_TIME);
+ watchface_complication_provider_data_set_extra_data(shared_data, "extra");
+}
+ * @endcode
+ */
+int watchface_complication_provider_data_set_extra_data(bundle *shared_data,
+ const char *extra_data);
/*
* @}
return COMPLICATION_ERROR_NONE;
}
-static int _add_bundle_data(bundle* shared_data, const char* key, char* value) {
+static int _add_bundle_data(bundle* shared_data, const char* key, const char* value) {
int ret;
ret = bundle_add_str(shared_data, key, value);
if (ret == BUNDLE_ERROR_KEY_EXISTS) {
- bundle_del(shared_data, TEXT_KEY);
+ bundle_del(shared_data, key);
ret = bundle_add_str(shared_data, key, value);
}
return COMPLICATION_ERROR_NONE;
}
-extern "C" EXPORT_API int watchface_complication_provider_set_short_text_data(
- bundle *shared_data, char *text, char *icon, char *title) {
+static int _get_data_type(bundle *shared_data, complication_type *type) {
int ret;
+ char *type_str = NULL;
- if (shared_data == NULL || text == NULL) {
- LOGE("Text value is NULL");
+ if (shared_data == NULL) {
+ LOGE("shared_data is NULL");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- ret = _add_bundle_data(shared_data, TEXT_KEY, text);
- if (ret != COMPLICATION_ERROR_NONE)
- return ret;
+ ret = bundle_get_str(shared_data, DATA_TYPE_KEY, &type_str);
+ if (ret != BUNDLE_ERROR_NONE) {
+ LOGE("Invalid data fail to get type !!");
+ return COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ *type = static_cast<complication_type>(strtol(type_str, NULL, 10));
+
+ return COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_provider_data_set_type(
+ bundle* shared_data, complication_type type) {
+ int ret;
+ char num_str[32] = {0,};
- if (icon) {
- ret = _add_bundle_data(shared_data, ICON_KEY, icon);
- if (ret != COMPLICATION_ERROR_NONE)
+ if (shared_data == NULL) {
+ LOGE("shared_data is NULL");
+ return COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ snprintf(num_str, sizeof(num_str), "%d", type);
+ ret = _add_bundle_data(shared_data, DATA_TYPE_KEY, num_str);
+ if (ret != COMPLICATION_ERROR_NONE)
return ret;
+
+ return COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_provider_data_set_title(
+ bundle* shared_data, const char* title) {
+ int ret;
+ complication_type type;
+
+ if (shared_data == NULL || title == NULL) {
+ LOGE("Invalid param");
+ return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- if (title) {
- ret = _add_bundle_data(shared_data, TITLE_KEY, title);
- if (ret != COMPLICATION_ERROR_NONE)
+
+ ret = _get_data_type(shared_data, &type);
+ if (ret != COMPLICATION_ERROR_NONE)
return ret;
+ if (type != COMPLICATION_SHORT_TEXT && type != COMPLICATION_RANGED_VALUE &&
+ type != COMPLICATION_LONG_TEXT && type != COMPLICATION_TIME) {
+ LOGE("Invalid type, not allowed for this type !!");
+ return COMPLICATION_ERROR_INVALID_PARAMETER;
}
+ ret = _add_bundle_data(shared_data, TITLE_KEY, title);
+ if (ret != COMPLICATION_ERROR_NONE)
+ return ret;
+
return COMPLICATION_ERROR_NONE;
}
-extern "C" EXPORT_API int watchface_complication_provider_set_long_text_data(
- bundle *shared_data, char *text, char *icon, char *title) {
+extern "C" EXPORT_API int watchface_complication_provider_data_set_short_text(
+ bundle* shared_data, const char* text) {
int ret;
+ complication_type type;
if (shared_data == NULL || text == NULL) {
- LOGE("Text value is NULL");
+ LOGE("Invalid param");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- ret = _add_bundle_data(shared_data, TEXT_KEY, text);
+ ret = _get_data_type(shared_data, &type);
if (ret != COMPLICATION_ERROR_NONE)
return ret;
- if (icon) {
- ret = _add_bundle_data(shared_data, ICON_KEY, icon);
- if (ret != COMPLICATION_ERROR_NONE)
- return ret;
+ if (type != COMPLICATION_SHORT_TEXT && type != COMPLICATION_RANGED_VALUE
+ && type != COMPLICATION_TIME) {
+ LOGE("Invalid type, not allowed for this type !!");
+ return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- if (title) {
- ret = _add_bundle_data(shared_data, TITLE_KEY, title);
- if (ret != COMPLICATION_ERROR_NONE)
+ ret = _add_bundle_data(shared_data, SHORT_TEXT_KEY, text);
+ if (ret != COMPLICATION_ERROR_NONE)
return ret;
- }
return COMPLICATION_ERROR_NONE;
}
-extern "C" EXPORT_API int watchface_complication_provider_set_ranged_value_data(
- bundle *shared_data, int current, int min, int max, char *text, char *icon,
- char *title) {
+extern "C" EXPORT_API int watchface_complication_provider_data_set_long_text(
+ bundle* shared_data, const char* text) {
int ret;
- char num_str[32] = {0,};
+ complication_type type;
- if (shared_data == NULL || current < min || current > max || min > max) {
- LOGE("wrong range %d, %d, %d", current, min, max);
+ if (shared_data == NULL || text == NULL) {
+ LOGE("Invalid param");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- snprintf(num_str, sizeof(num_str), "%d", current);
- ret = _add_bundle_data(shared_data, RANGE_CUR_KEY, num_str);
+ ret = _get_data_type(shared_data, &type);
if (ret != COMPLICATION_ERROR_NONE)
return ret;
+ if (type != COMPLICATION_LONG_TEXT) {
+ LOGE("Invalid type, not allowed for this type !!");
+ return COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
- snprintf(num_str, sizeof(num_str), "%d", min);
- ret = _add_bundle_data(shared_data, RANGE_MIN_KEY, num_str);
+ ret = _add_bundle_data(shared_data, LONG_TEXT_KEY, text);
if (ret != COMPLICATION_ERROR_NONE)
return ret;
- snprintf(num_str, sizeof(num_str), "%d", max);
- ret = _add_bundle_data(shared_data, RANGE_MAX_KEY, num_str);
+ return COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_provider_data_set_timestamp(
+ bundle* shared_data, long timestamp) {
+ int ret;
+ char num_str[32] = {0,};
+ complication_type type;
+
+ if (shared_data == NULL) {
+ LOGE("Invalid param");
+ return COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _get_data_type(shared_data, &type);
if (ret != COMPLICATION_ERROR_NONE)
return ret;
+ if (type != COMPLICATION_TIME) {
+ LOGE("Invalid type, not allowed for this type !!");
+ return COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
- if (text) {
- ret = _add_bundle_data(shared_data, TEXT_KEY, text);
- if (ret != COMPLICATION_ERROR_NONE)
+ snprintf(num_str, sizeof(num_str), "%ld", timestamp);
+ ret = _add_bundle_data(shared_data, TIME_KEY, num_str);
+ if (ret != COMPLICATION_ERROR_NONE)
return ret;
+
+ return COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_provider_data_set_image_path(
+ bundle* shared_data, const char* image_path) {
+ int ret;
+ complication_type type;
+
+ if (shared_data == NULL || image_path == NULL) {
+ LOGE("Invalid param");
+ return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- if (icon) {
- ret = _add_bundle_data(shared_data, ICON_KEY, icon);
- if (ret != COMPLICATION_ERROR_NONE)
+ ret = _get_data_type(shared_data, &type);
+ if (ret != COMPLICATION_ERROR_NONE)
return ret;
+ if (type != COMPLICATION_IMAGE) {
+ LOGE("Invalid type, not allowed for this type !!");
+ return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- if (title) {
- ret = _add_bundle_data(shared_data, TITLE_KEY, title);
- if (ret != COMPLICATION_ERROR_NONE)
+ ret = _add_bundle_data(shared_data, IMAGE_KEY, image_path);
+ if (ret != COMPLICATION_ERROR_NONE)
return ret;
- }
return COMPLICATION_ERROR_NONE;
+
}
-extern "C" EXPORT_API int watchface_complication_provider_set_time_value_data(
- bundle *shared_data, char *time_str, char *icon, char *title) {
+extern "C" EXPORT_API int watchface_complication_provider_data_set_ranged_value(
+ bundle* shared_data, double current_value, double min_value,
+ double max_value) {
+ char num_str[32] = {0,};
int ret;
+ complication_type type;
- if (shared_data == NULL || time_str == NULL) {
- LOGE("Time value is NULL");
+ if (shared_data == NULL || min_value > max_value || current_value < min_value
+ || current_value > max_value) {
+ LOGE("Invalid param");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- ret = _add_bundle_data(shared_data, TIME_KEY, time_str);
+ ret = _get_data_type(shared_data, &type);
if (ret != COMPLICATION_ERROR_NONE)
return ret;
- if (icon) {
- ret = _add_bundle_data(shared_data, ICON_KEY, icon);
+ if (type != COMPLICATION_RANGED_VALUE) {
+ LOGE("Invalid type, not allowed for this type !!");
+ return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- if (title) {
- ret = _add_bundle_data(shared_data, TITLE_KEY, title);
- if (ret != COMPLICATION_ERROR_NONE)
+ snprintf(num_str, sizeof(num_str), "%lf", current_value);
+ ret = _add_bundle_data(shared_data, RANGE_CUR_KEY, num_str);
+ if (ret != COMPLICATION_ERROR_NONE)
+ return ret;
+
+ snprintf(num_str, sizeof(num_str), "%lf", min_value);
+ ret = _add_bundle_data(shared_data, RANGE_MIN_KEY, num_str);
+ if (ret != COMPLICATION_ERROR_NONE)
+ return ret;
+
+ snprintf(num_str, sizeof(num_str), "%lf", max_value);
+ ret = _add_bundle_data(shared_data, RANGE_MAX_KEY, num_str);
+ if (ret != COMPLICATION_ERROR_NONE)
return ret;
- }
return COMPLICATION_ERROR_NONE;
}
-extern "C" EXPORT_API int complication_provider_set_icon_value_data(
- bundle *shared_data, char *icon) {
+extern "C" EXPORT_API int watchface_complication_provider_data_set_icon_path(
+ bundle* shared_data, const char* icon_path) {
int ret;
+ complication_type type;
+
+ if (shared_data == NULL || icon_path == NULL) {
+ LOGE("Invalid param");
+ return COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
- if (shared_data == NULL || icon == NULL) {
- LOGE("Time value is NULL");
+ ret = _get_data_type(shared_data, &type);
+ if (ret != COMPLICATION_ERROR_NONE)
+ return ret;
+ if (type != COMPLICATION_ICON && type != COMPLICATION_SHORT_TEXT
+ && type != COMPLICATION_LONG_TEXT && type != COMPLICATION_TIME) {
+ LOGE("Invalid type, not allowed for this type !!");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- ret = _add_bundle_data(shared_data, ICON_KEY, icon);
+
+ ret = _add_bundle_data(shared_data, ICON_KEY, icon_path);
if (ret != COMPLICATION_ERROR_NONE)
return ret;
return COMPLICATION_ERROR_NONE;
}
-extern "C" EXPORT_API int complication_provider_set_image_value_data(
- bundle *shared_data, char *image) {
+extern "C" EXPORT_API int watchface_complication_provider_data_set_extra_data(
+ bundle* shared_data, const char* extra_data) {
int ret;
- if (shared_data == NULL || image == NULL) {
- LOGE("Image value is NULL");
+ if (shared_data == NULL || extra_data == NULL) {
+ LOGE("Invalid param");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- ret = _add_bundle_data(shared_data, IMAGE_KEY, image);
+
+ ret = _add_bundle_data(shared_data, EXTRA_DATA_KEY, extra_data);
if (ret != COMPLICATION_ERROR_NONE)
return ret;
return COMPLICATION_ERROR_NONE;
}
-
#define SETUP_EDITOR_APPID_KEY "__SETUP_EDITOR_APPID_KEY__"
#define SETUP_EDITABLE_ID_KEY "__SETUP_EDITABLE_ID_KEY__"
#define SETUP_CONTEXT_DATA_KEY "__SETUP_CONTEXT_DATA_KEY__"
-#define TEXT_KEY "__TEXT_KEY__"
+#define SHORT_TEXT_KEY "__SHORT_TEXT_KEY__"
+#define LONG_TEXT_KEY "__LONG_TEXT_KEY__"
#define ICON_KEY "__ICON_KEY__"
#define TITLE_KEY "__TITLE_KEY__"
#define TIME_KEY "__TIME_KEY__"
#define RANGE_MAX_KEY "__MAX_KEY__"
#define RANGE_MIN_KEY "__MIN_KEY__"
#define IMAGE_KEY "__IMAGE_KEY__"
+#define DATA_TYPE_KEY "__DATA_TYPE_KEY__"
+#define EXTRA_DATA_KEY "__EXTRA_DATA_KEY__"
namespace watchface_complication {
complication_shape_type type,
complication_h *created_handle);
int watchface_complication_destroy(complication_h handle);
-int watchface_complication_get_short_text_data(bundle *data, char **text, char **icon,
- char **title);
-int watchface_complication_get_long_text_data(bundle *data, char **text, char **icon,
- char **title);
-int watchface_complication_get_ranged_value_data(bundle *data, int *current, int *min,
- int *max, char **text, char **icon, char **title);
-int watchface_complication_get_time_value_data(bundle *data, char **time_str, char **icon,
- char **title);
-int watchface_complication_get_icon_value_data(bundle *data, char **icon);
-int watchface_complication_get_image_value_data(bundle *data, char **image);
+
+/**
+ * @brief Gets data type of complication data.
+ * @details Developer can get different set of data from data depends on data type.
+ * Data will be passed through on_complication_update_cb callback and sent by complication provider app.
+ * @since_tizen 5.0
+ * @param[in] data The data received from complication provider app
+ * @param[out] type The data type
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_NO_DATA No data
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #on_complication_update_cb
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ complication_type type,
+ const bundle *data, void *user_data)
+{
+ complication_type type;
+ watchface_complication_data_get_type(data, &type);
+}
+ * @endcode
+ */
+int watchface_complication_data_get_type(const bundle *data, complication_type *type);
+
+/**
+ * @brief Gets short text from complication data.
+ * @since_tizen 5.0
+ * @param[in] data The data received from complication provider app
+ * @param[out] short_text The short text data
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_NO_DATA No data
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #on_complication_update_cb
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ complication_type type,
+ const bundle *data, void *user_data)
+{
+ char *value;
+ complication_type type;
+ watchface_complication_data_get_type(data, &type);
+ if (type == COMPLICATION_SHORT_TEXT)
+ watchface_complication_data_get_short_text(data, &value);
+}
+ * @endcode
+ */
+int watchface_complication_data_get_short_text(const bundle *data, char **short_text);
+
+/**
+ * @brief Gets long text from complication data.
+ * @since_tizen 5.0
+ * @param[in] data The data received from complication provider app
+ * @param[out] long_text The long text data
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_NO_DATA No data
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #on_complication_update_cb
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ complication_type type,
+ const bundle *data, void *user_data)
+{
+ char *value;
+ complication_type type;
+ watchface_complication_data_get_type(data, &type);
+ if (type == COMPLICATION_LONG_TEXT)
+ watchface_complication_data_get_long_text(data, &value);
+}
+ * @endcode
+ */
+int watchface_complication_data_get_long_text(const bundle *data, char **long_text);
+
+/**
+ * @brief Gets title text from complication data.
+ * @since_tizen 5.0
+ * @param[in] data The data received from complication provider app
+ * @param[out] title The title text data
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_NO_DATA No data
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #on_complication_update_cb
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ complication_type type,
+ const bundle *data, void *user_data)
+{
+ char *value;
+ complication_type type;
+ watchface_complication_data_get_type(data, &type);
+ if (type == COMPLICATION_LONG_TEXT)
+ watchface_complication_data_get_long_text(data, &value);
+}
+ * @endcode
+ */
+int watchface_complication_data_get_title(const bundle *data, char **title);
+
+/**
+ * @brief Gets timestamp from complication data.
+ * @since_tizen 5.0
+ * @param[in] data The data received from complication provider app
+ * @param[out] timestamp The timestamp
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #COMPLICATION_ERROR_NO_DATA No data
+* @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #on_complication_update_cb
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ complication_type type,
+ const bundle *data, void *user_data)
+{
+ long value;
+ complication_type type;
+ watchface_complication_data_get_type(data, &type);
+ if (type == COMPLICATION_TIME)
+ watchface_complication_data_get_timestamp(data, &value);
+}
+ * @endcode
+ */
+int watchface_complication_data_get_timestamp(const bundle *data, long *timestamp);
+
+/**
+ * @brief Gets image path from complication data.
+ * @since_tizen 5.0
+ * @param[in] data The data received from complication provider app
+ * @param[out] image_path The image path data
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_NO_DATA No data
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #on_complication_update_cb
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ complication_type type,
+ const bundle *data, void *user_data)
+{
+ char *value;
+ complication_type type;
+ watchface_complication_data_get_type(data, &type);
+ if (type == COMPLICATION_IMAGE_PATH)
+ watchface_complication_data_get_image_path(data, &value);
+}
+ * @endcode
+ */
+int watchface_complication_data_get_image_path(const bundle *data,
+ char **image_path);
+
+/**
+ * @brief Gets ranged value from complication data.
+ * @since_tizen 5.0
+ * @param[in] data The data received from complication provider app
+ * @param[out] current_value The current value
+ * @param[out] min_value The minimum value
+ * @param[out] max_value The max value
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_NO_DATA No data
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #on_complication_update_cb
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ complication_type type,
+ const bundle *data, void *user_data)
+{
+ double cur_val, min_val, max_val;
+ complication_type type;
+ watchface_complication_data_get_type(data, &type);
+ if (type == COMPLICATION_IMAGE_PATH)
+ watchface_complication_data_get_ranged_value(data, &cur_val, &min_val, &max_val);
+}
+ * @endcode
+ */
+int watchface_complication_data_get_ranged_value(const bundle *data,
+ double *current_value, double *min_value, double *max_value);
+
+/**
+ * @brief Gets icon path from complication data.
+ * @since_tizen 5.0
+ * @param[in] data The data received from complication provider app
+ * @param[out] icon_path The icon path data
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_NO_DATA No data
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #on_complication_update_cb
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ complication_type type,
+ const bundle *data, void *user_data)
+{
+ char *value;
+ complication_type type;
+ watchface_complication_data_get_type(data, &type);
+ if (type == COMPLICATION_ICON_PATH)
+ watchface_complication_data_get_icon_path(data, &value);
+}
+ * @endcode
+ */
+int watchface_complication_data_get_icon_path(const bundle *data, char **icon_path);
+
+/**
+ * @brief Gets extra data from complication data.
+ * @since_tizen 5.0
+ * @param[in] data The data received from complication provider app
+ * @param[out] extra_data The extra data
+ * @return #COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see COMPLICATION_ERROR_XXX) on failure
+ * @retval #COMPLICATION_ERROR_NONE Successful
+ * @retval #COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPLICATION_ERROR_NO_DATA No data
+ * @retval #COMPLICATION_ERROR_IO_ERROR IO Error
+ * @see #complication_type
+ * @see #on_complication_update_cb
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ complication_type type,
+ const bundle *data, void *user_data)
+{
+ char *value;
+ watchface_complication_data_get_extra_data(data, &value);
+}
+ * @endcode
+ */
+int watchface_complication_data_get_extra_data(const bundle *data,
+ char **extra_data);
/**
* @}
return COMPLICATION_ERROR_NONE;
}
-extern "C" EXPORT_API int watchface_complication_get_short_text_data(
- bundle* data, char** text, char** icon, char** title) {
+extern "C" EXPORT_API int watchface_complication_data_get_type(
+ const bundle *data, complication_type *type) {
+ char *type_str = NULL;
int ret;
- if (data == NULL || text == NULL) {
+ if (data == NULL || type == NULL) {
LOGE("Invalid param !!");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- ret = bundle_get_str(data, TEXT_KEY, text);
+ ret = bundle_get_str(const_cast<bundle*>(data), DATA_TYPE_KEY, &type_str);
if (ret != BUNDLE_ERROR_NONE) {
LOGE("Invalid data !!");
- return COMPLICATION_ERROR_INVALID_PARAMETER;
+ return COMPLICATION_ERROR_NO_DATA;
}
- if (icon)
- bundle_get_str(data, ICON_KEY, icon);
- if (title)
- bundle_get_str(data, TITLE_KEY, title);
-
+ *type = static_cast<complication_type>(strtol(type_str, NULL, 10));
return COMPLICATION_ERROR_NONE;
}
-extern "C" EXPORT_API int watchface_complication_get_long_text_data(
- bundle* data, char** text, char** icon, char** title) {
+extern "C" EXPORT_API int watchface_complication_data_get_short_text(
+ const bundle *data, char **short_text) {
int ret;
+ char *value = NULL;
- if (data == NULL || text == NULL) {
+ if (data == NULL || short_text == NULL) {
LOGE("Invalid param !!");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- ret = bundle_get_str(data, TEXT_KEY, text);
+ ret = bundle_get_str(const_cast<bundle*>(data), SHORT_TEXT_KEY, &value);
if (ret != BUNDLE_ERROR_NONE) {
LOGE("Invalid data !!");
- return COMPLICATION_ERROR_INVALID_PARAMETER;
+ return COMPLICATION_ERROR_NO_DATA;
+ }
+ *short_text = strdup(value);
+ if (*short_text == NULL) {
+ LOGE("Out of memory");
+ return COMPLICATION_ERROR_OUT_OF_MEMORY;
}
- if (icon)
- bundle_get_str(data, ICON_KEY, icon);
- if (title)
- bundle_get_str(data, TITLE_KEY, title);
return COMPLICATION_ERROR_NONE;
}
-extern "C" EXPORT_API int watchface_complication_get_ranged_value_data(
- bundle* data, int* current_val, int* min_val, int* max_val, char** text,
- char** icon, char** title) {
+extern "C" EXPORT_API int watchface_complication_data_get_long_text(
+ const bundle *data, char **long_text) {
int ret;
+ char *value = NULL;
- if (data == NULL || current_val == NULL || min_val == NULL
- || max_val == NULL) {
+ if (data == NULL || long_text == NULL) {
LOGE("Invalid param !!");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- char* num_str;
- ret = bundle_get_str(data, RANGE_CUR_KEY, &num_str);
+ ret = bundle_get_str(const_cast<bundle*>(data), LONG_TEXT_KEY, &value);
if (ret != BUNDLE_ERROR_NONE) {
LOGE("Invalid data !!");
+ return COMPLICATION_ERROR_NO_DATA;
+ }
+ *long_text = strdup(value);
+ if (*long_text == NULL) {
+ LOGE("Out of memory");
+ return COMPLICATION_ERROR_OUT_OF_MEMORY;
+ }
+
+ return COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_data_get_title(
+ const bundle *data, char **title) {
+ int ret;
+ char *value = NULL;
+
+ if (data == NULL || title == NULL) {
+ LOGE("Invalid param !!");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- *current_val = atoi(num_str);
- ret = bundle_get_str(data, RANGE_MIN_KEY, &num_str);
+ ret = bundle_get_str(const_cast<bundle*>(data), TITLE_KEY, &value);
if (ret != BUNDLE_ERROR_NONE) {
LOGE("Invalid data !!");
+ return COMPLICATION_ERROR_NO_DATA;
+ }
+ *title = strdup(value);
+ if (*title == NULL) {
+ LOGE("Out of memory");
+ return COMPLICATION_ERROR_OUT_OF_MEMORY;
+ }
+
+ return COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_data_get_timestamp(
+ const bundle *data, long *timestamp) {
+ int ret;
+ char *time_str = NULL;
+
+ if (data == NULL || timestamp == NULL) {
+ LOGE("Invalid param !!");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- *min_val = atoi(num_str);
- ret = bundle_get_str(data, RANGE_MAX_KEY, &num_str);
+ ret = bundle_get_str(const_cast<bundle*>(data), TIME_KEY, &time_str);
if (ret != BUNDLE_ERROR_NONE) {
LOGE("Invalid data !!");
+ return COMPLICATION_ERROR_NO_DATA;
+ }
+ *timestamp = strtol(time_str, NULL, 10);
+
+ return COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_data_get_image_path(
+ const bundle *data, char **image_path) {
+ int ret;
+ char *value = NULL;
+
+ if (data == NULL || image_path == NULL) {
+ LOGE("Invalid param !!");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- *max_val = atoi(num_str);
- if (text)
- bundle_get_str(data, TEXT_KEY, text);
- if (icon)
- bundle_get_str(data, ICON_KEY, icon);
- if (title)
- bundle_get_str(data, TITLE_KEY, title);
+ ret = bundle_get_str(const_cast<bundle*>(data), IMAGE_KEY, &value);
+ if (ret != BUNDLE_ERROR_NONE) {
+ LOGE("Invalid data !!");
+ return COMPLICATION_ERROR_NO_DATA;
+ }
+ *image_path = strdup(value);
+ if (*image_path == NULL) {
+ LOGE("Out of memory");
+ return COMPLICATION_ERROR_OUT_OF_MEMORY;
+ }
return COMPLICATION_ERROR_NONE;
}
-extern "C" EXPORT_API int watchface_complication_get_time_value_data(
- bundle* data, char** time_str, char** icon, char** title) {
+extern "C" EXPORT_API int watchface_complication_data_get_ranged_value(
+ const bundle *data, double *current_value, double *min_value,
+ double *max_value) {
int ret;
+ char *current_value_str = NULL;
+ char *min_value_str = NULL;
+ char *max_value_str = NULL;
- if (data == NULL || time_str == NULL) {
+ if (data == NULL || current_value == NULL || min_value == NULL
+ || max_value == NULL) {
LOGE("Invalid param !!");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- ret = bundle_get_str(data, TIME_KEY, time_str);
+ ret = bundle_get_str(const_cast<bundle*>(data), RANGE_CUR_KEY, ¤t_value_str);
if (ret != BUNDLE_ERROR_NONE) {
LOGE("Invalid data !!");
- return COMPLICATION_ERROR_INVALID_PARAMETER;
+ return COMPLICATION_ERROR_NO_DATA;
+ }
+
+ ret = bundle_get_str(const_cast<bundle*>(data), RANGE_MIN_KEY, &min_value_str);
+ if (ret != BUNDLE_ERROR_NONE) {
+ LOGE("Invalid data !!");
+ return COMPLICATION_ERROR_NO_DATA;
+ }
+
+ ret = bundle_get_str(const_cast<bundle*>(data), RANGE_MAX_KEY, &max_value_str);
+ if (ret != BUNDLE_ERROR_NONE) {
+ LOGE("Invalid data !!");
+ return COMPLICATION_ERROR_NO_DATA;
}
- if (icon)
- bundle_get_str(data, ICON_KEY, icon);
- if (title)
- bundle_get_str(data, TITLE_KEY, title);
+
+ *current_value = strtod(current_value_str, NULL);
+ *min_value = strtod(min_value_str, NULL);
+ *max_value = strtod(max_value_str, NULL);
return COMPLICATION_ERROR_NONE;
}
-extern "C" EXPORT_API int watchface_complication_get_icon_value_data(
- bundle* data, char** icon) {
+extern "C" EXPORT_API int watchface_complication_data_get_icon_path(
+ const bundle *data, char **icon_path) {
int ret;
+ char *value = NULL;
- if (data == NULL || icon == NULL) {
+ if (data == NULL || icon_path == NULL) {
LOGE("Invalid param !!");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- ret = bundle_get_str(data, ICON_KEY, icon);
+ ret = bundle_get_str(const_cast<bundle*>(data), ICON_KEY, &value);
if (ret != BUNDLE_ERROR_NONE) {
LOGE("Invalid data !!");
- return COMPLICATION_ERROR_INVALID_PARAMETER;
+ return COMPLICATION_ERROR_NO_DATA;
+ }
+ *icon_path = strdup(value);
+ if (*icon_path == NULL) {
+ LOGE("Out of memory");
+ return COMPLICATION_ERROR_OUT_OF_MEMORY;
}
return COMPLICATION_ERROR_NONE;
}
-extern "C" EXPORT_API int watchface_complication_get_image_value_data(
- bundle* data, char** image) {
+extern "C" EXPORT_API int watchface_complication_data_get_extra_data(
+ const bundle *data, char **extra_data) {
int ret;
+ char *value = NULL;
- if (data == NULL || image == NULL) {
+ if (data == NULL || extra_data == NULL) {
LOGE("Invalid param !!");
return COMPLICATION_ERROR_INVALID_PARAMETER;
}
- ret = bundle_get_str(data, IMAGE_KEY, image);
+ ret = bundle_get_str(const_cast<bundle*>(data), EXTRA_DATA_KEY, &value);
if (ret != BUNDLE_ERROR_NONE) {
LOGE("Invalid data !!");
- return COMPLICATION_ERROR_INVALID_PARAMETER;
+ return COMPLICATION_ERROR_NO_DATA;
+ }
+ *extra_data = strdup(value);
+ if (*extra_data == NULL) {
+ LOGE("Out of memory");
+ return COMPLICATION_ERROR_OUT_OF_MEMORY;
}
return COMPLICATION_ERROR_NONE;