aboutsummaryrefslogtreecommitdiff
path: root/src/gnunet_chat_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnunet_chat_lib.c')
-rw-r--r--src/gnunet_chat_lib.c58
1 files changed, 54 insertions, 4 deletions
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
index adf0eff..99d07cd 100644
--- a/src/gnunet_chat_lib.c
+++ b/src/gnunet_chat_lib.c
@@ -638,7 +638,7 @@ GNUNET_CHAT_context_send_file (struct GNUNET_CHAT_Context *context,
638 ); 638 );
639 639
640 if (file) 640 if (file)
641 goto file_upload; 641 goto file_binding;
642 642
643 if ((GNUNET_YES == GNUNET_DISK_file_test(filename)) || 643 if ((GNUNET_YES == GNUNET_DISK_file_test(filename)) ||
644 (GNUNET_OK != GNUNET_DISK_directory_create_for_file(filename)) || 644 (GNUNET_OK != GNUNET_DISK_directory_create_for_file(filename)) ||
@@ -677,9 +677,6 @@ GNUNET_CHAT_context_send_file (struct GNUNET_CHAT_Context *context,
677 return NULL; 677 return NULL;
678 } 678 }
679 679
680file_upload:
681 file_bind_upload(file, context, callback, cls);
682
683 struct GNUNET_FS_BlockOptions bo; 680 struct GNUNET_FS_BlockOptions bo;
684 681
685 bo.anonymity_level = 1; 682 bo.anonymity_level = 1;
@@ -707,6 +704,9 @@ file_upload:
707 ); 704 );
708 705
709 GNUNET_free(filename); 706 GNUNET_free(filename);
707
708file_binding:
709 file_bind_upload(file, context, callback, cls);
710 return file; 710 return file;
711} 711}
712 712
@@ -1016,6 +1016,56 @@ GNUNET_CHAT_file_is_local (const struct GNUNET_CHAT_File *file)
1016} 1016}
1017 1017
1018 1018
1019const char*
1020GNUNET_CHAT_file_open_preview (struct GNUNET_CHAT_File *file)
1021{
1022 if (!file)
1023 return NULL;
1024
1025 if (file->preview)
1026 return file->preview;
1027
1028 char *filename;
1029 util_get_filename (
1030 file->handle->directory, "files", &(file->hash), &filename
1031 );
1032
1033 if (GNUNET_YES != GNUNET_DISK_file_test(filename))
1034 goto free_filename;
1035
1036 file->preview = GNUNET_DISK_mktemp(file->name);
1037
1038 if (!(file->preview))
1039 goto free_filename;
1040
1041 remove(file->preview);
1042
1043 if ((GNUNET_OK != GNUNET_DISK_file_copy(filename, file->preview)) ||
1044 (GNUNET_OK != util_decrypt_file(file->preview, &(file->key))))
1045 {
1046 GNUNET_free(file->preview);
1047 file->preview = NULL;
1048 }
1049
1050free_filename:
1051 GNUNET_free(filename);
1052 return file->preview;
1053}
1054
1055
1056void
1057GNUNET_CHAT_file_close_preview (struct GNUNET_CHAT_File *file)
1058{
1059 if ((!file) || (!(file->preview)))
1060 return;
1061
1062 remove(file->preview);
1063
1064 GNUNET_free(file->preview);
1065 file->preview = NULL;
1066}
1067
1068
1019void 1069void
1020GNUNET_CHAT_file_set_user_pointer (struct GNUNET_CHAT_File *file, 1070GNUNET_CHAT_file_set_user_pointer (struct GNUNET_CHAT_File *file,
1021 void *user_pointer) 1071 void *user_pointer)