adding man page for gnunet-auto-share, updating man page for gnunet-publish
[oweals/gnunet.git] / src / fs / fs_api.h
index 42daa7bc24174968b9a010ff203cfcce255de0e6..7c91b5d23984d8d0029bf490fd0c80a1dc67ddcb 100644 (file)
@@ -205,7 +205,7 @@ struct GNUNET_FS_Uri
       /**
        * Hash of the public key for the namespace.
        */
-      GNUNET_HashCode namespace;
+      struct GNUNET_HashCode namespace;
 
       /**
        * Human-readable identifier chosen for this
@@ -333,7 +333,7 @@ struct GNUNET_FS_FileInformation
        * over the entire file (when the indexing process is started).
        * Otherwise this field is not used.
        */
-      GNUNET_HashCode file_id;
+      struct GNUNET_HashCode file_id;
 
       /**
        * Size of the file (in bytes).
@@ -417,6 +417,24 @@ typedef void (*GNUNET_FS_QueueStart) (void *cls,
 typedef void (*GNUNET_FS_QueueStop) (void *cls);
 
 
+
+/**
+ * Priorities for the queue.
+ */ 
+enum GNUNET_FS_QueuePriority
+  {
+    /**
+     * This is a probe (low priority).
+     */
+    GNUNET_FS_QUEUE_PRIORITY_PROBE,
+
+    /**
+     * Default priority.
+     */
+    GNUNET_FS_QUEUE_PRIORITY_NORMAL
+  };
+
+
 /**
  * Entry in the job queue.
  */
@@ -478,6 +496,11 @@ struct GNUNET_FS_QueueEntry
    */
   unsigned int blocks;
 
+  /**
+   * How important is this download?
+   */
+  enum GNUNET_FS_QueuePriority priority;
+
   /**
    * How often have we (re)started this download?
    */
@@ -545,7 +568,7 @@ struct GNUNET_FS_SearchResult
   /**
    * Key for the search result
    */
-  GNUNET_HashCode key;
+  struct GNUNET_HashCode key;
 
   /**
    * ID of the task that will clean up the probe_ctx should it not
@@ -599,11 +622,13 @@ struct GNUNET_FS_SearchResult
  * @param stop function to call to pause the job, or on dequeue (if the job was running)
  * @param cls closure for start and stop
  * @param blocks number of blocks this download has
+ * @param priority how important is this download
  * @return queue handle
  */
 struct GNUNET_FS_QueueEntry *
 GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, GNUNET_FS_QueueStart start,
-                  GNUNET_FS_QueueStop stop, void *cls, unsigned int blocks);
+                  GNUNET_FS_QueueStop stop, void *cls, unsigned int blocks,
+                 enum GNUNET_FS_QueuePriority priority);
 
 
 /**
@@ -705,7 +730,25 @@ GNUNET_FS_publish_main_ (void *cls,
  * @param file_id computed hash, NULL on error
  */
 void
-GNUNET_FS_unindex_process_hash_ (void *cls, const GNUNET_HashCode * file_id);
+GNUNET_FS_unindex_process_hash_ (void *cls, const struct GNUNET_HashCode * file_id);
+
+
+/**
+ * Extract the keywords for KBlock removal
+ *
+ * @param uc context for the unindex operation.
+ */
+void
+GNUNET_FS_unindex_do_extract_keywords_ (struct GNUNET_FS_UnindexContext *uc);
+
+
+/**
+ * If necessary, connect to the datastore and remove the KBlocks.
+ *
+ * @param uc context for the unindex operation.
+ */
+void
+GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc);
 
 
 /**
@@ -1160,6 +1203,18 @@ struct GNUNET_FS_PublishContext
    */
   struct GNUNET_DATASTORE_QueueEntry *qre;
 
+  /**
+   * Context for SKS publishing operation that is part of this publishing operation
+   * (NULL if not active).
+   */
+  struct GNUNET_FS_PublishSksContext *sks_pc;
+
+  /**
+   * Context for KSK publishing operation that is part of this publishing operation
+   * (NULL if not active).
+   */
+  struct GNUNET_FS_PublishKskContext *ksk_pc;
+
   /**
    * ID of the task performing the upload. NO_TASK if the upload has
    * completed.
@@ -1177,17 +1232,6 @@ struct GNUNET_FS_PublishContext
    */
   uint32_t reserve_entries;
 
-  /**
-   * Typically GNUNET_NO.  Set to GNUNET_YES if "upload_task" is
-   * GNUNET_SCHEDULER_NO_TASK and we're waiting for a response from
-   * the datastore service (in which case this struct must not be
-   * freed until we have that response).  If someone tries to stop the
-   * download for good during this period, "in_network_wait" is set to
-   * GNUNET_SYSERR which will cause the struct to be destroyed right
-   * after we have the reply (or timeout) from the datastore service.
-   */
-  int in_network_wait;
-
   /**
    * Options for publishing.
    */
@@ -1218,32 +1262,42 @@ struct GNUNET_FS_PublishContext
  */
 enum UnindexState
 {
-    /**
-     * We're currently hashing the file.
-     */
+  /**
+   * We're currently hashing the file.
+   */
   UNINDEX_STATE_HASHING = 0,
 
-    /**
-     * We're telling the datastore to delete
-     * the respective entries.
-     */
+  /**
+   * We're telling the datastore to delete
+   * the respective DBlocks and IBlocks.
+   */
   UNINDEX_STATE_DS_REMOVE = 1,
+  
+  /**
+   * Find out which keywords apply.
+   */
+  UNINDEX_STATE_EXTRACT_KEYWORDS = 2,
 
-    /**
-     * We're notifying the FS service about
-     * the unindexing.
-     */
-  UNINDEX_STATE_FS_NOTIFY = 2,
-
-    /**
-     * We're done.
-     */
-  UNINDEX_STATE_COMPLETE = 3,
+  /**
+   * We're telling the datastore to remove KBlocks.
+   */
+  UNINDEX_STATE_DS_REMOVE_KBLOCKS = 3,
 
-    /**
-     * We've encountered a fatal error.
-     */
-  UNINDEX_STATE_ERROR = 4
+  /**
+   * We're notifying the FS service about
+   * the unindexing.
+   */
+  UNINDEX_STATE_FS_NOTIFY = 4,
+  
+  /**
+   * We're done.
+   */
+  UNINDEX_STATE_COMPLETE = 5,
+  
+  /**
+   * We've encountered a fatal error.
+   */
+  UNINDEX_STATE_ERROR = 6
 };
 
 
@@ -1253,6 +1307,12 @@ enum UnindexState
 struct GNUNET_FS_UnindexContext
 {
 
+  /**
+   * The content hash key of the last block we processed, will in the
+   * end be set to the CHK from the URI.  Used to remove the KBlocks.
+   */
+  struct ContentHashKey chk; 
+
   /**
    * Global FS context.
    */
@@ -1263,6 +1323,21 @@ struct GNUNET_FS_UnindexContext
    */
   struct TopLevelActivity *top;
 
+  /**
+   * Directory scanner to find keywords (KBlock removal).
+   */
+  struct GNUNET_FS_DirScanner *dscan;
+
+  /**
+   * Keywords found (telling us which KBlocks to remove).
+   */
+  struct GNUNET_FS_Uri *ksk_uri;
+
+  /**
+   * Current offset in KSK removal.
+   */
+  uint32_t ksk_offset;
+
   /**
    * Name of the file that we are unindexing.
    */
@@ -1300,6 +1375,27 @@ struct GNUNET_FS_UnindexContext
    */
   struct GNUNET_DISK_FileHandle *fh;
 
+  /**
+   * Handle to datastore 'get_key' operation issued for
+   * obtaining KBlocks.
+   */
+  struct GNUNET_DATASTORE_QueueEntry *dqe;
+
+  /**
+   * Current key for decrypting KBLocks from 'get_key' operation.
+   */
+  struct GNUNET_HashCode key;
+
+  /**
+   * Current query of 'get_key' operation.
+   */
+  struct GNUNET_HashCode query;
+
+  /**
+   * First content UID, 0 for none.
+   */
+  uint64_t first_uid;
+
   /**
    * Error message, NULL on success.
    */
@@ -1315,6 +1411,11 @@ struct GNUNET_FS_UnindexContext
    */
   uint64_t file_size;
 
+  /**
+   * Random offset given to 'GNUNET_DATASTORE_get_key'.
+   */
+  uint64_t roff;
+
   /**
    * When did we start?
    */
@@ -1323,7 +1424,7 @@ struct GNUNET_FS_UnindexContext
   /**
    * Hash of the file's contents (once computed).
    */
-  GNUNET_HashCode file_id;
+  struct GNUNET_HashCode file_id;
 
   /**
    * Current operatinonal phase.
@@ -1343,12 +1444,12 @@ struct SearchRequestEntry
    * Hash of the original keyword, also known as the
    * key (for decrypting the KBlock).
    */
-  GNUNET_HashCode key;
+  struct GNUNET_HashCode key;
 
   /**
    * Hash of the public key, also known as the query.
    */
-  GNUNET_HashCode query;
+  struct GNUNET_HashCode query;
 
   /**
    * Map that contains a "struct GNUNET_FS_SearchResult" for each result that
@@ -1589,6 +1690,11 @@ struct DownloadRequest
    */
   unsigned int depth;
 
+  /**
+   * Offset of the CHK for this block in the parent block
+   */
+  unsigned int chk_idx;
+
   /**
    * State in the FSM.
    */
@@ -1820,6 +1926,11 @@ struct GNUNET_FS_DownloadContext
    */
   int in_receive;
 
+  /**
+   * Are we ready to issue requests (reconstructions are finished)?
+   */
+  int issue_requests;
+
 };