[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6954 - in GNUnet/src: applications/chat/lib applications/c
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6954 - in GNUnet/src: applications/chat/lib applications/chat/tools include |
Date: |
Sat, 31 May 2008 14:20:12 -0600 (MDT) |
Author: grothoff
Date: 2008-05-31 14:20:12 -0600 (Sat, 31 May 2008)
New Revision: 6954
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:
better API
Modified: GNUnet/src/applications/chat/lib/loopback_test.c
===================================================================
--- GNUnet/src/applications/chat/lib/loopback_test.c 2008-05-31 20:08:59 UTC
(rev 6953)
+++ GNUnet/src/applications/chat/lib/loopback_test.c 2008-05-31 20:20:12 UTC
(rev 6954)
@@ -36,49 +36,41 @@
#define START_PEERS 1
-static struct GNUNET_GC_Configuration *cfg;
+static unsigned int error;
-static int
-receive_callback1 (void *cls,
- struct GNUNET_CHAT_Room *room,
- const GNUNET_HashCode * sender,
- const struct GNUNET_ECRS_MetaData * member_info,
- const char *message,
- GNUNET_CHAT_MSG_OPTIONS options)
-{
+struct Wanted {
+ GNUNET_ECRS_MetaData * meta;
- return GNUNET_OK;
-}
+ GNUNET_HashCode sender;
-static int
-member_list_callback1 (void *cls,
- const struct GNUNET_ECRS_MetaData * member_info,
- const GNUNET_RSA_PublicKey * member_id)
-{
- return GNUNET_OK;
-}
+ char * msg;
+ GNUNET_CHAT_MSG_OPTIONS opt;
+
+};
+
static int
-receive_callback2 (void *cls,
- struct GNUNET_CHAT_Room *room,
- const GNUNET_HashCode * sender,
- const struct GNUNET_ECRS_MetaData * member_info,
- const char *message,
- GNUNET_CHAT_MSG_OPTIONS options)
+receive_callback (void *cls,
+ struct GNUNET_CHAT_Room *room,
+ const GNUNET_HashCode * sender,
+ const struct GNUNET_ECRS_MetaData * member_info,
+ const char *message,
+ GNUNET_CHAT_MSG_OPTIONS options)
{
+ struct Wanted * want = cls;
return GNUNET_OK;
}
static int
-member_list_callback2 (void *cls,
- const struct GNUNET_ECRS_MetaData * member_info,
- const GNUNET_RSA_PublicKey * member_id)
+member_list_callback (void *cls,
+ const struct GNUNET_ECRS_MetaData * member_info,
+ const GNUNET_RSA_PublicKey * member_id)
{
+ struct Wanted * want = cls;
+
return GNUNET_OK;
}
-
-
/**
* Testcase to test chat.
* @return 0: ok, -1: error
@@ -86,6 +78,7 @@
int
main (int argc, char **argv)
{
+ struct GNUNET_GC_Configuration *cfg;
struct GNUNET_TESTING_DaemonContext *peers;
int ret;
struct GNUNET_CHAT_Room *r1;
@@ -93,6 +86,10 @@
unsigned int seq;
struct GNUNET_ECRS_MetaData * meta1;
struct GNUNET_ECRS_MetaData * meta2;
+ GNUNET_HashCode alice;
+ GNUNET_HashCode bob;
+ struct Wanted alice_wanted;
+ struct Wanted bob_wanted;
ret = 0;
cfg = GNUNET_GC_create ();
@@ -123,22 +120,24 @@
EXTRACTOR_TITLE,
"Bob");
r1 =
- GNUNET_CHAT_join_room (NULL, cfg, "nick1",
+ GNUNET_CHAT_join_room (NULL, cfg, "alice",
meta1, "test", -1,
- &receive_callback1, NULL,
- &member_list_callback1, NULL,
- NULL, NULL);
+ &receive_callback, &alice_wanted,
+ &member_list_callback, &bob_wanted,
+ NULL, NULL,
+ &alice);
if (r1 == NULL)
{
ret = 1;
goto CLEANUP;
}
r2 =
- GNUNET_CHAT_join_room (NULL, cfg, "nick2",
+ GNUNET_CHAT_join_room (NULL, cfg, "bob",
meta2, "test", -1,
- &receive_callback2, NULL,
- &member_list_callback2, NULL,
- NULL, NULL);
+ &receive_callback, &bob_wanted,
+ &member_list_callback, &alice_wanted,
+ NULL, NULL,
+ &bob);
if (r2 == NULL)
{
ret = 1;
Modified: GNUnet/src/applications/chat/lib/messaging.c
===================================================================
--- GNUnet/src/applications/chat/lib/messaging.c 2008-05-31 20:08:59 UTC
(rev 6953)
+++ GNUnet/src/applications/chat/lib/messaging.c 2008-05-31 20:20:12 UTC
(rev 6954)
@@ -435,21 +435,31 @@
GNUNET_CHAT_MemberListCallback memberCallback,
void *member_cls,
GNUNET_CHAT_MessageConfirmation confirmationCallback,
- void *confirmation_cls)
+ void *confirmation_cls,
+ GNUNET_HashCode * me)
{
struct GNUNET_CHAT_Room *chat_room;
struct GNUNET_ClientServerConnection *sock;
GNUNET_RSA_PrivateKeyEncoded *key;
+ struct GNUNET_RSA_PrivateKey * priv_key;
+ GNUNET_RSA_PublicKey pub_key;
key = GNUNET_CHAT_initPrivateKey (ectx, cfg, nick_name);
if (key == NULL)
return NULL;
+ priv_key = GNUNET_RSA_decode_key(key);
+ GNUNET_RSA_get_public_key(priv_key,
+ &pub_key);
+ GNUNET_hash(&pub_key,
+ sizeof(GNUNET_RSA_PublicKey),
+ me);
+ GNUNET_RSA_free_key(priv_key);
sock = GNUNET_client_connection_create (ectx, cfg);
if (sock == NULL)
{
GNUNET_free (key);
return NULL;
- }
+ }
chat_room = GNUNET_malloc (sizeof (struct GNUNET_CHAT_Room));
chat_room->msg_options = msg_options;
chat_room->room_name = GNUNET_strdup (room_name);
Modified: GNUnet/src/applications/chat/tools/gnunet-chat.c
===================================================================
--- GNUnet/src/applications/chat/tools/gnunet-chat.c 2008-05-31 20:08:59 UTC
(rev 6953)
+++ GNUnet/src/applications/chat/tools/gnunet-chat.c 2008-05-31 20:20:12 UTC
(rev 6954)
@@ -147,7 +147,9 @@
struct GNUNET_RSA_PrivateKey *my_priv;
struct GNUNET_ECRS_MetaData *meta;
char message[MAX_MESSAGE_LENGTH + 1];
+ char * my_name;
unsigned int seq;
+ GNUNET_HashCode me;
if (GNUNET_SYSERR == GNUNET_init (argc,
argv,
@@ -172,7 +174,8 @@
-1,
&receive_callback, NULL,
&member_list_callback, NULL,
- &confirmation_callback, NULL);
+ &confirmation_callback, NULL,
+ &me);
GNUNET_ECRS_meta_data_destroy (meta);
if (room == NULL)
{
@@ -181,10 +184,14 @@
GNUNET_fini (ectx, cfg);
return -1;
}
+ my_name = GNUNET_PSEUDO_id_to_name(ectx, cfg, &me);
fprintf (stdout,
_
- ("Joined room `%s'.\nType message and hit return to send.\nType
`%s' when ready to quit.\n"),
- room_name, QUIT_COMMAND);
+ ("Joined room `%s' as user `%s'.\nType message and hit return to
send.\nType `%s' when ready to quit.\n"),
+ room_name,
+ my_name,
+ QUIT_COMMAND);
+ GNUNET_free(my_name);
/* read messages from command line and send */
while ((0 != strcmp (message, QUIT_COMMAND)) &&
(GNUNET_shutdown_test () == GNUNET_NO))
Modified: GNUnet/src/include/gnunet_chat_lib.h
===================================================================
--- GNUnet/src/include/gnunet_chat_lib.h 2008-05-31 20:08:59 UTC (rev
6953)
+++ GNUnet/src/include/gnunet_chat_lib.h 2008-05-31 20:20:12 UTC (rev
6954)
@@ -181,6 +181,8 @@
* @param message_cls argument to callback
* @param memberCallback which function to call for join/leave notifications
* @param confirmationCallback which function to call for confirmations (maybe
NULL)
+ * @param pid set to the pseudonym ID of ourselves
+ *
* @return NULL on error
*/
struct GNUNET_CHAT_Room *GNUNET_CHAT_join_room (struct GNUNET_GE_Context
@@ -200,7 +202,8 @@
void *member_cls,
GNUNET_CHAT_MessageConfirmation
confirmationCallback,
- void *confirmation_cls);
+ void *confirmation_cls,
+ GNUNET_HashCode * pid);
/**
* Leave a chat room.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6954 - in GNUnet/src: applications/chat/lib applications/chat/tools include,
gnunet <=