/* * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __QP_COMMON_H_ #define __QP_COMMON_H_ #define QP_OK (0) #define QP_FAIL (-1) #define QP_UTIL_PHONE_NUMBER_MAX_LEN 40 #define EDATA_BACKKEY_CB "bk_cb" #if !defined(_DLOG_USED) #define _DLOG_USED #endif #ifdef _DLOG_USED #undef LOG_TAG #define LOG_TAG "QUICKPANEL" #include #include #define HAPI __attribute__((visibility("hidden"))) #ifndef __MODULE__ #define __MODULE__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) #endif #undef LOG_ #define LOG_(prio, tag, fmt, arg...) \ ({ do { \ dlog_print(prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg);\ } while (0); }) #define DBG(format, arg...) LOG_(DLOG_DEBUG, LOG_TAG, format, ##arg) #define INFO(format, arg...) LOG_(DLOG_INFO, LOG_TAG, format, ##arg) #define WARN(format, arg...) LOG_(DLOG_WARN, LOG_TAG, format, ##arg) #define ERR(format, arg...) LOG_(DLOG_ERROR, LOG_TAG, format, ##arg) #endif /*_DLOG_USED*/ #define msgif(cond, str, args...) do { \ if (cond) { \ ERR(str, ##args);\ } \ } while (0); #define retif(cond, ret, str, args...) do { \ if (cond) { \ ERR(str, ##args);\ return ret;\ } \ } while (0); #define ret_if(expr) do { \ if (expr) { \ DBG("(%s) -> %s() return", #expr, __FUNCTION__); \ return; \ } \ } while (0) #define retv_if(expr, val) do { \ if (expr) { \ DBG("(%s) -> %s() return", #expr, __FUNCTION__); \ return (val); \ } \ } while (0) #define retif_nomsg(cond, ret) do { \ if (cond) { \ return ret;\ } \ } while (0); #define gotoif(cond, target, str, args...) do { \ if (cond) { \ WARN(str, ##args); \ goto target; \ } \ } while (0); extern void quickpanel_common_util_char_trim(char *text); extern void quickpanel_common_util_char_replace(char *text, char s, char t); extern void quickpanel_common_util_add_char_to_each_charactor(char *dst, const char *src, char t); extern int quickpanel_common_util_is_phone_number(const char *address); extern void quickpanel_common_util_phone_number_tts_make(char *dst, const char *src, int size); extern void quickpanel_common_ui_set_current_popup(Evas_Object *popup, Evas_Smart_Cb func_close); extern void quickpanel_common_ui_del_current_popup(void); extern void *quickpanel_common_ui_get_buffer_from_image(const char *file_path, size_t *memfile_size, char *ext, int ext_size); extern char *quickpanel_common_ui_get_pkginfo_icon(const char *pkgid); extern char *quickpanel_common_ui_get_pkginfo_label(const char *pkgid); extern char *quickpanel_common_ui_get_appinfo_icon(const char *pkgid); extern void quickpanel_common_inform_launch_app_result(const char *pkgname, int retcode); extern int quickpanel_common_send_message_to_app(const char *app_id, const char *operation, const char *key, const char *value); extern int quickpanel_common_launch_app(char *app_id, void *data); extern void _launch_powerkey_syspopup(void); enum app_subdir { APP_DIR_DATA, APP_DIR_CACHE, APP_DIR_RESOURCE, APP_DIR_SHARED_DATA, APP_DIR_SHARED_RESOURCE, APP_DIR_SHARED_TRUSTED, APP_DIR_EXTERNAL_DATA, APP_DIR_EXTERNAL_CACHE, }; const char *util_get_file_path(enum app_subdir dir, const char *relative); #define util_get_data_file_path(x) util_get_file_path(APP_DIR_DATA, (x)) #define util_get_cache_file_path(x) util_get_file_path(APP_DIR_CACHE, (x)) #define util_get_res_file_path(x) util_get_file_path(APP_DIR_RESOURCE, (x)) #define util_get_shared_data_file_path(x) util_get_file_path(APP_DIR_SHARED_DATA, (x)) #define util_get_shared_res_file_path(x) util_get_file_path(APP_DIR_SHARED_RESOURCE, (x)) #define util_get_trusted_file_path(x) util_get_file_path(APP_DIR_SHARED_TRUSTED, (x)) #define util_get_external_data_file_path(x) util_get_file_path(APP_DIR_EXTERNAL_DATA, (x)) #define util_get_external_cache_file_path(x) util_get_file_path(APP_DIR_EXTERNAL_CACHE, (x)) #endif /* __QP_COMMON_H_ */