err_code = *(uint32_t *)data;
data += 4;
- if (!save_data_to_tmpfile(path, suffixlen, sh_data, sh_len)) {
+ if (err_code == ERR_NO) {
+ if (save_data_to_tmpfile(path, suffixlen, sh_data, sh_len)) {
+ LOGE("Cannot save screenshot\n");
+ err_code = ERR_UNKNOWN;
+ }
+ }
+
+ if (err_code == ERR_NO) {
sendACKToHost(NMSG_GET_UI_SCREENSHOT,
err_code, path, sizeof(path));
} else {
- LOGE("Cannot save screenshot\n");
+ char empty_path[] = "";
+ sendACKToHost(NMSG_GET_UI_SCREENSHOT,
+ err_code, empty_path, sizeof(empty_path));
}
}
set_hierarchy_status(HIERARCHY_NOT_RUNNING);
}
-static int screenshot_send_to_socket(enum ErrorCode err, const char *path)
+static int screenshot_send_to_socket(const char *path)
{
struct file_data *fdata;
void *buf, *p;
}
/* pack err */
- p = pack_int32(buf, err);
+ p = pack_int32(buf, ERR_NO);
/* pack img.png */
memcpy(p, fdata->data, fdata->len);
return 0;
}
+static void screenshot_send_to_socket_error(enum ErrorCode err)
+{
+ char buf[4];
+
+ /* format:
+ * +-----+
+ * | err |
+ * +-----+
+ * | 4 |
+ */
+
+ /* pack err */
+ pack_int32(buf, err);
+
+ /* send screenshot error to manager */
+ msg_send(APP_MSG_GET_UI_SCREENSHOT, buf, sizeof(buf));
+}
+
bool print_log_ui_obj_screenshot(Evas_Object *obj)
{
- int ret;
+ int ret = -1;
enum ErrorCode err;
char path[PATH_MAX];
err = ui_obj_screenshot(obj, path);
- ret = screenshot_send_to_socket(err, path);
- if (err == ERR_NO)
- remove(path);
+ if (err == ERR_NO) {
+ ret = screenshot_send_to_socket(path);
+ if (ret)
+ err = ERR_UNKNOWN;
+
+ if (-1 == remove(path))
+ PRINTERR("Cannot remove file, path='%s', erron=%d",
+ path, errno);
+ }
+
+ if (err != ERR_NO)
+ screenshot_send_to_socket_error(err);
return !ret;
}