-options to play with
[oweals/gnunet.git] / src / fs / fs_api.h
index 154e63893dbe5c03915819a5dcb0298d86e4f5ac..12d4ae44b43f9de8b94777478d60e75d7a8e0f5b 100644 (file)
@@ -205,7 +205,7 @@ struct GNUNET_FS_Uri
       /**
        * Hash of the public key for the namespace.
        */
-      GNUNET_HashCode namespace;
+      struct GNUNET_HashCode ns;
 
       /**
        * 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).
@@ -568,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
@@ -577,6 +577,12 @@ struct GNUNET_FS_SearchResult
    */
   GNUNET_SCHEDULER_TaskIdentifier probe_cancel_task;
 
+  /**
+   * Task we use to report periodically to the application that the
+   * probe is still running.
+   */
+  GNUNET_SCHEDULER_TaskIdentifier probe_ping_task;
+
   /**
    * When did the current probe become active?
    */
@@ -633,10 +639,11 @@ GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, GNUNET_FS_QueueStart start,
 
 /**
  * Dequeue a job from the queue.
- * @param qh handle for the job
+ *
+ * @param qe handle for the job
  */
 void
-GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qh);
+GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qe);
 
 
 /**
@@ -730,7 +737,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);
 
 
 /**
@@ -1141,7 +1166,7 @@ struct GNUNET_FS_PublishContext
   /**
    * Namespace that we are publishing in, NULL if we have no namespace.
    */
-  struct GNUNET_FS_Namespace *namespace;
+  struct GNUNET_FS_Namespace *ns;
 
   /**
    * ID of the content in the namespace, NULL if we have no namespace.
@@ -1244,32 +1269,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
 };
 
 
@@ -1279,6 +1314,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.
    */
@@ -1289,6 +1330,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.
    */
@@ -1326,6 +1382,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.
    */
@@ -1341,6 +1418,11 @@ struct GNUNET_FS_UnindexContext
    */
   uint64_t file_size;
 
+  /**
+   * Random offset given to 'GNUNET_DATASTORE_get_key'.
+   */
+  uint64_t roff;
+
   /**
    * When did we start?
    */
@@ -1349,7 +1431,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.
@@ -1369,12 +1451,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
@@ -1460,6 +1542,11 @@ struct GNUNET_FS_SearchContext
    */
   struct GNUNET_TIME_Absolute start_time;
 
+  /**
+   * How long to wait before we try to reconnect to FS service?
+   */
+  struct GNUNET_TIME_Relative reconnect_backoff;
+
   /**
    * ID of a task that is using this struct and that must be cancelled
    * when the search is being stopped (if not
@@ -1615,6 +1702,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.
    */
@@ -1819,6 +1911,11 @@ struct GNUNET_FS_DownloadContext
    */
   struct GNUNET_TIME_Absolute start_time;
 
+  /**
+   * How long to wait before we try to reconnect to FS service?
+   */
+  struct GNUNET_TIME_Relative reconnect_backoff;
+
   /**
    * Desired level of anonymity.
    */
@@ -1846,6 +1943,11 @@ struct GNUNET_FS_DownloadContext
    */
   int in_receive;
 
+  /**
+   * Are we ready to issue requests (reconstructions are finished)?
+   */
+  int issue_requests;
+
 };