AUL_PAUSE,
AUL_WAKE,
AUL_SUSPEND,
+ AUL_WIDGET_CONTENT,
} aul_type;
typedef enum aul_widget_lifecycle_event {
/** AUL internal private key */
#define AUL_K_WIDGET_STATUS "__AUL_WIDGET_STATUS__"
/** AUL internal private key */
-#define AUL_K_APP_DATA_KEY "__AUL_APP_DATA_KEY__"
+#define AUL_K_WIDGET_CONTENT_INFO "__AUL_WIDGET_CONTENT_INFO__"
/** AUL internal private key */
#define AUL_K_TARGET_PID "__AUL_TARGET_PID__"
/** AUL internal private key */
int pid, int status, int is_subapp, void *data),
void *data);
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_widget_instance_get_content(const char *widget_id, const char *instance_id, char **content);
+
#ifdef __cplusplus
}
#endif
APP_COM_SEND,
APP_COM_LEAVE,
APP_COM_MESSAGE,
- APP_DATA_NEW,
- APP_DATA_GET_RAW,
- APP_DATA_PUT,
- APP_DATA_GET,
- APP_DATA_GET_OWNER,
- APP_DATA_DEL,
-
WIDGET_ADD,
WIDGET_DEL,
WIDGET_LIST,
WIDGET_UPDATE,
WIDGET_COUNT,
+ WIDGET_GET_CONTENT,
APP_REGISTER_PID,
return 0;
}
+static int widget_get_content(int clifd, bundle *kb)
+{
+ int ret;
+ int fd = 0;
+ char *widget_id = NULL;
+ char *instance_id = NULL;
+ char *content_info = NULL;
+
+ bundle_get_str(kb, AUL_K_WIDGET_ID, &widget_id);
+ bundle_get_str(kb, AUL_K_WIDGET_INSTANCE_ID, &instance_id);
+
+ ret = aul_sock_recv_reply_sock_fd(clifd, &fd, 1);
+ if (ret < 0) {
+ _E("failed to recv sock fd");
+ return ret;
+ }
+
+ if (!widget_id || !instance_id) {
+ aul_sock_send_raw_with_fd(fd, -EINVAL, 0, 0, AUL_SOCK_NOREPLY);
+ return 0;
+ }
+
+ __call_aul_handler(AUL_WIDGET_CONTENT, kb);
+
+ bundle_get_str(kb, AUL_K_WIDGET_CONTENT_INFO, &content_info);
+ if (content_info) {
+ ret = aul_sock_send_raw_with_fd(fd, 0,
+ (unsigned char *)content_info,
+ strlen(content_info) + 1, AUL_SOCK_NOREPLY);
+ } else {
+ ret = aul_sock_send_raw_with_fd(fd, -ENOENT,
+ NULL, 0, AUL_SOCK_NOREPLY);
+ }
+
+ if (ret < 0)
+ _E("failed to send content %d (%d)", fd, ret);
+
+ return ret;
+}
+
/**
* @brief caller & callee's sock handler
*/
if (pkt->opt & AUL_SOCK_NOREPLY) {
close(clifd);
- } else {
+ } else if (pkt->cmd != WIDGET_GET_CONTENT) {
ret = __send_result_to_launchpad(clifd, 0);
if (ret < 0) {
free(pkt);
case APP_STATUS_NOTIFICATION:
app_status_event(kbundle);
break;
+ case WIDGET_GET_CONTENT:
+ widget_get_content(clifd, kbundle);
+ break;
default:
_E("no support packet");
}
return ret;
}
+API int aul_widget_instance_get_content(const char *widget_id,
+ const char *instance_id, char **content)
+{
+ int ret;
+ bundle *kb;
+ int fd = 0;
+ app_pkt_t *pkt = NULL;
+
+ if (widget_id == NULL || instance_id == NULL || content == NULL)
+ return AUL_R_EINVAL;
+
+ kb = bundle_create();
+ if (kb == NULL) {
+ _E("out of memory");
+ return AUL_R_ERROR;
+ }
+
+ bundle_add_str(kb, AUL_K_APPID, __to_appid(widget_id));
+ bundle_add_str(kb, AUL_K_WIDGET_ID, widget_id);
+ bundle_add_str(kb, AUL_K_WIDGET_INSTANCE_ID, instance_id);
+
+ ret = aul_sock_send_bundle(AUL_UTIL_PID, getuid(), WIDGET_GET_CONTENT,
+ kb, AUL_SOCK_ASYNC);
+ if (ret > 0) {
+ ret = aul_sock_recv_reply_sock_fd(ret, &fd, 1);
+ if (ret == 0) {
+ ret = aul_sock_recv_reply_pkt(fd, &pkt);
+ if (ret == 0 && pkt && pkt->cmd == 0) {
+ *content = strdup((const char *)pkt->data);
+ _D("recieved content: %s", *content);
+ } else {
+ if (pkt)
+ ret = pkt->cmd;
+
+ _E("failed to get content");
+ }
+ } else {
+ _E("failed to get socket fd:%d", ret);
+ }
+ }
+
+ bundle_free(kb);
+
+ if (ret < 0)
+ ret = aul_error_convert(ret);
+
+ return ret;
+}
+
API int aul_widget_instance_count(const char *widget_id)
{
int ret;