1297 |
1297 |
1298 unsigned char rd[8]; |
1298 unsigned char rd[8]; |
1299 memset(rd, 0, 8); |
1299 memset(rd, 0, 8); |
1300 dav_rand_bytes(rd, 8); |
1300 dav_rand_bytes(rd, 8); |
1301 char *hex = util_hexstr(rd, 8); |
1301 char *hex = util_hexstr(rd, 8); |
1302 cxmutstr tmp = cx_asprintf("%sdownload-%s-%s", dir, name, hex); |
1302 cxmutstr tmp = cx_asprintf("%sdownload-%s-%s", dir, hex, name); |
1303 return tmp.ptr; |
1303 return tmp.ptr; |
1304 } |
1304 } |
1305 |
1305 |
1306 static int jobthr_resourceviewer_load(void *data) { |
1306 static int jobthr_resourceviewer_load(void *data) { |
1307 DavResourceViewer *doc = data; |
1307 DavResourceViewer *doc = data; |
1320 doc->error = err; |
1320 doc->error = err; |
1321 doc->message_str = "Cannot load content"; // TODO: better message |
1321 doc->message_str = "Cannot load content"; // TODO: better message |
1322 } |
1322 } |
1323 } else if(doc->type == DAV_RESOURCE_VIEW_IMAGE) { |
1323 } else if(doc->type == DAV_RESOURCE_VIEW_IMAGE) { |
1324 char *tmp = gen_tmp_download_filename(res->name); |
1324 char *tmp = gen_tmp_download_filename(res->name); |
1325 FILE *f = fopen(tmp, "w"); |
1325 FILE *f = sys_fopen(tmp, "wb"); |
1326 if(f) { |
1326 if(f) { |
1327 int err = dav_get_content(res, f, (dav_write_func)fwrite); |
1327 int err = dav_get_content(res, f, (dav_write_func)fwrite); |
1328 if(!err) { |
1328 if(!err) { |
1329 doc->tmp_file = tmp; |
1329 doc->tmp_file = tmp; |
1330 } else { |
1330 } else { |
1445 |
1445 |
1446 if(doc->type == DAV_RESOURCE_VIEW_TEXT) { |
1446 if(doc->type == DAV_RESOURCE_VIEW_TEXT) { |
1447 ui_set(doc->text, doc->text_content->space); |
1447 ui_set(doc->text, doc->text_content->space); |
1448 } else if(doc->type == DAV_RESOURCE_VIEW_IMAGE) { |
1448 } else if(doc->type == DAV_RESOURCE_VIEW_IMAGE) { |
1449 ui_image_load_file(doc->image, doc->tmp_file); |
1449 ui_image_load_file(doc->image, doc->tmp_file); |
1450 unlink(doc->tmp_file); |
|
1451 } |
1450 } |
1452 |
1451 |
1453 ui_set(doc->tabview, 1); |
1452 ui_set(doc->tabview, 1); |
1454 } |
1453 } |
1455 |
1454 |