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.c64
1 files changed, 48 insertions, 16 deletions
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
index 99d07cd..8332f1d 100644
--- a/src/gnunet_chat_lib.c
+++ b/src/gnunet_chat_lib.c
@@ -703,6 +703,9 @@ GNUNET_CHAT_context_send_file (struct GNUNET_CHAT_Context *context,
703 GNUNET_FS_PUBLISH_OPTION_NONE 703 GNUNET_FS_PUBLISH_OPTION_NONE
704 ); 704 );
705 705
706 if (file->publish)
707 file->status |= GNUNET_CHAT_FILE_STATUS_PUBLISH;
708
706 GNUNET_free(filename); 709 GNUNET_free(filename);
707 710
708file_binding: 711file_binding:
@@ -978,11 +981,18 @@ GNUNET_CHAT_file_get_hash (const struct GNUNET_CHAT_File *file)
978uint64_t 981uint64_t
979GNUNET_CHAT_file_get_size (const struct GNUNET_CHAT_File *file) 982GNUNET_CHAT_file_get_size (const struct GNUNET_CHAT_File *file)
980{ 983{
981 if (!file) 984 if ((!file) || (!(file->uri)))
982 return 0; 985 return 0;
983 986
984 if (file->uri) 987 return GNUNET_FS_uri_chk_get_file_size(file->uri);
985 return GNUNET_FS_uri_chk_get_file_size(file->uri); 988}
989
990
991uint64_t
992GNUNET_CHAT_file_get_local_size (const struct GNUNET_CHAT_File *file)
993{
994 if (!file)
995 return 0;
986 996
987 char *filename; 997 char *filename;
988 util_get_filename ( 998 util_get_filename (
@@ -999,20 +1009,12 @@ GNUNET_CHAT_file_get_size (const struct GNUNET_CHAT_File *file)
999 1009
1000 1010
1001int 1011int
1002GNUNET_CHAT_file_is_local (const struct GNUNET_CHAT_File *file) 1012GNUNET_CHAT_file_is_uploading (const struct GNUNET_CHAT_File *file)
1003{ 1013{
1004 if (!file) 1014 if ((!file) || (0 == (file->status & GNUNET_CHAT_FILE_STATUS_PUBLISH)))
1005 return GNUNET_SYSERR; 1015 return GNUNET_NO;
1006 1016 else
1007 char *filename; 1017 return GNUNET_YES;
1008 util_get_filename (
1009 file->handle->directory, "files", &(file->hash), &filename
1010 );
1011
1012 int result = GNUNET_DISK_file_test(filename);
1013
1014 GNUNET_free(filename);
1015 return result;
1016} 1018}
1017 1019
1018 1020
@@ -1088,6 +1090,16 @@ GNUNET_CHAT_file_get_user_pointer (const struct GNUNET_CHAT_File *file)
1088 1090
1089 1091
1090int 1092int
1093GNUNET_CHAT_file_is_downloading (const struct GNUNET_CHAT_File *file)
1094{
1095 if ((!file) || (0 == (file->status & GNUNET_CHAT_FILE_STATUS_DOWNLOAD)))
1096 return GNUNET_NO;
1097 else
1098 return GNUNET_YES;
1099}
1100
1101
1102int
1091GNUNET_CHAT_file_start_download (struct GNUNET_CHAT_File *file, 1103GNUNET_CHAT_file_start_download (struct GNUNET_CHAT_File *file,
1092 GNUNET_CHAT_FileDownloadCallback callback, 1104 GNUNET_CHAT_FileDownloadCallback callback,
1093 void *cls) 1105 void *cls)
@@ -1140,6 +1152,9 @@ GNUNET_CHAT_file_start_download (struct GNUNET_CHAT_File *file,
1140 NULL 1152 NULL
1141 ); 1153 );
1142 1154
1155 if (file->download)
1156 file->status |= GNUNET_CHAT_FILE_STATUS_DOWNLOAD;
1157
1143 GNUNET_free(filename); 1158 GNUNET_free(filename);
1144 return GNUNET_OK; 1159 return GNUNET_OK;
1145} 1160}
@@ -1180,6 +1195,18 @@ GNUNET_CHAT_file_stop_download (struct GNUNET_CHAT_File *file)
1180 1195
1181 1196
1182int 1197int
1198GNUNET_CHAT_file_is_unindexing (const struct GNUNET_CHAT_File *file)
1199{
1200 if ((!file) || (0 == (file->status & GNUNET_CHAT_FILE_STATUS_UNINDEX)))
1201 return GNUNET_NO;
1202 else
1203 return GNUNET_YES;
1204}
1205
1206
1207
1208
1209int
1183GNUNET_CHAT_file_unindex (struct GNUNET_CHAT_File *file, 1210GNUNET_CHAT_file_unindex (struct GNUNET_CHAT_File *file,
1184 GNUNET_CHAT_FileUnindexCallback callback, 1211 GNUNET_CHAT_FileUnindexCallback callback,
1185 void *cls) 1212 void *cls)
@@ -1208,11 +1235,16 @@ GNUNET_CHAT_file_unindex (struct GNUNET_CHAT_File *file,
1208 file->handle->fs, filename, file 1235 file->handle->fs, filename, file
1209 ); 1236 );
1210 1237
1238 if (file->unindex)
1239 file->status |= GNUNET_CHAT_FILE_STATUS_UNINDEX;
1240
1211 GNUNET_free(filename); 1241 GNUNET_free(filename);
1212 return GNUNET_OK; 1242 return GNUNET_OK;
1213} 1243}
1214 1244
1215 1245
1246
1247
1216void 1248void
1217GNUNET_CHAT_invitation_accept (struct GNUNET_CHAT_Invitation *invitation) 1249GNUNET_CHAT_invitation_accept (struct GNUNET_CHAT_Invitation *invitation)
1218{ 1250{