BuildRequires: pkgconfig(cynara-client)
BuildRequires: pkgconfig(cynara-creds-gdbus)
BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(capi-base-utils-i18n)
%if 0%{?gcov:1}
BuildRequires: lcov
BuildRequires: zip
#define DEFAULT_LONG_TEXT "default-long-text"
#define DEFAULT_ICON "default-icon"
#define DEFAULT_TITLE "default-title"
+#define DEFAULT_TIMEZONE_ID "default-timezone-id"
#define DEFAULT_HOUR "default-hour"
#define DEFAULT_MINUTE "default-minute"
#define DEFAULT_SECOND "default-second"
{DEFAULT_LONG_TEXT, LONG_TEXT_KEY},
{DEFAULT_ICON, ICON_KEY},
{DEFAULT_TITLE, TITLE_KEY},
+ {DEFAULT_TIMEZONE_ID, TIME_ZONE_ID_KEY},
{DEFAULT_HOUR, TIME_KEY},
{DEFAULT_MINUTE, TIME_KEY},
{DEFAULT_SECOND, TIME_KEY},
break;
case WATCHFACE_COMPLICATION_TYPE_TIME :
if (strcmp(element_name, DEFAULT_SHORT_TEXT) != 0 &&
+ strcmp(element_name, DEFAULT_TIMEZONE_ID) != 0 &&
strcmp(element_name, DEFAULT_HOUR) != 0 &&
strcmp(element_name, DEFAULT_MINUTE) != 0 &&
strcmp(element_name, DEFAULT_SECOND) != 0 &&
libtzplatform-config
sqlite3
libxml-2.0
+ capi-base-utils-i18n
)
FOREACH(flag ${watchface-complication_unittests_CFLAGS})
b.Add("__DATA_TYPE_KEY__", num_str);
watchface_complication_provider_data_set_timestamp(
b.GetHandle(), 10);
+
+ watchface_complication_provider_data_set_timestamp(
+ b.GetHandle(), 10);
+
+ complication_time_info_h info;
+ watchface_complication_provider_timeinfo_create(&info);
+ watchface_complication_provider_timeinfo_set_timezone(info, "UTC-10");
+ watchface_complication_provider_timeinfo_set_timezone_id(info, "US/Hawaii");
+ watchface_complication_provider_timeinfo_set_timezone_country(info, "US");
+ watchface_complication_provider_timeinfo_set_timezone_city(info, "Hawaii");
+ watchface_complication_provider_data_set_timeinfo(
+ b.GetHandle(), info);
+ watchface_complication_provider_timeinfo_destroy(info);
parameters = g_variant_new("(siis)", "org.tizen.gmock_comp_provider/test",
Time,
777,
long time;
watchface_complication_data_get_timestamp(data, &time);
EXPECT_EQ(time, 10);
+
+ complication_time_info_h info;
+ watchface_complication_data_get_timeinfo(data, &info);
+
+ char* value;
+ watchface_complication_timeinfo_get_timezone(info, &value);
+ EXPECT_STREQ(value, "UTC-10");
+
+ watchface_complication_timeinfo_get_timezone_id(info, &value);
+ EXPECT_STREQ(value, "US/Hawaii");
+
+ watchface_complication_timeinfo_get_timezone_country(info, &value);
+ EXPECT_STREQ(value, "US");
+
+ watchface_complication_timeinfo_get_timezone_city(info, &value);
+ EXPECT_STREQ(value, "Hawaii");
+
+ time_t timestamp;
+ watchface_complication_timeinfo_get_timestamp(info, ×tamp);
+
+ time_t seoul_timestamp;
+ watchface_complication_provider_timeinfo_set_timezone_id(info, "Asia/Seoul");
+ watchface_complication_timeinfo_get_timestamp(info, &seoul_timestamp);
+ EXPECT_EQ(difftime(seoul_timestamp, timestamp) / 3600, 19);
+ printf("Seoul %s\n", asctime(gmtime(&seoul_timestamp)));
+ printf("Hawaii %s\n", asctime(gmtime(×tamp)));
+ watchface_complication_timeinfo_destroy(info);
} else if (type == WATCHFACE_COMPLICATION_TYPE_IMAGE) {
char* value;
watchface_complication_data_get_image_path(data, &value);
} watchface_complication_event_type_e;
/**
+ * @brief The complication time information handle.
+ * @since_tizen 5.5
+ */
+typedef struct complication_time_info_s *complication_time_info_h;
+
+/**
* @}
*/
#define ICON_KEY "__ICON_KEY__"
#define TITLE_KEY "__TITLE_KEY__"
#define TIME_KEY "__TIME_KEY__"
+#define TIME_ZONE_KEY "__TIME_ZONE_KEY__"
+#define TIME_ZONE_ID_KEY "__TIME_ZONE_ID_KEY__"
+#define TIME_COUNTRY_KEY "__TIME_COUNTRY_KEY__"
+#define TIME_CITY_KEY "__TIME_CITY_KEY__"
#define RANGE_CUR_KEY "__CUR_KEY__"
#define RANGE_MAX_KEY "__MAX_KEY__"
#define RANGE_MIN_KEY "__MIN_KEY__"
WATCHFACE_EDITOR_ERROR_EVENT_NOT_SUPPORT = 0x04 /**< Watchface complication do not support provider's events. */
} watchface_editor_error_e;
+struct complication_time_info_s {
+ char *timezone;
+ char *timezone_id;
+ char *country;
+ char *city;
+};
+
#ifdef __cplusplus
}
#endif
break;
}
case WATCHFACE_COMPLICATION_TYPE_TIME : {
- if (shared_data.GetString(TIME_KEY).empty())
+ if (shared_data.GetString(TIME_KEY).empty() &&
+ shared_data.GetString(TIME_ZONE_ID_KEY).empty())
is_valid = false;
break;
}
return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
}
+ void DestroyTimeInfo(struct complication_time_info_s* info_s) {
+ if (info_s->timezone)
+ free(info_s->timezone);
+
+ if (info_s->timezone_id)
+ free(info_s->timezone_id);
+
+ if (info_s->country)
+ free(info_s->country);
+
+ if (info_s->city)
+ free(info_s->city);
+ free(info_s);
+ }
+
} // namespace util
} // namespace watchface_complication
#include <string>
#include "watchface-common/include/watchface-common.h"
+#include "watchface-common/watchface-common-internal.h"
#define PRIVILEGE_DATASHARING "http://tizen.org/privilege/datasharing"
EXPORT_API bool IsValidData(tizen_base::Bundle shared_data);
EXPORT_API int GetDataType(tizen_base::Bundle shared_data);
EXPORT_API int ConvertAulError(int ret);
+ EXPORT_API void DestroyTimeInfo(struct complication_time_info_s* info);
} // namespace util
} // namespace watchface_complication
const char *title);
/**
+ * @deprecated Deprecated since 5.5. Use watchface_complication_provider_data_set_timeinfo() instead.
* @brief Sets timestamp data for shared data.
* @since_tizen 5.0
* @remarks @a timestamp can be added only for #WATCHFACE_COMPLICATION_TYPE_TIME type shared data.
* @endcode
*/
int watchface_complication_provider_data_set_timestamp(bundle *shared_data,
- long timestamp);
+ long timestamp) TIZEN_DEPRECATED_API;
+
+/**
+ * @brief Creates timeinfo data.
+ * @since_tizen 5.5
+ * @remarks @a info can be added only for #WATCHFACE_COMPLICATION_TYPE_TIME type shared data.
+ * @remarks The @a info should be released using watchface_complication_provider_timeinfo_destroy().
+ * @param[out] info The time information handle
+ * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see #watchface_complication_error_e) on failure
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
+ * @retval #WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
+ * @see watchface_complication_provider_timeinfo_set_timezone()
+ * @see watchface_complication_provider_timeinfo_set_timezone_id()
+ * @see watchface_complication_provider_timeinfo_set_timezone_country()
+ * @see watchface_complication_provider_timeinfo_set_timezone_city()
+ * @see watchface_complication_provider_timeinfo_destroy()
+ * @see watchface_complication_provider_data_set_timeinfo()
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+void _watchface_complication_provider_update_requested_cb(const char *provider_id,
+ const char *req_appid, watchface_complication_type_e type,
+ const bundle *context, bundle *shared_data, void *user_data)
+{
+ if (type == WATCHFACE_COMPLICATION_TYPE_TIME) {
+ complication_time_info_h info;
+ watchface_complication_provider_timeinfo_create(&info);
+ watchface_complication_provider_timeinfo_destroy(info);
+ }
+}
+ * @endcode
+ */
+int watchface_complication_provider_timeinfo_create(complication_time_info_h *info);
+
+/**
+ * @brief Sets timezone information.
+ * @since_tizen 5.5
+ * @remarks @a info can be added only for #WATCHFACE_COMPLICATION_TYPE_TIME type shared data.
+ * @param[in] info The time information handle
+ * @param[in] timezone The timezone string
+ * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see #watchface_complication_error_e) on failure
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
+ * @retval #WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
+ * @see watchface_complication_provider_timeinfo_create()
+ * @see watchface_complication_provider_timeinfo_set_timezone_id()
+ * @see watchface_complication_provider_timeinfo_set_timezone_country()
+ * @see watchface_complication_provider_timeinfo_set_timezone_city()
+ * @see watchface_complication_provider_timeinfo_destroy()
+ * @see watchface_complication_provider_data_set_timeinfo()
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+void _watchface_complication_provider_update_requested_cb(const char *provider_id,
+ const char *req_appid, watchface_complication_type_e type,
+ const bundle *context, bundle *shared_data, void *user_data)
+{
+ if (type == WATCHFACE_COMPLICATION_TYPE_TIME) {
+ complication_time_info_h info;
+ watchface_complication_provider_timeinfo_create(&info);
+ watchface_complication_provider_timeinfo_set_timezone(info, "UTC+9");
+ watchface_complication_provider_timeinfo_destroy(info);
+ }
+}
+ * @endcode
+ */
+int watchface_complication_provider_timeinfo_set_timezone(complication_time_info_h info,
+ const char *timezone);
+
+/**
+ * @brief Sets timezone id.
+ * @since_tizen 5.5
+ * @remarks @a info can be added only for #WATCHFACE_COMPLICATION_TYPE_TIME type shared data.
+ * @param[in] info The time information handle
+ * @param[in] timezone_id The timezone id which is specified in TZ database
+ * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see #watchface_complication_error_e) on failure
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
+ * @retval #WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
+ * @see watchface_complication_provider_timeinfo_set_timezone()
+ * @see watchface_complication_provider_timeinfo_create()
+ * @see watchface_complication_provider_timeinfo_set_timezone_country()
+ * @see watchface_complication_provider_timeinfo_set_timezone_city()
+ * @see watchface_complication_provider_timeinfo_destroy()
+ * @see watchface_complication_provider_data_set_timeinfo()
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+void _watchface_complication_provider_update_requested_cb(const char *provider_id,
+ const char *req_appid, watchface_complication_type_e type,
+ const bundle *context, bundle *shared_data, void *user_data)
+{
+ if (type == WATCHFACE_COMPLICATION_TYPE_TIME) {
+ complication_time_info_h info;
+ watchface_complication_provider_timeinfo_create(&info);
+ watchface_complication_provider_timeinfo_set_timezone_id(info, "Asia/Seoul");
+ watchface_complication_provider_timeinfo_destroy(info);
+ }
+}
+ * @endcode
+ */
+int watchface_complication_provider_timeinfo_set_timezone_id(complication_time_info_h info,
+ const char *timezone_id);
+
+/**
+ * @brief Sets timezone country information.
+ * @since_tizen 5.5
+ * @remarks @a info can be added only for #WATCHFACE_COMPLICATION_TYPE_TIME type shared data.
+ * @param[in] info The time information handle
+ * @param[in] country The timezone country information
+ * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see #watchface_complication_error_e) on failure
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
+ * @retval #WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
+ * @see watchface_complication_provider_timeinfo_set_timezone()
+ * @see watchface_complication_provider_timeinfo_set_timezone_id()
+ * @see watchface_complication_provider_timeinfo_create()
+ * @see watchface_complication_provider_timeinfo_set_timezone_city()
+ * @see watchface_complication_provider_timeinfo_destroy()
+ * @see watchface_complication_provider_data_set_timeinfo()
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+void _watchface_complication_provider_update_requested_cb(const char *provider_id,
+ const char *req_appid, watchface_complication_type_e type,
+ const bundle *context, bundle *shared_data, void *user_data)
+{
+ if (type == WATCHFACE_COMPLICATION_TYPE_TIME) {
+ complication_time_info_h info;
+ watchface_complication_provider_timeinfo_create(&info);
+ watchface_complication_provider_timeinfo_set_timezone_country(info, "Korea");
+ watchface_complication_provider_timeinfo_destroy(info);
+ }
+}
+ * @endcode
+ */
+int watchface_complication_provider_timeinfo_set_timezone_country(complication_time_info_h info,
+ const char *country);
+
+/**
+ * @brief Sets timezone city information.
+ * @since_tizen 5.5
+ * @remarks @a info can be added only for #WATCHFACE_COMPLICATION_TYPE_TIME type shared data.
+ * @param[in] info The time information handle
+ * @param[in] city The timezone city information
+ * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see #watchface_complication_error_e) on failure
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
+ * @retval #WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
+ * @see watchface_complication_provider_timeinfo_set_timezone()
+ * @see watchface_complication_provider_timeinfo_set_timezone_id()
+ * @see watchface_complication_provider_timeinfo_set_timezone_country()
+ * @see watchface_complication_provider_timeinfo_create()
+ * @see watchface_complication_provider_timeinfo_destroy()
+ * @see watchface_complication_provider_data_set_timeinfo()
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+void _watchface_complication_provider_update_requested_cb(const char *provider_id,
+ const char *req_appid, watchface_complication_type_e type,
+ const bundle *context, bundle *shared_data, void *user_data)
+{
+ if (type == WATCHFACE_COMPLICATION_TYPE_TIME) {
+ complication_time_info_h info;
+ watchface_complication_provider_timeinfo_create(&info);
+ watchface_complication_provider_timeinfo_set_timezone_city(info, "Seoul");
+ watchface_complication_provider_timeinfo_destroy(info);
+ }
+}
+ * @endcode
+ */
+int watchface_complication_provider_timeinfo_set_timezone_city(complication_time_info_h info,
+ const char *city);
+
+/**
+ * @brief Destroys timezone handle.
+ * @since_tizen 5.5
+ * @param[in] info The time information handle
+ * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see #watchface_complication_error_e) on failure
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
+ * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
+ * @see watchface_complication_provider_timeinfo_set_timezone()
+ * @see watchface_complication_provider_timeinfo_set_timezone_id()
+ * @see watchface_complication_provider_timeinfo_set_timezone_country()
+ * @see watchface_complication_provider_timeinfo_set_timezone_city()
+ * @see watchface_complication_provider_timeinfo_create()
+ * @see watchface_complication_provider_data_set_timeinfo()
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+void _watchface_complication_provider_update_requested_cb(const char *provider_id,
+ const char *req_appid, watchface_complication_type_e type,
+ const bundle *context, bundle *shared_data, void *user_data)
+{
+ if (type == WATCHFACE_COMPLICATION_TYPE_TIME) {
+ complication_time_info_h info;
+ watchface_complication_provider_timeinfo_create(&info);
+ watchface_complication_provider_timeinfo_destroy(info);
+ }
+}
+ * @endcode
+ */
+int watchface_complication_provider_timeinfo_destroy(complication_time_info_h info);
+
+
+/**
+ * @brief Sets time information data to shared data.
+ * @since_tizen 5.5
+ * @remarks @a info can be added only for #WATCHFACE_COMPLICATION_TYPE_TIME type shared data.
+ * @param[in] shared_data The data which will be shared with watch application
+ * @param[in] info The time information handle
+ * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see #watchface_complication_error_e) on failure
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
+ * @retval #WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
+ * @see watchface_complication_provider_timeinfo_create()
+ * @see watchface_complication_provider_timeinfo_set_timezone()
+ * @see watchface_complication_provider_timeinfo_set_timezone_id()
+ * @see watchface_complication_provider_timeinfo_set_timezone_country()
+ * @see watchface_complication_provider_timeinfo_set_timezone_city()
+ * @see watchface_complication_provider_timeinfo_destroy()
+ * @par Sample code:
+ * @code
+#include <watchface-complication-provider.h>
+void _watchface_complication_provider_update_requested_cb(const char *provider_id,
+ const char *req_appid, watchface_complication_type_e type,
+ const bundle *context, bundle *shared_data, void *user_data)
+{
+ if (type == WATCHFACE_COMPLICATION_TYPE_TIME) {
+ complication_time_info_h info;
+ watchface_complication_provider_timeinfo_create(&info);
+ watchface_complication_provider_timeinfo_set_timezone(info, "UTC+9");
+ watchface_complication_provider_data_set_timeinfo(shared_data, info);
+ watchface_complication_provider_timeinfo_destroy(info);
+ }
+}
+ * @endcode
+ */
+int watchface_complication_provider_data_set_timeinfo(bundle *shared_data,
+ complication_time_info_h info);
/**
* @brief Sets image path data for shared data.
* #WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT : short text\n
* #WATCHFACE_COMPLICATION_TYPE_LONG_TEXT : long text\n
* #WATCHFACE_COMPLICATION_TYPE_RANGED_VALUE : current, min, max\n
- * #WATCHFACE_COMPLICATION_TYPE_TIME : timestamp\n
+ * #WATCHFACE_COMPLICATION_TYPE_TIME : timestamp or timezone_id\n
* #WATCHFACE_COMPLICATION_TYPE_ICON : icon path\n
* #WATCHFACE_COMPLICATION_TYPE_IMAGE : image path\n
* @since_tizen 5.0
* @see watchface_complication_provider_data_set_short_text()
* @see watchface_complication_provider_data_set_long_text()
* @see watchface_complication_provider_data_set_ranged_value()
- * @see watchface_complication_provider_data_set_timestamp()
* @see watchface_complication_provider_data_set_icon_path()
* @see watchface_complication_provider_data_set_image_path()
+ * @see watchface_complication_provider_timeinfo_create()
+ * @see watchface_complication_provider_timeinfo_set_timezone_id()
* @par Sample code:
* @code
#include <watchface-complication-provider.h>
return _add_bundle_data(shared_data, TIME_KEY, num_str);
}
+extern "C" EXPORT_API int watchface_complication_provider_timeinfo_create(
+ complication_time_info_h *info) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (info == nullptr) {
+ LOGE("Invalid param");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ complication_time_info_h h = (complication_time_info_h)calloc(1, sizeof(struct complication_time_info_s));
+ if (h == nullptr) {
+ LOGE("Out of memory");
+ return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ }
+ *info = h;
+
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_provider_timeinfo_set_timezone(
+ complication_time_info_h info, const char *timezone) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (info == nullptr || timezone == nullptr) {
+ LOGE("Invalid param");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ struct complication_time_info_s* info_s = (struct complication_time_info_s*)info;
+ char *dup_timezone = strdup(timezone);
+ if (dup_timezone == nullptr) {
+ LOGE("Invalid param");
+ return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ }
+ if (info_s->timezone)
+ free(info_s->timezone);
+ info_s->timezone = dup_timezone;
+
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_provider_timeinfo_set_timezone_id(
+ complication_time_info_h info, const char *timezone_id) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (info == nullptr || timezone_id == nullptr) {
+ LOGE("Invalid param");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ struct complication_time_info_s* info_s = (struct complication_time_info_s*)info;
+ char *dup_timezone_id = strdup(timezone_id);
+ if (dup_timezone_id == nullptr) {
+ LOGE("Invalid param");
+ return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ }
+ if (info_s->timezone_id)
+ free(info_s->timezone_id);
+ info_s->timezone_id = dup_timezone_id;
+
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int
+watchface_complication_provider_timeinfo_set_timezone_country(complication_time_info_h info,
+ const char *country) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (info == nullptr || country == nullptr) {
+ LOGE("Invalid param");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ struct complication_time_info_s* info_s = (struct complication_time_info_s*)info;
+ char *dup_country = strdup(country);
+ if (dup_country == nullptr) {
+ LOGE("Invalid param");
+ return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ }
+ if (info_s->country)
+ free(info_s->country);
+ info_s->country = dup_country;
+
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int
+watchface_complication_provider_timeinfo_set_timezone_city(complication_time_info_h info,
+ const char *city) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (info == nullptr || city == nullptr) {
+ LOGE("Invalid param");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ struct complication_time_info_s* info_s = (struct complication_time_info_s*)info;
+ char *dup_city = strdup(city);
+ if (dup_city == nullptr) {
+ LOGE("Invalid param");
+ return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ }
+ if (info_s->city)
+ free(info_s->city);
+ info_s->city = dup_city;
+
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_provider_timeinfo_destroy(
+ complication_time_info_h info) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (info == nullptr) {
+ LOGE("Invalid param");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+ watchface_complication::util::DestroyTimeInfo((struct complication_time_info_s*)info);
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_provider_data_set_timeinfo(
+ bundle *shared_data, complication_time_info_h info) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (shared_data == nullptr || info == nullptr) {
+ LOGE("Invalid param");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ watchface_complication_type_e type;
+ int ret = _get_data_type(shared_data, &type);
+ if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
+ return ret;
+
+ if (type != WATCHFACE_COMPLICATION_TYPE_TIME) {
+ LOGE("Invalid type, not allowed for this type !!");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ struct complication_time_info_s* info_s = (struct complication_time_info_s*)info;
+ if (info_s->timezone) {
+ ret = _add_bundle_data(shared_data, TIME_ZONE_KEY, info_s->timezone);
+ if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
+ return ret;
+ }
+
+ if (info_s->timezone_id) {
+ ret = _add_bundle_data(shared_data, TIME_ZONE_ID_KEY, info_s->timezone_id);
+ if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
+ return ret;
+ }
+
+ if (info_s->country) {
+ ret = _add_bundle_data(shared_data, TIME_COUNTRY_KEY, info_s->country);
+ if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
+ return ret;
+ }
+
+ if (info_s->city) {
+ ret = _add_bundle_data(shared_data, TIME_CITY_KEY, info_s->city);
+ if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
+ return ret;
+ }
+
+ return ret;
+}
+
extern "C" EXPORT_API int watchface_complication_provider_data_set_image_path(
bundle* shared_data, const char* image_path) {
int ret;
pkgmgr
pkgmgr-info
capi-system-info
+ capi-base-utils-i18n
)
FOREACH(flag ${watchface-complication_CFLAGS})
int watchface_complication_data_get_title(const bundle *data, char **title);
/**
+ * @deprecated Deprecated since 5.5. Use watchface_complication_data_get_timeinfo() instead.
* @brief Gets timestamp from complication data.
* @since_tizen 5.0
* @param[in] data The data received from complication provider app
* @endcode
*/
int watchface_complication_data_get_timestamp(const bundle *data,
- long *timestamp);
+ long *timestamp) TIZEN_DEPRECATED_API;
+
+/**
+ * @brief Gets timeinfo from complication data.
+ * @since_tizen 5.5
+ * @remarks The @a info should be destroyed using watchface_complication_timeinfo_destroy().
+ * @param[in] data The data received from complication provider app
+ * @param[out] info The time information handle
+ * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see #watchface_complication_error_e) on failure
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
+ * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NO_DATA No data
+ * @retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
+ * @see #complication_time_info_h
+ * @see watchface_complication_timeinfo_get_timezone()
+ * @see watchface_complication_timeinfo_get_timezone_id()
+ * @see watchface_complication_timeinfo_get_timezone_country()
+ * @see watchface_complication_timeinfo_get_timezone_city()
+ * @see watchface_complication_timeinfo_destroy()
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ watchface_complication_type_e type,
+ const bundle *data, void *user_data)
+{
+ complication_time_info_h info;
+ watchface_complication_type_e type;
+
+ watchface_complication_data_get_type(data, &type);
+ if (type == WATCHFACE_COMPLICATION_TYPE_TIME) {
+ watchface_complication_data_get_timeinfo(data, &info);
+ watchface_complication_timeinfo_destroy(info);
+ }
+}
+ * @endcode
+ */
+int watchface_complication_data_get_timeinfo(const bundle *data,
+ complication_time_info_h *info);
+
+/**
+ * @brief Gets timezone from timeinfo.
+ * @since_tizen 5.5
+ * @remarks The @a timezone should be freed using free().
+ * @param[in] info The time information handle
+ * @param[out] timezone The timezone
+ * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see #watchface_complication_error_e) on failure
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
+ * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NO_DATA No data
+ * @retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
+ * @see #complication_time_info_h
+ * @see watchface_complication_data_get_timeinfo()
+ * @see watchface_complication_timeinfo_get_timezone_id()
+ * @see watchface_complication_timeinfo_get_timezone_country()
+ * @see watchface_complication_timeinfo_get_timezone_city()
+ * @see watchface_complication_timeinfo_destroy()
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ watchface_complication_type_e type,
+ const bundle *data, void *user_data)
+{
+ complication_time_info_h info;
+ watchface_complication_type_e type;
+ char *timezone;
+
+ watchface_complication_data_get_type(data, &type);
+ if (type == WATCHFACE_COMPLICATION_TYPE_TIME) {
+ watchface_complication_data_get_timeinfo(data, &info);
+ watchface_complication_timeinfo_get_timezone(info, &timezone);
+ watchface_complication_timeinfo_destroy(info);
+ }
+}
+ * @endcode
+ */
+int watchface_complication_timeinfo_get_timezone(complication_time_info_h info,
+ char **timezone);
+
+/**
+ * @brief Gets timezone ID from timeinfo.
+ * @since_tizen 5.5
+ * @remarks The @a timezone_id should be freed using free().
+ * @param[in] info The time information handle
+ * @param[out] timezone_id The timezone ID
+ * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see #watchface_complication_error_e) on failure
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
+ * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NO_DATA No data
+ * @retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
+ * @see #complication_time_info_h
+ * @see watchface_complication_timeinfo_get_timezone()
+ * @see watchface_complication_data_get_timeinfo()
+ * @see watchface_complication_timeinfo_get_timezone_country()
+ * @see watchface_complication_timeinfo_get_timezone_city()
+ * @see watchface_complication_timeinfo_destroy()
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ watchface_complication_type_e type,
+ const bundle *data, void *user_data)
+{
+ complication_time_info_h info;
+ watchface_complication_type_e type;
+ char *timezone_id;
+
+ watchface_complication_data_get_type(data, &type);
+ if (type == WATCHFACE_COMPLICATION_TYPE_TIME) {
+ watchface_complication_data_get_timeinfo(data, &info);
+ watchface_complication_timeinfo_get_timezone_id(info, &timezone_id);
+ watchface_complication_timeinfo_destroy(info);
+ }
+}
+ * @endcode
+ */
+int watchface_complication_timeinfo_get_timezone_id(complication_time_info_h info,
+ char **timezone_id);
+
+/**
+ * @brief Gets timezone country from timeinfo.
+ * @since_tizen 5.5
+ * @remarks The @a country should be freed using free().
+ * @param[in] info The time information handle
+ * @param[out] country The timezone country
+ * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see #watchface_complication_error_e) on failure
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
+ * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NO_DATA No data
+ * @retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
+ * @see #complication_time_info_h
+ * @see watchface_complication_timeinfo_get_timezone()
+ * @see watchface_complication_data_get_timeinfo()
+ * @see watchface_complication_timeinfo_get_timezone_id()
+ * @see watchface_complication_timeinfo_get_timezone_city()
+ * @see watchface_complication_timeinfo_destroy()
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ watchface_complication_type_e type,
+ const bundle *data, void *user_data)
+{
+ complication_time_info_h info;
+ watchface_complication_type_e type;
+ char *country;
+
+ watchface_complication_data_get_type(data, &type);
+ if (type == WATCHFACE_COMPLICATION_TYPE_TIME) {
+ watchface_complication_data_get_timeinfo(data, &info);
+ watchface_complication_timeinfo_get_timezone_country(info, &country);
+ watchface_complication_timeinfo_destroy(info);
+ }
+}
+ * @endcode
+ */
+int watchface_complication_timeinfo_get_timezone_country(complication_time_info_h info,
+ char **country);
+
+/**
+ * @brief Gets timezone city from timeinfo.
+ * @since_tizen 5.5
+ * @remarks The @a city should be freed using free().
+ * @param[in] info The time information handle
+ * @param[out] city The timezone city
+ * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see #watchface_complication_error_e) on failure
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
+ * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NO_DATA No data
+ * @retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
+ * @see #complication_time_info_h
+ * @see watchface_complication_timeinfo_get_timezone()
+ * @see watchface_complication_data_get_timeinfo()
+ * @see watchface_complication_timeinfo_get_timezone_id()
+ * @see watchface_complication_timeinfo_get_timezone()
+ * @see watchface_complication_timeinfo_destroy()
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ watchface_complication_type_e type,
+ const bundle *data, void *user_data)
+{
+ complication_time_info_h info;
+ watchface_complication_type_e type;
+ char *city;
+
+ watchface_complication_data_get_type(data, &type);
+ if (type == WATCHFACE_COMPLICATION_TYPE_TIME) {
+ watchface_complication_data_get_timeinfo(data, &info);
+ watchface_complication_timeinfo_get_timezone_city(info, &city);
+ watchface_complication_timeinfo_destroy(info);
+ }
+}
+ * @endcode
+ */
+int watchface_complication_timeinfo_get_timezone_city(complication_time_info_h info,
+ char **city);
+
+/**
+ * @brief Gets timestamp from timeinfo.
+ * @since_tizen 5.5
+ * @param[in] info The time information handle
+ * @param[out] timestamp The number of seconds since 00:00, Jan 1 1970 UTC, corresponding to POSIX time.
+ * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see #watchface_complication_error_e) on failure
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
+ * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NO_DATA No data
+ * @retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
+ * @see #complication_time_info_h
+ * @see watchface_complication_data_get_timeinfo()
+ * @see watchface_complication_timeinfo_get_timezone_id()
+ * @see watchface_complication_timeinfo_get_timezone()
+ * @see watchface_complication_timeinfo_destroy()
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ watchface_complication_type_e type,
+ const bundle *data, void *user_data)
+{
+ complication_time_info_h info;
+ watchface_complication_type_e type;
+ time_t timestamp;
+
+ watchface_complication_data_get_type(data, &type);
+ if (type == WATCHFACE_COMPLICATION_TYPE_TIME) {
+ watchface_complication_data_get_timeinfo(data, &info);
+ watchface_complication_timeinfo_get_timestamp(info, ×tamp);
+ watchface_complication_timeinfo_destroy(info);
+ }
+}
+ * @endcode
+ */
+int watchface_complication_timeinfo_get_timestamp(complication_time_info_h info,
+ time_t *timestamp);
+
+/**
+ * @brief Destroys time information handle.
+ * @since_tizen 5.5
+ * @param[in] info The time information handle
+ * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
+ * otherwise an error code (see #watchface_complication_error_e) on failure
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
+ * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
+ * @see #complication_time_info_h
+ * @see watchface_complication_data_get_timeinfo()
+ * @par Sample code:
+ * @code
+#include <watchface-complication.h>
+void _on_complication_update(int complication_id,
+ const char *provider_id,
+ watchface_complication_type_e type,
+ const bundle *data, void *user_data)
+{
+ complication_time_info_h info;
+ watchface_complication_type_e type;
+
+ watchface_complication_data_get_type(data, &type);
+ if (type == WATCHFACE_COMPLICATION_TYPE_TIME) {
+ watchface_complication_data_get_timeinfo(data, &info);
+ watchface_complication_timeinfo_destroy(info);
+ }
+}
+ * @endcode
+ */
+int watchface_complication_timeinfo_destroy(complication_time_info_h info);
/**
* @brief Gets image path from complication data.
#include <glib.h>
#include <math.h>
#include <gio/gio.h>
+#include <sys/time.h>
+#include <utils_i18n.h>
#include <aul.h>
#include <dlog.h>
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
+static int __get_dup_string_from_bundle(const bundle* data,
+ const char* key, char** dup_str) {
+ char* str;
+ int ret = bundle_get_str(const_cast<bundle*>(data), key, &str);
+ if (ret == BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
+ return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
+ } else if (ret != BUNDLE_ERROR_NONE) {
+ LOGE("failed to get data %d", ret);
+ return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
+ }
+
+ *dup_str = strdup(str);
+ if (*dup_str == nullptr) {
+ LOGE("Out of memory");
+ return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ }
+
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_data_get_timeinfo(
+ const bundle* data, complication_time_info_h* info) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (data == nullptr || info == nullptr) {
+ LOGE("Invalid param !!");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ complication_time_info_h h = (complication_time_info_h)calloc(1,
+ sizeof(struct complication_time_info_s));
+ if (h == nullptr) {
+ LOGE("Out of memory");
+ return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ }
+
+ int ret = __get_dup_string_from_bundle(data, TIME_ZONE_KEY, &h->timezone);
+ if (ret != WATCHFACE_COMPLICATION_ERROR_NO_DATA &&
+ ret != WATCHFACE_COMPLICATION_ERROR_NONE) {
+ watchface_complication_timeinfo_destroy(h);
+ return ret;
+ }
+
+ ret = __get_dup_string_from_bundle(data, TIME_ZONE_ID_KEY, &h->timezone_id);
+ if (ret != WATCHFACE_COMPLICATION_ERROR_NO_DATA &&
+ ret != WATCHFACE_COMPLICATION_ERROR_NONE) {
+ watchface_complication_timeinfo_destroy(h);
+ return ret;
+ }
+
+ ret = __get_dup_string_from_bundle(data, TIME_COUNTRY_KEY, &h->country);
+ if (ret != WATCHFACE_COMPLICATION_ERROR_NO_DATA &&
+ ret != WATCHFACE_COMPLICATION_ERROR_NONE) {
+ watchface_complication_timeinfo_destroy(h);
+ return ret;
+ }
+
+ ret = __get_dup_string_from_bundle(data, TIME_CITY_KEY, &h->city);
+ if (ret != WATCHFACE_COMPLICATION_ERROR_NO_DATA &&
+ ret != WATCHFACE_COMPLICATION_ERROR_NONE) {
+ watchface_complication_timeinfo_destroy(h);
+ return ret;
+ }
+
+ if (h->timezone == nullptr && h->timezone_id == nullptr &&
+ h->country == nullptr && h->city == nullptr) {
+ watchface_complication_timeinfo_destroy(h);
+ return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
+ }
+ *info = h;
+
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_timeinfo_get_timezone(
+ complication_time_info_h info, char** timezone) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (info == nullptr || timezone == nullptr) {
+ LOGE("Invalid param !!");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (info->timezone == nullptr)
+ return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
+
+ char* str = strdup(info->timezone);
+ if (str == nullptr)
+ return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ *timezone = str;
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_timeinfo_get_timezone_id(
+ complication_time_info_h info, char** timezone_id) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (info == nullptr || timezone_id == nullptr) {
+ LOGE("Invalid param !!");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (info->timezone_id == nullptr)
+ return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
+
+ char* str = strdup(info->timezone_id);
+ if (str == nullptr)
+ return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ *timezone_id = str;
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_timeinfo_get_timezone_country(
+ complication_time_info_h info, char** country) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (info == nullptr || country == nullptr) {
+ LOGE("Invalid param !!");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (info->country == nullptr)
+ return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
+
+ char* str = strdup(info->country);
+ if (str == nullptr)
+ return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ *country = str;
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_timeinfo_get_timezone_city(
+ complication_time_info_h info, char** city) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (info == nullptr || city == nullptr) {
+ LOGE("Invalid param !!");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (info->city == nullptr)
+ return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
+
+ char* str = strdup(info->city);
+ if (str == nullptr)
+ return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ *city = str;
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
+static int __get_timestamp(complication_time_info_h info, time_t* timestamp) {
+ static i18n_timezone_h tmz;
+ int err = i18n_timezone_detect_host_timezone(&tmz);
+ if (err != 0) {
+ LOGE("Fail to get timezone !!");
+ return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
+ }
+
+ int32_t host_offset;
+ err = i18n_timezone_get_raw_offset(tmz, &host_offset);
+ if (err != 0) {
+ LOGE("Fail to get timezone offset !!");
+ i18n_timezone_destroy(tmz);
+ return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
+ }
+
+ i18n_timezone_destroy(tmz);
+ err = i18n_timezone_create(&tmz, info->timezone_id);
+ if (err != 0) {
+ LOGE("Fail to get timezone !!");
+ return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
+ }
+
+ int32_t offset;
+ err = i18n_timezone_get_raw_offset(tmz, &offset);
+ if (err != 0) {
+ LOGE("Fail to get timezone offset !!");
+ i18n_timezone_destroy(tmz);
+ return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
+ }
+
+ struct timeval current;
+ gettimeofday(¤t, nullptr);
+ *timestamp = current.tv_sec + ((offset - host_offset) / 1000);
+ i18n_timezone_destroy(tmz);
+
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int watchface_complication_timeinfo_get_timestamp(
+ complication_time_info_h info, time_t* timestamp) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (info == nullptr || info->timezone_id == nullptr || timestamp == nullptr) {
+ LOGE("Invalid param !!");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ return __get_timestamp(info, timestamp);
+}
+
+extern "C" EXPORT_API int watchface_complication_timeinfo_destroy(
+ complication_time_info_h info) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (info == nullptr) {
+ LOGE("Invalid param");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+ watchface_complication::util::DestroyTimeInfo(
+ (struct complication_time_info_s*)info);
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
extern "C" EXPORT_API int watchface_complication_data_get_image_path(
const bundle* data, char** image_path) {
if (data == nullptr || image_path == nullptr) {