types
[oweals/gnunet.git] / src / fs / fs.c
index 0522b794131b94b9a61da267cc7ba1a563c6fa60..8396fc18f87983e78ad6d7a61ff7d513bb61754f 100644 (file)
@@ -29,7 +29,6 @@
 #include "fs.h"
 
 
-
 /**
  * Setup a connection to the file-sharing service.
  *
  * @param client_name unique identifier for this client 
  * @param upcb function to call to notify about FS actions
  * @param upcb_cls closure for upcb
+ * @param flags specific attributes for fs-operations
+ * @param ... list of optional options, terminated with GNUNET_FS_OPTIONS_END
+ * @return NULL on error
  */
 struct GNUNET_FS_Handle *
 GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched,
                 const struct GNUNET_CONFIGURATION_Handle *cfg,
                 const char *client_name,
                 GNUNET_FS_ProgressCallback upcb,
-                void *upcb_cls)
+                void *upcb_cls,
+                enum GNUNET_FS_Flags flags,
+                ...)
 {
-  return NULL;
+  struct GNUNET_FS_Handle *ret;
+  struct GNUNET_CLIENT_Connection *client;
+  
+  client = GNUNET_CLIENT_connect (sched,
+                                 "fs",
+                                 cfg);
+  if (NULL == client)
+    return NULL;
+  ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Handle));
+  ret->sched = sched;
+  ret->cfg = cfg;
+  ret->client_name = GNUNET_strdup (client_name);
+  ret->upcb = upcb;
+  ret->upcb_cls = upcb_cls;
+  ret->client = client;
+  ret->flags = flags;
+  // FIXME: process varargs!
+  // FIXME: setup receive-loop with client
+
+  // FIXME: deserialize state; use client-name to find master-directory!
+  // Deserialize-Upload:
+  // * read FNs for upload FIs, deserialize each
+  // Deserialize Search:
+  // * read search queries
+  // * for each query, read file with search results
+  // * for each search result with active download, deserialize download
+  // * for each directory search result, check for active downloads of contents
+  // Deserialize Download:
+  // * always part of search???
+  // Deserialize Unindex:
+  // * read FNs for unindex with progress offset
+  return ret;
 }
 
 
@@ -60,6 +95,12 @@ GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched,
 void 
 GNUNET_FS_stop (struct GNUNET_FS_Handle *h)
 {
+  // FIXME: serialize state!? (or is it always serialized???)
+  // FIXME: terminate receive-loop with client  
+  GNUNET_CLIENT_disconnect (h->client);
+  GNUNET_free (h->client_name);
+  GNUNET_free (h);
 }
 
+
 /* end of fs.c */