int ret = watchface_editable_candidate_create(&candidate, "test");
EXPECT_EQ(WATCHFACE_COMPLICATION_ERROR_NONE, ret);
+ char* id;
+ watchface_editable_candidate_get_id(candidate, &id);
+ EXPECT_STREQ(id, "test");
+ free(id);
+
watchface_editable_candidate_color_create(&color, 12, 34, 56, 78);
watchface_editable_candidate_set_color(candidate, color);
watchface_editable_candidate_color_destroy(color);
EXPECT_EQ(78, a);
char* name;
+ watchface_editable_candidate_set_name(candidate, "test_name");
watchface_editable_candidate_get_name(candidate, &name);
- EXPECT_STREQ(name, "test");
+ EXPECT_STREQ(name, "test_name");
free(name);
bundle_free(candidate);
typedef struct editable_color_ *watchface_editable_color_h;
-int watchface_editable_candidate_create(bundle **candidate, const char *name);
-int watchface_editable_candidate_get_name(bundle* candidate, char** name);
+int watchface_editable_candidate_create(bundle **candidate, const char *id);
+int watchface_editable_candidate_get_id(bundle *candidate, char **id);
+int watchface_editable_candidate_get_name(bundle *candidate, char** name);
+int watchface_editable_candidate_set_name(bundle *candidate, const char* name);
int watchface_editable_candidate_set_color(bundle *candidate, watchface_editable_color_h color);
int watchface_editable_candidate_get_color(bundle *candidate, watchface_editable_color_h *color);
int watchface_editable_candidate_color_create(watchface_editable_color_h *color, int r, int g, int b, int a);
#define LOG_TAG "WATCHFACE_COMPLICATION"
+#define CANDIDATE_ID_KEY "__CANDIDATE_ID_KEY__"
#define CANDIDATE_NAME_KEY "__CANDIDATE_NAME_KEY__"
#define CANDIDATE_COLOR_R_KEY "__CANDIDATE_COLOR_R_KEY__"
#define CANDIDATE_COLOR_G_KEY "__CANDIDATE_COLOR_G_KEY__"
}
extern "C" EXPORT_API int watchface_editable_candidate_create(
- bundle** candidate, const char* name) {
- if (candidate == nullptr || name == nullptr) {
+ bundle** candidate, const char* id) {
+ if (candidate == nullptr || id == nullptr) {
LOGE("Invalid parameter");
return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
}
bundle* data = bundle_create();
- int ret = bundle_add_str(data, CANDIDATE_NAME_KEY, name);
+ int ret = bundle_add_str(data, CANDIDATE_ID_KEY, id);
if (ret != BUNDLE_ERROR_NONE) {
- LOGE("fail to add name (%d)", ret);
+ LOGE("fail to add id (%d)", ret);
bundle_free(data);
return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
}
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
+extern "C" EXPORT_API int watchface_editable_candidate_get_id(
+ bundle* candidate, char** id) {
+ if (candidate == nullptr || id == nullptr) {
+ LOGE("Invalid parameter");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ char* data;
+ int ret = bundle_get_str(candidate, CANDIDATE_ID_KEY, &data);
+ if (ret != BUNDLE_ERROR_NONE) {
+ LOGW("No data");
+ return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
+ }
+ *id = strdup(data);
+
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_editable_candidate_set_name(
+ bundle* candidate, const char* name) {
+ if (candidate == nullptr || name == nullptr) {
+ LOGE("Invalid parameter");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = bundle_add_str(candidate, CANDIDATE_NAME_KEY, name);
+ if (ret != BUNDLE_ERROR_NONE) {
+ LOGE("fail to add name (%d)", ret);
+ return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
+ }
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
extern "C" EXPORT_API int watchface_editable_candidate_get_name(
bundle* candidate, char** name) {
if (candidate == nullptr || name == nullptr) {