gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r5356 - in GNUnet: m4 src/applications/chat src/include


From: gnunet
Subject: [GNUnet-SVN] r5356 - in GNUnet: m4 src/applications/chat src/include
Date: Wed, 25 Jul 2007 21:10:53 -0600 (MDT)

Author: grothoff
Date: 2007-07-25 21:10:53 -0600 (Wed, 25 Jul 2007)
New Revision: 5356

Added:
   GNUnet/src/applications/chat/clientapi.c
   GNUnet/src/include/gnunet_chat_lib.h
Modified:
   GNUnet/m4/Makefile.in
   GNUnet/src/applications/chat/Makefile.am
   GNUnet/src/applications/chat/gnunet-chat.c
Log:
draft

Modified: GNUnet/m4/Makefile.in
===================================================================
--- GNUnet/m4/Makefile.in       2007-07-26 02:21:38 UTC (rev 5355)
+++ GNUnet/m4/Makefile.in       2007-07-26 03:10:53 UTC (rev 5356)
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.8.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004  Free Software Foundation, Inc.
+# 2003, 2004, 2005  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -33,6 +33,7 @@
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+build_triplet = @build@
 host_triplet = @host@
 subdir = m4
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
@@ -94,7 +95,6 @@
 GMSGFMT = @GMSGFMT@
 GNUNETGTK_CFLAGS = @GNUNETGTK_CFLAGS@
 GNUNETGTK_LIBS = @GNUNETGTK_LIBS@
-GREP = @GREP@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 HAVE_ADNS_FALSE = @HAVE_ADNS_FALSE@
@@ -170,7 +170,6 @@
 PKG_CONFIG = @PKG_CONFIG@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
-SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOLARIS_FALSE = @SOLARIS_FALSE@
@@ -187,9 +186,15 @@
 XML_CPPFLAGS = @XML_CPPFLAGS@
 XML_LIBS = @XML_LIBS@
 _libcurl_config = @_libcurl_config@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_AS = @ac_ct_AS@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DLLTOOL = @ac_ct_DLLTOOL@
 ac_ct_F77 = @ac_ct_F77@
+ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
 am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
@@ -197,6 +202,8 @@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
 bindir = @bindir@
 build = @build@
 build_alias = @build_alias@
@@ -204,30 +211,23 @@
 build_os = @build_os@
 build_vendor = @build_vendor@
 datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
 exec_prefix = @exec_prefix@
 host = @host@
 host_alias = @host_alias@
 host_cpu = @host_cpu@
 host_os = @host_os@
 host_vendor = @host_vendor@
-htmldir = @htmldir@
 includedir = @includedir@
 infodir = @infodir@
 install_sh = @install_sh@
 libdir = @libdir@
 libexecdir = @libexecdir@
-localedir = @localedir@
 localstatedir = @localstatedir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
-psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 subdirs = @subdirs@
@@ -371,7 +371,7 @@
 clean-generic:
 
 distclean-generic:
-       -rm -f $(CONFIG_CLEAN_FILES)
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 
 maintainer-clean-generic:
        @echo "This command is intended for maintainers to use"

Modified: GNUnet/src/applications/chat/Makefile.am
===================================================================
--- GNUnet/src/applications/chat/Makefile.am    2007-07-26 02:21:38 UTC (rev 
5355)
+++ GNUnet/src/applications/chat/Makefile.am    2007-07-26 03:10:53 UTC (rev 
5356)
@@ -2,25 +2,34 @@
 
 plugindir = $(libdir)/GNUnet
 
-LDADD =  \
-  $(top_builddir)/src/util/libgnunetutil.la \
-  $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
-
 bin_PROGRAMS = \
   gnunet-chat
 
+lib_LTLIBRARIES = \
+  libgnunetstats_api.la
+
 plugin_LTLIBRARIES = \
   libgnunetmodule_chat.la
 
-
 gnunet_chat_SOURCES = \
-  gnunet-chat.c \
-  chat.h 
+  gnunet-chat.c 
+gnunet_chat_LDADD = \
+  $(top_builddir)/src/applications/chat/libgnunetchat.so \
+  $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
+  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
+  $(top_builddir)/src/util/libgnunetutil.la
 
+libgnunetchat_api_la_SOURCES = \
+  clientapi.c 
+libgnunetchat_api_la_LIBADD = \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la
+
 libgnunetmodule_chat_la_SOURCES = \
   chat.c \
   chat.h
 libgnunetmodule_chat_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
 libgnunetmodule_chat_la_LIBADD = \
-  $(LDADD)
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/util/boot/libgnunetutil_boot.la 

Added: GNUnet/src/applications/chat/clientapi.c
===================================================================
--- GNUnet/src/applications/chat/clientapi.c                            (rev 0)
+++ GNUnet/src/applications/chat/clientapi.c    2007-07-26 03:10:53 UTC (rev 
5356)
@@ -0,0 +1,140 @@
+/*
+     This file is part of GNUnet.
+     (C) 2007 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file applications/chat/clientapi.c
+ * @brief convenience API to the chat application
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunet_util.h"
+#include "gnunet_protocols.h"
+#include "gnunet_chat_lib.h"
+#include "chat.h"
+
+/**
+ * Handle for a (joined) chat room.
+ */
+struct GNUNET_CHAT_Room {
+  struct ClientServerConnection * sock;
+
+  struct PTHREAD * listen_thread;
+
+  struct GE_Context * ectx;
+
+  struct GC_Configuration * cfg;
+
+  char * nickname;
+
+  const PublicKey * my_public_key;
+
+  const struct PrivateKey * my_private_key;
+
+  char * memberInfo;
+
+  GNUNET_CHAT_Message_Callback callback;
+
+  void * callback_cls;
+
+};
+
+static void * thread_main(void * rcls) {
+  struct GNUNET_CHAT_Room * room = rcls;
+  return NULL;
+}
+
+/**
+ * List all of the (publically visible) chat rooms.
+ * @return number of rooms on success, SYSERR if iterator aborted
+ */
+int GNUNET_CHAT_list_rooms(struct GE_Context * ectx,
+                          struct GC_Configuration * cfg,
+                          GNUNET_CHAT_Room_Iterator it,
+                          void * cls) {
+  return SYSERR;
+}
+
+/**
+ * Join a chat room.  
+ *
+ * @param nickname the nick you want to use
+ * @param memberInfo public information about you
+ * @param callback which function to call if a message has
+ *        been received?
+ * @param cls argument to callback
+ * @return NULL on error 
+ */ 
+struct GNUNET_CHAT_Room *
+GNUNET_CHAT_join_room(struct GE_Context * ectx,
+                     struct GC_Configuration * cfg,
+                     const char * nickname,
+                     const PublicKey * me,
+                     const struct PrivateKey * key,
+                     const char * memberInfo,
+                     GNUNET_CHAT_Message_Callback callback,
+                     void * cls) {
+  // connect
+
+  // allocate & init room struct
+
+  // create pthread
+
+  // return room struct
+  return NULL;
+}
+
+/**
+ * Leave a chat room.
+ */ 
+void GNUNET_CHAT_leave_room(struct GNUNET_CHAT_Room * room) {
+  // stop thread
+  // join thread
+  // free room struct
+}
+
+/**
+ * Send a message.
+ *
+ * @param receiver use NULL to send to everyone in the room
+ * @return OK on success, SYSERR on error
+ */
+int
+GNUNET_CHAT_send_message(struct GNUNET_CHAT_Room * room,
+                        const char * message,
+                        GNUNET_CHAT_Message_Confirmation callback,
+                        void * cls,
+                        GNUNET_CHAT_MSG_OPTIONS options,
+                        const PublicKey * receiver) {
+  return SYSERR;
+}
+
+/**
+ * List all of the (known) chat members.
+ * @return number of rooms on success, SYSERR if iterator aborted
+ */
+int GNUNET_CHAT_list_members(struct GNUNET_CHAT_Room * room,
+                            GNUNET_CHAT_Member_Iterator it,
+                            void * cls) {
+  return SYSERR;
+}
+
+
+/* end of clientapi.c */

Modified: GNUnet/src/applications/chat/gnunet-chat.c
===================================================================
--- GNUnet/src/applications/chat/gnunet-chat.c  2007-07-26 02:21:38 UTC (rev 
5355)
+++ GNUnet/src/applications/chat/gnunet-chat.c  2007-07-26 03:10:53 UTC (rev 
5356)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002 Christian Grothoff (and other contributing authors)
+     (C) 2007 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -20,164 +20,157 @@
 
 /**
  * @file applications/chat/gnunet-chat.c
- * @brief Chat command line tool
+ * @brief Minimal chat command line tool
  * @author Christian Grothoff
  */
 
 #include "platform.h"
 #include "gnunet_protocols.h"
-#include "chat.h"
+#include "gnunet_chat_lib.h"
 
-#define CHAT_VERSION "0.0.3"
+static struct GC_Configuration *cfg;
 
-static Semaphore *doneSem;
+static struct GE_Context *ectx;
 
+static char * cfgFilename = DEFAULT_CLIENT_CONFIG_FILE;
+
+static char * nickname;
+
+static char * roomname = "gnunet";
+
 /**
- * Parse the options, set the timeout.
- * @param argc the number of options
- * @param argv the option list (including keywords)
- * @return OK on error, SYSERR if we should exit
+ * All gnunet-chat command line options
  */
-static int
-parseOptions (int argc, char **argv)
-{
-  int option_index;
-  int c;
+static struct CommandLineOption gnunetchatOptions[] = {
+  COMMAND_LINE_OPTION_HELP (gettext_noop ("Join a chat on GNUnet.")),      /* 
-h */
+  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
+  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+  {'n', "nick", "NAME",
+   gettext_noop ("set the nickname to use (requred)"),
+   1, &gnunet_getopt_configure_set_string, &nickname},
+  {'r', "room", "NAME",
+   gettext_noop ("set the chat room to join (requred)"),
+   1, &gnunet_getopt_configure_set_string, &roomname},
+  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
+  COMMAND_LINE_OPTION_VERBOSE,
+  COMMAND_LINE_OPTION_END,
+};
 
-  FREENONNULL (setConfigurationString ("GNUNETD", "LOGFILE", NULL));
-  while (1)
-    {
-      static struct GNoption long_options[] = {
-        LONG_DEFAULT_OPTIONS,
-        {"nickname", 1, 0, 'n'},
-        {0, 0, 0, 0}
-      };
-      option_index = 0;
-      c = GNgetopt_long (argc,
-                         argv, "vhdc:L:H:n:", long_options, &option_index);
-      if (c == -1)
-        break;                  /* No more flags to process */
-      if (YES == parseDefaultOptions (c, GNoptarg))
-        continue;
-      switch (c)
-        {
-        case 'n':
-          FREENONNULL (setConfigurationString ("GNUNET-CHAT",
-                                               "NICK", GNoptarg));
-          break;
-        case 'v':
-          printf ("GNUnet v%s, gnunet-chat v%s\n", VERSION, CHAT_VERSION);
-          return SYSERR;
-        case 'h':
-          {
-            static Help help[] = {
-              HELP_CONFIG,
-              HELP_HELP,
-              HELP_LOGLEVEL,
-              {'n', "nickname", NULL,
-               gettext_noop ("specify nickname")},
-              HELP_VERSION,
-              HELP_END,
-            };
-            formatHelp ("gnunet-chat [OPTIONS]",
-                        _("Start GNUnet chat client."), help);
-            return SYSERR;
-          }
-        default:
-          GE_LOG (ectx, GE_ERROR | GE_IMMEDIATE | GE_USER,
-                  _("Use --help to get a list of options.\n"));
-          return -1;
-        }                       /* end of parsing commandline */
-    }                           /* while (1) */
+/**
+ * A message was send in the chat to us.
+ *
+ * @param timestamp when was the message sent?
+ * @param senderNick what is the nickname of the sender? (maybe NULL)
+ * @param message the message (maybe NULL, especially if confirmation
+ *        is requested before delivery; the protocol will ensure
+ *        that this function is called again with the full message
+ *        if a confirmation is transmitted; if the message is NULL,
+ *        the user is merely asked if engaging in the exchange is ok
+ * @param room in which room was the message received?
+ * @param options options for the message
+ * @return OK to accept the message now, NO to 
+ *         accept (but user is away), SYSERR to signal denied delivery
+ */
+static int receive_callback(void * cls,
+                           struct GNUNET_CHAT_Room * room,
+                           const char * senderNick,
+                           const char * message,
+                           cron_t timestamp,
+                           GNUNET_CHAT_MSG_OPTIONS options) {
+  fprintf(stdout,
+         "%s: %s\n",
+         senderNick,
+         message);
   return OK;
 }
 
-static void *
-receiveThread (void *arg)
-{
-  struct ClientServerConnection *sock = arg;
-  CS_chat_MESSAGE *buffer;
-
-  buffer = MALLOC (MAX_BUFFER_SIZE);
-  while (OK == connection_read (sock, (CS_MESSAGE_HEADER **) & buffer))
-    {
-      char timebuf[64];
-      time_t timetmp;
-      struct tm *tmptr;
-
-      time (&timetmp);
-      tmptr = localtime (&timetmp);
-      strftime (timebuf, 64, "%b %e %H:%M ", tmptr);
-
-      if ((ntohs (buffer->header.size) != sizeof (CS_chat_MESSAGE)) ||
-          (ntohs (buffer->header.type) != CS_PROTO_chat_MSG))
-        continue;
-      buffer->nick[CHAT_NICK_LENGTH - 1] = '\0';
-      buffer->message[CHAT_MSG_LENGTH - 1] = '\0';
-      printf ("[%s][%s]: %s", timebuf, &buffer->nick[0], &buffer->message[0]);
-    }
-  FREE (buffer);
-  SEMAPHORE_UP (doneSem);
-  printf ("CHAT receive loop ends!\n");
-  return NULL;
+/**
+ * Message delivery confirmations.
+ *
+ * @param timestamp when was the message sent?
+ * @param senderNick what is the nickname of the receiver?
+ * @param message the message (maybe NULL)
+ * @param room in which room was the message received?
+ * @param options what were the options of the message
+ * @param response what was the receivers response (OK, NO, SYSERR).
+ * @param receipt signature confirming delivery (maybe NULL, only
+ *        if confirmation was requested)
+ * @return OK to continue, SYSERR to refuse processing further
+ *         confirmations from anyone for this message
+ */
+static int confirmation_callback(void * cls,
+                                struct GNUNET_CHAT_Room * room,
+                                const char * receiverNick,
+                                const PublicKey * receiverKey,
+                                const char * message,
+                                cron_t timestamp,
+                                GNUNET_CHAT_MSG_OPTIONS options,
+                                int response,
+                                const Signature * receipt) {
+  return OK;
 }
 
 /**
- * The main function to search for files on GNet.
+ * GNUnet-chat main.
+ *
  * @param argc number of arguments from the command line
  * @param argv command line arguments
- * @return return value from gnunetsearch: 0: ok, -1: error
+ * @return  0: ok, otherwise error
  */
 int
 main (int argc, char **argv)
 {
-  struct ClientServerConnection *sock;
-  PTHREAD_T messageReceiveThread;
-  void *unused;
-  CS_chat_MESSAGE msg;
-  char *nick;
+  struct GNUNET_CHAT_Room * room;
+  PublicKey * my_pub;
+  struct PrivateKey * my_priv;
+  char message[1024];
+  
+  if (SYSERR == GNUNET_init (argc, 
+                            argv,
+                            "gnunet-chat [OPTIONS]",
+                            &cfgFilename,
+                            gnunetchatOptions,
+                            &ectx,
+                            &cfg))
+    return 1;                   /* parse error, --help, etc. */
+  if (nickname == NULL) {
+    fprintf(stderr,
+           _("You must specify a nickname\n"));
+    return 1;
+  }
+  /* FIXME: load/generate private key! */
+  room = GNUNET_CHAT_join_room(ectx,
+                              cfg,
+                              nickname,
+                              my_pub,
+                              my_priv,
+                              "",
+                              &receive_callback,
+                              NULL);
+  if (room == NULL) {
+    fprintf(stderr,
+           _("Failed to join the room\n"));
+    return 1;
+  }
 
-  if (SYSERR == initUtil (argc, argv, &parseOptions))
-    return 0;                   /* parse error, --help, etc. */
-  sock = getClientSocket ();
-  if (sock == NULL)
-    errexit (_("Could not connect to gnunetd.\n"));
-
-  nick = getConfigurationString ("GNUNET-CHAT", "NICK");
-  if (nick == NULL)
-    errexit (_("You must specify a nickname (use option `%s').\n"), "-n");
-
-  doneSem = SEMAPHORE_CREATE (0);
-  if (0 != PTHREAD_CREATE (&messageReceiveThread,
-                           &receiveThread, sock, 128 * 1024))
-    DIE_STRERROR ("pthread_create");
-
-  memset (&msg, 0, sizeof (CS_chat_MESSAGE));
-  memcpy (&msg.message[0], "Hi!\n", strlen ("Hi!\n"));
-  msg.header.size = htons (sizeof (CS_chat_MESSAGE));
-  msg.header.type = htons (CS_PROTO_chat_MSG);
-  memcpy (&msg.nick[0], nick, strlen (nick));
-
-  /* send first "Hi!" message to gnunetd to indicate "join" */
-  if (SYSERR == connection_write (sock, &msg.header))
-    errexit (_("Could not send join message to gnunetd\n"));
-
   /* read messages from command line and send */
   while (1)
     {
-      memset (&msg.message, 0, 1024);
-      if (NULL == fgets (&msg.message[0], 1024, stdin))
+      memset (message, 0, 1024);
+      if (NULL == fgets (message, 1023, stdin))
         break;
-      if (SYSERR == connection_write (sock, &msg.header))
-        errexit (_("Could not send message to gnunetd\n"));
+      if (OK != GNUNET_CHAT_send_message(room,
+                                        message,
+                                        &confirmation_callback,
+                                        NULL,
+                                        GNUNET_CHAT_MSG_OPTION_NONE,
+                                        NULL)) {
+       fprintf(stderr,
+               _("Failed to send message.\n"));
+      }
     }
-  closeSocketTemporarily (sock);
-  SEMAPHORE_DOWN (doneSem);
-  SEMAPHORE_DESTROY (doneSem);
-  PTHREAD_JOIN (&messageReceiveThread, &unused);
-  connection_destroy (sock);
-
-  doneUtil ();
+  GNUNET_CHAT_leave_room(room);
+  GNUNET_fini(ectx, cfg);
   return 0;
 }
 

Added: GNUnet/src/include/gnunet_chat_lib.h
===================================================================
--- GNUnet/src/include/gnunet_chat_lib.h                                (rev 0)
+++ GNUnet/src/include/gnunet_chat_lib.h        2007-07-26 03:10:53 UTC (rev 
5356)
@@ -0,0 +1,223 @@
+/*
+     This file is part of GNUnet
+     (C) 2007 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file include/gnunet_chat_lib.h
+ * @brief support for chat
+ * @author Christian Grothoff
+ */
+
+#ifndef GNUNET_CHAT_LIB_H
+#define GNUNET_CHAT_LIB_H
+
+#include "gnunet_util_core.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0                           /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+/**
+ * Version number.
+ */
+#define GNUNET_CHAT_VERSION "0.0.0"
+
+typedef enum {
+  /**
+   * No special options.
+   */
+  GNUNET_CHAT_MSG_OPTION_NONE = 0,
+
+  /**
+   * Encrypt the message so that only the
+   * receiver can decrypt it.
+   */
+  GNUNET_CHAT_MSG_PRIVATE = 1,
+
+  /**
+   * Hide the identity of the sender.
+   */
+  GNUNET_CHAT_MSG_ANONYMOUS = 2,
+
+  /**
+   * Sign the content, authenticating the
+   * sender (using the provided private
+   * key, which may represent a pseudonym).
+   */
+  GNUNET_CHAT_MSG_AUTHENTICATED = 4,
+
+  /**
+   * Authenticate for the receiver, but
+   * ensure that receiver cannot prove
+   * authenticity to third parties later.
+   */
+  GNUNET_CHAT_MSG_OFF_THE_RECORD = 8,
+
+  /**
+   * Require signed acknowledgement before 
+   * completing delivery (and of course, only
+   * acknowledge if delivery is guaranteed).
+   */
+  GNUNET_CHAT_MSG_ACKNOWLEDGED = 16,
+
+} GNUNET_CHAT_MSG_OPTIONS;
+
+/**
+ * Callback function to iterate over rooms.
+ *
+ * @return OK to continue, SYSERR to abort iteration
+ */
+typedef int (*GNUNET_CHAT_Room_Iterator)(const char * room,
+                                        const char * topic,
+                                        void * cls);
+
+/**
+ * List all of the (publically visible) chat rooms.
+ * @return number of rooms on success, SYSERR if iterator aborted
+ */
+int GNUNET_CHAT_list_rooms(struct GE_Context * ectx,
+                          struct GC_Configuration * cfg,
+                          GNUNET_CHAT_Room_Iterator it,
+                          void * cls);
+
+
+/**
+ * Handle for a (joined) chat room.
+ */
+struct GNUNET_CHAT_Room;
+
+/**
+ * A message was send in the chat to us.
+ *
+ * @param timestamp when was the message sent?
+ * @param senderNick what is the nickname of the sender? (maybe NULL)
+ * @param message the message (maybe NULL, especially if confirmation
+ *        is requested before delivery; the protocol will ensure
+ *        that this function is called again with the full message
+ *        if a confirmation is transmitted; if the message is NULL,
+ *        the user is merely asked if engaging in the exchange is ok
+ * @param room in which room was the message received?
+ * @param options options for the message
+ * @return OK to accept the message now, NO to 
+ *         accept (but user is away), SYSERR to signal denied delivery
+ */
+typedef int (*GNUNET_CHAT_Message_Callback)(void * cls,
+                                           struct GNUNET_CHAT_Room * room,
+                                           const char * senderNick,
+                                           const char * message,
+                                           cron_t timestamp,
+                                           GNUNET_CHAT_MSG_OPTIONS options);
+
+/**
+ * Join a chat room.  
+ *
+ * @param nickname the nick you want to use
+ * @param memberInfo public information about you
+ * @param callback which function to call if a message has
+ *        been received?
+ * @param cls argument to callback
+ * @return NULL on error 
+ */ 
+struct GNUNET_CHAT_Room *
+GNUNET_CHAT_join_room(struct GE_Context * ectx,
+                     struct GC_Configuration * cfg,
+                     const char * nickname,
+                     const PublicKey * me,
+                     const struct PrivateKey * key,
+                     const char * memberInfo,
+                     GNUNET_CHAT_Message_Callback callback,
+                     void * cls);
+
+/**
+ * Leave a chat room.
+ */ 
+void GNUNET_CHAT_leave_room(struct GNUNET_CHAT_Room * room);
+
+
+/**
+ * Message delivery confirmations.
+ *
+ * @param timestamp when was the message sent?
+ * @param senderNick what is the nickname of the receiver?
+ * @param message the message (maybe NULL)
+ * @param room in which room was the message received?
+ * @param options what were the options of the message
+ * @param response what was the receivers response (OK, NO, SYSERR).
+ * @param receipt signature confirming delivery (maybe NULL, only
+ *        if confirmation was requested)
+ * @return OK to continue, SYSERR to refuse processing further
+ *         confirmations from anyone for this message
+ */
+typedef int (*GNUNET_CHAT_Message_Confirmation)(void * cls,
+                                               struct GNUNET_CHAT_Room * room,
+                                               const char * receiverNick,
+                                               const PublicKey * receiverKey,
+                                               const char * message,
+                                               cron_t timestamp,
+                                               GNUNET_CHAT_MSG_OPTIONS options,
+                                               int response,
+                                               const Signature * receipt);
+
+
+/**
+ * Send a message.
+ *
+ * @param receiver use NULL to send to everyone in the room
+ * @return OK on success, SYSERR on error
+ */
+int
+GNUNET_CHAT_send_message(struct GNUNET_CHAT_Room * room,
+                        const char * message,
+                        GNUNET_CHAT_Message_Confirmation callback,
+                        void * cls,
+                        GNUNET_CHAT_MSG_OPTIONS options,
+                        const PublicKey * receiver);
+
+
+/**
+ * Callback function to iterate over room members.
+ */
+typedef int (*GNUNET_CHAT_Member_Iterator)(const char * nickname,
+                                          const PublicKey * owner,
+                                          const char * memberInfo,
+                                          cron_t lastConfirmed,
+                                          void * cls);
+
+/**
+ * List all of the (known) chat members.
+ * @return number of rooms on success, SYSERR if iterator aborted
+ */
+int GNUNET_CHAT_list_members(struct GNUNET_CHAT_Room * room,
+                            GNUNET_CHAT_Member_Iterator it,
+                            void * cls);
+
+
+
+#if 0                           /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]