* - KBlocks
* - SBlocks
* - indexing support
- * - calling of progress function
- * - handling of IO errors (emsg)
- * - code-sharing with unindex
- * - datastore reservation support
- * - persistence support
+ * - code-sharing with unindex (can wait)
+ * - persistence support (can wait)
+ * - datastore reservation support (optimization)
*/
#include "platform.h"
make_publish_status (&pi, pcc->sc, pcc->p);
pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
pi.value.publish.specifics.error.message = pcc->p->emsg;
- pcc->sc->h->upcb (pcc->sc->h->upcb_cls,
- &pi);
+ pcc->p->client_info
+ = pcc->sc->h->upcb (pcc->sc->h->upcb_cls,
+ &pi);
return;
}
GNUNET_FS_file_information_sync (pcc->p);
make_publish_status (&pi, sc, p);
pi.value.publish.eta = GNUNET_TIME_UNIT_ZERO;
pi.value.publish.specifics.completed.chk_uri = p->chk_uri;
- sc->h->upcb (sc->h->upcb_cls,
- &pi);
+ p->client_info
+ = sc->h->upcb (sc->h->upcb_cls,
+ &pi);
}
make_publish_status (&pi, sc, p);
pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
pi.value.publish.specifics.error.message = p->emsg;
- sc->h->upcb (sc->h->upcb_cls,
- &pi);
+ p->client_info
+ = sc->h->upcb (sc->h->upcb_cls,
+ &pi);
/* continue with main (to propagate error up) */
sc->upload_task
= GNUNET_SCHEDULER_add_delayed (sc->h->sched,
pi.value.publish.specifics.progress.data = pt_block;
pi.value.publish.specifics.progress.offset = p->publish_offset;
pi.value.publish.specifics.progress.data_len = pt_size;
- sc->h->upcb (sc->h->upcb_cls,
- &pi);
+ p->client_info
+ = sc->h->upcb (sc->h->upcb_cls,
+ &pi);
}
GNUNET_CRYPTO_hash (enc, pt_size, &mychk->query);
if (p->current_depth == p->chk_tree_depth)
make_publish_status (&pi, sc, p);
pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
pi.value.publish.specifics.error.message = p->emsg;
- sc->h->upcb (sc->h->upcb_cls,
- &pi);
+ p->client_info
+ = sc->h->upcb (sc->h->upcb_cls,
+ &pi);
}
return;
}
}
+/**
+ * Signal the FS's progress function that we are starting
+ * an upload.
+ *
+ * @param cls closure (of type "struct GNUNET_FS_PublishContext*")
+ * @param fi the entry in the publish-structure
+ * @param length length of the file or directory
+ * @param meta metadata for the file or directory (can be modified)
+ * @param uri pointer to the keywords that will be used for this entry (can be modified)
+ * @param anonymity pointer to selected anonymity level (can be modified)
+ * @param priority pointer to selected priority (can be modified)
+ * @param expirationTime pointer to selected expiration time (can be modified)
+ * @param client_info pointer to client context set upon creation (can be modified)
+ * @return GNUNET_OK to continue (always)
+ */
+static int
+fip_signal_start(void *cls,
+ struct GNUNET_FS_FileInformation *fi,
+ uint64_t length,
+ struct GNUNET_CONTAINER_MetaData *meta,
+ struct GNUNET_FS_Uri **uri,
+ unsigned int *anonymity,
+ unsigned int *priority,
+ struct GNUNET_TIME_Absolute *expirationTime,
+ void **client_info)
+{
+ struct GNUNET_FS_PublishContext *sc = cls;
+ struct GNUNET_FS_ProgressInfo pi;
+
+ pi.status = GNUNET_FS_STATUS_PUBLISH_START;
+ make_publish_status (&pi, sc, fi);
+ *client_info = sc->h->upcb (sc->h->upcb_cls,
+ &pi);
+ return GNUNET_OK;
+}
+
+
/**
* Publish a file or directory.
*
// FIXME: make upload persistent!
/* signal start */
-
-
+ GNUNET_FS_file_information_inspect (ret->fi,
+ &fip_signal_start,
+ ret);
/* find first leaf, DFS */
p = ret->fi;
while ( (p->is_directory) &&
}
+/**
+ * Signal the FS's progress function that we are stopping
+ * an upload.
+ *
+ * @param cls closure (of type "struct GNUNET_FS_PublishContext*")
+ * @param fi the entry in the publish-structure
+ * @param length length of the file or directory
+ * @param meta metadata for the file or directory (can be modified)
+ * @param uri pointer to the keywords that will be used for this entry (can be modified)
+ * @param anonymity pointer to selected anonymity level (can be modified)
+ * @param priority pointer to selected priority (can be modified)
+ * @param expirationTime pointer to selected expiration time (can be modified)
+ * @param client_info pointer to client context set upon creation (can be modified)
+ * @return GNUNET_OK to continue (always)
+ */
+static int
+fip_signal_stop(void *cls,
+ struct GNUNET_FS_FileInformation *fi,
+ uint64_t length,
+ struct GNUNET_CONTAINER_MetaData *meta,
+ struct GNUNET_FS_Uri **uri,
+ unsigned int *anonymity,
+ unsigned int *priority,
+ struct GNUNET_TIME_Absolute *expirationTime,
+ void **client_info)
+{
+ struct GNUNET_FS_PublishContext*sc = cls;
+ struct GNUNET_FS_ProgressInfo pi;
+
+ pi.status = GNUNET_FS_STATUS_PUBLISH_STOPPED;
+ make_publish_status (&pi, sc, fi);
+ GNUNET_break (NULL ==
+ sc->h->upcb (sc->h->upcb_cls,
+ &pi));
+ *client_info = NULL;
+ return GNUNET_OK;
+}
+
+
/**
* Stop an upload. Will abort incomplete uploads (but
* not remove blocks that have already been publishd) or
GNUNET_SCHEDULER_cancel (sc->h->sched, sc->upload_task);
// FIXME: remove from persistence DB (?) --- think more about
// shutdown / persistent-resume APIs!!!
+ GNUNET_FS_file_information_inspect (sc->fi,
+ &fip_signal_stop,
+ sc);
GNUNET_FS_file_information_destroy (sc->fi, NULL, NULL);
GNUNET_FS_namespace_delete (sc->namespace, GNUNET_NO);
GNUNET_free_non_null (sc->nid);