gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r6955 - in GNUnet/src: applications/chat/lib applications/c


From: gnunet
Subject: [GNUnet-SVN] r6955 - in GNUnet/src: applications/chat/lib applications/chat/tools include
Date: Sat, 31 May 2008 14:29:18 -0600 (MDT)

Author: grothoff
Date: 2008-05-31 14:29:16 -0600 (Sat, 31 May 2008)
New Revision: 6955

Modified:
   GNUnet/src/applications/chat/lib/loopback_test.c
   GNUnet/src/applications/chat/lib/messaging.c
   GNUnet/src/applications/chat/tools/gnunet-chat.c
   GNUnet/src/include/gnunet_chat_lib.h
Log:
even better API

Modified: GNUnet/src/applications/chat/lib/loopback_test.c
===================================================================
--- GNUnet/src/applications/chat/lib/loopback_test.c    2008-05-31 20:20:12 UTC 
(rev 6954)
+++ GNUnet/src/applications/chat/lib/loopback_test.c    2008-05-31 20:29:16 UTC 
(rev 6955)
@@ -23,6 +23,12 @@
  * @brief chat testcase, loopback only
  * @author Christian Grothoff
  * @author Nathan Evans
+ *
+ * TODO:
+ * - test private messages (need more than 2 users!)
+ * - test anonymous messages
+ * - test acknowledgements
+ * - test authenticated message
  */
 
 #include "platform.h"
@@ -41,7 +47,7 @@
 struct Wanted {
   GNUNET_ECRS_MetaData * meta;
 
-  GNUNET_HashCode sender;
+  GNUNET_HashCode * sender;
 
   char * msg;
 
@@ -58,16 +64,35 @@
                  GNUNET_CHAT_MSG_OPTIONS options)
 {
   struct Wanted * want = cls;
+  if (! ( (0 == strcmp(message, want->msg)) &&
+         ( ( (sender == NULL) && (want->sender == NULL) ) ||
+           ( (sender != NULL) && 
+             (want->sender != NULL) && 
+             (0 == memcmp(sender, want->sender, sizeof(GNUNET_HashCode))) ) ) 
&&
+         (0 == GNUNET_ECRS_meta_data_test_equal(member_info,
+                                                want->meta)) &&
+         (options == want->opt) ) )
+    error++;
   return GNUNET_OK;
 }
 
 static int
 member_list_callback (void *cls,
                      const struct GNUNET_ECRS_MetaData * member_info,
-                     const GNUNET_RSA_PublicKey * member_id) 
+                     const GNUNET_RSA_PublicKey * member_id,
+                     GNUNET_CHAT_MSG_OPTIONS options) 
 {
   struct Wanted * want = cls;
-  
+  GNUNET_HashCode sender;
+
+  GNUNET_hash(member_id,
+             sizeof(GNUNET_RSA_PublicKey),
+             &sender);  
+  if (! ( (0 == memcmp(&sender, want->sender, sizeof(GNUNET_HashCode))) &&
+          (0 == GNUNET_ECRS_meta_data_test_equal(member_info,
+                                                want->meta)) &&
+         (options == want->opt) ) )
+    error++
   return GNUNET_OK;
 }
 

Modified: GNUnet/src/applications/chat/lib/messaging.c
===================================================================
--- GNUnet/src/applications/chat/lib/messaging.c        2008-05-31 20:20:12 UTC 
(rev 6954)
+++ GNUnet/src/applications/chat/lib/messaging.c        2008-05-31 20:29:16 UTC 
(rev 6955)
@@ -226,7 +226,8 @@
                        sizeof (GNUNET_RSA_PublicKey), &pos->id);
           GNUNET_PSEUDO_add (room->ectx, room->cfg, &pos->id, meta);
           room->member_list_callback (room->member_list_callback_cls,
-                                      meta, &join_msg->public_key);
+                                      meta, &join_msg->public_key,
+                                     ntohl(join_msg->msg_options));
           pos->next = members;
           members = pos;
           break;
@@ -238,7 +239,8 @@
             }
           leave_msg = (CS_chat_MESSAGE_LeaveNotification *) reply;
           room->member_list_callback (room->member_list_callback_cls,
-                                      NULL, &leave_msg->user);
+                                      NULL, &leave_msg->user,
+                                     GNUNET_CHAT_MSG_OPTION_NONE);
           prev = NULL;
           pos = members;
           while ((pos != NULL) &&

Modified: GNUnet/src/applications/chat/tools/gnunet-chat.c
===================================================================
--- GNUnet/src/applications/chat/tools/gnunet-chat.c    2008-05-31 20:20:12 UTC 
(rev 6954)
+++ GNUnet/src/applications/chat/tools/gnunet-chat.c    2008-05-31 20:29:16 UTC 
(rev 6955)
@@ -97,7 +97,8 @@
 static int
 member_list_callback (void *cls,
                       const struct GNUNET_ECRS_MetaData *member_info,
-                      const GNUNET_RSA_PublicKey * member_id)
+                      const GNUNET_RSA_PublicKey * member_id,
+                     GNUNET_CHAT_MSG_OPTIONS options)
 {
   char *nick;
   GNUNET_HashCode id;

Modified: GNUnet/src/include/gnunet_chat_lib.h
===================================================================
--- GNUnet/src/include/gnunet_chat_lib.h        2008-05-31 20:20:12 UTC (rev 
6954)
+++ GNUnet/src/include/gnunet_chat_lib.h        2008-05-31 20:29:16 UTC (rev 
6955)
@@ -70,41 +70,23 @@
   GNUNET_CHAT_MSG_AUTHENTICATED = 4,
 
   /**
+   * Require signed acknowledgement before
+   * completing delivery (and of course, only
+   * acknowledge if delivery is guaranteed).
+   */
+  GNUNET_CHAT_MSG_ACKNOWLEDGED = 8,
+
+  /**
    * Authenticate for the receiver, but
    * ensure that receiver cannot prove
    * authenticity to third parties later.
+   * (not yet implemented)
    */
-  GNUNET_CHAT_MSG_OFF_THE_RECORD = 8,
+  GNUNET_CHAT_MSG_OFF_THE_RECORD = 16,
 
-  /**
-   * Require signed acknowledgement before
-   * completing delivery (and of course, only
-   * acknowledge if delivery is guaranteed).
-   */
-  GNUNET_CHAT_MSG_ACKNOWLEDGED = 16,
-
 } GNUNET_CHAT_MSG_OPTIONS;
 
-#if 0
-/* these are not yet implemented / supported */
 /**
- * Callback function to iterate over rooms.
- *
- * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
- */
-typedef int (*GNUNET_CHAT_RoomIterator) (const char *room,
-                                         const char *topic, void *cls);
-
-/**
- * List all of the (publically visible) chat rooms.
- * @return number of rooms on success, GNUNET_SYSERR if iterator aborted
- */
-int GNUNET_CHAT_list_rooms (struct GNUNET_GE_Context *ectx,
-                            struct GNUNET_GC_Configuration *cfg,
-                            GNUNET_CHAT_RoomIterator it, void *cls);
-#endif
-
-/**
  * Handle for a (joined) chat room.
  */
 struct GNUNET_CHAT_Room;
@@ -135,13 +117,15 @@
 /**
  * @param member_info will be non-null if the member is joining, NULL if he is 
leaving
  * @param member_id hash of public key of the user (for unique identification)
+ * @param options what types of messages is this member willing to receive?
  */
 typedef int (*GNUNET_CHAT_MemberListCallback) (void *cls,
                                                const struct
                                                GNUNET_ECRS_MetaData *
                                                member_info,
                                                const GNUNET_RSA_PublicKey *
-                                               member_id);
+                                               member_id,
+                                              GNUNET_CHAT_MSG_OPTIONS options);
 
 
 /**
@@ -227,6 +211,29 @@
                           const GNUNET_RSA_PublicKey * receiver,
                           unsigned int *sequence_number);
 
+
+
+
+#if 0
+/* these are not yet implemented / supported */
+/**
+ * Callback function to iterate over rooms.
+ *
+ * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
+ */
+typedef int (*GNUNET_CHAT_RoomIterator) (const char *room,
+                                         const char *topic, void *cls);
+
+/**
+ * List all of the (publically visible) chat rooms.
+ * @return number of rooms on success, GNUNET_SYSERR if iterator aborted
+ */
+int GNUNET_CHAT_list_rooms (struct GNUNET_GE_Context *ectx,
+                            struct GNUNET_GC_Configuration *cfg,
+                            GNUNET_CHAT_RoomIterator it, void *cls);
+#endif
+
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif





reply via email to

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