gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: MESSENGER: fix remaining warnings


From: gnunet
Subject: [gnunet] branch master updated: MESSENGER: fix remaining warnings
Date: Mon, 09 Sep 2024 14:17:27 +0200

This is an automated email from the git hooks/post-receive script.

thejackimonster pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 3c2987e48 MESSENGER: fix remaining warnings
3c2987e48 is described below

commit 3c2987e48fbdb9e6394ee479258a43fe13229438
Author: Jacki <jacki@thejackimonster.de>
AuthorDate: Mon Sep 9 14:16:29 2024 +0200

    MESSENGER: fix remaining warnings
    
    Signed-off-by: Jacki <jacki@thejackimonster.de>
---
 src/service/messenger/Makefile.am                  |   2 +-
 .../messenger/gnunet-service-messenger_operation.c |  53 +++++++-
 .../gnunet-service-messenger_operation_store.c     |  39 ------
 .../messenger/gnunet-service-messenger_room.c      | 134 ---------------------
 .../messenger/gnunet-service-messenger_tunnel.c    | 103 ++++++++++++++--
 .../messenger/gnunet-service-messenger_tunnel.h    |  35 +++++-
 src/service/messenger/messenger_api.c              |  32 +----
 src/service/messenger/messenger_api.h              |  37 ++++++
 src/service/messenger/messenger_api_message.c      |   7 +-
 src/service/messenger/messenger_api_message_kind.c |   2 +-
 src/service/messenger/messenger_api_message_kind.h |   2 +-
 src/service/messenger/messenger_api_room.c         |  31 +++--
 src/service/messenger/messenger_api_room.h         |  13 ++
 src/service/messenger/messenger_api_util.c         |   4 +-
 src/service/messenger/messenger_api_util.h         |  10 +-
 15 files changed, 264 insertions(+), 240 deletions(-)

diff --git a/src/service/messenger/Makefile.am 
b/src/service/messenger/Makefile.am
index 2a216584e..c02a7e605 100644
--- a/src/service/messenger/Makefile.am
+++ b/src/service/messenger/Makefile.am
@@ -30,7 +30,7 @@ lib_LTLIBRARIES = \
 #  libgnunettestingmessenger.la
 
 libgnunetmessenger_la_SOURCES = \
-  messenger_api.c \
+  messenger_api.c messenger_api.h \
   messenger_api_contact.c messenger_api_contact.h \
   messenger_api_contact_store.c messenger_api_contact_store.h \
   messenger_api_message.c messenger_api_message.h \
diff --git a/src/service/messenger/gnunet-service-messenger_operation.c 
b/src/service/messenger/gnunet-service-messenger_operation.c
index 0ef8d7188..b733f1df7 100644
--- a/src/service/messenger/gnunet-service-messenger_operation.c
+++ b/src/service/messenger/gnunet-service-messenger_operation.c
@@ -25,7 +25,9 @@
 
 #include "gnunet-service-messenger_operation.h"
 
+#include "gnunet-service-messenger_message_kind.h"
 #include "gnunet-service-messenger_operation_store.h"
+#include "gnunet-service-messenger_room.h"
 
 struct GNUNET_MESSENGER_Operation*
 create_operation (const struct GNUNET_HashCode *hash)
@@ -192,21 +194,64 @@ save_operation (const struct GNUNET_MESSENGER_Operation 
*op,
 
 
 extern void
-callback_store_operation (struct GNUNET_MESSENGER_OperationStore *store,
-                          enum GNUNET_MESSENGER_OperationType type,
-                          const struct GNUNET_HashCode *hash);
+callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room,
+                        const struct GNUNET_HashCode *hash);
+
+extern void
+callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room,
+                     const struct GNUNET_HashCode *hash);
 
 static void
 callback_operation (void *cls)
 {
   struct GNUNET_MESSENGER_Operation *op;
+  struct GNUNET_MESSENGER_OperationStore *store;
+  struct GNUNET_MESSENGER_SrvRoom *room;
+  enum GNUNET_MESSENGER_OperationType type;
+  struct GNUNET_HashCode hash;
 
   GNUNET_assert (cls);
   
   op = cls;
   op->task = NULL;
 
-  callback_store_operation (op->store, op->type, &(op->hash));
+  GNUNET_assert ((op->store) && (op->store->room));
+
+  store = op->store;
+  room = store->room;
+  type = op->type;
+
+  GNUNET_memcpy (&hash, &(op->hash), sizeof(hash));
+
+  cancel_store_operation (store, &hash);
+
+  switch (type)
+  {
+  case GNUNET_MESSENGER_OP_REQUEST:
+    break;
+  case GNUNET_MESSENGER_OP_DELETE:
+  {
+    if (GNUNET_OK != delete_store_message (get_srv_room_message_store (room),
+                                           &hash))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Deletion of message failed! 
(%s)\n",
+                  GNUNET_h2s (&hash));
+      break;
+    }
+
+    break;
+  }
+  case GNUNET_MESSENGER_OP_MERGE:
+  {
+    if (! room->host)
+      break;
+
+    send_srv_room_message (room, room->host, create_message_merge (&hash));
+    break;
+  }
+  default:
+    break;
+  }
 }
 
 
diff --git a/src/service/messenger/gnunet-service-messenger_operation_store.c 
b/src/service/messenger/gnunet-service-messenger_operation_store.c
index 1bd823db3..a8fb50a00 100644
--- a/src/service/messenger/gnunet-service-messenger_operation_store.c
+++ b/src/service/messenger/gnunet-service-messenger_operation_store.c
@@ -246,42 +246,3 @@ cancel_store_operation (struct 
GNUNET_MESSENGER_OperationStore *store,
 
   destroy_operation (op);
 }
-
-
-extern void
-callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room,
-                        const struct GNUNET_HashCode *hash);
-
-extern void
-callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room,
-                     const struct GNUNET_HashCode *hash);
-
-void
-callback_store_operation (struct GNUNET_MESSENGER_OperationStore *store,
-                          enum GNUNET_MESSENGER_OperationType type,
-                          const struct GNUNET_HashCode *hash)
-{
-  struct GNUNET_HashCode op_hash;
-  struct GNUNET_MESSENGER_SrvRoom *room;
-
-  GNUNET_assert ((store) && (hash));
-
-  GNUNET_memcpy (&op_hash, hash, sizeof(op_hash));
-  cancel_store_operation (store, &op_hash);
-
-  room = store->room;
-
-  switch (type)
-  {
-  case GNUNET_MESSENGER_OP_REQUEST:
-    break;
-  case GNUNET_MESSENGER_OP_DELETE:
-    callback_room_deletion (room, &op_hash);
-    break;
-  case GNUNET_MESSENGER_OP_MERGE:
-    callback_room_merge (room, &op_hash);
-    break;
-  default:
-    break;
-  }
-}
diff --git a/src/service/messenger/gnunet-service-messenger_room.c 
b/src/service/messenger/gnunet-service-messenger_room.c
index 44c3e4624..9ff9c1ae0 100644
--- a/src/service/messenger/gnunet-service-messenger_room.c
+++ b/src/service/messenger/gnunet-service-messenger_room.c
@@ -297,19 +297,6 @@ join_room_locally (struct GNUNET_MESSENGER_SrvRoom *room,
 }
 
 
-extern enum GNUNET_GenericReturnValue
-check_tunnel_message (void *cls,
-                      const struct GNUNET_MessageHeader *header);
-
-extern void
-handle_tunnel_message (void *cls,
-                       const struct GNUNET_MessageHeader *header);
-
-extern void
-callback_tunnel_disconnect (void *cls,
-                            const struct GNUNET_CADET_Channel *channel);
-
-
 enum GNUNET_GenericReturnValue
 open_srv_room (struct GNUNET_MESSENGER_SrvRoom *room,
                struct GNUNET_MESSENGER_SrvHandle *handle)
@@ -742,31 +729,6 @@ merge_srv_room_last_messages (struct 
GNUNET_MESSENGER_SrvRoom *room,
 }
 
 
-void
-callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room,
-                        const struct GNUNET_HashCode *hash)
-{
-  if (GNUNET_OK != delete_store_message (get_srv_room_message_store (room),
-                                         hash))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Deletion of message failed! 
(%s)\n",
-                GNUNET_h2s (hash));
-    return;
-  }
-}
-
-
-void
-callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room,
-                     const struct GNUNET_HashCode *hash)
-{
-  if (! room->host)
-    return;
-
-  send_srv_room_message (room, room->host, create_message_merge (hash));
-}
-
-
 enum GNUNET_GenericReturnValue
 delete_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
                          struct GNUNET_MESSENGER_MemberSession *session,
@@ -932,102 +894,6 @@ request_srv_room_message (struct GNUNET_MESSENGER_SrvRoom 
*room,
 }
 
 
-void
-callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room,
-                          void *cls)
-{
-  struct GNUNET_MESSENGER_SrvTunnel *tunnel;
-  struct GNUNET_PeerIdentity identity;
-
-  GNUNET_assert ((room) && (cls));
-  
-  tunnel = cls;
-
-  if (! room->host)
-    return;
-
-  get_tunnel_peer_identity (tunnel, &identity);
-
-  if ((GNUNET_YES != GNUNET_CONTAINER_multipeermap_remove (room->tunnels,
-                                                           &identity,
-                                                           tunnel)) ||
-      (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (room->tunnels,
-                                                             &identity)))
-    return;
-
-  if (GNUNET_YES == contains_list_tunnels (&(room->basement), &identity))
-    send_srv_room_message (room, room->host, create_message_miss (&identity));
-
-  if ((0 < GNUNET_CONTAINER_multipeermap_size (room->tunnels)) ||
-      (GNUNET_NO == room->service->auto_connecting))
-    return;
-
-  {
-    struct GNUNET_MESSENGER_ListTunnel *element;
-    element = find_list_tunnels_alternate (&(room->basement), &identity);
-
-    if (! element)
-      return;
-
-    GNUNET_PEER_resolve (element->peer, &identity);
-  }
-
-  enter_srv_room_at (room, room->host, &identity);
-}
-
-
-enum GNUNET_GenericReturnValue
-callback_verify_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
-                              void *cls,
-                              struct GNUNET_MESSENGER_Message *message,
-                              struct GNUNET_HashCode *hash)
-{
-  const struct GNUNET_MESSENGER_Message *previous;
-
-  GNUNET_assert ((room) && (message));
-
-  if (GNUNET_MESSENGER_KIND_UNKNOWN == message->header.kind)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Message error: Kind is unknown! (%d)\n", 
message->header.kind);
-    return GNUNET_SYSERR;
-  }
-
-  {
-    struct GNUNET_MESSENGER_MessageStore *message_store;
-
-    message_store = get_srv_room_message_store (room);
-
-    previous = get_store_message (
-      message_store, &(message->header.previous));
-  }
-
-  if (! previous)
-    goto skip_time_comparison;
-
-  {
-    struct GNUNET_TIME_Absolute timestamp;
-    struct GNUNET_TIME_Absolute last;
-    
-    timestamp = GNUNET_TIME_absolute_ntoh (message->header.timestamp);
-    last = GNUNET_TIME_absolute_ntoh (previous->header.timestamp);
-
-    if (GNUNET_TIME_relative_get_zero_ ().rel_value_us !=
-        GNUNET_TIME_absolute_get_difference (timestamp, last).rel_value_us)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  "Message warning: Timestamp does not check out!\n");
-    }
-  }
-
-skip_time_comparison:
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving message of kind: %s!\n",
-              GNUNET_MESSENGER_name_of_kind (message->header.kind));
-
-  return GNUNET_OK;
-}
-
-
 static void
 idle_request_room_messages (void *cls)
 {
diff --git a/src/service/messenger/gnunet-service-messenger_tunnel.c 
b/src/service/messenger/gnunet-service-messenger_tunnel.c
index be74e0aa0..f42df9423 100644
--- a/src/service/messenger/gnunet-service-messenger_tunnel.c
+++ b/src/service/messenger/gnunet-service-messenger_tunnel.c
@@ -26,10 +26,12 @@
 #include "gnunet-service-messenger_tunnel.h"
 
 #include "gnunet-service-messenger_handle.h"
+#include "gnunet-service-messenger_message_kind.h"
 #include "gnunet-service-messenger_message_recv.h"
 #include "gnunet-service-messenger_message_store.h"
 #include "gnunet-service-messenger_operation_store.h"
 #include "gnunet-service-messenger_operation.h"
+#include "gnunet-service-messenger_room.h"
 
 #include "messenger_api_util.h"
 
@@ -90,32 +92,107 @@ bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
 }
 
 
-extern void
-callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room,
-                          void *cls);
-
 void
 callback_tunnel_disconnect (void *cls,
                             const struct GNUNET_CADET_Channel *channel)
 {
   struct GNUNET_MESSENGER_SrvTunnel *tunnel;
+  struct GNUNET_MESSENGER_SrvRoom *room;
+  struct GNUNET_PeerIdentity identity;
   
   tunnel = cls;
 
-  if (tunnel)
+  if (! tunnel)
+    return;
+  
+  tunnel->channel = NULL;
+
+  GNUNET_assert (tunnel->room);
+
+  room = tunnel->room;
+
+  if (! room->host)
+    return;
+
+  get_tunnel_peer_identity (tunnel, &identity);
+
+  if ((GNUNET_YES != GNUNET_CONTAINER_multipeermap_remove (room->tunnels,
+                                                           &identity,
+                                                           tunnel)) ||
+      (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (room->tunnels,
+                                                             &identity)))
+    return;
+
+  if (GNUNET_YES == contains_list_tunnels (&(room->basement), &identity))
+    send_srv_room_message (room, room->host, create_message_miss (&identity));
+
+  if ((0 < GNUNET_CONTAINER_multipeermap_size (room->tunnels)) ||
+      (GNUNET_NO == room->service->auto_connecting))
+    return;
+
   {
-    tunnel->channel = NULL;
+    struct GNUNET_MESSENGER_ListTunnel *element;
+    element = find_list_tunnels_alternate (&(room->basement), &identity);
 
-    callback_room_disconnect (tunnel->room, cls);
+    if (! element)
+      return;
+
+    GNUNET_PEER_resolve (element->peer, &identity);
   }
+
+  enter_srv_room_at (room, room->host, &identity);
 }
 
 
-extern enum GNUNET_GenericReturnValue
-callback_verify_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
-                              void *cls,
-                              struct GNUNET_MESSENGER_Message *message,
-                              struct GNUNET_HashCode *hash);
+static enum GNUNET_GenericReturnValue
+verify_tunnel_message (struct GNUNET_MESSENGER_SrvRoom *room,
+                       struct GNUNET_MESSENGER_Message *message,
+                       struct GNUNET_HashCode *hash)
+{
+  const struct GNUNET_MESSENGER_Message *previous;
+
+  GNUNET_assert ((room) && (message));
+
+  if (GNUNET_MESSENGER_KIND_UNKNOWN == message->header.kind)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Message error: Kind is unknown! (%d)\n", 
message->header.kind);
+    return GNUNET_SYSERR;
+  }
+
+  {
+    struct GNUNET_MESSENGER_MessageStore *message_store;
+
+    message_store = get_srv_room_message_store (room);
+
+    previous = get_store_message (
+      message_store, &(message->header.previous));
+  }
+
+  if (! previous)
+    goto skip_time_comparison;
+
+  {
+    struct GNUNET_TIME_Absolute timestamp;
+    struct GNUNET_TIME_Absolute last;
+    
+    timestamp = GNUNET_TIME_absolute_ntoh (message->header.timestamp);
+    last = GNUNET_TIME_absolute_ntoh (previous->header.timestamp);
+
+    if (GNUNET_TIME_relative_get_zero_ ().rel_value_us !=
+        GNUNET_TIME_absolute_get_difference (timestamp, last).rel_value_us)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "Message warning: Timestamp does not check out!\n");
+    }
+  }
+
+skip_time_comparison:
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving message of kind: %s!\n",
+              GNUNET_MESSENGER_name_of_kind (message->header.kind));
+
+  return GNUNET_OK;
+}
 
 enum GNUNET_GenericReturnValue
 check_tunnel_message (void *cls,
@@ -159,7 +236,7 @@ check_tunnel_message (void *cls,
     hash_message (&message, length - padding, buffer, &hash);
   }
 
-  return callback_verify_room_message (tunnel->room, cls, &message, &hash);
+  return verify_tunnel_message (tunnel->room, &message, &hash);
 }
 
 
diff --git a/src/service/messenger/gnunet-service-messenger_tunnel.h 
b/src/service/messenger/gnunet-service-messenger_tunnel.h
index 6a8452f61..77c730b6e 100644
--- a/src/service/messenger/gnunet-service-messenger_tunnel.h
+++ b/src/service/messenger/gnunet-service-messenger_tunnel.h
@@ -1,6 +1,6 @@
 /*
    This file is part of GNUnet.
-   Copyright (C) 2020--2023 GNUnet e.V.
+   Copyright (C) 2020--2024 GNUnet e.V.
 
    GNUnet is free software: you can redistribute it and/or modify it
    under the terms of the GNU Affero General Public License as published
@@ -75,6 +75,39 @@ void
 bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
              struct GNUNET_CADET_Channel *channel);
 
+/**
+ * Callback for message verification via <i>header</i> in a tunnel that is 
+ * provided as a closure from a CADET channel.
+ *
+ * @param[in,out] cls Closure
+ * @param[in] header Message header
+ */
+enum GNUNET_GenericReturnValue
+check_tunnel_message (void *cls,
+                      const struct GNUNET_MessageHeader *header);
+
+/**
+ * Callback for message handling via <i>header</i> in a tunnel that is 
+ * provided as a closure from a CADET channel.
+ *
+ * @param[in,out] cls Closure
+ * @param[in] header Message header
+ */
+void
+handle_tunnel_message (void *cls,
+                       const struct GNUNET_MessageHeader *header);
+
+/**
+ * Callback for a CADET <i>channel</i> disconnecting to manage this event
+ * as a proper tunnel provided as its closure.
+ *
+ * @param[in,out] cls Closure
+ * @param[in] channel CADET channel
+ */
+void
+callback_tunnel_disconnect (void *cls,
+                            const struct GNUNET_CADET_Channel *channel);
+
 /**
  * Tries to connect a <i>tunnel</i> by creating a new CADET channel and 
binding it.
  * The function returns #GNUNET_YES on success, otherwise #GNUNET_NO.
diff --git a/src/service/messenger/messenger_api.c 
b/src/service/messenger/messenger_api.c
index 50656ebc6..89a64d927 100644
--- a/src/service/messenger/messenger_api.c
+++ b/src/service/messenger/messenger_api.c
@@ -27,9 +27,10 @@
 #include "gnunet_messenger_service.h"
 
 #include "gnunet-service-messenger.h"
-
 #include "gnunet_reclaim_service.h"
 #include "gnunet_time_lib.h"
+
+#include "messenger_api.h"
 #include "messenger_api_contact.h"
 #include "messenger_api_contact_store.h"
 #include "messenger_api_handle.h"
@@ -208,11 +209,6 @@ handle_room_sync (void *cls,
 }
 
 
-void
-enqueue_message_to_room (struct GNUNET_MESSENGER_Room *room,
-                         struct GNUNET_MESSENGER_Message *message,
-                         struct GNUNET_MESSENGER_Message *transcript);
-
 static void
 handle_member_id (void *cls,
                   const struct GNUNET_MESSENGER_MemberMessage *msg)
@@ -1469,28 +1465,6 @@ GNUNET_MESSENGER_send_message (struct 
GNUNET_MESSENGER_Room *room,
 }
 
 
-void
-delete_message_in_room (struct GNUNET_MESSENGER_Room *room,
-                        const struct GNUNET_HashCode *hash,
-                        const struct GNUNET_TIME_Relative delay)
-{
-  struct GNUNET_MESSENGER_Message *message;
-
-  GNUNET_assert ((room) && (hash));
-  
-  message = create_message_delete (hash, delay);
-
-  if (! message)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Sending deletion aborted: Message creation failed!\n");
-    return;
-  }
-
-  enqueue_message_to_room (room, message, NULL);
-}
-
-
 void
 GNUNET_MESSENGER_delete_message (struct GNUNET_MESSENGER_Room *room,
                                  const struct GNUNET_HashCode *hash,
@@ -1499,7 +1473,7 @@ GNUNET_MESSENGER_delete_message (struct 
GNUNET_MESSENGER_Room *room,
   if ((! room) || (! hash))
     return;
 
-  delete_message_in_room (room, hash, delay);
+  delete_room_message (room, hash, delay);
 }
 
 
diff --git a/src/service/messenger/messenger_api.h 
b/src/service/messenger/messenger_api.h
new file mode 100644
index 000000000..2761a433c
--- /dev/null
+++ b/src/service/messenger/messenger_api.h
@@ -0,0 +1,37 @@
+/*
+   This file is part of GNUnet.
+   Copyright (C) 2024 GNUnet e.V.
+
+   GNUnet is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Affero General Public License as published
+   by the Free Software Foundation, either version 3 of the License,
+   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
+   Affero General Public License for more details.
+
+   You should have received a copy of the GNU Affero General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+   SPDX-License-Identifier: AGPL3.0-or-later
+ */
+/**
+ * @author Tobias Frisch
+ * @file src/messenger/messenger_api.h
+ * @brief messenger api: client implementation of GNUnet MESSENGER service
+ */
+
+#ifndef GNUNET_MESSENGER_API_H
+#define GNUNET_MESSENGER_API_H
+
+#include "messenger_api_message.h"
+#include "messenger_api_room.h"
+
+void
+enqueue_message_to_room (struct GNUNET_MESSENGER_Room *room,
+                         struct GNUNET_MESSENGER_Message *message,
+                         struct GNUNET_MESSENGER_Message *transcript);
+
+#endif //GNUNET_MESSENGER_API_H
diff --git a/src/service/messenger/messenger_api_message.c 
b/src/service/messenger/messenger_api_message.c
index 12158acc9..c359414da 100644
--- a/src/service/messenger/messenger_api_message.c
+++ b/src/service/messenger/messenger_api_message.c
@@ -1012,9 +1012,9 @@ decode_message (struct GNUNET_MESSENGER_Message *message,
   }
 
   decode_step (buffer, offset, &kind);
+  kind = GNUNET_be32toh (kind);
 
-  message->header.kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh (
-    kind);
+  message->header.kind = (enum GNUNET_MESSENGER_MessageKind) kind;
 
   if (count < get_message_kind_size (message->header.kind, include_header))
     return GNUNET_NO;
@@ -1059,8 +1059,9 @@ decode_short_message (struct 
GNUNET_MESSENGER_ShortMessage *message,
     return GNUNET_NO;
 
   decode_step (buffer, offset, &kind);
+  kind = GNUNET_be32toh (kind);
 
-  message->kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh (kind);
+  message->kind = (enum GNUNET_MESSENGER_MessageKind) kind;
 
   if (length < get_short_message_size (message, GNUNET_NO))
     return GNUNET_NO;
diff --git a/src/service/messenger/messenger_api_message_kind.c 
b/src/service/messenger/messenger_api_message_kind.c
index 3006376d5..a3d5172da 100644
--- a/src/service/messenger/messenger_api_message_kind.c
+++ b/src/service/messenger/messenger_api_message_kind.c
@@ -46,7 +46,7 @@ create_message_join (const struct GNUNET_CRYPTO_PrivateKey 
*key)
 
 
 struct GNUNET_MESSENGER_Message*
-create_message_leave ()
+create_message_leave (void)
 {
   return create_message (GNUNET_MESSENGER_KIND_LEAVE);
 }
diff --git a/src/service/messenger/messenger_api_message_kind.h 
b/src/service/messenger/messenger_api_message_kind.h
index 5d3e4e532..a5865b1fa 100644
--- a/src/service/messenger/messenger_api_message_kind.h
+++ b/src/service/messenger/messenger_api_message_kind.h
@@ -45,7 +45,7 @@ create_message_join (const struct GNUNET_CRYPTO_PrivateKey 
*key);
  * @return New message
  */
 struct GNUNET_MESSENGER_Message*
-create_message_leave ();
+create_message_leave (void);
 
 /**
  * Creates and allocates a new name message containing the <i>name</i> to 
change to.
diff --git a/src/service/messenger/messenger_api_room.c 
b/src/service/messenger/messenger_api_room.c
index ee972f9ba..e1751c239 100644
--- a/src/service/messenger/messenger_api_room.c
+++ b/src/service/messenger/messenger_api_room.c
@@ -28,6 +28,7 @@
 #include "gnunet_common.h"
 #include "gnunet_messenger_service.h"
 
+#include "messenger_api.h"
 #include "messenger_api_contact_store.h"
 #include "messenger_api_handle.h"
 #include "messenger_api_message.h"
@@ -286,6 +287,28 @@ get_room_recipient (const struct GNUNET_MESSENGER_Room 
*room,
 }
 
 
+void
+delete_room_message (struct GNUNET_MESSENGER_Room *room,
+                     const struct GNUNET_HashCode *hash,
+                     const struct GNUNET_TIME_Relative delay)
+{
+  struct GNUNET_MESSENGER_Message *message;
+
+  GNUNET_assert ((room) && (hash));
+  
+  message = create_message_delete (hash, delay);
+
+  if (! message)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Sending deletion aborted: Message creation failed!\n");
+    return;
+  }
+
+  enqueue_message_to_room (room, message, NULL);
+}
+
+
 void
 callback_room_message (struct GNUNET_MESSENGER_Room *room,
                        const struct GNUNET_HashCode *hash)
@@ -519,12 +542,6 @@ handle_private_message (struct GNUNET_MESSENGER_Room *room,
 }
 
 
-extern void
-delete_message_in_room (struct GNUNET_MESSENGER_Room *room,
-                        const struct GNUNET_HashCode *hash,
-                        const struct GNUNET_TIME_Relative delay);
-
-
 static void
 handle_delete_message (struct GNUNET_MESSENGER_Room *room,
                        const struct GNUNET_HashCode *hash,
@@ -550,7 +567,7 @@ handle_delete_message (struct GNUNET_MESSENGER_Room *room,
     delay = GNUNET_TIME_absolute_get_difference (GNUNET_TIME_absolute_get (),
                                                  action);
 
-    link_room_deletion (room, target_hash, delay, delete_message_in_room);
+    link_room_deletion (room, target_hash, delay, delete_room_message);
   }
 
   target = GNUNET_CONTAINER_multihashmap_get (room->messages, target_hash);
diff --git a/src/service/messenger/messenger_api_room.h 
b/src/service/messenger/messenger_api_room.h
index effe0bd96..b4a8bc543 100644
--- a/src/service/messenger/messenger_api_room.h
+++ b/src/service/messenger/messenger_api_room.h
@@ -183,6 +183,19 @@ struct GNUNET_MESSENGER_Contact*
 get_room_recipient (const struct GNUNET_MESSENGER_Room *room,
                     const struct GNUNET_HashCode *hash);
 
+
+/**
+ * Deletes a message with a given <i>hash</i> inside a <i>room</i> under a 
specific <i>delay</i>.
+ *
+ * @param[in,out] room Room
+ * @param[in] hash Hash of message
+ * @param[in] delay Delay of deletion
+ */
+void
+delete_room_message (struct GNUNET_MESSENGER_Room *room,
+                     const struct GNUNET_HashCode *hash,
+                     const struct GNUNET_TIME_Relative delay);
+
 /**
  * Executes the message callback for a given <i>hash</i> in a <i>room</i>.
  *
diff --git a/src/service/messenger/messenger_api_util.c 
b/src/service/messenger/messenger_api_util.c
index 2c89b0e76..fed111aab 100644
--- a/src/service/messenger/messenger_api_util.c
+++ b/src/service/messenger/messenger_api_util.c
@@ -82,7 +82,7 @@ generate_free_member_id (struct GNUNET_ShortHashCode *id,
 
 
 const struct GNUNET_CRYPTO_PrivateKey*
-get_anonymous_private_key ()
+get_anonymous_private_key (void)
 {
   const struct GNUNET_IDENTITY_Ego *ego;
   ego = GNUNET_IDENTITY_ego_get_anonymous ();
@@ -91,7 +91,7 @@ get_anonymous_private_key ()
 
 
 const struct GNUNET_CRYPTO_PublicKey*
-get_anonymous_public_key ()
+get_anonymous_public_key (void)
 {
   static struct GNUNET_CRYPTO_PublicKey public_key;
   static struct GNUNET_IDENTITY_Ego *ego = NULL;
diff --git a/src/service/messenger/messenger_api_util.h 
b/src/service/messenger/messenger_api_util.h
index 877491c93..2313d621a 100644
--- a/src/service/messenger/messenger_api_util.h
+++ b/src/service/messenger/messenger_api_util.h
@@ -23,8 +23,8 @@
  * @brief messenger api: client implementation of GNUnet MESSENGER service
  */
 
-#ifndef GNUNET_SERVICE_MESSENGER_UTIL_H
-#define GNUNET_SERVICE_MESSENGER_UTIL_H
+#ifndef GNUNET_MESSENGER_API_UTIL_H
+#define GNUNET_MESSENGER_API_UTIL_H
 
 #include "gnunet_cadet_service.h"
 #include "gnunet_util_lib.h"
@@ -56,7 +56,7 @@ generate_free_member_id (struct GNUNET_ShortHashCode *id,
  * @return anonymous private key
  */
 const struct GNUNET_CRYPTO_PrivateKey*
-get_anonymous_private_key ();
+get_anonymous_private_key (void);
 
 /**
  * Returns the public identity key of #GNUNET_IDENTITY_ego_get_anonymous() 
without
@@ -65,7 +65,7 @@ get_anonymous_private_key ();
  * @return anonymous public key
  */
 const struct GNUNET_CRYPTO_PublicKey*
-get_anonymous_public_key ();
+get_anonymous_public_key (void);
 
 /**
  * Converts a Messenger service key of a room to the specific port which
@@ -92,4 +92,4 @@ void
 convert_peer_identity_to_id (const struct GNUNET_PeerIdentity *identity,
                              struct GNUNET_ShortHashCode *id);
 
-#endif //GNUNET_SERVICE_MESSENGER_UTIL_H
+#endif //GNUNET_MESSENGER_API_UTIL_H

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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