aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gnunet_chat_handle_intern.c9
-rw-r--r--src/gnunet_chat_lib.c24
-rw-r--r--src/gnunet_chat_util.c28
-rw-r--r--src/gnunet_chat_util.h13
4 files changed, 48 insertions, 26 deletions
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c
index a026617..04afcbc 100644
--- a/src/gnunet_chat_handle_intern.c
+++ b/src/gnunet_chat_handle_intern.c
@@ -374,7 +374,7 @@ intern_provide_contact_for_member(struct GNUNET_CHAT_Handle *handle,
374 GNUNET_assert((handle) && (handle->contacts)); 374 GNUNET_assert((handle) && (handle->contacts));
375 375
376 if (!member) 376 if (!member)
377 return GNUNET_OK; 377 return GNUNET_SYSERR;
378 378
379 struct GNUNET_ShortHashCode shorthash; 379 struct GNUNET_ShortHashCode shorthash;
380 util_shorthash_from_member(member, &shorthash); 380 util_shorthash_from_member(member, &shorthash);
@@ -584,12 +584,15 @@ on_handle_message (void *cls,
584 (hash)); 584 (hash));
585 585
586 if ((handle->destruction) || 586 if ((handle->destruction) ||
587 (GNUNET_OK != handle_request_context_by_room(handle, room)) || 587 (GNUNET_OK != handle_request_context_by_room(handle, room)))
588 (GNUNET_OK != intern_provide_contact_for_member(handle, sender, NULL)))
589 return; 588 return;
590 589
591 GNUNET_MESSENGER_get_message(room, &(msg->header.previous)); 590 GNUNET_MESSENGER_get_message(room, &(msg->header.previous));
592 591
592 if ((GNUNET_CHAT_KIND_UNKNOWN == util_message_kind_from_kind(msg->header.kind)) ||
593 (GNUNET_OK != intern_provide_contact_for_member(handle, sender, NULL)))
594 return;
595
593 struct GNUNET_CHAT_Context *context = GNUNET_CONTAINER_multihashmap_get( 596 struct GNUNET_CHAT_Context *context = GNUNET_CONTAINER_multihashmap_get(
594 handle->contexts, GNUNET_MESSENGER_room_get_key(room) 597 handle->contexts, GNUNET_MESSENGER_room_get_key(room)
595 ); 598 );
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
index 114f40c..b6911e7 100644
--- a/src/gnunet_chat_lib.c
+++ b/src/gnunet_chat_lib.c
@@ -1327,29 +1327,7 @@ GNUNET_CHAT_message_get_kind (const struct GNUNET_CHAT_Message *message)
1327 if (!(message->msg)) 1327 if (!(message->msg))
1328 return GNUNET_CHAT_KIND_UNKNOWN; 1328 return GNUNET_CHAT_KIND_UNKNOWN;
1329 1329
1330 switch (message->msg->header.kind) 1330 return util_message_kind_from_kind(message->msg->header.kind);
1331 {
1332 case GNUNET_MESSENGER_KIND_JOIN:
1333 return GNUNET_CHAT_KIND_JOIN;
1334 case GNUNET_MESSENGER_KIND_LEAVE:
1335 return GNUNET_CHAT_KIND_LEAVE;
1336 case GNUNET_MESSENGER_KIND_NAME:
1337 case GNUNET_MESSENGER_KIND_KEY:
1338 case GNUNET_MESSENGER_KIND_ID:
1339 return GNUNET_CHAT_KIND_CONTACT;
1340 case GNUNET_MESSENGER_KIND_INVITE:
1341 return GNUNET_CHAT_KIND_INVITATION;
1342 case GNUNET_MESSENGER_KIND_TEXT:
1343 return GNUNET_CHAT_KIND_TEXT;
1344 case GNUNET_MESSENGER_KIND_FILE:
1345 return GNUNET_CHAT_KIND_FILE;
1346 case GNUNET_MESSENGER_KIND_PRIVATE:
1347 return GNUNET_CHAT_KIND_WHISPER;
1348 case GNUNET_MESSENGER_KIND_DELETE:
1349 return GNUNET_CHAT_KIND_DELETION;
1350 default:
1351 return GNUNET_CHAT_KIND_UNKNOWN;
1352 }
1353} 1331}
1354 1332
1355 1333
diff --git a/src/gnunet_chat_util.c b/src/gnunet_chat_util.c
index 26d2985..8a0879b 100644
--- a/src/gnunet_chat_util.c
+++ b/src/gnunet_chat_util.c
@@ -347,3 +347,31 @@ util_lobby_name (const struct GNUNET_HashCode *hash,
347 GNUNET_free(low); 347 GNUNET_free(low);
348 return result; 348 return result;
349} 349}
350
351enum GNUNET_CHAT_MessageKind
352util_message_kind_from_kind (enum GNUNET_MESSENGER_MessageKind kind)
353{
354 switch (kind)
355 {
356 case GNUNET_MESSENGER_KIND_JOIN:
357 return GNUNET_CHAT_KIND_JOIN;
358 case GNUNET_MESSENGER_KIND_LEAVE:
359 return GNUNET_CHAT_KIND_LEAVE;
360 case GNUNET_MESSENGER_KIND_NAME:
361 case GNUNET_MESSENGER_KIND_KEY:
362 case GNUNET_MESSENGER_KIND_ID:
363 return GNUNET_CHAT_KIND_CONTACT;
364 case GNUNET_MESSENGER_KIND_INVITE:
365 return GNUNET_CHAT_KIND_INVITATION;
366 case GNUNET_MESSENGER_KIND_TEXT:
367 return GNUNET_CHAT_KIND_TEXT;
368 case GNUNET_MESSENGER_KIND_FILE:
369 return GNUNET_CHAT_KIND_FILE;
370 case GNUNET_MESSENGER_KIND_PRIVATE:
371 return GNUNET_CHAT_KIND_WHISPER;
372 case GNUNET_MESSENGER_KIND_DELETE:
373 return GNUNET_CHAT_KIND_DELETION;
374 default:
375 return GNUNET_CHAT_KIND_UNKNOWN;
376 }
377}
diff --git a/src/gnunet_chat_util.h b/src/gnunet_chat_util.h
index 8845eab..9229586 100644
--- a/src/gnunet_chat_util.h
+++ b/src/gnunet_chat_util.h
@@ -32,6 +32,8 @@
32#include <gnunet/gnunet_messenger_service.h> 32#include <gnunet/gnunet_messenger_service.h>
33#include <gnunet/gnunet_util_lib.h> 33#include <gnunet/gnunet_util_lib.h>
34 34
35#include "gnunet_chat_lib.h"
36
35/** 37/**
36 * Enum for the types of chat contexts. 38 * Enum for the types of chat contexts.
37 */ 39 */
@@ -185,4 +187,15 @@ int
185util_lobby_name (const struct GNUNET_HashCode *hash, 187util_lobby_name (const struct GNUNET_HashCode *hash,
186 char **name); 188 char **name);
187 189
190/**
191 * Return the chat related kind for a messages original kind
192 * from the service. It will return #GNUNET_CHAT_KIND_UNKNOWN
193 * in case the message kind is not supported.
194 *
195 * @param[in] kind Messenger service message kind
196 * @return Chat message kind or #GNUNET_CHAT_KIND_UNKNOWN_
197 */
198enum GNUNET_CHAT_MessageKind
199util_message_kind_from_kind (enum GNUNET_MESSENGER_MessageKind kind);
200
188#endif /* GNUNET_CHAT_UTIL_H_ */ 201#endif /* GNUNET_CHAT_UTIL_H_ */