diff options
author | Sung-jae Park <nicesj.park@samsung.com> | 2015-04-20 14:49:45 +0900 |
---|---|---|
committer | Sung-jae Park <nicesj.park@samsung.com> | 2015-04-20 14:49:45 +0900 |
commit | 140f9fa89b261e482675a610b945ab67ace0d9c6 (patch) | |
tree | 592b81fb8de6b2cded3061f50a63230b18700359 /src | |
parent | 2320f030e73071253137fc5ce92ebbfd37cc3352 (diff) | |
download | widget-service-140f9fa89b261e482675a610b945ab67ace0d9c6.tar.gz widget-service-140f9fa89b261e482675a610b945ab67ace0d9c6.tar.bz2 widget-service-140f9fa89b261e482675a610b945ab67ace0d9c6.zip |
Prepare for supporting the wayland.
[model] Redwood,Kiran,B3(Wearable)
[binary_type] AP
[customer] Docomo/Orange/ATT/Open
[issue#] N/A
[problem]
[cause]
[solution]
[team] HomeTF
[request]
[horizontal_expansion]
Change-Id: Ie8997de37e2d9b4a139fc3558a62f7d476900a94
Diffstat (limited to 'src')
-rw-r--r-- | src/util_wayland.c | 92 | ||||
-rw-r--r-- | src/widget_service.c | 6 |
2 files changed, 81 insertions, 17 deletions
diff --git a/src/util_wayland.c b/src/util_wayland.c index 62aa894..db02498 100644 --- a/src/util_wayland.c +++ b/src/util_wayland.c @@ -12,8 +12,20 @@ #include "widget_service.h" #include "debug.h" +#define CONF_PATH_FORMAT "/usr/share/data-provider-master/%dx%d/resolution.ini" + int errno; +static struct { + unsigned int w; + unsigned int h; + int res_resolved; +} s_info = { + .w = 0, + .h = 0, + .res_resolved = 0, +}; + static int update_info(struct supported_size_list *SIZE_LIST, int width_type, int height_type, int width, int height) { int idx; @@ -208,25 +220,39 @@ static inline int update_from_file(struct service_info *info, struct supported_s return WIDGET_NR_OF_SIZE_LIST - updated; } -int util_update_resolution(struct service_info *info, struct supported_size_list *SIZE_LIST) +/* + * Find proper configuration and install(link) it to conf path. + */ +static char *conf_path(void) { - unsigned int width; - unsigned int height; - unsigned int border; - unsigned int depth; - register int i; - static int res_resolved = 0; - - if (res_resolved) { - return WIDGET_ERROR_NONE; + char *path; + int length; + + length = strlen(CONF_PATH_FORMAT) + 12; // 12 == RESERVED SPACE + path = calloc(1, length); + if (!path) { + ErrPrint("calloc: %s\n", strerror(errno)); + return NULL; } - if (update_from_file(info, SIZE_LIST) == 0) { - DbgPrint("Resolution info is all updated by file\n"); + if (s_info.w == 0 || s_info.h == 0) { + /* Try to update resolution first if it is not initialized */ + util_screen_size_get(NULL, NULL); } - res_resolved = 1; - return WIDGET_ERROR_NONE; + snprintf(path, length, CONF_PATH_FORMAT, s_info.w, s_info.h); + DbgPrint("Selected conf file: %s\n", path); + if (access(path, F_OK) != 0) { + ErrPrint("Fallback to default, access: %s\n", strerror(errno)); + strncpy(path, RESOLUTION_FILE, length); + if (access(path, F_OK) != 0) { + ErrPrint("Serious error - there is no conf file, use default setting: %s\n", strerror(errno)); + free(path); + path = NULL; + } + } + + return path; } int util_screen_size_get(unsigned int *width, unsigned int *height) @@ -234,4 +260,42 @@ int util_screen_size_get(unsigned int *width, unsigned int *height) return WIDGET_ERROR_NONE; } +int util_update_resolution(struct service_info *info, struct supported_size_list *SIZE_LIST) +{ + if (s_info.res_resolved) { + return WIDGET_ERROR_NONE; + } + + if (!info->conf_file) { + info->conf_file = conf_path(); + } + + if (info->conf_file) { + register int i; + unsigned int width; + unsigned int height; + + i = util_screen_size_get(&width, &height); + if (i != WIDGET_ERROR_NONE) { + return i; + } + + if (update_from_file(info, SIZE_LIST) == 0) { + DbgPrint("Resolution info is all updated by file\n"); + } + + if (width != info->base_w) { + for (i = 0; i < WIDGET_NR_OF_SIZE_LIST; i++) { + SIZE_LIST[i].w = (unsigned int)((double)SIZE_LIST[i].w * (double)width / (double)info->base_w); + SIZE_LIST[i].h = (unsigned int)((double)SIZE_LIST[i].h * (double)width / (double)info->base_w); + } + } + } else { + DbgPrint("Conf file is not loaded\n"); + } + + s_infos_info..res_resolved = 1; + return WIDGET_ERROR_NONE; +} + /* End of a file */ diff --git a/src/widget_service.c b/src/widget_service.c index 1aeef1b..18e750a 100644 --- a/src/widget_service.c +++ b/src/widget_service.c @@ -606,7 +606,7 @@ EAPI int widget_service_get_instance_count(const char *pkgname, const char *clus return ret; } -EAPI int widget_service_trigger_update(const char *pkgname, const char *id, const char *content, int force) +EAPI int widget_service_trigger_update(const char *widget_id, const char *id, const char *content, int force) { struct packet *packet; struct packet *result; @@ -614,7 +614,7 @@ EAPI int widget_service_trigger_update(const char *pkgname, const char *id, cons char *uri; int ret; - if (!pkgname) { + if (!widget_id) { ErrPrint("Invalid argument\n"); return WIDGET_ERROR_INVALID_PARAMETER; } @@ -633,7 +633,7 @@ EAPI int widget_service_trigger_update(const char *pkgname, const char *id, cons uri = NULL; } - packet = packet_create((const char *)&cmd, "sssssi", pkgname, uri, "user,created", "default", content, force); + packet = packet_create((const char *)&cmd, "sssssi", widget_id, uri, "user,created", "default", content, force); /*! * \note * "free" function accepts NULL |