*/
struct GNUNET_FS_Handle *h;
- /**
- * Argument to pass to the client in callbacks.
- */
- void *client_ctx;
-
/**
* File-structure that is being shared.
*/
* @param length how many bytes should be downloaded starting at offset
* @param anonymity anonymity level to use for the download
* @param options various options
+ * @param cctx initial value for the client context for this download
* @param parent parent download to associate this download with (use NULL
* for top-level downloads; useful for manually-triggered recursive downloads)
* @return context that can be used to control this download
uint64_t length,
uint32_t anonymity,
enum GNUNET_FS_DownloadOptions options,
+ void *cctx,
struct GNUNET_FS_DownloadContext *parent)
{
struct GNUNET_FS_ProgressInfo pi;
dc->parent = parent;
dc->uri = GNUNET_FS_uri_dup (uri);
dc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
+ dc->client_info = cctx;
if (NULL != filename)
{
dc->filename = GNUNET_strdup (filename);
* Publish a file or directory.
*
* @param h handle to the file sharing subsystem
- * @param ctx initial value to use for the '*ctx'
- * in the callback (for the GNUNET_FS_STATUS_PUBLISH_START event).
* @param fi information about the file or directory structure to publish
* @param namespace namespace to publish the file in, NULL for no namespace
* @param nid identifier to use for the publishd content in the namespace
*/
struct GNUNET_FS_PublishContext *
GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
- void *ctx,
struct GNUNET_FS_FileInformation *fi,
struct GNUNET_FS_Namespace *namespace,
const char *nid,
ret = GNUNET_malloc (sizeof (struct GNUNET_FS_PublishContext));
ret->dsh = dsh;
ret->h = h;
- ret->client_ctx = ctx;
ret->fi = fi;
ret->namespace = namespace;
if (namespace != NULL)
GNUNET_FS_uri_chk_get_file_size (uri),
anonymity,
options,
+ NULL,
NULL);
GNUNET_FS_uri_destroy (uri);
}
return;
}
pc = GNUNET_FS_publish_start (ctx,
- NULL,
fi,
namespace,
this_id,
abort_download_task (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ uint64_t size;
+
GNUNET_FS_download_stop (download, GNUNET_YES);
download = NULL;
+ GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES));
+ GNUNET_assert (size == FILESIZE);
+ GNUNET_DISK_directory_remove (fn);
+ GNUNET_free (fn);
+ fn = NULL;
}
(unsigned long long) event->value.publish.size,
event->value.publish.specifics.progress.depth,
(unsigned long long) event->value.publish.specifics.progress.offset);
-#endif
+#endif
break;
case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
printf ("Publishing complete, %llu kbps.\n",
FILESIZE,
1,
GNUNET_FS_DOWNLOAD_OPTION_NONE,
+ "download",
NULL);
GNUNET_assert (download != NULL);
break;
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
break;
case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
+ GNUNET_assert (download == event->value.download.dc);
#if VERBOSE
printf ("Download is progressing (%llu/%llu at level %u off %llu)...\n",
(unsigned long long) event->value.download.completed,
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
break;
case GNUNET_FS_STATUS_PUBLISH_START:
- /* FIXME: add checks here... */
+ GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx));
+ GNUNET_assert (NULL == event->value.publish.pctx);
+ GNUNET_assert (FILESIZE == event->value.publish.size);
+ GNUNET_assert (0 == event->value.publish.completed);
+ GNUNET_assert (1 == event->value.publish.anonymity);
break;
case GNUNET_FS_STATUS_PUBLISH_STOPPED:
+ GNUNET_assert (publish == event->value.publish.sc);
+ GNUNET_assert (FILESIZE == event->value.publish.size);
+ GNUNET_assert (1 == event->value.publish.anonymity);
/* FIXME: add checks here... */
GNUNET_FS_stop (fs);
fs = NULL;
break;
case GNUNET_FS_STATUS_DOWNLOAD_START:
- /* FIXME: add checks here... */
+ GNUNET_assert (download == NULL);
+ GNUNET_assert (0 == strcmp ("download", event->value.download.cctx));
+ GNUNET_assert (NULL == event->value.download.pctx);
+ GNUNET_assert (NULL != event->value.download.uri);
+ GNUNET_assert (0 == strcmp (fn, event->value.download.filename));
+ GNUNET_assert (FILESIZE == event->value.download.size);
+ GNUNET_assert (0 == event->value.download.completed);
+ GNUNET_assert (1 == event->value.download.anonymity);
break;
case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
- /* FIXME: add checks here... */
+ GNUNET_assert (download == event->value.download.dc);
GNUNET_SCHEDULER_add_continuation (sched,
GNUNET_NO,
&abort_publish_task,
buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
meta = GNUNET_CONTAINER_meta_data_create ();
kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
- fi = GNUNET_FS_file_information_create_from_data ("file-to-publish",
+ fi = GNUNET_FS_file_information_create_from_data ("publish-context",
FILESIZE,
buf,
kuri,
GNUNET_assert (NULL != fi);
start = GNUNET_TIME_absolute_get ();
publish = GNUNET_FS_publish_start (fs,
- "publish-context",
fi,
NULL, NULL, NULL,
GNUNET_FS_PUBLISH_OPTION_NONE);
const struct GNUNET_FS_FileInformation *fi;
/**
- * Client context pointer (set the last time
- * by the client for this operation; initially
- * NULL on START/RESUME events).
+ * Client context pointer (set the last time by the client for
+ * this operation; initially NULL on START/RESUME events).
*/
void *cctx;
* Publish a file or directory.
*
* @param h handle to the file sharing subsystem
- * @param ctx initial value to use for the '*ctx'
- * in the callback (for the GNUNET_FS_STATUS_PUBLISH_START event).
* @param fi information about the file or directory structure to publish
* @param namespace namespace to publish the file in, NULL for no namespace
* @param nid identifier to use for the publishd content in the namespace
*/
struct GNUNET_FS_PublishContext *
GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
- void *ctx,
struct GNUNET_FS_FileInformation *fi,
struct GNUNET_FS_Namespace *namespace,
const char *nid,
* @param length how many bytes should be downloaded starting at offset
* @param anonymity anonymity level to use for the download
* @param options various download options
+ * @param cctx initial value for the client context for this download
* @param parent parent download to associate this download with (use NULL
* for top-level downloads; useful for manually-triggered recursive downloads)
* @return context that can be used to control this download
*/
-// FIXME: add a "void *" context for the client to arguments!?
struct GNUNET_FS_DownloadContext *
GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
const struct GNUNET_FS_Uri *uri,
uint64_t length,
uint32_t anonymity,
enum GNUNET_FS_DownloadOptions options,
+ void *cctx,
struct GNUNET_FS_DownloadContext *parent);