[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6950 - in GNUnet: . src/applications/chat/lib src/applicat
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6950 - in GNUnet: . src/applications/chat/lib src/applications/chat/tools |
Date: |
Sat, 31 May 2008 13:53:36 -0600 (MDT) |
Author: grothoff
Date: 2008-05-31 13:53:36 -0600 (Sat, 31 May 2008)
New Revision: 6950
Modified:
GNUnet/src/applications/chat/lib/Makefile.am
GNUnet/src/applications/chat/lib/messaging.c
GNUnet/src/applications/chat/tools/Makefile.am
GNUnet/src/applications/chat/tools/gnunet-chat.c
GNUnet/todo
Log:
done
Modified: GNUnet/src/applications/chat/lib/Makefile.am
===================================================================
--- GNUnet/src/applications/chat/lib/Makefile.am 2008-05-31 19:38:50 UTC
(rev 6949)
+++ GNUnet/src/applications/chat/lib/Makefile.am 2008-05-31 19:53:36 UTC
(rev 6950)
@@ -9,6 +9,7 @@
libgnunetchat_api_la_SOURCES = \
messaging.c
libgnunetchat_api_la_LIBADD = \
+ $(top_builddir)/src/applications/fs/pseudonyms/libgnunetpseudonym.la \
$(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
$(top_builddir)/src/util/libgnunetutil.la
Modified: GNUnet/src/applications/chat/lib/messaging.c
===================================================================
--- GNUnet/src/applications/chat/lib/messaging.c 2008-05-31 19:38:50 UTC
(rev 6949)
+++ GNUnet/src/applications/chat/lib/messaging.c 2008-05-31 19:53:36 UTC
(rev 6950)
@@ -20,7 +20,7 @@
/**
* @file applications/chat/lib/messaging.c
- * @brief convenience API to the chat application
+ * @brief convenience API for sending and receiving chat messages
* @author Christian Grothoff
* @author Nathan Evans
*/
@@ -29,6 +29,7 @@
#include "gnunet_util.h"
#include "gnunet_protocols.h"
#include "gnunet_chat_lib.h"
+#include "gnunet_pseudonym_lib.h"
#include "gnunet_directories.h"
#include "chat.h"
@@ -71,6 +72,25 @@
};
+/**
+ * Linked list of members in the chat room.
+ */
+struct MemberList
+{
+ struct MemberList * next;
+
+ /**
+ * Description of the member.
+ */
+ struct GNUNET_ECRS_MetaData * meta;
+
+ /**
+ * Member ID (pseudonym).
+ */
+ GNUNET_HashCode id;
+
+};
+
static int
GNUNET_CHAT_rejoin_room (struct GNUNET_CHAT_Room *chat_room)
{
@@ -127,6 +147,9 @@
CS_chat_MESSAGE_JoinNotification *join_msg;
CS_chat_MESSAGE_ReceiveNotification *received_msg;
struct GNUNET_ECRS_MetaData *meta;
+ struct MemberList * members;
+ struct MemberList * pos;
+ struct MemberList * prev;
unsigned int size;
unsigned int meta_len;
unsigned int msg_len;
@@ -139,6 +162,7 @@
malformed = GNUNET_NO;
ret = GNUNET_OK;
reply = NULL;
+ members = NULL;
while ((ret == GNUNET_OK) && (room->shutdown_flag != GNUNET_YES))
{
if (malformed)
@@ -192,8 +216,19 @@
malformed = GNUNET_YES;
continue;
}
+ pos = GNUNET_malloc(sizeof(struct MemberList));
+ pos->meta = meta;
+ GNUNET_hash(&join_msg->public_key,
+ 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);
+ pos->next = members;
+ members = pos;
break;
case GNUNET_CS_PROTO_CHAT_LEAVE_NOTIFICATION:
if (size < sizeof (CS_chat_MESSAGE_LeaveNotification))
@@ -204,6 +239,23 @@
leave_msg = (CS_chat_MESSAGE_LeaveNotification *) reply;
room->member_list_callback (room->member_list_callback_cls,
NULL, &leave_msg->user);
+ prev = NULL;
+ pos = members;
+ while ( (pos != NULL) &&
+ (0 != memcmp(&pos->id,
+ &leave_msg->user,
+ sizeof(GNUNET_HashCode))) )
+ {
+ prev = pos;
+ pos = pos->next;
+ }
+ GNUNET_GE_ASSERT(NULL, pos != NULL);
+ if (prev == NULL)
+ members = pos->next;
+ else
+ prev->next = pos->next;
+ GNUNET_ECRS_meta_data_destroy(pos->meta);
+ GNUNET_free(pos);
break;
case GNUNET_CS_PROTO_CHAT_MESSAGE_NOTIFICATION:
if (size < sizeof (CS_chat_MESSAGE_ReceiveNotification))
@@ -216,10 +268,17 @@
message_content = GNUNET_malloc (msg_len + 1);
memcpy (message_content, &received_msg[1], msg_len);
message_content[msg_len] = '\0';
- room->message_callback (room->message_callback_cls,
+ pos = members;
+ while ( (pos != NULL) &&
+ (0 != memcmp(&pos->id,
+ &received_msg->sender,
+ sizeof(GNUNET_HashCode))) )
+ pos = pos->next;
+ GNUNET_GE_ASSERT(NULL, pos != NULL);
+ room->message_callback (room->message_callback_cls,
room,
&received_msg->sender,
- NULL,
+ pos->meta,
message_content,
ntohl (received_msg->msg_options));
GNUNET_free (message_content);
@@ -246,24 +305,17 @@
}
}
GNUNET_free_non_null (reply);
+ while (members != NULL)
+ {
+ pos = members;
+ members = pos->next;
+ GNUNET_ECRS_meta_data_destroy(pos->meta);
+ GNUNET_free(pos);
+ }
return NULL;
}
-#if 0
/**
- * 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)
-{
- return GNUNET_SYSERR;
-}
-#endif
-
-/**
* Returns the private key on success,
* NULL on error.
*/
@@ -487,4 +539,4 @@
return ret;
}
-/* end of clientapi.c */
+/* end of messaging.c */
Modified: GNUnet/src/applications/chat/tools/Makefile.am
===================================================================
--- GNUnet/src/applications/chat/tools/Makefile.am 2008-05-31 19:38:50 UTC
(rev 6949)
+++ GNUnet/src/applications/chat/tools/Makefile.am 2008-05-31 19:53:36 UTC
(rev 6950)
@@ -9,5 +9,7 @@
gnunet_chat_SOURCES = \
gnunet-chat.c
gnunet_chat_LDADD = \
- $(top_builddir)/src/applications/chat/lib/libgnunetchat_api.la
+ $(top_builddir)/src/applications/chat/lib/libgnunetchat_api.la \
+ $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
+ $(top_builddir)/src/applications/fs/pseudonyms/libgnunetpseudonym.la
Modified: GNUnet/src/applications/chat/tools/gnunet-chat.c
===================================================================
--- GNUnet/src/applications/chat/tools/gnunet-chat.c 2008-05-31 19:38:50 UTC
(rev 6949)
+++ GNUnet/src/applications/chat/tools/gnunet-chat.c 2008-05-31 19:53:36 UTC
(rev 6950)
@@ -30,6 +30,7 @@
#include "gnunet_directories.h"
#include "gnunet_chat_lib.h"
#include "gnunet_ecrs_lib.h"
+#include "gnunet_pseudonym_lib.h"
#define MAX_MESSAGE_LENGTH 1024
@@ -86,7 +87,11 @@
const char *message,
GNUNET_CHAT_MSG_OPTIONS options)
{
- fprintf (stdout, _("`%s' said: %s\n"), "FIXME", message);
+ char * nick;
+
+ nick = GNUNET_PSEUDO_id_to_name(ectx, cfg, sender);
+ fprintf (stdout, _("`%s' said: %s\n"), nick, message);
+ GNUNET_free(nick);
return GNUNET_OK;
}
@@ -95,9 +100,17 @@
const struct GNUNET_ECRS_MetaData *member_info,
const GNUNET_RSA_PublicKey * member_id)
{
+ char * nick;
+ GNUNET_HashCode id;
+
+ GNUNET_hash(member_id,
+ sizeof(GNUNET_RSA_PublicKey),
+ &id);
+ nick = GNUNET_PSEUDO_id_to_name(ectx, cfg, &id);
fprintf (stdout, member_info != NULL
? _("`%s' entered the room\n")
- : _("`%s' left the room\n"), "FIXME");
+ : _("`%s' left the room\n"), nick);
+ GNUNET_free(nick);
return GNUNET_OK;
}
Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2008-05-31 19:38:50 UTC (rev 6949)
+++ GNUnet/todo 2008-05-31 19:53:36 UTC (rev 6950)
@@ -3,7 +3,7 @@
Annotations:
RC == Release Critical
-0.8.0 [5'08] (aka "new protocol"):
+0.8.0pre1 [5'08]:
- namespaces / pseudonyms:
+ need better / actual / compiling testcase!
+ including testing for id_to_name and back!
@@ -11,6 +11,10 @@
+ adapt gnunet-chat for new client api
=> add support for new options (private msg, anon msg, confirmation)
+ write reasonable testcase!
+
+
+0.8.0 [6'08] (aka "new protocol"):
+- move ECRS metadata and libpseudonym out of fs/
- Windows: gnunet-auto-share
- document gnunet-auto-share on webpage [RC]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6950 - in GNUnet: . src/applications/chat/lib src/applications/chat/tools,
gnunet <=