libtzplatform-config
uuid
cynara-client
+ ecore-wayland
+ iniparser
)
FOREACH(flag ${pkgs_CFLAGS})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/widget_conf.h DESTINATION include/${PROJECT_NAME})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/widget_instance.h DESTINATION include/${PROJECT_NAME})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/${PROFILE}.conf.ini DESTINATION /usr/share/${PROJECT_NAME} RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/${PROFILE}.resolution.ini DESTINATION /usr/share/${PROJECT_NAME} RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.320x480.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/320x480 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.320x480.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/320x480 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.480x800.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/480x800 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.480x800.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/480x800 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.wearable.360x480.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/360x480 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.wearable.360x480.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/360x480 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.wearable.360x360.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/360x360 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.wearable.360x360.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/360x360 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/720x1280 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/720x1280 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.wearable.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/320x320 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.wearable.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/320x320 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.540x960.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/540x960 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.540x960.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/540x960 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/${PROFILE}.conf.ini DESTINATION /usr/share/${PROJECT_NAME} RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/${PROFILE}.resolution.ini DESTINATION /usr/share/${PROJECT_NAME} RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
ADD_SUBDIRECTORY(parser)
# End of a file
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/types.h>
+#include <iniparser.h>
#include <glib.h>
#include <sqlite3.h>
+#include <Ecore_Wayland.h>
#include <aul.h>
#include <tzplatform_config.h>
#include <pkgmgr-info.h>
#include "widget_service.h"
#include "widget_service_internal.h"
+#define MAX_COLUMN 80
#define MAX_BUF_SIZE 4096
#define SMACK_LABEL_LEN 255
+#define RESOLUTION_PATH_FORMAT "/usr/share/widget_service/%dx%d/resolution.ini"
+#define RESOLUTION_PATH_DEFAULT "/usr/share/widget_service/resolution.ini"
+#define RESOLUTION_SECTION_NAME "resolution"
+#define RESOLUTION_FORMAT "%dx%d"
+
static GList *lifecycle_cbs;
+static bool _is_resolution_loaded = false;
static inline bool _is_widget_feature_enabled(void)
{
*i = sqlite3_column_int(stmt, idx);
}
-/* TODO: get pixel size type from configuration file */
#define WIDGET_SIZE_TYPE_MAX 13
static int size_list[WIDGET_SIZE_TYPE_MAX][5] = {
{ 1, 1, 175, 175, WIDGET_SIZE_TYPE_1x1 }, /*!< 1x1 */
{ 0, 0, 720, 1280, WIDGET_SIZE_TYPE_FULL }, /*!< 0x0 */
};
+static char *_resolution_file_path(void)
+{
+ char *path;
+ int length;
+ int w, h;
+
+ length = strlen(RESOLUTION_PATH_FORMAT) + 12;
+ path = calloc(1, length);
+ if (!path) {
+ _E("calloc: %d\n", errno);
+ return NULL;
+ }
+
+ ecore_wl_screen_size_get(&w, &h);
+ _D("screen size : %d %d", w, h);
+
+ snprintf(path, length, RESOLUTION_PATH_FORMAT, w, h);
+ _D("Selected conf file: %s", path);
+ if (access(path, F_OK) != 0) {
+ _E("Fallback to default, access: %d", errno);
+ strncpy(path, RESOLUTION_PATH_DEFAULT, length);
+ if (access(path, F_OK) != 0) {
+ _E("Serious error - there is no conf file, use default setting: %d\n", errno);
+ free(path);
+ path = NULL;
+ }
+ }
+
+ return path;
+}
+
+static void _resolution_update_size_list(int width_type, int height_type, int width, int height)
+{
+ int idx = 0;
+
+ if (width_type == 1 && height_type == 1) {
+ idx = 0;
+ } else if (width_type == 2 && height_type == 1) {
+ idx = 1;
+ } else if (width_type == 2 && height_type == 2) {
+ idx = 2;
+ } else if (width_type == 4 && height_type == 1) {
+ idx = 3;
+ } else if (width_type == 4 && height_type == 2) {
+ idx = 4;
+ } else if (width_type == 4 && height_type == 3) {
+ idx = 5;
+ } else if (width_type == 4 && height_type == 4) {
+ idx = 6;
+ } else if (width_type == 4 && height_type == 5) {
+ idx = 7;
+ } else if (width_type == 4 && height_type == 6) {
+ idx = 8;
+ } else if (width_type == 21 && height_type == 21) {
+ idx = 9;
+ } else if (width_type == 23 && height_type == 21) {
+ idx = 10;
+ } else if (width_type == 23 && height_type == 23) {
+ idx = 11;
+ } else if (width_type == 0 && height_type == 0) {
+ idx = 12;
+ } else {
+ _E("Unknown size type: %dx%d (%dx%d)\n", width_type, height_type, width, height);
+ return;
+ }
+
+ size_list[idx][2] = width;
+ size_list[idx][3] = height;
+}
+
+static int _resolution_update_from_file(void)
+{
+ int width_type = 0;
+ int height_type = 0;
+ int width = 0;
+ int height = 0;
+ char *type_str;
+ char *size_str;
+ dictionary *dic;
+ char *file_path = NULL;
+ int key_num;
+ char **key_list;
+ char key_format[MAX_COLUMN];
+ int i;
+
+ file_path = _resolution_file_path();
+ if (file_path == NULL)
+ return WIDGET_ERROR_OUT_OF_MEMORY;
+
+ dic = iniparser_load(file_path);
+ if (dic == NULL) {
+ _E("fail to load [%s] ", file_path);
+ return WIDGET_ERROR_IO_ERROR;
+ }
+ snprintf(key_format, sizeof(key_format), "%s:%s",
+ RESOLUTION_SECTION_NAME, RESOLUTION_FORMAT);
+ key_num = iniparser_getsecnkeys(dic, RESOLUTION_SECTION_NAME);
+ key_list = iniparser_getseckeys(dic, RESOLUTION_SECTION_NAME);
+ for (i = 0; i < key_num; i++) {
+ type_str = key_list[i];
+ size_str = iniparser_getstring(dic, type_str, NULL);
+ if (sscanf(type_str, key_format, &width_type, &height_type) != 2) {
+ _E("Invalid syntax: [%s]", type_str);
+ continue;
+ }
+
+ if (sscanf(size_str, "%dx%d", &width, &height) != 2) {
+ _E("Invalid syntax: [%s]", size_str);
+ continue;
+ }
+ _resolution_update_size_list(width_type, height_type, width, height);
+ }
+ iniparser_freedict(dic);
+
+ return WIDGET_ERROR_NONE;
+}
+
static int _get_supported_size_type(int width, int height, int *type)
{
int i;
+ if (!_is_resolution_loaded) {
+ _resolution_update_from_file();
+ _is_resolution_loaded = true;
+ }
+
for (i = 0; i < WIDGET_SIZE_TYPE_MAX; i++) {
if (width == size_list[i][2] && height == size_list[i][3])
break;
{
int i;
+ if (!_is_resolution_loaded) {
+ _resolution_update_from_file();
+ _is_resolution_loaded = true;
+ }
+
for (i = 0; i < WIDGET_SIZE_TYPE_MAX; i++) {
if (type == size_list[i][4])
break;
int i;
int j;
+ if (!_is_resolution_loaded) {
+ _resolution_update_from_file();
+ _is_resolution_loaded = true;
+ }
+
for (j = 0; j < count; j++) {
for (i = 0; i < WIDGET_SIZE_TYPE_MAX; i++) {
if (size_list[i][0] == width[j] &&
{
int i;
+ if (!_is_resolution_loaded) {
+ _resolution_update_from_file();
+ _is_resolution_loaded = true;
+ }
+
for (i = 0; i < WIDGET_SIZE_TYPE_MAX; i++) {
if (size_list[i][2] == width &&
size_list[i][3] == height)