[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32454 - in gnunet-dbus: . src/lib src/lib/block src/lib/co
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32454 - in gnunet-dbus: . src/lib src/lib/block src/lib/common src/lib/dht src/lib/gnsrecord src/lib/include src/lib/util src/services |
Date: |
Sat, 22 Feb 2014 08:55:41 +0100 |
Author: canndrew
Date: 2014-02-22 08:55:41 +0100 (Sat, 22 Feb 2014)
New Revision: 32454
Added:
gnunet-dbus/src/lib/block/
gnunet-dbus/src/lib/block/Makefile.am
gnunet-dbus/src/lib/block/gnunet_block_dbus_lib.c
gnunet-dbus/src/lib/block/gnunet_block_dbus_lib_pop.c
gnunet-dbus/src/lib/block/gnunet_block_dbus_lib_push.c
gnunet-dbus/src/lib/common/
gnunet-dbus/src/lib/common/Makefile.am
gnunet-dbus/src/lib/common/gnunet_dbus_lib_arg.c
gnunet-dbus/src/lib/common/gnunet_dbus_lib_client.c
gnunet-dbus/src/lib/common/gnunet_dbus_lib_interface.c
gnunet-dbus/src/lib/common/gnunet_dbus_lib_message.c
gnunet-dbus/src/lib/common/gnunet_dbus_lib_method.c
gnunet-dbus/src/lib/common/gnunet_dbus_lib_method_context.c
gnunet-dbus/src/lib/common/gnunet_dbus_lib_object.c
gnunet-dbus/src/lib/common/gnunet_dbus_lib_pop.c
gnunet-dbus/src/lib/common/gnunet_dbus_lib_push.c
gnunet-dbus/src/lib/common/gnunet_dbus_lib_service.c
gnunet-dbus/src/lib/common/gnunet_dbus_lib_signature.c
gnunet-dbus/src/lib/common/timeout.c
gnunet-dbus/src/lib/common/timeout.h
gnunet-dbus/src/lib/common/watch.c
gnunet-dbus/src/lib/common/watch.h
gnunet-dbus/src/lib/dht/
gnunet-dbus/src/lib/dht/Makefile.am
gnunet-dbus/src/lib/dht/gnunet_dht_dbus_lib.c
gnunet-dbus/src/lib/dht/gnunet_dht_dbus_lib_pop.c
gnunet-dbus/src/lib/dht/gnunet_dht_dbus_lib_push.c
gnunet-dbus/src/lib/gnsrecord/
gnunet-dbus/src/lib/gnsrecord/Makefile.am
gnunet-dbus/src/lib/gnsrecord/gnunet_gnsrecord_dbus_lib.c
gnunet-dbus/src/lib/gnsrecord/gnunet_gnsrecord_dbus_lib_pop.c
gnunet-dbus/src/lib/gnsrecord/gnunet_gnsrecord_dbus_lib_push.c
gnunet-dbus/src/lib/include/
gnunet-dbus/src/lib/include/gnunet_block_dbus_lib.h
gnunet-dbus/src/lib/include/gnunet_block_dbus_lib_pop.h
gnunet-dbus/src/lib/include/gnunet_block_dbus_lib_push.h
gnunet-dbus/src/lib/include/gnunet_block_dbus_lib_signature.h
gnunet-dbus/src/lib/include/gnunet_crypto_dbus_lib.h
gnunet-dbus/src/lib/include/gnunet_crypto_dbus_lib_pop.h
gnunet-dbus/src/lib/include/gnunet_crypto_dbus_lib_signature.h
gnunet-dbus/src/lib/include/gnunet_dbus_lib.h
gnunet-dbus/src/lib/include/gnunet_dbus_lib_arg.h
gnunet-dbus/src/lib/include/gnunet_dbus_lib_client.h
gnunet-dbus/src/lib/include/gnunet_dbus_lib_interface.h
gnunet-dbus/src/lib/include/gnunet_dbus_lib_message.h
gnunet-dbus/src/lib/include/gnunet_dbus_lib_method.h
gnunet-dbus/src/lib/include/gnunet_dbus_lib_method_context.h
gnunet-dbus/src/lib/include/gnunet_dbus_lib_object.h
gnunet-dbus/src/lib/include/gnunet_dbus_lib_pop.h
gnunet-dbus/src/lib/include/gnunet_dbus_lib_push.h
gnunet-dbus/src/lib/include/gnunet_dbus_lib_service.h
gnunet-dbus/src/lib/include/gnunet_dbus_lib_signature.h
gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib.h
gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib_pop.h
gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib_push.h
gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib_signature.h
gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib.h
gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib_pop.h
gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib_push.h
gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib_signature.h
gnunet-dbus/src/lib/include/gnunet_time_dbus_lib.h
gnunet-dbus/src/lib/include/gnunet_time_dbus_lib_pop.h
gnunet-dbus/src/lib/include/gnunet_time_dbus_lib_push.h
gnunet-dbus/src/lib/include/gnunet_time_dbus_lib_signature.h
gnunet-dbus/src/lib/util/
gnunet-dbus/src/lib/util/Makefile.am
gnunet-dbus/src/lib/util/gnunet_crypto_dbus_lib_pop.c
gnunet-dbus/src/lib/util/gnunet_crypto_dbus_lib_push.c
gnunet-dbus/src/lib/util/gnunet_time_dbus_lib_pop.c
gnunet-dbus/src/lib/util/gnunet_time_dbus_lib_push.c
gnunet-dbus/src/services/gnunet-service-dht-dbus.c
Removed:
gnunet-dbus/src/lib/gnunet_dbus_lib.h
gnunet-dbus/src/lib/gnunet_dbus_lib_arg.c
gnunet-dbus/src/lib/gnunet_dbus_lib_arg.h
gnunet-dbus/src/lib/gnunet_dbus_lib_client.c
gnunet-dbus/src/lib/gnunet_dbus_lib_client.h
gnunet-dbus/src/lib/gnunet_dbus_lib_interface.c
gnunet-dbus/src/lib/gnunet_dbus_lib_interface.h
gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_pop.c
gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_pop.h
gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_push.c
gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_push.h
gnunet-dbus/src/lib/gnunet_dbus_lib_method.c
gnunet-dbus/src/lib/gnunet_dbus_lib_method.h
gnunet-dbus/src/lib/gnunet_dbus_lib_method_context.c
gnunet-dbus/src/lib/gnunet_dbus_lib_method_context.h
gnunet-dbus/src/lib/gnunet_dbus_lib_object.c
gnunet-dbus/src/lib/gnunet_dbus_lib_object.h
gnunet-dbus/src/lib/gnunet_dbus_lib_service.c
gnunet-dbus/src/lib/gnunet_dbus_lib_service.h
gnunet-dbus/src/lib/gnunet_dbus_lib_signature.c
gnunet-dbus/src/lib/gnunet_dbus_lib_signature.h
gnunet-dbus/src/lib/timeout.c
gnunet-dbus/src/lib/timeout.h
gnunet-dbus/src/lib/watch.c
gnunet-dbus/src/lib/watch.h
Modified:
gnunet-dbus/configure.ac
gnunet-dbus/src/lib/Makefile.am
gnunet-dbus/src/services/Makefile.am
gnunet-dbus/src/services/gnunet-service-gns-dbus.c
Log:
Refactor. Split service-specific code into seperate directories/libraries
Modified: gnunet-dbus/configure.ac
===================================================================
--- gnunet-dbus/configure.ac 2014-02-21 17:05:07 UTC (rev 32453)
+++ gnunet-dbus/configure.ac 2014-02-22 07:55:41 UTC (rev 32454)
@@ -9,6 +9,11 @@
Makefile
src/Makefile
src/lib/Makefile
+src/lib/common/Makefile
+src/lib/block/Makefile
+src/lib/dht/Makefile
+src/lib/gnsrecord/Makefile
+src/lib/util/Makefile
src/services/Makefile
])
Modified: gnunet-dbus/src/lib/Makefile.am
===================================================================
--- gnunet-dbus/src/lib/Makefile.am 2014-02-21 17:05:07 UTC (rev 32453)
+++ gnunet-dbus/src/lib/Makefile.am 2014-02-22 07:55:41 UTC (rev 32454)
@@ -1,26 +1,2 @@
-AM_CFLAGS = \
- -I$(top_builddir)/src/lib
+SUBDIRS = common block dht util gnsrecord
-lib_LTLIBRARIES = \
- libgnunetdbus.la
-
-libgnunetdbus_la_SOURCES = \
- watch.c \
- timeout.c \
- gnunet_dbus_lib_service.c \
- gnunet_dbus_lib_object.c \
- gnunet_dbus_lib_interface.c \
- gnunet_dbus_lib_method.c \
- gnunet_dbus_lib_arg.c \
- gnunet_dbus_lib_method_context.c \
- gnunet_dbus_lib_message_iter_pop.c \
- gnunet_dbus_lib_message_iter_push.c \
- gnunet_dbus_lib_client.c \
- gnunet_dbus_lib_signature.c
-
-libgnunetdbus_la_CFLAGS = \
- $(DBUS_CFLAGS)
-
-libgnunetdbus_la_LDFLAGS = \
- $(DBUS_LIBS)
-
Added: gnunet-dbus/src/lib/block/Makefile.am
===================================================================
--- gnunet-dbus/src/lib/block/Makefile.am (rev 0)
+++ gnunet-dbus/src/lib/block/Makefile.am 2014-02-22 07:55:41 UTC (rev
32454)
@@ -0,0 +1,15 @@
+lib_LTLIBRARIES = \
+ libgnunetblockdbus.la
+
+libgnunetblockdbus_la_SOURCES = \
+ gnunet_block_dbus_lib.c \
+ gnunet_block_dbus_lib_pop.c \
+ gnunet_block_dbus_lib_push.c
+
+libgnunetblockdbus_la_CFLAGS = \
+ -I$(top_builddir)/src/lib/include \
+ $(DBUS_CFLAGS)
+
+libgnunetblockdbus_la_LDFLAGS = \
+ $(DBUS_LIBS)
+
Added: gnunet-dbus/src/lib/block/gnunet_block_dbus_lib.c
===================================================================
--- gnunet-dbus/src/lib/block/gnunet_block_dbus_lib.c
(rev 0)
+++ gnunet-dbus/src/lib/block/gnunet_block_dbus_lib.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,26 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_block_lib.h>
+
+#include "gnunet_block_dbus_lib.h"
+
+const struct GNUNET_DBUS_StringEnumPair GNUNET_BLOCK_DBUS_type_description[] =
{
+ {"any", GNUNET_BLOCK_TYPE_ANY},
+ {"fs_dblock", GNUNET_BLOCK_TYPE_FS_DBLOCK},
+ {"fs_iblock", GNUNET_BLOCK_TYPE_FS_IBLOCK},
+ {"fs_kblock", GNUNET_BLOCK_TYPE_FS_KBLOCK},
+ {"fs_sblock", GNUNET_BLOCK_TYPE_FS_SBLOCK},
+ {"fs_nblock", GNUNET_BLOCK_TYPE_FS_NBLOCK},
+ {"fs_ondemand", GNUNET_BLOCK_TYPE_FS_ONDEMAND},
+ {"dht_hello", GNUNET_BLOCK_TYPE_DHT_HELLO},
+ {"test", GNUNET_BLOCK_TYPE_TEST},
+ {"fs_ublock", GNUNET_BLOCK_TYPE_FS_UBLOCK},
+ {"dns", GNUNET_BLOCK_TYPE_DNS},
+ {"gns_namerecord", GNUNET_BLOCK_TYPE_GNS_NAMERECORD},
+ {"regex", GNUNET_BLOCK_TYPE_REGEX},
+ {"regex_accept", GNUNET_BLOCK_TYPE_REGEX_ACCEPT},
+ {NULL, 0}
+};
+
Added: gnunet-dbus/src/lib/block/gnunet_block_dbus_lib_pop.c
===================================================================
--- gnunet-dbus/src/lib/block/gnunet_block_dbus_lib_pop.c
(rev 0)
+++ gnunet-dbus/src/lib/block/gnunet_block_dbus_lib_pop.c 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,20 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_block_lib.h>
+
+#include "gnunet_dbus_lib.h"
+#include "gnunet_block_dbus_lib.h"
+
+DBusMessage *
+GNUNET_BLOCK_DBUS_pop_type (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ enum GNUNET_BLOCK_Type *value)
+{
+ return GNUNET_DBUS_pop_enum (message, iter, arg_name, (int *)value,
GNUNET_BLOCK_DBUS_type_description);
+};
+
+
Added: gnunet-dbus/src/lib/block/gnunet_block_dbus_lib_push.c
===================================================================
--- gnunet-dbus/src/lib/block/gnunet_block_dbus_lib_push.c
(rev 0)
+++ gnunet-dbus/src/lib/block/gnunet_block_dbus_lib_push.c 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,18 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_block_lib.h>
+
+#include "gnunet_dbus_lib.h"
+#include "gnunet_block_dbus_lib.h"
+
+void
+GNUNET_BLOCK_DBUS_push_type (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const enum GNUNET_BLOCK_Type *value)
+{
+ return GNUNET_DBUS_push_enum (message, iter, (const int *)value,
GNUNET_BLOCK_DBUS_type_description);
+};
+
Copied: gnunet-dbus/src/lib/common/Makefile.am (from rev 32345,
gnunet-dbus/src/lib/Makefile.am)
===================================================================
--- gnunet-dbus/src/lib/common/Makefile.am (rev 0)
+++ gnunet-dbus/src/lib/common/Makefile.am 2014-02-22 07:55:41 UTC (rev
32454)
@@ -0,0 +1,28 @@
+AM_CFLAGS = \
+ -I$(top_builddir)/src/lib/include
+
+lib_LTLIBRARIES = \
+ libgnunetdbus.la
+
+libgnunetdbus_la_SOURCES = \
+ watch.c \
+ timeout.c \
+ gnunet_dbus_lib_service.c \
+ gnunet_dbus_lib_object.c \
+ gnunet_dbus_lib_interface.c \
+ gnunet_dbus_lib_method.c \
+ gnunet_dbus_lib_arg.c \
+ gnunet_dbus_lib_message.c \
+ gnunet_dbus_lib_method_context.c \
+ gnunet_dbus_lib_pop.c \
+ gnunet_dbus_lib_push.c \
+ gnunet_dbus_lib_client.c \
+ gnunet_dbus_lib_signature.c
+
+libgnunetdbus_la_CFLAGS = \
+ -I$(top_builddir)/src/lib/include \
+ $(DBUS_CFLAGS)
+
+libgnunetdbus_la_LDFLAGS = \
+ $(DBUS_LIBS)
+
Copied: gnunet-dbus/src/lib/common/gnunet_dbus_lib_arg.c (from rev 32345,
gnunet-dbus/src/lib/gnunet_dbus_lib_arg.c)
===================================================================
--- gnunet-dbus/src/lib/common/gnunet_dbus_lib_arg.c
(rev 0)
+++ gnunet-dbus/src/lib/common/gnunet_dbus_lib_arg.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,76 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+
+#include "gnunet_dbus_lib.h"
+
+#define LOG(kind, ...) GNUNET_log_from(kind, "dbus-arg", __VA_ARGS__)
+
+struct GNUNET_DBUS_Arg
+{
+ char *name;
+ const char *signature;
+ unsigned ref_count;
+};
+
+struct GNUNET_DBUS_Arg *
+GNUNET_DBUS_arg_create (
+ const char *name,
+ const char *signature)
+{
+ struct GNUNET_DBUS_Arg *arg = GNUNET_new (struct GNUNET_DBUS_Arg);
+ arg->name = GNUNET_strdup (name);
+ arg->signature = signature;
+ arg->ref_count = 0;
+ return arg;
+};
+
+void
+GNUNET_DBUS_arg_destroy (
+ struct GNUNET_DBUS_Arg *arg)
+{
+ if (0 != arg->ref_count)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to destroy arg that still has
references. name == \"%s\", ref_count == %zu\n", arg->name, arg->ref_count);
+ GNUNET_abort ();
+ };
+
+ GNUNET_free (arg->name);
+ GNUNET_free (arg);
+};
+
+void
+GNUNET_DBUS_arg_ref (
+ struct GNUNET_DBUS_Arg *arg)
+{
+ arg->ref_count++;
+};
+
+void
+GNUNET_DBUS_arg_unref (
+ struct GNUNET_DBUS_Arg *arg)
+{
+ if (arg->ref_count == 0)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unreference arg with ref count
0\n");
+ GNUNET_abort ();
+ };
+ if (--arg->ref_count == 0)
+ GNUNET_DBUS_arg_destroy (arg);
+};
+
+const char *
+GNUNET_DBUS_arg_get_name (
+ const struct GNUNET_DBUS_Arg *arg)
+{
+ return arg->name;
+};
+
+const char *
+GNUNET_DBUS_arg_get_signature (
+ const struct GNUNET_DBUS_Arg *arg)
+{
+ return arg->signature;
+};
+
Copied: gnunet-dbus/src/lib/common/gnunet_dbus_lib_client.c (from rev 32345,
gnunet-dbus/src/lib/gnunet_dbus_lib_client.c)
===================================================================
--- gnunet-dbus/src/lib/common/gnunet_dbus_lib_client.c
(rev 0)
+++ gnunet-dbus/src/lib/common/gnunet_dbus_lib_client.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,77 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+
+#include "gnunet_dbus_lib.h"
+
+#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-client", __VA_ARGS__)
+
+struct GNUNET_DBUS_Client
+{
+ char *unique_name;
+ void *data;
+ bool prefers_pretty_encodings;
+};
+
+struct GNUNET_DBUS_Client *
+GNUNET_DBUS_client_create (
+ const char *unique_name)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Creating client with unique name %s\n",
unique_name);
+
+ struct GNUNET_DBUS_Client *client = GNUNET_new (struct GNUNET_DBUS_Client);
+ client->unique_name = GNUNET_strdup (unique_name);
+ client->data = NULL;
+ client->prefers_pretty_encodings = false;
+
+ return client;
+};
+
+void
+GNUNET_DBUS_client_destroy (
+ struct GNUNET_DBUS_Client *client)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroying client with unique name %s\n",
client->unique_name);
+
+ GNUNET_free (client->unique_name);
+ GNUNET_free (client);
+};
+
+const char *
+GNUNET_DBUS_client_get_unique_name (
+ const struct GNUNET_DBUS_Client *client)
+{
+ return client->unique_name;
+};
+
+void
+GNUNET_DBUS_client_set_data (
+ struct GNUNET_DBUS_Client *client,
+ void *data)
+{
+ client->data = data;
+};
+
+void *
+GNUNET_DBUS_client_get_data (
+ const struct GNUNET_DBUS_Client *client)
+{
+ return client->data;
+};
+
+void
+GNUNET_DBUS_client_set_prefers_pretty_encodings (
+ struct GNUNET_DBUS_Client *client,
+ bool prefers_pretty_encodings)
+{
+ client->prefers_pretty_encodings = prefers_pretty_encodings;
+}
+
+bool
+GNUNET_DBUS_client_get_prefers_pretty_encodings (
+ const struct GNUNET_DBUS_Client *client)
+{
+ return client->prefers_pretty_encodings;
+};
+
Copied: gnunet-dbus/src/lib/common/gnunet_dbus_lib_interface.c (from rev 32345,
gnunet-dbus/src/lib/gnunet_dbus_lib_interface.c)
===================================================================
--- gnunet-dbus/src/lib/common/gnunet_dbus_lib_interface.c
(rev 0)
+++ gnunet-dbus/src/lib/common/gnunet_dbus_lib_interface.c 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,208 @@
+#include "config.h"
+
+#include <dbus/dbus.h>
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_container_lib.h>
+
+#include "gnunet_dbus_lib.h"
+
+#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-interface", __VA_ARGS__)
+
+struct GNUNET_DBUS_Interface
+{
+ struct GNUNET_DBUS_MethodIterator *methods_front;
+ struct GNUNET_DBUS_MethodIterator *methods_back;
+
+ char *name;
+ unsigned ref_count;
+};
+
+struct GNUNET_DBUS_Interface *
+GNUNET_DBUS_interface_create (
+ const char *name)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Creating interface %s\n", name);
+
+ struct GNUNET_DBUS_Interface *interface = GNUNET_new (struct
GNUNET_DBUS_Interface);
+
+ interface->methods_front = NULL;
+ interface->methods_back = NULL;
+ interface->name = GNUNET_strdup (name);
+ interface->ref_count = 0;
+
+ return interface;
+};
+
+void
+GNUNET_DBUS_interface_destroy (
+ struct GNUNET_DBUS_Interface *interface)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroying interface %s\n", interface->name);
+
+ if (0 != interface->ref_count)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to destroy interface that still has
references. name == \"%s\", ref_count == %zu\n", interface->name,
interface->ref_count);
+ GNUNET_abort ();
+ };
+
+ struct GNUNET_DBUS_MethodIterator *methods_iter = interface->methods_front;
+ while (methods_iter)
+ {
+ struct GNUNET_DBUS_MethodIterator *next = methods_iter->next;
+ GNUNET_DBUS_method_unref (methods_iter->method);
+ GNUNET_free (methods_iter);
+ methods_iter = next;
+ };
+
+ GNUNET_free (interface->name);
+ GNUNET_free (interface);
+};
+
+void
+GNUNET_DBUS_interface_ref (
+ struct GNUNET_DBUS_Interface *interface)
+{
+ interface->ref_count++;
+};
+
+void
+GNUNET_DBUS_interface_unref (
+ struct GNUNET_DBUS_Interface *interface)
+{
+ if (interface->ref_count == 0)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unreference interface with ref
count 0\n");
+ GNUNET_abort ();
+ };
+ if (--interface->ref_count == 0)
+ GNUNET_DBUS_interface_destroy (interface);
+};
+
+void
+GNUNET_DBUS_interface_add_method (
+ struct GNUNET_DBUS_Interface *interface,
+ struct GNUNET_DBUS_Method *method)
+{
+ struct GNUNET_DBUS_MethodIterator *meth_it = GNUNET_new (struct
GNUNET_DBUS_MethodIterator);
+ meth_it->method = method;
+ GNUNET_DBUS_method_ref (method);
+
+ GNUNET_CONTAINER_DLL_insert (interface->methods_front,
+ interface->methods_back,
+ meth_it);
+};
+
+const char *
+GNUNET_DBUS_interface_get_name (
+ const struct GNUNET_DBUS_Interface *interface)
+{
+ return interface->name;
+};
+
+const struct GNUNET_DBUS_MethodIterator *
+GNUNET_DBUS_interface_iterate_methods (
+ const struct GNUNET_DBUS_Interface *interface)
+{
+ return interface->methods_front;
+};
+
+static void
+introspectable_introspect (
+ struct GNUNET_DBUS_MethodContext *mc)
+{
+ char *data = NULL;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Introspecting\n");
+ struct GNUNET_DBUS_Object *object = mc->object;
+ GNUNET_append_sprintf (&data, DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "here\n");
+ GNUNET_append_sprintf (&data, "<node>\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "and here\n");
+ const struct GNUNET_DBUS_InterfaceIterator *int_it =
GNUNET_DBUS_object_iterate_interfaces (object);
+ while (int_it)
+ {
+ struct GNUNET_DBUS_Interface *interface = int_it->interface;
+ const char *interface_name = GNUNET_DBUS_interface_get_name (interface);
+ GNUNET_append_sprintf (&data, " <interface name='%s'>\n", interface_name);
+ const struct GNUNET_DBUS_MethodIterator *meth_it =
GNUNET_DBUS_interface_iterate_methods (interface);
+ while (meth_it)
+ {
+ struct GNUNET_DBUS_Method *method = meth_it->method;
+ const char *method_name = GNUNET_DBUS_method_get_name (method);
+ GNUNET_append_sprintf (&data, " <method name='%s'>\n", method_name);
+ const struct GNUNET_DBUS_ArgIterator *arg_it =
GNUNET_DBUS_method_iterate_args (method);
+ while (arg_it)
+ {
+ struct GNUNET_DBUS_Arg *arg = arg_it->arg;
+ const char *arg_name = GNUNET_DBUS_arg_get_name (arg);
+ const char *signature = GNUNET_DBUS_arg_get_signature (arg);
+ GNUNET_append_sprintf (
+ &data,
+ " <arg name='%s' type='%s' direction='in'/>\n",
+ arg_name,
+ signature);
+ arg_it = arg_it->next;
+ };
+
+ arg_it = GNUNET_DBUS_method_iterate_return_args (method);
+ while (arg_it)
+ {
+ struct GNUNET_DBUS_Arg *arg = arg_it->arg;
+ const char *arg_name = GNUNET_DBUS_arg_get_name (arg);
+ const char *signature = GNUNET_DBUS_arg_get_signature (arg);
+ GNUNET_append_sprintf (
+ &data,
+ " <arg name='%s' type='%s' direction='out'/>\n",
+ arg_name,
+ signature);
+ arg_it = arg_it->next;
+ };
+ GNUNET_append_sprintf (&data, " </method>\n");
+ meth_it = meth_it->next;
+ };
+ GNUNET_append_sprintf (&data, " </interface>\n");
+ int_it = int_it->next;
+ };
+ GNUNET_append_sprintf (&data, "</node>\n");
+
+ DBusMessage *reply = GNUNET_DBUS_method_context_create_reply (mc);
+ DBusMessageIter reply_iter;
+ dbus_message_iter_init_append (reply, &reply_iter);
+ GNUNET_DBUS_push_string (reply, &reply_iter, (const char *const *)&data);
+ GNUNET_DBUS_method_context_send_reply (mc, reply);
+ GNUNET_DBUS_method_context_unref (mc);
+ GNUNET_free (data);
+};
+
+struct GNUNET_DBUS_Interface *
+GNUNET_DBUS_interface_introspectable ()
+{
+ static struct GNUNET_DBUS_Interface *introspectable = NULL;
+
+ if (NULL == introspectable)
+ {
+ introspectable = GNUNET_DBUS_interface_create
("org.freedesktop.DBus.Introspectable");
+ struct GNUNET_DBUS_Method *introspect = GNUNET_DBUS_method_create
("Introspect", introspectable_introspect);
+ GNUNET_DBUS_method_add_return_arg (introspect, "data",
GNUNET_DBUS_SIGNATURE_STRING);
+ GNUNET_DBUS_interface_add_method (introspectable, introspect);
+ GNUNET_DBUS_interface_ref (introspectable);
+ };
+
+ return introspectable;
+};
+
+const struct GNUNET_DBUS_InterfaceIterator *
+GNUNET_DBUS_interface_find (
+ const struct GNUNET_DBUS_InterfaceIterator *int_it,
+ const char *name)
+{
+ for (; int_it; int_it = int_it->next)
+ {
+ if (! strcmp (name, int_it->interface->name))
+ return int_it;
+ }
+ return NULL;
+}
+
Added: gnunet-dbus/src/lib/common/gnunet_dbus_lib_message.c
===================================================================
--- gnunet-dbus/src/lib/common/gnunet_dbus_lib_message.c
(rev 0)
+++ gnunet-dbus/src/lib/common/gnunet_dbus_lib_message.c 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,47 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+
+#include "gnunet_dbus_lib_message.h"
+
+#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-message", __VA_ARGS__)
+
+static dbus_int32_t
+pretty_slot_id ()
+{
+ static dbus_int32_t id = -1;
+ if (-1 == id)
+ {
+ dbus_bool_t succ = dbus_message_allocate_data_slot (&id);
+ if (! succ || -1 == id)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "dbus_message_allocate_data_slot failed.
id == %lld\n", (long long)id);
+ GNUNET_abort ();
+ };
+ };
+
+ return id;
+};
+
+bool
+GNUNET_DBUS_message_get_pretty (
+ DBusMessage *message)
+{
+ return (bool)dbus_message_get_data (message, pretty_slot_id ());
+}
+
+void
+GNUNET_DBUS_message_set_pretty (
+ DBusMessage *message,
+ bool pretty)
+{
+ dbus_int32_t id = pretty_slot_id ();
+ bool succ = dbus_message_set_data (message, id, (void *)pretty, NULL);
+ if (! succ)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "dbus_message_set_data failed. id ==
%lld\n", (long long)id);
+ GNUNET_abort ();
+ };
+};
+
Copied: gnunet-dbus/src/lib/common/gnunet_dbus_lib_method.c (from rev 32345,
gnunet-dbus/src/lib/gnunet_dbus_lib_method.c)
===================================================================
--- gnunet-dbus/src/lib/common/gnunet_dbus_lib_method.c
(rev 0)
+++ gnunet-dbus/src/lib/common/gnunet_dbus_lib_method.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,144 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_container_lib.h>
+
+#include "gnunet_dbus_lib.h"
+
+#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-method", __VA_ARGS__)
+
+struct GNUNET_DBUS_Method
+{
+ struct GNUNET_DBUS_ArgIterator *args_front;
+ struct GNUNET_DBUS_ArgIterator *args_back;
+
+ struct GNUNET_DBUS_ArgIterator *return_args_front;
+ struct GNUNET_DBUS_ArgIterator *return_args_back;
+
+ char *name;
+
+ void (*underlying_method)(struct GNUNET_DBUS_MethodContext *mc);
+
+ unsigned ref_count;
+};
+
+struct GNUNET_DBUS_Method *
+GNUNET_DBUS_method_create (
+ const char *name,
+ void (*underlying_method)(struct GNUNET_DBUS_MethodContext *mc))
+{
+ struct GNUNET_DBUS_Method *method = GNUNET_new (struct GNUNET_DBUS_Method);
+ method->name = GNUNET_strdup (name);
+ method->underlying_method = underlying_method;
+ method->ref_count = 0;
+
+ return method;
+};
+
+void
+GNUNET_DBUS_method_destroy (
+ struct GNUNET_DBUS_Method *method)
+{
+ if (0 != method->ref_count)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to destroy method that still has
references. name == \"%s\", ref_count == %zu\n", method->name,
method->ref_count);
+ GNUNET_abort ();
+ };
+
+ GNUNET_free (method->name);
+ GNUNET_free (method);
+};
+
+void
+GNUNET_DBUS_method_ref (
+ struct GNUNET_DBUS_Method *method)
+{
+ method->ref_count++;
+};
+
+void
+GNUNET_DBUS_method_unref (
+ struct GNUNET_DBUS_Method *method)
+{
+ if (method->ref_count == 0)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unreference method with ref count
0\n");
+ GNUNET_abort ();
+ };
+ if (--method->ref_count == 0)
+ GNUNET_DBUS_method_destroy (method);
+};
+
+void
+GNUNET_DBUS_method_add_arg (
+ struct GNUNET_DBUS_Method *method,
+ const char *name,
+ const char *signature)
+{
+ struct GNUNET_DBUS_Arg *arg = GNUNET_DBUS_arg_create (name, signature);
+ struct GNUNET_DBUS_ArgIterator *arg_it = GNUNET_new (struct
GNUNET_DBUS_ArgIterator);
+ arg_it->arg = arg;
+ GNUNET_DBUS_arg_ref (arg);
+ GNUNET_CONTAINER_DLL_insert_tail (method->args_front,
+ method->args_back,
+ arg_it);
+};
+
+void
+GNUNET_DBUS_method_add_return_arg (
+ struct GNUNET_DBUS_Method *method,
+ const char *name,
+ const char *signature)
+{
+ struct GNUNET_DBUS_Arg *arg = GNUNET_DBUS_arg_create (name, signature);
+ struct GNUNET_DBUS_ArgIterator *arg_it = GNUNET_new (struct
GNUNET_DBUS_ArgIterator);
+ arg_it->arg = arg;
+ GNUNET_DBUS_arg_ref (arg);
+ GNUNET_CONTAINER_DLL_insert_tail (method->return_args_front,
+ method->return_args_back,
+ arg_it);
+};
+
+const char *
+GNUNET_DBUS_method_get_name (
+ const struct GNUNET_DBUS_Method *method)
+{
+ return method->name;
+};
+
+const struct GNUNET_DBUS_ArgIterator *
+GNUNET_DBUS_method_iterate_args (
+ const struct GNUNET_DBUS_Method *method)
+{
+ return method->args_front;
+};
+
+const struct GNUNET_DBUS_ArgIterator *
+GNUNET_DBUS_method_iterate_return_args (
+ const struct GNUNET_DBUS_Method *method)
+{
+ return method->return_args_front;
+};
+
+void
+GNUNET_DBUS_method_call (
+ struct GNUNET_DBUS_Method *method,
+ struct GNUNET_DBUS_MethodContext *mc)
+{
+ method->underlying_method (mc);
+};
+
+const struct GNUNET_DBUS_MethodIterator *
+GNUNET_DBUS_method_find (
+ const struct GNUNET_DBUS_MethodIterator *meth_it,
+ const char *name)
+{
+ for (; meth_it; meth_it = meth_it->next)
+ {
+ if (! strcmp (name, meth_it->method->name))
+ return meth_it;
+ }
+ return NULL;
+}
+
Copied: gnunet-dbus/src/lib/common/gnunet_dbus_lib_method_context.c (from rev
32345, gnunet-dbus/src/lib/gnunet_dbus_lib_method_context.c)
===================================================================
--- gnunet-dbus/src/lib/common/gnunet_dbus_lib_method_context.c
(rev 0)
+++ gnunet-dbus/src/lib/common/gnunet_dbus_lib_method_context.c 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,94 @@
+#include "config.h"
+
+#include <dbus/dbus.h>
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_container_lib.h>
+
+#include "gnunet_dbus_lib.h"
+
+#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-method-context",
__VA_ARGS__)
+
+struct GNUNET_DBUS_MethodContext *
+GNUNET_DBUS_method_context_create (
+ struct GNUNET_DBUS_Client *client,
+ struct GNUNET_DBUS_Service *service,
+ struct GNUNET_DBUS_Object *object,
+ struct GNUNET_DBUS_Interface *interface,
+ struct GNUNET_DBUS_Method *method,
+ DBusMessage *message)
+{
+ struct GNUNET_DBUS_MethodContext *ret = GNUNET_new (struct
GNUNET_DBUS_MethodContext);
+ ret->client = client;
+ ret->service = service;
+ ret->object = object;
+ ret->interface = interface;
+ ret->method = method;
+ ret->message = message;
+ ret->expects_reply = ! dbus_message_get_no_reply (message);
+
+ ret->replied = false;
+ ret->ref_count = 0;
+ dbus_message_ref (message);
+
+ return ret;
+};
+
+void
+GNUNET_DBUS_method_context_destroy (
+ struct GNUNET_DBUS_MethodContext *mc)
+{
+ if (0 != mc->ref_count)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to destroy method context with ref
count %u\n", mc->ref_count);
+ GNUNET_abort ();
+ };
+
+ dbus_message_unref (mc->message);
+ GNUNET_free (mc);
+};
+
+void
+GNUNET_DBUS_method_context_ref (
+ struct GNUNET_DBUS_MethodContext *mc)
+{
+ mc->ref_count++;
+};
+
+void
+GNUNET_DBUS_method_context_unref (
+ struct GNUNET_DBUS_MethodContext *mc)
+{
+ if (0 == mc->ref_count)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unreference method context with
ref count 0\n");
+ GNUNET_abort ();
+ };
+ if (0 == --mc->ref_count)
+ GNUNET_DBUS_method_context_destroy (mc);
+};
+
+void
+GNUNET_DBUS_method_context_send_reply (
+ struct GNUNET_DBUS_MethodContext *mc,
+ DBusMessage *reply)
+{
+ if (! mc->expects_reply)
+ return;
+
+ GNUNET_DBUS_service_send (mc->service, reply);
+ dbus_message_unref (reply);
+};
+
+DBusMessage *
+GNUNET_DBUS_method_context_create_reply (
+ struct GNUNET_DBUS_MethodContext *mc)
+{
+ DBusMessage *ret = dbus_message_new_method_return (mc->message);
+ //GNUNET_DBUS_message_set_pretty (ret,
GNUNET_DBUS_client_get_prefers_pretty_encodings (mc->client));
+ GNUNET_DBUS_message_set_pretty (ret, GNUNET_DBUS_message_get_pretty
(mc->message));
+ return ret;
+}
+
+
Copied: gnunet-dbus/src/lib/common/gnunet_dbus_lib_object.c (from rev 32345,
gnunet-dbus/src/lib/gnunet_dbus_lib_object.c)
===================================================================
--- gnunet-dbus/src/lib/common/gnunet_dbus_lib_object.c
(rev 0)
+++ gnunet-dbus/src/lib/common/gnunet_dbus_lib_object.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,113 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_container_lib.h>
+
+#include "gnunet_dbus_lib.h"
+
+#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-object", __VA_ARGS__)
+
+struct GNUNET_DBUS_Object
+{
+ struct GNUNET_DBUS_InterfaceIterator *interfaces_front;
+ struct GNUNET_DBUS_InterfaceIterator *interfaces_back;
+
+ char *path;
+ void *data;
+ unsigned ref_count;
+};
+
+struct GNUNET_DBUS_Object *
+GNUNET_DBUS_object_create (
+ const char *path,
+ void *data)
+{
+ struct GNUNET_DBUS_Object *object = GNUNET_new (struct GNUNET_DBUS_Object);
+ object->path = GNUNET_strdup (path);
+ object->data = data;
+ object->interfaces_front = NULL;
+ object->interfaces_back = NULL;
+ object->ref_count = 0;
+
+ return object;
+};
+
+void
+GNUNET_DBUS_object_destroy (
+ struct GNUNET_DBUS_Object *object)
+{
+ if (0 != object->ref_count)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to destroy object that still has
references. path == \"%s\", ref_count == %zu\n", object->path,
object->ref_count);
+ GNUNET_abort ();
+ };
+
+ struct GNUNET_DBUS_InterfaceIterator *int_it = object->interfaces_front;
+ while (int_it)
+ {
+ struct GNUNET_DBUS_InterfaceIterator *next = int_it->next;
+ GNUNET_DBUS_interface_unref (int_it->interface);
+ GNUNET_free (int_it);
+ int_it = next;
+ };
+
+ GNUNET_free (object->path);
+ GNUNET_free (object);
+};
+
+void
+GNUNET_DBUS_object_ref (
+ struct GNUNET_DBUS_Object *object)
+{
+ object->ref_count++;
+};
+
+void
+GNUNET_DBUS_object_unref (
+ struct GNUNET_DBUS_Object *object)
+{
+ if (object->ref_count == 0)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unreference object with ref count
0\n");
+ GNUNET_abort ();
+ };
+ if (--object->ref_count == 0)
+ GNUNET_DBUS_object_destroy (object);
+};
+
+const char *
+GNUNET_DBUS_object_get_path (
+ struct GNUNET_DBUS_Object *object)
+{
+ return object->path;
+};
+
+void
+GNUNET_DBUS_object_add_interface (
+ struct GNUNET_DBUS_Object *object,
+ struct GNUNET_DBUS_Interface *interface)
+{
+ struct GNUNET_DBUS_InterfaceIterator *int_it = GNUNET_new (struct
GNUNET_DBUS_InterfaceIterator);
+ int_it->interface = interface;
+ GNUNET_DBUS_interface_ref (interface);
+
+ GNUNET_CONTAINER_DLL_insert (object->interfaces_front,
+ object->interfaces_back,
+ int_it);
+};
+
+const struct GNUNET_DBUS_InterfaceIterator *
+GNUNET_DBUS_object_iterate_interfaces (
+ struct GNUNET_DBUS_Object *object)
+{
+ return object->interfaces_front;
+};
+
+void *
+GNUNET_DBUS_object_get_data (
+ struct GNUNET_DBUS_Object *object)
+{
+ return object->data;
+};
+
Added: gnunet-dbus/src/lib/common/gnunet_dbus_lib_pop.c
===================================================================
--- gnunet-dbus/src/lib/common/gnunet_dbus_lib_pop.c
(rev 0)
+++ gnunet-dbus/src/lib/common/gnunet_dbus_lib_pop.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,706 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_strings_lib.h>
+
+#include "gnunet_dbus_lib.h"
+
+#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-pop", __VA_ARGS__)
+
+static DBusMessage *
+pop_basic (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ int expected_type,
+ void *value)
+{
+ int arg_type = dbus_message_iter_get_arg_type (iter);
+ if (expected_type != arg_type)
+ {
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. Expected %s. Got %s",
+ arg_name,
+ GNUNET_DBUS_signature_typecode_to_string (expected_type),
+ GNUNET_DBUS_signature_typecode_to_string (arg_type));
+ };
+ dbus_message_iter_get_basic (iter, value);
+ dbus_message_iter_next (iter);
+
+ return NULL;
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_byte (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ unsigned char *value)
+{
+ return pop_basic (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_BYTE,
+ (void *)value);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_boolean (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ dbus_bool_t *value)
+{
+ return pop_basic (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_BOOLEAN,
+ (void *)value);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_int16 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ dbus_int16_t *value)
+{
+ return pop_basic (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_INT16,
+ (void *)value);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_uint16 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ dbus_uint16_t *value)
+{
+ return pop_basic (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_UINT16,
+ (void *)value);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_int32 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ dbus_int32_t *value)
+{
+ return pop_basic (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_INT32,
+ (void *)value);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_uint32 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ dbus_uint32_t *value)
+{
+ return pop_basic (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_UINT32,
+ (void *)value);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_int64 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ dbus_int64_t *value)
+{
+ return pop_basic (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_INT64,
+ (void *)value);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_uint64 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ dbus_uint64_t *value)
+{
+ return pop_basic (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_UINT64,
+ (void *)value);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_double (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ double *value)
+{
+ return pop_basic (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_DOUBLE,
+ (void *)value);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_string (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const char **value)
+{
+ return pop_basic (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_STRING,
+ (void *)value);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_object_path (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const char **value)
+{
+ return pop_basic (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_OBJECT_PATH,
+ (void *)value);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_signature (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const char **value)
+{
+ return pop_basic (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_SIGNATURE,
+ (void *)value);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_unix_fd (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ int *value)
+{
+ return pop_basic (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_UNIX_FD,
+ (void *)value);
+};
+
+static DBusMessage *
+pop_enter_container (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub,
+ int type,
+ const char *arg_name)
+{
+ int arg_type = dbus_message_iter_get_arg_type (iter);
+ if (type != arg_type)
+ {
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. Expected '%s'. Got '%s'",
+ arg_name,
+ GNUNET_DBUS_signature_typecode_to_string (type),
+ GNUNET_DBUS_signature_typecode_to_string (arg_type));
+ }
+ dbus_message_iter_recurse (iter, iter_sub);
+ dbus_message_iter_next (iter);
+ return NULL;
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_enter_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub,
+ const char *arg_name)
+{
+ return pop_enter_container (message, iter, iter_sub, DBUS_TYPE_ARRAY,
arg_name);
+}
+
+DBusMessage *
+GNUNET_DBUS_pop_enter_struct (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub,
+ const char *arg_name)
+{
+ return pop_enter_container (message, iter, iter_sub, DBUS_TYPE_STRUCT,
arg_name);
+}
+
+DBusMessage *
+GNUNET_DBUS_pop_enter_variant (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub,
+ const char *arg_name)
+{
+ return pop_enter_container (message, iter, iter_sub, DBUS_TYPE_VARIANT,
arg_name);
+}
+
+DBusMessage *
+GNUNET_DBUS_pop_enter_dict_entry (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub,
+ const char *arg_name)
+{
+ return pop_enter_container (message, iter, iter_sub, DBUS_TYPE_DICT_ENTRY,
arg_name);
+}
+
+static DBusMessage *
+pop_fixed_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ int expected_type,
+ void *value,
+ int *n_elements)
+{
+ int arg_type = dbus_message_iter_get_arg_type (iter);
+ if (DBUS_TYPE_ARRAY != arg_type)
+ {
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. Expected array of %s. Got %s.",
+ arg_name,
+ GNUNET_DBUS_signature_typecode_to_string (expected_type),
+ GNUNET_DBUS_signature_typecode_to_string (arg_type));
+ };
+
+ int element_type = dbus_message_iter_get_element_type (iter);
+ if (expected_type != element_type)
+ {
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. Expected array of %s. Got array of %s",
+ arg_name,
+ GNUNET_DBUS_signature_typecode_to_string (expected_type),
+ GNUNET_DBUS_signature_typecode_to_string (element_type));
+ };
+
+ DBusMessageIter iter_sub;
+ dbus_message_iter_recurse (iter, &iter_sub);
+ dbus_message_iter_get_fixed_array (&iter_sub, value, n_elements);
+ dbus_message_iter_next (iter);
+
+ return NULL;
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_byte_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const unsigned char **value,
+ int *n_elements)
+{
+ return pop_fixed_array (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_BYTE,
+ (void *)value,
+ n_elements);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_boolean_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const dbus_bool_t **value,
+ int *n_elements)
+{
+ return pop_fixed_array (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_BOOLEAN,
+ (void *)value,
+ n_elements);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_int16_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const int16_t **value,
+ int *n_elements)
+{
+ return pop_fixed_array (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_INT16,
+ (void *)value,
+ n_elements);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_uint16_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const uint16_t **value,
+ int *n_elements)
+{
+ return pop_fixed_array (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_UINT16,
+ (void *)value,
+ n_elements);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_int32_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const int32_t **value,
+ int *n_elements)
+{
+ return pop_fixed_array (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_INT32,
+ (void *)value,
+ n_elements);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_uint32_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const uint32_t **value,
+ int *n_elements)
+{
+ return pop_fixed_array (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_UINT32,
+ (void *)value,
+ n_elements);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_int64_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const int64_t **value,
+ int *n_elements)
+{
+ return pop_fixed_array (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_INT64,
+ (void *)value,
+ n_elements);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_uint64_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const uint64_t **value,
+ int *n_elements)
+{
+ return pop_fixed_array (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_UINT64,
+ (void *)value,
+ n_elements);
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_double_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const double **value,
+ int *n_elements)
+{
+ return pop_fixed_array (
+ message,
+ iter,
+ arg_name,
+ DBUS_TYPE_DOUBLE,
+ (void *)value,
+ n_elements);
+};
+
+/*
+ * bitfield enums can be sent across the wire in either their integer form (as
+ * an array of bit flags) or as an array of strings. Sending an int is more
+ * efficient and is what libraries built around the DBus API would use, people
+ * using the DBus API directly may want to pass human-readable strings for
+ * convenience.
+ */
+DBusMessage *
+GNUNET_DBUS_pop_bitfield (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ int *value,
+ const struct GNUNET_DBUS_StringEnumPair *fields)
+{
+ DBusMessageIter iter_sub;
+ DBusMessage *ret = GNUNET_DBUS_pop_enter_variant (message, iter, &iter_sub,
arg_name);
+ if (ret)
+ return ret;
+
+ int arg_type = dbus_message_iter_get_arg_type (&iter_sub);
+ switch (arg_type)
+ {
+ case DBUS_TYPE_ARRAY: {
+ int element_type = dbus_message_iter_get_element_type (&iter_sub);
+ if (DBUS_TYPE_STRING != element_type)
+ {
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. Variant should contain a uint32 or an array
of strings.",
+ arg_name);
+ };
+ DBusMessageIter iter_sub_sub;
+ dbus_message_iter_recurse (&iter_sub, &iter_sub_sub);
+ *value = 0;
+ while (dbus_message_iter_get_arg_type (&iter_sub_sub) != DBUS_TYPE_INVALID)
+ {
+ char *option;
+ dbus_message_iter_get_basic (&iter_sub_sub, &option);
+ const struct GNUNET_DBUS_StringEnumPair *field;
+ for (field = fields; field->name; field++)
+ {
+ if (! strcmp (field->name, option))
+ {
+ *value |= field->value;
+ break;
+ };
+ };
+ if (! field->name)
+ {
+ char *errmsg;
+ GNUNET_asprintf (&errmsg, "Bad argument for '%s'. Unrecognised option
'%s'. Valid options are [", arg_name, option);
+ for (field = fields; field->name; field++)
+ {
+ char *errmsg_new;
+ GNUNET_asprintf (&errmsg_new, "%s'%s'%s", errmsg, field->name,
(field + 1)->name ? ", " : "].");
+ GNUNET_free (errmsg);
+ errmsg = errmsg_new;
+ };
+ DBusMessage *ret = dbus_message_new_error (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ errmsg);
+ GNUNET_free (errmsg);
+ return ret;
+ };
+ dbus_message_iter_next (&iter_sub_sub);
+ };
+ GNUNET_DBUS_message_set_pretty (message, true);
+ return NULL;
+ };
+ case DBUS_TYPE_UINT32: {
+ uint32_t flags;
+ dbus_message_iter_get_basic (&iter_sub, &flags);
+ *value = (int)flags;
+ return NULL;
+ };
+ default:
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. Variant contains a %s. Should contain a uint32
or array of strings.",
+ arg_name);
+ };
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_enum (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ int *value,
+ const struct GNUNET_DBUS_StringEnumPair *names)
+{
+ DBusMessageIter iter_sub;
+ DBusMessage *ret = GNUNET_DBUS_pop_enter_variant (message, iter, &iter_sub,
arg_name);
+ if (ret)
+ return ret;
+
+ int arg_type = dbus_message_iter_get_arg_type (&iter_sub);
+ switch (arg_type)
+ {
+ case DBUS_TYPE_STRING: {
+ char *option;
+ dbus_message_iter_get_basic (&iter_sub, &option);
+ const struct GNUNET_DBUS_StringEnumPair *name;
+ for (name = names; name->name; name++)
+ {
+ if (! strcmp (name->name, option))
+ {
+ *value = name->value;
+ return NULL;
+ };
+ };
+ char *errmsg;
+ GNUNET_asprintf (&errmsg, "Bad argument for '%s'. Unrecognised option
'%s'. Valid options are [", arg_name, option);
+ for (name = names; name->name; name++)
+ {
+ char *errmsg_new;
+ GNUNET_asprintf (&errmsg_new, "%s'%s'%s", errmsg, name->name, (name +
1)->name ? ", " : "].");
+ GNUNET_free (errmsg);
+ errmsg = errmsg_new;
+ };
+
+ DBusMessage *ret = dbus_message_new_error (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ errmsg);
+ GNUNET_free (errmsg);
+ return ret;
+ };
+ case DBUS_TYPE_UINT32: {
+ uint32_t option;
+ dbus_message_iter_get_basic (&iter_sub, &option);
+ *value = (int)option;
+ return NULL;
+ };
+ default:
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. Variant contains a %s. Should contain a uint32
or strings.",
+ arg_name,
+ GNUNET_DBUS_signature_typecode_to_string (arg_type));
+ };
+};
+
+DBusMessage *
+GNUNET_DBUS_pop_hashcode (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ struct GNUNET_HashCode *value)
+{
+ DBusMessageIter iter_sub;
+ DBusMessage *ret = GNUNET_DBUS_pop_enter_variant (message, iter, &iter_sub,
arg_name);
+ if (ret)
+ return ret;
+
+ int arg_type = dbus_message_iter_get_arg_type (&iter_sub);
+ switch (arg_type)
+ {
+ case DBUS_TYPE_STRING: {
+ char *encoded;
+ dbus_message_iter_get_basic (&iter_sub, &encoded);
+ int success = GNUNET_CRYPTO_hash_from_string2 (encoded, strlen (encoded),
value);
+ if (GNUNET_OK != success)
+ {
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. Malformed hash string.
GNUNET_CRYPTO_hash_from_string2 returned %d",
+ arg_name,
+ success);
+ };
+ GNUNET_DBUS_message_set_pretty (message, true);
+ return NULL;
+ }
+ case DBUS_TYPE_ARRAY: {
+ DBusMessageIter iter_sub_sub;
+ unsigned char *data;
+ int n_elements;
+ int element_type = dbus_message_iter_get_element_type (&iter_sub);
+ if (DBUS_TYPE_BYTE != element_type)
+ {
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. Variant contains an array of %s. Should
contain a base32 encoded string or array of 64 bytes.",
+ arg_name,
+ GNUNET_DBUS_signature_typecode_to_string (element_type));
+ };
+ dbus_message_iter_recurse (&iter_sub, &iter_sub_sub);
+ dbus_message_iter_get_fixed_array (&iter_sub_sub, &data, &n_elements);
+ if (sizeof (value->bits) != n_elements)
+ {
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. Hash code consists of 64 bytes (512 bits).
Array contains %d bytes.",
+ arg_name,
+ n_elements);
+ };
+ memcpy (value->bits, data, n_elements);
+ return NULL;
+ };
+ default:
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. Variant contains a %s. Should contain a base32
encoded string or array of 64 bytes.",
+ arg_name,
+ GNUNET_DBUS_signature_typecode_to_string (arg_type));
+ };
+}
+
+
Added: gnunet-dbus/src/lib/common/gnunet_dbus_lib_push.c
===================================================================
--- gnunet-dbus/src/lib/common/gnunet_dbus_lib_push.c
(rev 0)
+++ gnunet-dbus/src/lib/common/gnunet_dbus_lib_push.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,494 @@
+#include "config.h"
+
+#include <stdbool.h>
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_strings_lib.h>
+
+#include "gnunet_dbus_lib.h"
+
+#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-push", __VA_ARGS__)
+
+static void
+push_basic (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ int type,
+ const void *value)
+{
+ (void)message;
+ bool success = dbus_message_iter_append_basic (iter, type, value);
+ if (! success)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Ran out of memory in
dbus_message_iter_append_basic\n");
+ GNUNET_abort ();
+ }
+}
+
+void
+GNUNET_DBUS_push_byte (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const unsigned char *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing byte\n");
+ push_basic (message, iter, DBUS_TYPE_BYTE, value);
+}
+
+void
+GNUNET_DBUS_push_boolean (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_bool_t *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing boolean\n");
+ push_basic (message, iter, DBUS_TYPE_BOOLEAN, value);
+}
+
+void
+GNUNET_DBUS_push_int16 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_int16_t *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing int16\n");
+ push_basic (message, iter, DBUS_TYPE_INT16, value);
+}
+
+void
+GNUNET_DBUS_push_uint16 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_uint16_t *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing uint16\n");
+ push_basic (message, iter, DBUS_TYPE_UINT16, value);
+}
+
+void
+GNUNET_DBUS_push_int32 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_int32_t *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing int32\n");
+ push_basic (message, iter, DBUS_TYPE_INT32, value);
+}
+
+void
+GNUNET_DBUS_push_uint32 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_uint32_t *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing uint32\n");
+ push_basic (message, iter, DBUS_TYPE_UINT32, value);
+}
+
+void
+GNUNET_DBUS_push_int64 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_int64_t *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing int64\n");
+ push_basic (message, iter, DBUS_TYPE_INT64, value);
+}
+
+void
+GNUNET_DBUS_push_uint64 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_uint64_t *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing uint64\n");
+ push_basic (message, iter, DBUS_TYPE_UINT64, value);
+}
+
+void
+GNUNET_DBUS_push_double (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const double *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing double\n");
+ push_basic (message, iter, DBUS_TYPE_DOUBLE, value);
+}
+
+void
+GNUNET_DBUS_push_string (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *const *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing string\n");
+ push_basic (message, iter, DBUS_TYPE_STRING, value);
+}
+
+void
+GNUNET_DBUS_push_object_path (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *const *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing object path\n");
+ push_basic (message, iter, DBUS_TYPE_OBJECT_PATH, value);
+}
+
+void
+GNUNET_DBUS_push_signature (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *const *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing signature\n");
+ push_basic (message, iter, DBUS_TYPE_SIGNATURE, value);
+}
+
+void
+GNUNET_DBUS_push_unix_fd (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const int *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing unix fd\n");
+ push_basic (message, iter, DBUS_TYPE_UNIX_FD, value);
+}
+
+static void
+push_open_container (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub,
+ int type,
+ const char *signature)
+{
+ (void)message;
+ bool success = dbus_message_iter_open_container (iter, type, signature,
iter_sub);
+ if (! success)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Ran out of memory in
dbus_message_iter_open_container\n");
+ GNUNET_abort ();
+ }
+}
+
+void
+GNUNET_DBUS_push_open_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub,
+ const char *signature)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Opening array\n");
+ push_open_container (message, iter, iter_sub, DBUS_TYPE_ARRAY, signature);
+}
+
+void
+GNUNET_DBUS_push_open_struct (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Opening struct\n");
+ push_open_container (message, iter, iter_sub, DBUS_TYPE_STRUCT, NULL);
+}
+
+void
+GNUNET_DBUS_push_open_variant (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub,
+ const char *signature)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Opening variant\n");
+ push_open_container (message, iter, iter_sub, DBUS_TYPE_VARIANT, signature);
+}
+
+void
+GNUNET_DBUS_push_open_dict_entry (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Opening dict entry\n");
+ push_open_container (message, iter, iter_sub, DBUS_TYPE_DICT_ENTRY, NULL);
+}
+
+static void
+push_close_container (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub)
+{
+ (void)message;
+ bool success = dbus_message_iter_close_container (iter, iter_sub);
+ if (! success)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Ran out of memory in
dbus_message_iter_close_container\n");
+ GNUNET_abort ();
+ }
+}
+
+void
+GNUNET_DBUS_push_close_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing array\n");
+ push_close_container (message, iter, iter_sub);
+}
+
+void
+GNUNET_DBUS_push_close_struct (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing struct\n");
+ push_close_container (message, iter, iter_sub);
+}
+
+void
+GNUNET_DBUS_push_close_variant (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing variant\n");
+ push_close_container (message, iter, iter_sub);
+}
+
+void
+GNUNET_DBUS_push_close_dict_entry (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing dict entry\n");
+ push_close_container (message, iter, iter_sub);
+}
+
+static void
+push_fixed_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ int type,
+ const void *value,
+ size_t value_count)
+{
+ char sig[2] = { (char)type, '\0' };
+ DBusMessageIter iter_sub;
+
+ GNUNET_DBUS_push_open_array (message, iter, &iter_sub, sig);
+ bool success = dbus_message_iter_append_fixed_array (&iter_sub, type, value,
(int)value_count);
+ if (! success)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Ran out of memory in
dbus_message_iter_push_fixed_array\n");
+ GNUNET_abort ();
+ }
+ GNUNET_DBUS_push_close_array (message, iter, &iter_sub);
+}
+
+void
+GNUNET_DBUS_push_byte_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const unsigned char *value,
+ size_t value_count)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing byte array\n");
+ push_fixed_array (message, iter, DBUS_TYPE_BYTE, &value, value_count);
+}
+
+void
+GNUNET_DBUS_push_boolean_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_bool_t *value,
+ size_t value_count)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing boolean array\n");
+ push_fixed_array (message, iter, DBUS_TYPE_BOOLEAN, &value, value_count);
+}
+
+void
+GNUNET_DBUS_push_int16_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_int16_t *value,
+ size_t value_count)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing int16 array\n");
+ push_fixed_array (message, iter, DBUS_TYPE_INT16, &value, value_count);
+}
+
+void
+GNUNET_DBUS_push_uint16_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_uint16_t *value,
+ size_t value_count)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing uint16 array\n");
+ push_fixed_array (message, iter, DBUS_TYPE_UINT16, &value, value_count);
+}
+
+void
+GNUNET_DBUS_push_int32_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const unsigned char *value,
+ size_t value_count)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing int32 array\n");
+ push_fixed_array (message, iter, DBUS_TYPE_INT32, &value, value_count);
+}
+
+void
+GNUNET_DBUS_push_uint32_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const unsigned char *value,
+ size_t value_count)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing uint32 array\n");
+ push_fixed_array (message, iter, DBUS_TYPE_UINT32, &value, value_count);
+}
+
+void
+GNUNET_DBUS_push_int64_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const unsigned char *value,
+ size_t value_count)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing int64 array\n");
+ push_fixed_array (message, iter, DBUS_TYPE_INT64, &value, value_count);
+}
+
+void
+GNUNET_DBUS_push_uint64_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const unsigned char *value,
+ size_t value_count)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing uint64 array\n");
+ push_fixed_array (message, iter, DBUS_TYPE_UINT64, &value, value_count);
+}
+
+void
+GNUNET_DBUS_push_double_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const unsigned char *value,
+ size_t value_count)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing double array\n");
+ push_fixed_array (message, iter, DBUS_TYPE_DOUBLE, &value, value_count);
+}
+
+void
+GNUNET_DBUS_push_bitfield (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const int *value,
+ const struct GNUNET_DBUS_StringEnumPair *fields)
+{
+ DBusMessageIter iter_sub;
+ if (GNUNET_DBUS_message_get_pretty (message))
+ {
+ DBusMessageIter iter_sub_sub;
+
+ GNUNET_DBUS_push_open_variant (message, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_ARRAY (GNUNET_DBUS_SIGNATURE_STRING));
+ GNUNET_DBUS_push_open_array (message, &iter_sub, &iter_sub_sub,
GNUNET_DBUS_SIGNATURE_STRING);
+ const struct GNUNET_DBUS_StringEnumPair *field;
+ for (field = fields; field->name; field++)
+ {
+ if ((*value & field->value) == field->value)
+ GNUNET_DBUS_push_string (message, &iter_sub_sub, &field->name);
+ };
+ GNUNET_DBUS_push_close_array (message, &iter_sub, &iter_sub_sub);
+ GNUNET_DBUS_push_close_variant (message, iter, &iter_sub);
+ }
+ else
+ {
+ uint32_t push_value = (uint32_t)*value;
+ GNUNET_DBUS_push_open_variant (message, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_UINT32);
+ GNUNET_DBUS_push_uint32 (message, &iter_sub, &push_value);
+ GNUNET_DBUS_push_close_variant (message, iter, &iter_sub);
+ };
+};
+
+void
+GNUNET_DBUS_push_enum (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const int *value,
+ const struct GNUNET_DBUS_StringEnumPair *names)
+{
+ DBusMessageIter iter_sub;
+ if (GNUNET_DBUS_message_get_pretty (message))
+ {
+ GNUNET_DBUS_push_open_variant (message, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_STRING);
+ const struct GNUNET_DBUS_StringEnumPair *name;
+ for (name = names; name->name; name++)
+ {
+ if (name->value == *value)
+ {
+ GNUNET_DBUS_push_string (message, &iter_sub, &name->name);
+ break;
+ }
+ }
+ GNUNET_DBUS_push_close_variant (message, iter, &iter_sub);
+ }
+ else
+ {
+ uint32_t push_value = (uint32_t)*value;
+ GNUNET_DBUS_push_open_variant (message, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_UINT32);
+ GNUNET_DBUS_push_uint32 (message, &iter_sub, &push_value);
+ GNUNET_DBUS_push_close_variant (message, iter, &iter_sub);
+ };
+};
+
+void
+GNUNET_DBUS_push_data (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const void *value,
+ size_t value_size)
+{
+ DBusMessageIter iter_sub;
+ if (GNUNET_DBUS_message_get_pretty (message))
+ {
+ size_t string_size = (value_size * 8 + 4) / 5 + 1;
+ char *string = GNUNET_malloc (string_size);
+ char *end = GNUNET_STRINGS_data_to_string (value, value_size, string,
string_size);
+ *end = '\0';
+ const char *string_const = string;
+
+ GNUNET_DBUS_push_open_variant (message, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_STRING);
+ GNUNET_DBUS_push_string (message, &iter_sub, &string_const);
+ GNUNET_DBUS_push_close_variant (message, iter, &iter_sub);
+ GNUNET_free (string);
+ }
+ else
+ {
+ GNUNET_DBUS_push_open_variant (message, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_ARRAY (GNUNET_DBUS_SIGNATURE_BYTE));
+ GNUNET_DBUS_push_byte_array (message, &iter_sub, value, value_size);
+ GNUNET_DBUS_push_close_variant (message, iter, &iter_sub);
+ };
+}
+
+void
+GNUNET_DBUS_push_hashcode (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const struct GNUNET_HashCode *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing GNUNET_HashCode\n");
+ GNUNET_DBUS_push_data (message, iter, value->bits, sizeof (value->bits));
+}
+
Copied: gnunet-dbus/src/lib/common/gnunet_dbus_lib_service.c (from rev 32345,
gnunet-dbus/src/lib/gnunet_dbus_lib_service.c)
===================================================================
--- gnunet-dbus/src/lib/common/gnunet_dbus_lib_service.c
(rev 0)
+++ gnunet-dbus/src/lib/common/gnunet_dbus_lib_service.c 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,555 @@
+#include "config.h"
+
+#include <stdbool.h>
+#include <dbus/dbus.h>
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_scheduler_lib.h>
+#include <gnunet/gnunet_container_lib.h>
+
+#include "gnunet_dbus_lib.h"
+
+#include "watch.h"
+#include "timeout.h"
+
+#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-service", __VA_ARGS__)
+
+struct GNUNET_DBUS_Service
+{
+ struct GNUNET_DBUS_ObjectIterator *objects_front;
+ struct GNUNET_DBUS_ObjectIterator *objects_back;
+
+ DBusConnection *dbus_connection;
+ const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+ char *gnunet_name;
+ char *well_known_name;
+
+ /*
+ * Linked list of watches
+ */
+ struct WatchIter *watches_front;
+ struct WatchIter *watches_back;
+
+ /*
+ * Linked list of timeouts
+ */
+ struct TimeoutIter *timeouts_front;
+ struct TimeoutIter *timeouts_back;
+
+ /*
+ * Linked list of clients
+ */
+ struct GNUNET_DBUS_ClientIterator *clients_front;
+ struct GNUNET_DBUS_ClientIterator *clients_back;
+
+ GNUNET_DBUS_ClientConnectsHandler client_connects;
+ GNUNET_DBUS_ClientDisconnectsHandler client_disconnects;
+};
+
+static dbus_int32_t service_slot_id ()
+{
+ static dbus_int32_t id = -1;
+ if (-1 == id)
+ {
+ dbus_bool_t succ = dbus_connection_allocate_data_slot (&id);
+ if (! succ || -1 == id)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "dbus_connection_allocate_data_slot
failed. id == %lld\n", (long long)id);
+ GNUNET_abort ();
+ };
+ };
+
+ return id;
+};
+
+/*
+ * Called by DBus when it has a new watch that it wants us to watch.
+ *
+ * @param watch The DBus watch, created and passed to us by DBus.
+ * @param data the GNUNET_DBUS_Service we passed to
dbus_connection_set_watch_functions
+ * @return true on success, false on an unrecoverable error.
+ */
+static dbus_bool_t
+watch_add (
+ DBusWatch *watch,
+ void *data)
+{
+ struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
+ struct Watch *w = watch_create (watch);
+
+ if (dbus_watch_get_enabled (watch))
+ watch_schedule (w);
+
+ struct WatchIter *wi = GNUNET_new (struct WatchIter);
+ wi->w = w;
+ GNUNET_CONTAINER_DLL_insert (service->watches_front,
+ service->watches_back,
+ wi);
+ watch_ref (w);
+ return true;
+};
+
+/*
+ * Called by DBus when it want to permanently disable and remove a watch
+ *
+ * @param watch The DBus watch, passed to us by DBus.
+ * @param data the GNUNET_DBUS_Service we passed to
dbus_connection_set_watch_functions
+ */
+static void
+watch_remove (
+ DBusWatch *watch,
+ void *data)
+{
+ struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
+ struct WatchIter *wi = watch_find (service->watches_front, watch);
+
+ if (NULL == wi)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Asked to remove watch that has not been
added\n");
+ GNUNET_abort ();
+ };
+
+ struct Watch *w = wi->w;
+ watch_unschedule (w);
+ GNUNET_CONTAINER_DLL_remove (service->watches_front,
+ service->watches_back,
+ wi);
+ watch_unref (w);
+};
+
+/*
+ * Called by DBus when it wants to enable or disable a watch.
+ * Schedules or unschedules the scheduler to monitor this watch as appropriate.
+ *
+ * @param watch The DBus watch, passed to us by DBus.
+ * @param data the GNUNET_DBUS_Service we passed to
dbus_connection_set_watch_functions
+ */
+static void
+watch_toggle (
+ DBusWatch *watch,
+ void *data)
+{
+ struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
+ struct WatchIter *wi = watch_find (service->watches_front, watch);
+
+ if (NULL == wi)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Asked to toggle watch that has not been
added\n");
+ GNUNET_abort ();
+ };
+
+ struct Watch *w = wi->w;
+ if (dbus_watch_get_enabled (watch))
+ watch_unschedule (w);
+ else
+ watch_schedule (w);
+};
+
+static dbus_bool_t
+timeout_add (
+ DBusTimeout *timeout,
+ void *data)
+{
+ struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
+ struct Timeout *t = timeout_create (timeout);
+
+ if (dbus_timeout_get_enabled (timeout))
+ timeout_schedule (t);
+
+ struct TimeoutIter *ti = GNUNET_new (struct TimeoutIter);
+ ti->t = t;
+ GNUNET_CONTAINER_DLL_insert (service->timeouts_front,
+ service->timeouts_back,
+ ti);
+ timeout_ref (t);
+ return true;
+};
+
+static void
+timeout_remove (
+ DBusTimeout *timeout,
+ void *data)
+{
+ struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
+ struct TimeoutIter *ti = timeout_find (service->timeouts_front, timeout);
+
+ if (NULL == ti)
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Asked to remove timeout that has not been
added\n");
+ return;
+ };
+
+ struct Timeout *t = ti->t;
+ timeout_unschedule (t);
+ GNUNET_CONTAINER_DLL_remove (service->timeouts_front,
+ service->timeouts_back,
+ ti);
+ timeout_unref (t);
+};
+
+static void
+timeout_toggle (
+ DBusTimeout *timeout,
+ void *data)
+{
+ struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
+ struct TimeoutIter *ti = timeout_find (service->timeouts_front, timeout);
+
+ if (NULL == ti)
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING, "asked to toggle timeout that has not been
added\n");
+ return;
+ };
+
+ struct Timeout *t = ti->t;
+ if (dbus_timeout_get_enabled (timeout))
+ timeout_unschedule (t);
+ else
+ timeout_schedule (t);
+};
+
+static void
+dispatch (
+ void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc);
+
+static void
+handle_dispatch (
+ DBusConnection *dbus_connection,
+ DBusDispatchStatus status)
+{
+ switch (status)
+ {
+ case DBUS_DISPATCH_DATA_REMAINS:
+ GNUNET_SCHEDULER_add_continuation (
+ dispatch,
+ dbus_connection,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ break;
+ case DBUS_DISPATCH_COMPLETE:
+ break;
+ case DBUS_DISPATCH_NEED_MEMORY:
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Out of memory!\n");
+ GNUNET_abort ();
+ break;
+ default:
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Unrecognized dispatch status\n");
+ break;
+ };
+};
+
+static void
+dispatch (
+ void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct DBusConnection *dbus_connection = (struct DBusConnection *)cls;
+ dbus_connection_dispatch (dbus_connection);
+ handle_dispatch (dbus_connection, dbus_connection_get_dispatch_status
(dbus_connection));
+};
+
+static void
+dispatch_status_changed (
+ DBusConnection *dbus_connection,
+ DBusDispatchStatus new_status,
+ void *data)
+{
+ (void)data;
+ handle_dispatch (dbus_connection, new_status);
+};
+
+struct GNUNET_DBUS_Service *
+GNUNET_DBUS_service_create (
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *name)
+{
+ struct GNUNET_DBUS_Service *service = GNUNET_new (struct
GNUNET_DBUS_Service);
+ service->cfg = cfg;
+ service->gnunet_name = GNUNET_strdup (name);
+ service->watches_front = NULL;
+ service->watches_back = NULL;
+ service->timeouts_front = NULL;
+ service->timeouts_back = NULL;
+ service->objects_front = NULL;
+ service->objects_back = NULL;
+ service->client_connects = NULL;
+ service->client_disconnects = NULL;
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ service->dbus_connection = dbus_bus_get_private (DBUS_BUS_SYSTEM, &err);
+ if (! service->dbus_connection)
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to connect to dbus system bus
(%s)\n", dbus_error_is_set (&err) ? err.message : "dbus_bus_get_private
returned NULL");
+ else
+ {
+ dbus_connection_set_exit_on_disconnect (service->dbus_connection,
+ false);
+ dbus_bool_t succ = dbus_connection_set_data (service->dbus_connection,
+ service_slot_id (),
+ service,
+ NULL);
+ if (! succ)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "dbus_connection_set_data returned false.
Out of memory.\n");
+ GNUNET_abort ();
+ };
+
+ succ = dbus_connection_set_watch_functions (service->dbus_connection,
watch_add, watch_remove, watch_toggle, service, NULL);
+ if(! succ)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "dbus_connection_set_watch_functions
returned false. Out of memory.\n");
+ GNUNET_abort ();
+ };
+
+ dbus_connection_set_dispatch_status_function (service->dbus_connection,
dispatch_status_changed, service, NULL);
+ handle_dispatch (service->dbus_connection,
dbus_connection_get_dispatch_status (service->dbus_connection));
+
+ succ = dbus_connection_set_timeout_functions (service->dbus_connection,
timeout_add, timeout_remove, timeout_toggle, service, NULL);
+ if (! succ)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "dbus_connection_set_timeout_functions
returned false. Out of memory.\n");
+ GNUNET_abort ();
+ };
+
+ service->well_known_name = NULL;
+ GNUNET_asprintf (&service->well_known_name, "gnu.gnunet.%s", name);
+ int request_result = dbus_bus_request_name (service->dbus_connection,
service->well_known_name, DBUS_NAME_FLAG_DO_NOT_QUEUE, &err);
+ if (dbus_error_is_set (&err))
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to request the bus name (%s)\n",
err.message);
+ else
+ {
+ switch(request_result)
+ {
+ case DBUS_REQUEST_NAME_REPLY_EXISTS:
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to request the bus name \"%s\";
name is already taken.\n", service->well_known_name);
+ break;
+ default:
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Unable to interpret result of
dbus_request_name (%d)\n", request_result);
+ break;
+ case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
+
+ /* Success! */
+ return service;
+
+ }
+ }
+ dbus_connection_close (service->dbus_connection);
+ dbus_connection_unref (service->dbus_connection);
+ }
+ GNUNET_free (service->well_known_name);
+ GNUNET_free (service->gnunet_name);
+ GNUNET_free (service);
+ LOG (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DBUS_service create failed.\n");
+ return NULL;
+};
+
+void
+GNUNET_DBUS_service_destroy (
+ struct GNUNET_DBUS_Service *service)
+{
+ struct GNUNET_DBUS_ObjectIterator *objects_it = service->objects_front;
+ while (objects_it)
+ {
+ struct GNUNET_DBUS_ObjectIterator *next = objects_it->next;
+ GNUNET_DBUS_object_unref (objects_it->object);
+ GNUNET_free (objects_it);
+ objects_it = next;
+ };
+
+ GNUNET_free (service->well_known_name);
+ GNUNET_free (service->gnunet_name);
+ GNUNET_free (service);
+};
+
+const struct GNUNET_CONFIGURATION_Handle *
+GNUNET_DBUS_service_get_config (
+ struct GNUNET_DBUS_Service *service)
+{
+ return service->cfg;
+};
+
+/*
+ * Called whenever a message arrives from DBus
+ *
+ * @param conn The connection it arrived on.
+ * @param message The message
+ * @param cls The closure passed to dbus_connection_try_register_object_path
+ * in our case this is the GNUNET_DBUS_Object that the message was
+ * sent to.
+ *
+ * @return DBUS_HANDLER_RESULT_NEED_MEMORY if anything failed due to lack of
+ * memory.
+ * DBUS_HANDLER_RESULT_HANDLED if any method returned a reply.
+ * DBUS_HANDLER_RESULT_NOT_YET_HANDLED otherwise.
+ */
+DBusHandlerResult
+handle_object_message (
+ DBusConnection *connection,
+ DBusMessage *dbus_message,
+ void *cls)
+{
+ struct GNUNET_DBUS_Object *object = (struct GNUNET_DBUS_Object *)cls;
+
+ const char *object_path = dbus_message_get_path (dbus_message);
+ const char *type_string = dbus_message_type_to_string
(dbus_message_get_type (dbus_message));
+ const char *interface_name = dbus_message_get_interface (dbus_message);
+ const char *member_name = dbus_message_get_member (dbus_message);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Recieved DBus message for %s\n", object_path);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " type == %s\n", type_string ?
type_string : "(none)");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " interface == %s\n", interface_name ?
interface_name : "(none)");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " member == %s\n", member_name ?
member_name : "(none)");
+
+ struct GNUNET_DBUS_Service *service = dbus_connection_get_data (connection,
service_slot_id ());
+
+ const char *unique_name = dbus_message_get_sender (dbus_message);
+ struct GNUNET_DBUS_ClientIterator *client_it = service->clients_front;
+ struct GNUNET_DBUS_Client *client = NULL;
+ for (; client_it; client_it = client_it->next)
+ {
+ client = client_it->client;
+ const char *this_unique_name = GNUNET_DBUS_client_get_unique_name (client);
+ if (! strcmp (unique_name, this_unique_name))
+ break;
+ };
+ if (! client_it)
+ {
+ client = GNUNET_DBUS_client_create (unique_name);
+ client_it = GNUNET_new (struct GNUNET_DBUS_ClientIterator);
+ client_it->client = client;
+ GNUNET_CONTAINER_DLL_insert (service->clients_front,
+ service->clients_back,
+ client_it);
+ if (service->client_connects)
+ service->client_connects (service, client);
+ /*
+
+ ** TODO **
+
+ detect when a client is no longer on the bus and
+ destroy the client object. At the moment this will slowly
+ leak memory as clients come and go.
+
+ */
+ };
+
+ if (! member_name)
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+ if (! interface_name)
+ interface_name = service->well_known_name;
+
+ int dbus_message_type = dbus_message_get_type (dbus_message);
+ if (dbus_message_type != DBUS_MESSAGE_TYPE_METHOD_CALL)
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+ const struct GNUNET_DBUS_InterfaceIterator *int_it = \
+ GNUNET_DBUS_interface_find ( \
+ GNUNET_DBUS_object_iterate_interfaces (object),
+ interface_name);
+ if (! int_it)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "No such interface: %s\n", interface_name);
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ };
+ struct GNUNET_DBUS_Interface *interface = int_it->interface;
+
+ const struct GNUNET_DBUS_MethodIterator *meth_it = \
+ GNUNET_DBUS_method_find ( \
+ GNUNET_DBUS_interface_iterate_methods (interface),
+ member_name);
+ if (! meth_it)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "No such method: %s\n", member_name);
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ };
+ struct GNUNET_DBUS_Method *method = meth_it->method;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Found method.\n");
+
+ struct GNUNET_DBUS_MethodContext *mc = GNUNET_DBUS_method_context_create (
+ client,
+ service,
+ object,
+ interface,
+ method,
+ dbus_message
+ );
+ GNUNET_DBUS_method_context_ref (mc);
+ GNUNET_DBUS_method_call (method, mc);
+ GNUNET_DBUS_method_context_unref (mc);
+ return DBUS_HANDLER_RESULT_HANDLED;
+};
+
+int
+GNUNET_DBUS_service_add_object (
+ struct GNUNET_DBUS_Service *service,
+ struct GNUNET_DBUS_Object *object)
+{
+ DBusError err;
+ dbus_error_init(&err);
+
+ const char *path = GNUNET_DBUS_object_get_path (object);
+
+ DBusObjectPathVTable vtable;
+ vtable.message_function = handle_object_message;
+ vtable.unregister_function = NULL;
+ dbus_bool_t succ = dbus_connection_try_register_object_path (
+ service->dbus_connection,
+ path,
+ &vtable,
+ object,
+ &err);
+ if (dbus_error_is_set (&err))
+ {
+ LOG (
+ GNUNET_ERROR_TYPE_ERROR,
+ "dbus_connection_try_register failed to register path \"%s\": %s\n",
+ path,
+ err.message);
+ return GNUNET_SYSERR;
+ };
+ if (! succ)
+ {
+ LOG (
+ GNUNET_ERROR_TYPE_ERROR,
+ "dbus_connection_try_register returned false when registering path
\"%s\"\n",
+ path);
+ return GNUNET_SYSERR;
+ };
+
+ struct GNUNET_DBUS_ObjectIterator *object_it = GNUNET_new (struct
GNUNET_DBUS_ObjectIterator);
+ object_it->object = object;
+ GNUNET_DBUS_object_ref (object);
+ GNUNET_CONTAINER_DLL_insert (service->objects_front,
+ service->objects_back,
+ object_it);
+
+ return GNUNET_OK;
+};
+
+void
+GNUNET_DBUS_service_send (
+ struct GNUNET_DBUS_Service *service,
+ DBusMessage *dbus_message)
+{
+ dbus_bool_t succ = dbus_connection_send (service->dbus_connection,
dbus_message, NULL);
+ if (! succ)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "dbus_connection_send failed. Out of
memory.\n");
+ GNUNET_abort ();
+ };
+};
+
+void
+GNUNET_DBUS_service_set_client_handlers (
+ struct GNUNET_DBUS_Service *service,
+ GNUNET_DBUS_ClientConnectsHandler client_connects,
+ GNUNET_DBUS_ClientDisconnectsHandler client_disconnects)
+{
+ service->client_connects = client_connects;
+ service->client_disconnects = client_disconnects;
+};
+
Copied: gnunet-dbus/src/lib/common/gnunet_dbus_lib_signature.c (from rev 32345,
gnunet-dbus/src/lib/gnunet_dbus_lib_signature.c)
===================================================================
--- gnunet-dbus/src/lib/common/gnunet_dbus_lib_signature.c
(rev 0)
+++ gnunet-dbus/src/lib/common/gnunet_dbus_lib_signature.c 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,60 @@
+#include "config.h"
+
+#include "gnunet_dbus_lib.h"
+
+const char *
+GNUNET_DBUS_signature_typecode_to_string (
+ int typecode)
+{
+ switch (typecode)
+ {
+ case DBUS_TYPE_INVALID:
+ return "nothing";
+ case DBUS_TYPE_BOOLEAN:
+ return "boolean";
+ case DBUS_TYPE_BYTE:
+ return "byte";
+ case DBUS_TYPE_INT16:
+ return "int16";
+ case DBUS_TYPE_UINT16:
+ return "uint16";
+ case DBUS_TYPE_INT32:
+ return "int32";
+ case DBUS_TYPE_UINT32:
+ return "uint32";
+ case DBUS_TYPE_INT64:
+ return "int64";
+ case DBUS_TYPE_UINT64:
+ return "uint64";
+ case DBUS_TYPE_DOUBLE:
+ return "double";
+ case DBUS_TYPE_STRING:
+ return "string";
+ case DBUS_TYPE_OBJECT_PATH:
+ return "object_path";
+ case DBUS_TYPE_SIGNATURE:
+ return "signature";
+ case DBUS_TYPE_STRUCT:
+ return "struct";
+ case DBUS_TYPE_DICT_ENTRY:
+ return "dict_entry";
+ case DBUS_TYPE_ARRAY:
+ return "array";
+ case DBUS_TYPE_VARIANT:
+ return "variant";
+ case DBUS_STRUCT_BEGIN_CHAR:
+ return "begin_struct";
+ case DBUS_STRUCT_END_CHAR:
+ return "end_struct";
+ case DBUS_DICT_ENTRY_BEGIN_CHAR:
+ return "begin_dict_entry";
+ case DBUS_DICT_ENTRY_END_CHAR:
+ return "end_dict_entry";
+ case DBUS_TYPE_UNIX_FD:
+ return "unix_fd";
+ default:
+ return "unknown";
+ }
+}
+
+
Copied: gnunet-dbus/src/lib/common/timeout.c (from rev 32345,
gnunet-dbus/src/lib/timeout.c)
===================================================================
--- gnunet-dbus/src/lib/common/timeout.c (rev 0)
+++ gnunet-dbus/src/lib/common/timeout.c 2014-02-22 07:55:41 UTC (rev
32454)
@@ -0,0 +1,141 @@
+#include "timeout.h"
+
+#include <stdbool.h>
+
+#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-timeout", __VA_ARGS__)
+
+struct Timeout
+{
+ /* doubly-linked list */
+ struct Timeout *next;
+ struct Timeout *prev;
+
+ DBusTimeout *timeout;
+
+ bool scheduled;
+
+ GNUNET_SCHEDULER_TaskIdentifier task;
+
+ unsigned ref_count;
+};
+
+struct Timeout *
+timeout_create (
+ DBusTimeout *timeout)
+{
+ struct Timeout *t = GNUNET_new (struct Timeout);
+
+ t->timeout = timeout;
+ t->scheduled = false;
+
+ return t;
+}
+
+void
+timeout_destroy (
+ struct Timeout *t)
+{
+ if (0 != t->ref_count)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to destroy timeout with ref_count ==
%u\n", t->ref_count);
+ GNUNET_abort ();
+ };
+
+ GNUNET_free (t);
+}
+
+void
+timeout_ref (
+ struct Timeout *t)
+{
+ t->ref_count++;
+}
+
+void
+timeout_unref (
+ struct Timeout *t)
+{
+ if (0 == t->ref_count)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unref timeout with ref_count ==
0\n");
+ GNUNET_abort ();
+ };
+
+ if (0 == --t->ref_count)
+ timeout_destroy (t);
+}
+
+static void
+handle_timeout (
+ void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct Timeout *t = (struct Timeout *)cls;
+
+ t->scheduled = false;
+
+ if (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)
+ dbus_timeout_handle (t->timeout);
+
+ if (t->ref_count > 1 && ! (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+ timeout_schedule (t);
+ timeout_unref (t);
+};
+
+void
+timeout_schedule (
+ struct Timeout *t)
+{
+ if (! dbus_timeout_get_enabled (t->timeout))
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Tried to schedule timeout that is
disabled!\n");
+ return;
+ };
+
+ if (t->scheduled)
+ return;
+
+ int interval = dbus_timeout_get_interval (t->timeout);
+ struct GNUNET_TIME_Relative delay;
+ delay.rel_value_us = interval * 1000;
+ t->task = GNUNET_SCHEDULER_add_delayed (
+ delay,
+ handle_timeout,
+ t);
+ t->scheduled = true;
+ timeout_ref (t);
+}
+
+void
+do_timeout_unschedule (
+ void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ (void)tc;
+ struct Timeout *t = (struct Timeout *)cls;
+
+ if (! t->scheduled)
+ return;
+
+ void *ret = GNUNET_SCHEDULER_cancel (t->task);
+ if ((struct Timeout *)ret != t)
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Weird result unscheduling task. t == %p,
GNUNET_SCHEDULER_cancel returned %p\n", t, ret);
+
+ timeout_unref (t);
+}
+
+void
+timeout_unschedule (
+ struct Timeout *t)
+{
+ GNUNET_SCHEDULER_add_now (do_timeout_unschedule, t);
+}
+
+struct TimeoutIter *
+timeout_find (struct TimeoutIter *ti, DBusTimeout *timeout)
+{
+ while (ti && ti->t->timeout != timeout)
+ ti = ti->next;
+ return ti;
+}
+
Copied: gnunet-dbus/src/lib/common/timeout.h (from rev 32345,
gnunet-dbus/src/lib/timeout.h)
===================================================================
--- gnunet-dbus/src/lib/common/timeout.h (rev 0)
+++ gnunet-dbus/src/lib/common/timeout.h 2014-02-22 07:55:41 UTC (rev
32454)
@@ -0,0 +1,32 @@
+#ifndef TIMEOUT_H
+#define TIMEOUT_H
+
+#include <dbus/dbus.h>
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_scheduler_lib.h>
+
+struct Timeout;
+
+struct TimeoutIter
+{
+ struct TimeoutIter *next;
+ struct TimeoutIter *prev;
+
+ struct Timeout *t;
+};
+
+struct Timeout *timeout_create (DBusTimeout *timeout);
+void timeout_destroy (struct Timeout *t);
+void timeout_ref (struct Timeout *t);
+void timeout_unref (struct Timeout *t);
+
+void timeout_schedule (struct Timeout *t);
+void timeout_unschedule (struct Timeout *t);
+void do_timeout_unschedule (void *cls, const struct
GNUNET_SCHEDULER_TaskContext *tc);
+
+struct TimeoutIter *timeout_find (struct TimeoutIter *, DBusTimeout *timeout);
+
+#endif
+
Copied: gnunet-dbus/src/lib/common/watch.c (from rev 32345,
gnunet-dbus/src/lib/watch.c)
===================================================================
--- gnunet-dbus/src/lib/common/watch.c (rev 0)
+++ gnunet-dbus/src/lib/common/watch.c 2014-02-22 07:55:41 UTC (rev 32454)
@@ -0,0 +1,245 @@
+#include "watch.h"
+
+#include <stdbool.h>
+
+#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-watch", __VA_ARGS__)
+
+/*
+ * Wraps a file descriptor that needs to be watched
+ * for activity with select()
+ */
+struct Watch
+{
+ /*
+ * DBus watch data. Contains the actual file descritor wrapped by libdbus
+ */
+ DBusWatch *watch;
+
+ /*
+ * Have we asked the scheduler to watch this?
+ * Will be false if the associated task has not been
+ * re-scheduled yet after execution or because dbus has asked
+ * us to disable this watch.
+ */
+ bool scheduled;
+
+ /*
+ * The task that is watching our file descriptor.
+ * Only valid if scheduled is true.
+ */
+ GNUNET_SCHEDULER_TaskIdentifier task;
+
+ struct GNUNET_NETWORK_Handle *net_handle;
+ struct GNUNET_DISK_FileHandle *file_handle;
+
+ unsigned ref_count;
+};
+
+struct Watch *
+watch_create (
+ DBusWatch *watch)
+{
+ struct Watch *w = GNUNET_new (struct Watch);
+
+ w->watch = watch;
+ w->scheduled = false;
+ w->net_handle = NULL;
+ w->file_handle = NULL;
+
+ SOCKTYPE sock = dbus_watch_get_socket (watch);
+ if (-1 != sock)
+ {
+ w->net_handle = GNUNET_NETWORK_socket_box_native (sock);
+ if (NULL == w->net_handle)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to box network socket passed in
from dbus.\n");
+ GNUNET_abort ();
+ };
+ }
+ else {
+ int fd = dbus_watch_get_unix_fd (watch);
+ if (-1 != fd)
+ {
+ w->file_handle = GNUNET_DISK_get_handle_from_int_fd (fd);
+ if (NULL == w->file_handle)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to box file handle passed in
from dbus.\n");
+ GNUNET_abort ();
+ };
+ };
+ };
+
+ if (! w->net_handle && ! w->file_handle)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to create watch.
dbus_watch_get_socket returned %d\n", (int)sock);
+ GNUNET_abort ();
+ };
+
+ return w;
+};
+
+void
+watch_destroy (
+ struct Watch *w)
+{
+ if (0 != w->ref_count)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to destroy watch with ref_count ==
%zu\n", w->ref_count);
+ GNUNET_abort ();
+ };
+
+ if (w->net_handle)
+ GNUNET_free (w->net_handle);
+ if (w->file_handle)
+ GNUNET_free (w->file_handle);
+
+ GNUNET_free (w);
+};
+
+void
+watch_ref (
+ struct Watch *w)
+{
+ w->ref_count++;
+};
+
+void
+watch_unref (
+ struct Watch *w)
+{
+ if (0 == w->ref_count)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unref watch with ref_count ==
0\n");
+ GNUNET_abort ();
+ };
+
+ if (0 == --w->ref_count)
+ watch_destroy (w);
+};
+
+/*
+ * Callback called by the scheduler to tell libdbus that there is activity on
+ * one of its file descriptors.
+ *
+ * @param cls The watch
+ * @param tc the context given to us by the scheduler for this execution
+ */
+void
+handle_watch (
+ void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct Watch *w = (struct Watch *)cls;
+
+ w->scheduled = false;
+
+ unsigned flags = 0;
+ if (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)
+ flags |= DBUS_WATCH_READABLE;
+ if (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)
+ flags |= DBUS_WATCH_WRITABLE;
+ if (flags)
+ {
+ dbus_watch_handle(w->watch, flags);
+ };
+
+ if(w->ref_count > 1 && ! (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+ watch_schedule (w);
+ watch_unref (w);
+};
+
+/*
+ * Ask the scheduler to watch this watch for activity.
+ *
+ * @param w The watch
+ * @return GNUNET_OK or GNUNET_SYSERR
+ */
+void
+watch_schedule (
+ struct Watch *w)
+{
+ unsigned flags = dbus_watch_get_flags (w->watch);
+
+ if (! dbus_watch_get_enabled (w->watch))
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Tried to schedule watch that is
disabled!\n");
+ return;
+ };
+
+ if (w->scheduled)
+ return;
+
+ if (w->net_handle)
+ {
+ w->task = GNUNET_SCHEDULER_add_net_with_priority(
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+ w->net_handle,
+ flags & DBUS_WATCH_READABLE,
+ flags & DBUS_WATCH_WRITABLE,
+ handle_watch,
+ w);
+ w->scheduled = true;
+ watch_ref (w);
+ return;
+ };
+
+ if (w->file_handle)
+ {
+ w->task = GNUNET_SCHEDULER_add_file_with_priority(
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+ w->file_handle,
+ flags & DBUS_WATCH_READABLE,
+ flags & DBUS_WATCH_WRITABLE,
+ handle_watch,
+ w);
+ w->scheduled = true;
+ watch_ref (w);
+ return;
+ };
+
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to schedule watch.\n");
+ GNUNET_abort ();
+};
+
+/*
+ * Ask the scheduler to stop monitoring a watch either because we are shutting
+ * down or dbus has asked us to disable this watch.
+ *
+ * @param w The watch
+ * @return GNUNET_OK or GNUNET_SYSERR
+ */
+void
+do_watch_unschedule (
+ void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ (void)tc;
+ struct Watch *w = (struct Watch *)cls;
+
+ if (! w->scheduled)
+ return;
+
+ void *ret = GNUNET_SCHEDULER_cancel (w->task);
+ if ((struct Watch *)ret != w)
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Weird result unscheduling task. w == %p,
GNUNET_SCHEDULER_cancel returned %p\n", w, ret);
+
+ watch_unref (w);
+};
+
+void
+watch_unschedule (
+ struct Watch *w)
+{
+ GNUNET_SCHEDULER_add_now (do_watch_unschedule, w);
+};
+
+struct WatchIter *
+watch_find (struct WatchIter *wi, DBusWatch *watch)
+{
+ while (wi && wi->w->watch != watch)
+ wi = wi->next;
+ return wi;
+};
+
Copied: gnunet-dbus/src/lib/common/watch.h (from rev 32345,
gnunet-dbus/src/lib/watch.h)
===================================================================
--- gnunet-dbus/src/lib/common/watch.h (rev 0)
+++ gnunet-dbus/src/lib/common/watch.h 2014-02-22 07:55:41 UTC (rev 32454)
@@ -0,0 +1,35 @@
+#ifndef WATCH_H
+#define WATCH_H
+
+#include <dbus/dbus.h>
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_scheduler_lib.h>
+
+struct Watch;
+
+struct WatchIter
+{
+ struct WatchIter *next;
+ struct WatchIter *prev;
+
+ struct Watch *w;
+};
+
+struct Watch *watch_create (DBusWatch *watch);
+void watch_destroy (struct Watch *w);
+void watch_ref (struct Watch *w);
+void watch_unref (struct Watch *w);
+
+/*
+ * Schedule or schedule the scheduler to monitor dbus file descriptors.
+ */
+void watch_schedule (struct Watch *w);
+void watch_unschedule (struct Watch *w);
+void do_watch_unschedule (void *cls, const struct GNUNET_SCHEDULER_TaskContext
*tc);
+
+struct WatchIter *watch_find (struct WatchIter *, DBusWatch *watch);
+
+#endif
+
Added: gnunet-dbus/src/lib/dht/Makefile.am
===================================================================
--- gnunet-dbus/src/lib/dht/Makefile.am (rev 0)
+++ gnunet-dbus/src/lib/dht/Makefile.am 2014-02-22 07:55:41 UTC (rev 32454)
@@ -0,0 +1,15 @@
+lib_LTLIBRARIES = \
+ libgnunetdhtdbus.la
+
+libgnunetdhtdbus_la_SOURCES = \
+ gnunet_dht_dbus_lib.c \
+ gnunet_dht_dbus_lib_pop.c \
+ gnunet_dht_dbus_lib_push.c
+
+libgnunetdhtdbus_la_CFLAGS = \
+ -I$(top_builddir)/src/lib/include \
+ $(DBUS_CFLAGS)
+
+libgnunetdhtdbus_la_LDFLAGS = \
+ $(DBUS_LIBS)
+
Added: gnunet-dbus/src/lib/dht/gnunet_dht_dbus_lib.c
===================================================================
--- gnunet-dbus/src/lib/dht/gnunet_dht_dbus_lib.c
(rev 0)
+++ gnunet-dbus/src/lib/dht/gnunet_dht_dbus_lib.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,13 @@
+#include "config.h"
+
+#include "gnunet_dbus_lib.h"
+#include "gnunet_dht_dbus_lib.h"
+
+const struct GNUNET_DBUS_StringEnumPair
GNUNET_DHT_DBUS_route_option_description[] = {
+ { "demultiplex_everywhere", GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE },
+ { "record_route", GNUNET_DHT_RO_RECORD_ROUTE },
+ { "find_peer", GNUNET_DHT_RO_FIND_PEER },
+ { "bart", GNUNET_DHT_RO_BART },
+ { NULL, 0}
+};
+
Added: gnunet-dbus/src/lib/dht/gnunet_dht_dbus_lib_pop.c
===================================================================
--- gnunet-dbus/src/lib/dht/gnunet_dht_dbus_lib_pop.c
(rev 0)
+++ gnunet-dbus/src/lib/dht/gnunet_dht_dbus_lib_pop.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,16 @@
+#include "config.h"
+
+#include "gnunet_dbus_lib.h"
+#include "gnunet_dht_dbus_lib.h"
+
+DBusMessage *
+GNUNET_DHT_DBUS_pop_route_option (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ enum GNUNET_DHT_RouteOption *value)
+{
+ return GNUNET_DBUS_pop_bitfield (message, iter, arg_name, (int *)value,
GNUNET_DHT_DBUS_route_option_description);
+};
+
+
Added: gnunet-dbus/src/lib/dht/gnunet_dht_dbus_lib_push.c
===================================================================
--- gnunet-dbus/src/lib/dht/gnunet_dht_dbus_lib_push.c
(rev 0)
+++ gnunet-dbus/src/lib/dht/gnunet_dht_dbus_lib_push.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,14 @@
+#include "config.h"
+
+#include "gnunet_dbus_lib.h"
+#include "gnunet_dht_dbus_lib.h"
+
+void
+GNUNET_DHT_DBUS_push_route_option (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const enum GNUNET_DHT_RouteOption *value)
+{
+ return GNUNET_DBUS_push_bitfield (message, iter, (const int *)value,
GNUNET_DHT_DBUS_route_option_description);
+};
+
Added: gnunet-dbus/src/lib/gnsrecord/Makefile.am
===================================================================
--- gnunet-dbus/src/lib/gnsrecord/Makefile.am (rev 0)
+++ gnunet-dbus/src/lib/gnsrecord/Makefile.am 2014-02-22 07:55:41 UTC (rev
32454)
@@ -0,0 +1,16 @@
+lib_LTLIBRARIES = \
+ libgnunetgnsrecorddbus.la
+
+libgnunetgnsrecorddbus_la_SOURCES = \
+ gnunet_gnsrecord_dbus_lib.c \
+ gnunet_gnsrecord_dbus_lib_pop.c \
+ gnunet_gnsrecord_dbus_lib_push.c
+
+libgnunetgnsrecorddbus_la_CFLAGS = \
+ -I$(top_builddir)/src/lib/include \
+ $(DBUS_CFLAGS)
+
+libgnunetgnsrecorddbus_la_LDFLAGS = \
+ $(top_builddir)/src/lib/util/libgnunettimedbus.la \
+ $(DBUS_LIBS)
+
Added: gnunet-dbus/src/lib/gnsrecord/gnunet_gnsrecord_dbus_lib.c
===================================================================
--- gnunet-dbus/src/lib/gnsrecord/gnunet_gnsrecord_dbus_lib.c
(rev 0)
+++ gnunet-dbus/src/lib/gnsrecord/gnunet_gnsrecord_dbus_lib.c 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,23 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_crypto_lib.h>
+#include <gnunet/gnunet_gnsrecord_lib.h>
+
+#include "gnunet_dbus_lib.h"
+
+const struct GNUNET_DBUS_StringEnumPair *
+GNUNET_GNSRECORD_DBUS_describe_flags()
+{
+ static const struct GNUNET_DBUS_StringEnumPair options[] = {
+ { "private", GNUNET_GNSRECORD_RF_PRIVATE },
+ { "pending", GNUNET_GNSRECORD_RF_PENDING },
+ { "relative_expiration", GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION },
+ { "shadow_record", GNUNET_GNSRECORD_RF_SHADOW_RECORD },
+ { NULL, 0 }
+ };
+ return options;
+};
+
+
Added: gnunet-dbus/src/lib/gnsrecord/gnunet_gnsrecord_dbus_lib_pop.c
===================================================================
--- gnunet-dbus/src/lib/gnsrecord/gnunet_gnsrecord_dbus_lib_pop.c
(rev 0)
+++ gnunet-dbus/src/lib/gnsrecord/gnunet_gnsrecord_dbus_lib_pop.c
2014-02-22 07:55:41 UTC (rev 32454)
@@ -0,0 +1,85 @@
+#include "config.h"
+
+#include "gnunet_gnsrecord_dbus_lib.h"
+
+DBusMessage *
+GNUNET_GNSRECORD_DBUS_pop_type (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ uint32_t *value)
+{
+ DBusMessageIter iter_sub;
+ DBusMessage *ret = GNUNET_DBUS_pop_enter_variant (message, iter, &iter_sub,
arg_name);
+ if (ret)
+ return ret;
+
+ int arg_type = dbus_message_iter_get_arg_type (&iter_sub);
+ switch (arg_type)
+ {
+ case DBUS_TYPE_STRING: {
+ const char *string;
+ dbus_message_iter_get_basic (&iter_sub, &string);
+ *value = GNUNET_GNSRECORD_typename_to_number (string);
+ if (*value == UINT32_MAX)
+ {
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. %s is not a valid GNS record type. (Should be
something like 'AAAA' or 'CNAME' etc.)",
+ arg_name,
+ string);
+ };
+ return NULL;
+ };
+ case DBUS_TYPE_UINT32:
+ dbus_message_iter_get_basic (&iter_sub, value);
+ return NULL;
+ default:
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. Variant should contain a string or uint32.
Contains a %s.",
+ arg_name,
+ GNUNET_DBUS_signature_typecode_to_string (arg_type));
+ };
+};
+
+DBusMessage *
+GNUNET_GNSRECORD_DBUS_pop_flags (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ enum GNUNET_GNSRECORD_Flags *value)
+{
+ return GNUNET_DBUS_pop_bitfield (message, iter, arg_name, (int *)value,
GNUNET_GNSRECORD_DBUS_describe_flags ());
+};
+
+#if 0
+DBusMessage *
+GNUNET_GNSRECORD_DBUS_pop_data (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ struct GNUNET_GNSRECORD_Data *value)
+{
+ DBusMessageIter iter_sub;
+ DBusMessage *ret = GNUNET_DBUS_pop_enter_struct (message, iter, &iter_sub,
arg_name);
+ if (ret)
+ return ret;
+
+ DBusMessageIter iter_sub_sub;
+ GNUNET_GNSRECORD_DBUS_pop_type (message, &iter_sub, "record_type",
&value->record_type);
+ GNUNET_GNSRECORD_DBUS_pop_flags (message, &iter_sub, "flags", &value->flags);
+ GNUNET_DBUS_pop_enter_variant (message, &iter_sub, &iter_sub_sub);
+ int arg_type = dbus_message_iter_get_arg_type (&iter_sub_sub);
+ switch (arg_type)
+ {
+ case DBUS_TYPE_STRING: {
+ const char *stringified;
+ dbus_message_iter_get_basic (&iter_sub_sub, &stringified);
+ int success = GNUNET_GNSRECORD_string_to_value (value->record_type,
stringified,
+
+#endif
+
+
Added: gnunet-dbus/src/lib/gnsrecord/gnunet_gnsrecord_dbus_lib_push.c
===================================================================
--- gnunet-dbus/src/lib/gnsrecord/gnunet_gnsrecord_dbus_lib_push.c
(rev 0)
+++ gnunet-dbus/src/lib/gnsrecord/gnunet_gnsrecord_dbus_lib_push.c
2014-02-22 07:55:41 UTC (rev 32454)
@@ -0,0 +1,88 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+
+#include "gnunet_gnsrecord_dbus_lib.h"
+#include "gnunet_time_dbus_lib.h"
+
+#define LOG(kind, ...) GNUNET_log_from(kind, "gnsrecord-dbus-push",
__VA_ARGS__)
+
+void
+GNUNET_GNSRECORD_DBUS_push_type (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const uint32_t *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing GNSRECORD type\n");
+ DBusMessageIter iter_sub;
+ if (GNUNET_DBUS_message_get_pretty (message))
+ {
+ GNUNET_DBUS_push_open_variant (message, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_STRING);
+ const char *stringified = GNUNET_GNSRECORD_number_to_typename (*value);
+ GNUNET_DBUS_push_string (message, &iter_sub, &stringified);
+ GNUNET_DBUS_push_close_variant (message, iter, &iter_sub);
+ }
+ else
+ {
+ GNUNET_DBUS_push_open_variant (message, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_UINT32);
+ GNUNET_DBUS_push_uint32 (message, &iter_sub, value);
+ GNUNET_DBUS_push_close_variant (message, iter, &iter_sub);
+ }
+};
+
+void
+GNUNET_GNSRECORD_DBUS_push_flags (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const enum GNUNET_GNSRECORD_Flags *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing GNUNET_GNSRECORD_Flags\n");
+ GNUNET_DBUS_push_bitfield (message, iter, (const int *)value,
GNUNET_GNSRECORD_DBUS_describe_flags ());
+};
+
+void
+GNUNET_GNSRECORD_DBUS_push_data (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const struct GNUNET_GNSRECORD_Data *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing GNUNET_GNSRECORD_Data\n");
+ DBusMessageIter iter_sub;
+ DBusMessageIter iter_sub_sub;
+
+ GNUNET_DBUS_push_open_struct (message, iter, &iter_sub);
+ GNUNET_GNSRECORD_DBUS_push_type (message, &iter_sub, &value->record_type);
+ GNUNET_GNSRECORD_DBUS_push_flags (message, &iter_sub, &value->flags);
+
+ if (GNUNET_DBUS_message_get_pretty (message))
+ {
+ GNUNET_DBUS_push_open_variant (message, &iter_sub, &iter_sub_sub,
GNUNET_DBUS_SIGNATURE_STRING);
+ char *stringified = GNUNET_GNSRECORD_value_to_string (value->record_type,
value->data, value->data_size);
+ const char *stringified_const = stringified;
+ GNUNET_DBUS_push_string (message, &iter_sub_sub, &stringified_const);
+ GNUNET_free (stringified);
+ GNUNET_DBUS_push_close_variant (message, &iter_sub, &iter_sub_sub);
+ }
+ else
+ {
+ GNUNET_DBUS_push_open_variant (message, &iter_sub, &iter_sub_sub,
GNUNET_DBUS_SIGNATURE_ARRAY (GNUNET_DBUS_SIGNATURE_BYTE));
+ GNUNET_DBUS_push_byte_array (message, &iter_sub_sub, (const unsigned char
*)value->data, value->data_size);
+ GNUNET_DBUS_push_close_variant (message, &iter_sub, &iter_sub_sub);
+ };
+
+ if (value->flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)
+ {
+ struct GNUNET_TIME_Relative expiration_time;
+ expiration_time.rel_value_us = value->expiration_time;
+ GNUNET_TIME_DBUS_push_relative (message, &iter_sub, &expiration_time);
+ }
+ else
+ {
+ struct GNUNET_TIME_Absolute expiration_time;
+ expiration_time.abs_value_us = value->expiration_time;
+ GNUNET_TIME_DBUS_push_absolute (message, &iter_sub, &expiration_time);
+ };
+ GNUNET_DBUS_push_close_struct (message, iter, &iter_sub);
+}
+
+
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib.h
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib.h 2014-02-21 17:05:07 UTC (rev
32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib.h 2014-02-22 07:55:41 UTC (rev
32454)
@@ -1,16 +0,0 @@
-#ifndef GNUNET_DBUS_LIB_H
-#define GNUNET_DBUS_LIB_H
-
-#include "gnunet_dbus_lib_service.h"
-#include "gnunet_dbus_lib_object.h"
-#include "gnunet_dbus_lib_interface.h"
-#include "gnunet_dbus_lib_method.h"
-#include "gnunet_dbus_lib_arg.h"
-#include "gnunet_dbus_lib_method_context.h"
-#include "gnunet_dbus_lib_client.h"
-#include "gnunet_dbus_lib_signature.h"
-#include "gnunet_dbus_lib_message_iter_push.h"
-#include "gnunet_dbus_lib_message_iter_pop.h"
-
-#endif
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_arg.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_arg.c 2014-02-21 17:05:07 UTC (rev
32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_arg.c 2014-02-22 07:55:41 UTC (rev
32454)
@@ -1,76 +0,0 @@
-#include "config.h"
-
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-
-#include "gnunet_dbus_lib_arg.h"
-
-#define LOG(kind, ...) GNUNET_log_from(kind, "dbus-arg", __VA_ARGS__)
-
-struct GNUNET_DBUS_Arg
-{
- char *name;
- const char *signature;
- unsigned ref_count;
-};
-
-struct GNUNET_DBUS_Arg *
-GNUNET_DBUS_arg_create (
- const char *name,
- const char *signature)
-{
- struct GNUNET_DBUS_Arg *arg = GNUNET_new (struct GNUNET_DBUS_Arg);
- arg->name = GNUNET_strdup (name);
- arg->signature = signature;
- arg->ref_count = 0;
- return arg;
-};
-
-void
-GNUNET_DBUS_arg_destroy (
- struct GNUNET_DBUS_Arg *arg)
-{
- if (0 != arg->ref_count)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to destroy arg that still has
references. name == \"%s\", ref_count == %zu\n", arg->name, arg->ref_count);
- GNUNET_abort ();
- };
-
- GNUNET_free (arg->name);
- GNUNET_free (arg);
-};
-
-void
-GNUNET_DBUS_arg_ref (
- struct GNUNET_DBUS_Arg *arg)
-{
- arg->ref_count++;
-};
-
-void
-GNUNET_DBUS_arg_unref (
- struct GNUNET_DBUS_Arg *arg)
-{
- if (arg->ref_count == 0)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unreference arg with ref count
0\n");
- GNUNET_abort ();
- };
- if (--arg->ref_count == 0)
- GNUNET_DBUS_arg_destroy (arg);
-};
-
-const char *
-GNUNET_DBUS_arg_get_name (
- const struct GNUNET_DBUS_Arg *arg)
-{
- return arg->name;
-};
-
-const char *
-GNUNET_DBUS_arg_get_signature (
- const struct GNUNET_DBUS_Arg *arg)
-{
- return arg->signature;
-};
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_arg.h
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_arg.h 2014-02-21 17:05:07 UTC (rev
32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_arg.h 2014-02-22 07:55:41 UTC (rev
32454)
@@ -1,55 +0,0 @@
-#ifndef GNUNET_DBUS_LIB_ARG_H
-#define GNUNET_DBUS_LIB_ARG_H
-
-struct GNUNET_DBUS_Arg;
-
-struct GNUNET_DBUS_ArgIterator
-{
- /* linked list */
- struct GNUNET_DBUS_ArgIterator *next;
- struct GNUNET_DBUS_ArgIterator *prev;
-
- struct GNUNET_DBUS_Arg *arg;
-};
-
-struct GNUNET_DBUS_Arg *
-GNUNET_DBUS_arg_create (
- const char *name,
- const char *signature);
-
-void
-GNUNET_DBUS_arg_destroy (
- struct GNUNET_DBUS_Arg *arg);
-
-void
-GNUNET_DBUS_arg_ref (
- struct GNUNET_DBUS_Arg *arg);
-
-void
-GNUNET_DBUS_arg_unref (
- struct GNUNET_DBUS_Arg *arg);
-
-const char *
-GNUNET_DBUS_arg_get_name (
- const struct GNUNET_DBUS_Arg *arg);
-
-const char *
-GNUNET_DBUS_arg_get_signature (
- const struct GNUNET_DBUS_Arg *arg);
-
-#if 0
-void
-GNUNET_DBUS_arg_pop_message (
- const struct GNUNET_DBUS_Arg *arg,
- DBusMessageIter *dbus_message_iter,
- void *value);
-
-void
-GNUNET_DBUS_arg_push_message (
- const struct GNUNET_DBUS_Arg *arg,
- DBusMessageIter *dbus_message_iter,
- va_list vl);
-#endif
-
-#endif
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_client.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_client.c 2014-02-21 17:05:07 UTC
(rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_client.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -1,77 +0,0 @@
-#include "config.h"
-
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-
-#include "gnunet_dbus_lib_client.h"
-
-#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-client", __VA_ARGS__)
-
-struct GNUNET_DBUS_Client
-{
- char *unique_name;
- void *data;
- bool prefers_pretty_encodings;
-};
-
-struct GNUNET_DBUS_Client *
-GNUNET_DBUS_client_create (
- const char *unique_name)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Creating client with unique name %s\n",
unique_name);
-
- struct GNUNET_DBUS_Client *client = GNUNET_new (struct GNUNET_DBUS_Client);
- client->unique_name = GNUNET_strdup (unique_name);
- client->data = NULL;
- client->prefers_pretty_encodings = false;
-
- return client;
-};
-
-void
-GNUNET_DBUS_client_destroy (
- struct GNUNET_DBUS_Client *client)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroying client with unique name %s\n",
client->unique_name);
-
- GNUNET_free (client->unique_name);
- GNUNET_free (client);
-};
-
-const char *
-GNUNET_DBUS_client_get_unique_name (
- const struct GNUNET_DBUS_Client *client)
-{
- return client->unique_name;
-};
-
-void
-GNUNET_DBUS_client_set_data (
- struct GNUNET_DBUS_Client *client,
- void *data)
-{
- client->data = data;
-};
-
-void *
-GNUNET_DBUS_client_get_data (
- const struct GNUNET_DBUS_Client *client)
-{
- return client->data;
-};
-
-void
-GNUNET_DBUS_client_set_prefers_pretty_encodings (
- struct GNUNET_DBUS_Client *client,
- bool prefers_pretty_encodings)
-{
- client->prefers_pretty_encodings = prefers_pretty_encodings;
-}
-
-bool
-GNUNET_DBUS_client_get_prefers_pretty_encodings (
- const struct GNUNET_DBUS_Client *client)
-{
- return client->prefers_pretty_encodings;
-};
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_client.h
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_client.h 2014-02-21 17:05:07 UTC
(rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_client.h 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -1,47 +0,0 @@
-#ifndef GNUNET_DBUS_CLIENT_H
-#define GNUNET_DBUS_CLIENT_H
-
-#include <stdbool.h>
-
-struct GNUNET_DBUS_Client;
-
-struct GNUNET_DBUS_ClientIterator
-{
- struct GNUNET_DBUS_ClientIterator *next;
- struct GNUNET_DBUS_ClientIterator *prev;
-
- struct GNUNET_DBUS_Client *client;
-};
-
-struct GNUNET_DBUS_Client *
-GNUNET_DBUS_client_create (
- const char *unique_name);
-
-void
-GNUNET_DBUS_client_destroy (
- struct GNUNET_DBUS_Client *client);
-
-const char *
-GNUNET_DBUS_client_get_unique_name (
- const struct GNUNET_DBUS_Client *client);
-
-void
-GNUNET_DBUS_client_set_data (
- struct GNUNET_DBUS_Client *client,
- void *data);
-
-void *
-GNUNET_DBUS_client_get_data (
- const struct GNUNET_DBUS_Client *client);
-
-void
-GNUNET_DBUS_client_set_prefers_pretty_encodings (
- struct GNUNET_DBUS_Client *client,
- bool prefers_pretty_encodings);
-
-bool
-GNUNET_DBUS_client_get_prefers_pretty_encodings (
- const struct GNUNET_DBUS_Client *client);
-
-#endif
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_interface.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_interface.c 2014-02-21 17:05:07 UTC
(rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_interface.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -1,214 +0,0 @@
-#include "config.h"
-
-#include <dbus/dbus.h>
-
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_container_lib.h>
-
-#include "gnunet_dbus_lib_object.h"
-#include "gnunet_dbus_lib_interface.h"
-#include "gnunet_dbus_lib_method.h"
-#include "gnunet_dbus_lib_arg.h"
-#include "gnunet_dbus_lib_message_iter_push.h"
-#include "gnunet_dbus_lib_signature.h"
-
-#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-interface", __VA_ARGS__)
-
-struct GNUNET_DBUS_Interface
-{
- struct GNUNET_DBUS_MethodIterator *methods_front;
- struct GNUNET_DBUS_MethodIterator *methods_back;
-
- char *name;
- unsigned ref_count;
-};
-
-struct GNUNET_DBUS_Interface *
-GNUNET_DBUS_interface_create (
- const char *name)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Creating interface %s\n", name);
-
- struct GNUNET_DBUS_Interface *interface = GNUNET_new (struct
GNUNET_DBUS_Interface);
-
- interface->methods_front = NULL;
- interface->methods_back = NULL;
- interface->name = GNUNET_strdup (name);
- interface->ref_count = 0;
-
- return interface;
-};
-
-void
-GNUNET_DBUS_interface_destroy (
- struct GNUNET_DBUS_Interface *interface)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroying interface %s\n", interface->name);
-
- if (0 != interface->ref_count)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to destroy interface that still has
references. name == \"%s\", ref_count == %zu\n", interface->name,
interface->ref_count);
- GNUNET_abort ();
- };
-
- struct GNUNET_DBUS_MethodIterator *methods_iter = interface->methods_front;
- while (methods_iter)
- {
- struct GNUNET_DBUS_MethodIterator *next = methods_iter->next;
- GNUNET_DBUS_method_unref (methods_iter->method);
- GNUNET_free (methods_iter);
- methods_iter = next;
- };
-
- GNUNET_free (interface->name);
- GNUNET_free (interface);
-};
-
-void
-GNUNET_DBUS_interface_ref (
- struct GNUNET_DBUS_Interface *interface)
-{
- interface->ref_count++;
-};
-
-void
-GNUNET_DBUS_interface_unref (
- struct GNUNET_DBUS_Interface *interface)
-{
- if (interface->ref_count == 0)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unreference interface with ref
count 0\n");
- GNUNET_abort ();
- };
- if (--interface->ref_count == 0)
- GNUNET_DBUS_interface_destroy (interface);
-};
-
-void
-GNUNET_DBUS_interface_add_method (
- struct GNUNET_DBUS_Interface *interface,
- struct GNUNET_DBUS_Method *method)
-{
- struct GNUNET_DBUS_MethodIterator *meth_it = GNUNET_new (struct
GNUNET_DBUS_MethodIterator);
- meth_it->method = method;
- GNUNET_DBUS_method_ref (method);
-
- GNUNET_CONTAINER_DLL_insert (interface->methods_front,
- interface->methods_back,
- meth_it);
-};
-
-const char *
-GNUNET_DBUS_interface_get_name (
- const struct GNUNET_DBUS_Interface *interface)
-{
- return interface->name;
-};
-
-const struct GNUNET_DBUS_MethodIterator *
-GNUNET_DBUS_interface_iterate_methods (
- const struct GNUNET_DBUS_Interface *interface)
-{
- return interface->methods_front;
-};
-
-static void
-introspectable_introspect (
- struct GNUNET_DBUS_MethodContext *mc)
-{
- char *data = NULL;
-
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Introspecting\n");
- struct GNUNET_DBUS_Object *object = mc->object;
- GNUNET_append_sprintf (&data, DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "here\n");
- GNUNET_append_sprintf (&data, "<node>\n");
- LOG (GNUNET_ERROR_TYPE_DEBUG, "and here\n");
- const struct GNUNET_DBUS_InterfaceIterator *int_it =
GNUNET_DBUS_object_iterate_interfaces (object);
- while (int_it)
- {
- struct GNUNET_DBUS_Interface *interface = int_it->interface;
- const char *interface_name = GNUNET_DBUS_interface_get_name (interface);
- GNUNET_append_sprintf (&data, " <interface name='%s'>\n", interface_name);
- const struct GNUNET_DBUS_MethodIterator *meth_it =
GNUNET_DBUS_interface_iterate_methods (interface);
- while (meth_it)
- {
- struct GNUNET_DBUS_Method *method = meth_it->method;
- const char *method_name = GNUNET_DBUS_method_get_name (method);
- GNUNET_append_sprintf (&data, " <method name='%s'>\n", method_name);
- const struct GNUNET_DBUS_ArgIterator *arg_it =
GNUNET_DBUS_method_iterate_args (method);
- while (arg_it)
- {
- struct GNUNET_DBUS_Arg *arg = arg_it->arg;
- const char *arg_name = GNUNET_DBUS_arg_get_name (arg);
- const char *signature = GNUNET_DBUS_arg_get_signature (arg);
- GNUNET_append_sprintf (
- &data,
- " <arg name='%s' type='%s' direction='in'/>\n",
- arg_name,
- signature);
- arg_it = arg_it->next;
- };
-
- arg_it = GNUNET_DBUS_method_iterate_return_args (method);
- while (arg_it)
- {
- struct GNUNET_DBUS_Arg *arg = arg_it->arg;
- const char *arg_name = GNUNET_DBUS_arg_get_name (arg);
- const char *signature = GNUNET_DBUS_arg_get_signature (arg);
- GNUNET_append_sprintf (
- &data,
- " <arg name='%s' type='%s' direction='out'/>\n",
- arg_name,
- signature);
- arg_it = arg_it->next;
- };
- GNUNET_append_sprintf (&data, " </method>\n");
- meth_it = meth_it->next;
- };
- GNUNET_append_sprintf (&data, " </interface>\n");
- int_it = int_it->next;
- };
- GNUNET_append_sprintf (&data, "</node>\n");
-
- DBusMessage *message = mc->message;
- DBusMessage *reply = dbus_message_new_method_return (message);
- DBusMessageIter reply_iter;
- dbus_message_iter_init_append (reply, &reply_iter);
- GNUNET_DBUS_message_iter_push_string (mc, &reply_iter, data);
- GNUNET_DBUS_method_context_send_reply (mc, reply);
- GNUNET_DBUS_method_context_unref (mc);
- GNUNET_free (data);
-};
-
-struct GNUNET_DBUS_Interface *
-GNUNET_DBUS_interface_introspectable ()
-{
- static struct GNUNET_DBUS_Interface *introspectable = NULL;
-
- if (NULL == introspectable)
- {
- introspectable = GNUNET_DBUS_interface_create
("org.freedesktop.DBus.Introspectable");
- struct GNUNET_DBUS_Method *introspect = GNUNET_DBUS_method_create
("Introspect", introspectable_introspect);
- GNUNET_DBUS_method_add_return_arg (introspect, "data",
GNUNET_DBUS_SIGNATURE_STRING);
- GNUNET_DBUS_interface_add_method (introspectable, introspect);
- GNUNET_DBUS_interface_ref (introspectable);
- };
-
- return introspectable;
-};
-
-const struct GNUNET_DBUS_InterfaceIterator *
-GNUNET_DBUS_interface_find (
- const struct GNUNET_DBUS_InterfaceIterator *int_it,
- const char *name)
-{
- for (; int_it; int_it = int_it->next)
- {
- if (! strcmp (name, int_it->interface->name))
- return int_it;
- }
- return NULL;
-}
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_interface.h
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_interface.h 2014-02-21 17:05:07 UTC
(rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_interface.h 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -1,59 +0,0 @@
-#ifndef GNUNET_DBUS_LIB_INTERFACE_H
-#define GNUNET_DBUS_LIB_INTERFACE_H
-
-#include <stdbool.h>
-
-struct GNUNET_DBUS_Interface;
-
-#include "gnunet_dbus_lib_object.h"
-#include "gnunet_dbus_lib_method.h"
-#include "gnunet_dbus_lib_method_context.h"
-
-struct GNUNET_DBUS_InterfaceIterator
-{
- /* linked list */
- struct GNUNET_DBUS_InterfaceIterator *next;
- struct GNUNET_DBUS_InterfaceIterator *prev;
-
- struct GNUNET_DBUS_Interface *interface;
-};
-
-struct GNUNET_DBUS_Interface *
-GNUNET_DBUS_interface_create (
- const char *name);
-
-void
-GNUNET_DBUS_interface_destroy (
- struct GNUNET_DBUS_Interface *interface);
-
-void
-GNUNET_DBUS_interface_ref (
- struct GNUNET_DBUS_Interface *interface);
-
-void
-GNUNET_DBUS_interface_unref (
- struct GNUNET_DBUS_Interface *interface);
-
-void
-GNUNET_DBUS_interface_add_method (
- struct GNUNET_DBUS_Interface *interface,
- struct GNUNET_DBUS_Method *method);
-
-const char *
-GNUNET_DBUS_interface_get_name (
- const struct GNUNET_DBUS_Interface *interface);
-
-const struct GNUNET_DBUS_MethodIterator *
-GNUNET_DBUS_interface_iterate_methods (
- const struct GNUNET_DBUS_Interface *interface);
-
-struct GNUNET_DBUS_Interface *
-GNUNET_DBUS_interface_introspectable ();
-
-const struct GNUNET_DBUS_InterfaceIterator *
-GNUNET_DBUS_interface_find (
- const struct GNUNET_DBUS_InterfaceIterator *int_it,
- const char *name);
-
-#endif
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_pop.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_pop.c 2014-02-21
17:05:07 UTC (rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_pop.c 2014-02-22
07:55:41 UTC (rev 32454)
@@ -1,620 +0,0 @@
-#include "config.h"
-
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_strings_lib.h>
-
-#include "gnunet_dbus_lib_message_iter_pop.h"
-#include "gnunet_dbus_lib_method_context.h"
-#include "gnunet_dbus_lib_client.h"
-#include "gnunet_dbus_lib_signature.h"
-
-#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-pop", __VA_ARGS__)
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_basic (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- int expected_type,
- void *value)
-{
- int arg_type = dbus_message_iter_get_arg_type (iter);
- if (expected_type != arg_type)
- {
- return dbus_message_new_error_printf (
- mc->message,
- DBUS_ERROR_INVALID_ARGS,
- "Bad argument for '%s'. Expected %s. Got %s",
- arg_name,
- GNUNET_DBUS_signature_typecode_to_string (expected_type),
- GNUNET_DBUS_signature_typecode_to_string (arg_type));
- };
- dbus_message_iter_get_basic (iter, value);
- dbus_message_iter_next (iter);
-
- return NULL;
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_string (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- const char **value)
-{
- return GNUNET_DBUS_message_iter_pop_basic (
- mc,
- iter,
- arg_name,
- DBUS_TYPE_STRING,
- (void *)value);
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_byte (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- unsigned char *value)
-{
- return GNUNET_DBUS_message_iter_pop_basic (
- mc,
- iter,
- arg_name,
- DBUS_TYPE_BYTE,
- (void *)value);
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_int32 (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- dbus_int32_t *value)
-{
- return GNUNET_DBUS_message_iter_pop_basic (
- mc,
- iter,
- arg_name,
- DBUS_TYPE_INT32,
- (void *)value);
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_uint32 (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- dbus_uint32_t *value)
-{
- return GNUNET_DBUS_message_iter_pop_basic (
- mc,
- iter,
- arg_name,
- DBUS_TYPE_UINT32,
- (void *)value);
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_uint64 (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- dbus_uint64_t *value)
-{
- return GNUNET_DBUS_message_iter_pop_basic (
- mc,
- iter,
- arg_name,
- DBUS_TYPE_UINT64,
- (void *)value);
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_bool (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- dbus_bool_t *value)
-{
- return GNUNET_DBUS_message_iter_pop_basic (
- mc,
- iter,
- arg_name,
- DBUS_TYPE_BOOLEAN,
- (void *)value);
-};
-
-#if 0
-void
-GNUNET_DBUS_message_iter_pop_recurse_array (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- DBusMessageIter *iter_sub,
- const char *arg_name)
-{
- int arg_type = dbus_message_iter_get_arg_type (iter);
- if (DBUS_TYPE_ARRAY != arg_type)
- {
- return dbus_message_new_error_printf (
- mc->message,
- DBUS_ERROR_INVALID_ARGS,
- "Bad argument for '%s'. Expected '%s'. Got '%s'",
- arg_name,
- dbus_message_type_to_string (DBUS_TYPE_ARRAY),
- dbus_message_type_to_string (arg_type));
- }
-
- DBusMessageIter iter_sub;
- dbus_message_iter_recurse (iter, &iter_sub);
-}
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_fixed_array (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- int expected_type,
- void *value,
- int *n_elements)
-{
- int element_type = dbus_message_iter_get_arg_type (iter);
- if (expected_type != element_type)
- {
- return dbus_message_new_error_printf (
- message,
- DBUS_ERROR_INVALID_ARGS,
- "Bad argument for '%s'. Expected array of %s. Got array of %s",
- arg_name,
- dbus_message_type_to_string (expected_type),
- dbus_message_type_to_string (element_type));
- };
-
- DBusMessageIter itersub;
- dbus_message_iter_recurse (iter, &itersub);
- dbus_message_iter_get_fixed_array (&itersub, value, n_elements);
-
- return NULL;
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_array_byte (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- const char **value,
- int *n_elements)
-{
- return GNUNET_DBUS_message_iter_pop_fixed_array (
- message,
- iter,
- arg_name,
- DBUS_TYPE_BYTE,
- (void *)value,
- n_elements);
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_array_string (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- const char ***value,
- int *n_elements)
-{
- return GNUNET_DBUS_message_iter_pop_fixed_array (
- message,
- iter,
- arg_name,
- DBUS_TYPE_STRING,
- (void *)value,
- n_elements);
-};
-
-/*
- * bitfield enums can be sent across the wire in either their integer form (as
- * an array of bit flags) or as an array of strings. Sending an int is more
- * efficient and is what libraries built around the DBus API would use, people
- * using the DBus API directly may want to pass human-readable strings for
- * convenience.
- */
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_bitfield (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- int *value,
- const struct GNUNET_DBUS_StringEnumPair *fields)
-{
- uint32_t flags;
- DBusMessage *ret = GNUNET_DBUS_message_iter_pop_uint32 (message, iter,
arg_name, &flags);
- if (! ret)
- {
- *value = (int)flags;
- return NULL;
- };
- dbus_message_unref (ret);
-
- const char **options;
- int num_options;
- ret = GNUNET_DBUS_message_iter_pop_array_string (message, iter, arg_name,
&options, &num_options);
- if (! ret)
- {
- *value = 0;
- int i;
- for (i = 0; i < num_options; i++)
- {
- int j;
- for (j = 0; fields[j].name; j++)
- {
- if (! strcmp (options[i], fields[j].name))
- {
- *value |= fields[j].value;
- break;
- };
- };
- if (! fields[j].name)
- {
- char *errmsg = NULL;
- GNUNET_append_sprintf (&errmsg, "Unrecognized option '%s'. Valid
options are: [", options[i]);
- for (j = 0; fields[j].name; j++)
- GNUNET_append_sprintf (&errmsg, "%s'%s'", j ? ", " : "",
fields[j].name);
- GNUNET_append_sprintf (&errmsg, "].");
- ret = dbus_message_new_error_printf (
- message,
- DBUS_ERROR_INVALID_ARGS,
- "%s",
- errmsg);
- GNUNET_free (errmsg);
- return ret;
- };
- };
-
- return NULL;
- };
- dbus_message_unref (ret);
-
- return dbus_message_new_error_printf (
- message,
- DBUS_ERROR_INVALID_ARGS,
- "Bad argument for '%s'. Expected either a bitfield uint32 or an array of
string options.",
- arg_name);
-};
-#endif
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_enum (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- int *value,
- const struct GNUNET_DBUS_StringEnumPair *names)
-{
- uint32_t v;
- DBusMessage *ret = GNUNET_DBUS_message_iter_pop_uint32 (mc, iter, arg_name,
&v);
- if (! ret)
- {
- *value = (int)v;
- return NULL;
- };
- dbus_message_unref (ret);
-
- const char *name;
- ret = GNUNET_DBUS_message_iter_pop_string (mc, iter, arg_name, &name);
- if (! ret)
- {
- int i;
- for (i = 0; names[i].name; i++)
- {
- if (! strcmp (name, names[i].name))
- {
- *value = names[i].value;
- break;
- };
- };
- if (! names[i].name)
- {
- char *errmsg = NULL;
- GNUNET_append_sprintf (&errmsg, "Unrecognized option '%s'. Valid options
are: [", name);
- for (i = 0; names[i].name; i++)
- GNUNET_append_sprintf (&errmsg, "%s'%s'", i ? ", " : "",
names[i].name);
- GNUNET_append_sprintf (&errmsg, "].");
- ret = dbus_message_new_error_printf (
- mc->message,
- DBUS_ERROR_INVALID_ARGS,
- "%s",
- errmsg);
- GNUNET_free (errmsg);
- return ret;
- };
- return NULL;
- };
- dbus_message_unref (ret);
-
- return dbus_message_new_error_printf (
- mc->message,
- DBUS_ERROR_INVALID_ARGS,
- "Bad argument for '%s'. Expected either a uint32 or a string option",
- arg_name);
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_hashcode (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- struct GNUNET_HashCode *hc)
-{
- const char *hc_in;
- DBusMessage *ret = GNUNET_DBUS_message_iter_pop_string (mc, iter, arg_name,
&hc_in);
- if (ret)
- return ret;
-
- int err = GNUNET_CRYPTO_hash_from_string2 (hc_in, strlen(hc_in), hc);
- if (GNUNET_OK != err)
- {
- return dbus_message_new_error_printf (
- mc->message,
- DBUS_ERROR_INVALID_ARGS,
- "Bad argument for '%s'. Malformed hash string.
GNUNET_CRYPTO_hash_from_string2 returned %d",
- arg_name,
- err);
- };
-
- return NULL;
-};
-
-#if 0
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_socket (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- struct GNUNET_NETWORK_Handle **socket_handle)
-{
- const char *address;
-
- DBusMessage *ret = GNUNET_DBUS_message_iter_pop_string (message, iter,
arg_name, &address);
- if (ret)
- return ret;
-
- *socket_handle = GNUNET_DBUS_create_socket_from_dbus_address (address);
- if (! *socket_handle)
- {
- return dbus_message_new_error_printf (
- message,
- DBUS_ERROR_INVALID_ARGS,
- "Bad argument for '%s'. Malformed address",
- arg_name);
- };
-
- return NULL;
-};
-#endif
-
-
-#if 0 // make it use variants and set pretty
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_absolute_time (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- struct GNUNET_TIME_Absolute *value)
-{
- const char *time;
- DBusMessage *ret = GNUNET_DBUS_message_iter_pop_string (mc, iter, arg_name,
&time);
- if (ret)
- {
- dbus_message_unref (ret);
- ret = GNUNET_DBUS_message_iter_pop_uint64 (mc, iter, arg_name,
&value->abs_value_us);
- if (ret)
- return ret;
- };
-
- int err = GNUNET_STRINGS_fancy_time_to_absolute (time, value);
- if (GNUNET_OK != err)
- {
- return dbus_message_new_error_printf (
- mc->message,
- DBUS_ERROR_INVALID_ARGS,
- "Bad argument for '%s'. Malformed time string.
GNUNET_STRINGS_fancy_time_to_absolute returned %d",
- arg_name,
- err);
- };
-
- return NULL;
-};
-#endif
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_enter_variant (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- DBusMessageIter *iter_sub,
- const char *arg_name)
-{
- int arg_type = dbus_message_iter_get_arg_type (iter);
- if (DBUS_TYPE_VARIANT != arg_type)
- {
- return dbus_message_new_error_printf (
- mc->message,
- DBUS_ERROR_INVALID_ARGS,
- "Bad argument for '%s'. Expected '%s'. Got '%s'.",
- arg_name,
- GNUNET_DBUS_signature_typecode_to_string (DBUS_TYPE_VARIANT),
- GNUNET_DBUS_signature_typecode_to_string (arg_type));
- };
-
- dbus_message_iter_recurse (iter, iter_sub);
- dbus_message_iter_next (iter);
- return NULL;
-}
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_enter_struct (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- DBusMessageIter *iter_sub,
- const char *arg_name)
-{
- int arg_type = dbus_message_iter_get_arg_type (iter);
- if (DBUS_TYPE_STRUCT != arg_type)
- {
- return dbus_message_new_error_printf (
- mc->message,
- DBUS_ERROR_INVALID_ARGS,
- "Bad argument for '%s'. Expected '%s'. Got '%s'.",
- arg_name,
- GNUNET_DBUS_signature_typecode_to_string (DBUS_TYPE_STRUCT),
- GNUNET_DBUS_signature_typecode_to_string (arg_type));
- };
-
- dbus_message_iter_recurse (iter, iter_sub);
- return NULL;
-}
-
-void
-GNUNET_DBUS_message_iter_pop_exit_struct (
- DBusMessageIter *iter)
-{
- int arg_type = dbus_message_iter_get_arg_type (iter);
- if (DBUS_TYPE_STRUCT != arg_type)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DBUS_message_iter_pop_exit_struct
called when not inside a struct\n");
- GNUNET_abort ();
- }
-
- dbus_message_iter_next (iter);
-}
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_ecdsa_public_key (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- struct GNUNET_CRYPTO_EcdsaPublicKey *value)
-{
- DBusMessage *ret = NULL;
- DBusMessageIter iter_sub;
- DBusMessageIter iter_sub_sub;
-
- ret = GNUNET_DBUS_message_iter_pop_enter_variant (mc, iter, &iter_sub,
arg_name);
- if (ret)
- return ret;
-
- const char *encoded;
- int success;
- int arg_type = dbus_message_iter_get_arg_type (&iter_sub);
- int element_type;
- int n_elements;
- unsigned char *marshalled_array;
- switch (arg_type)
- {
- case DBUS_TYPE_STRING:
- dbus_message_iter_get_basic (&iter_sub, &encoded);
- success = GNUNET_CRYPTO_ecdsa_public_key_from_string (encoded, strlen
(encoded), value);
- if (GNUNET_OK != success)
- {
- return dbus_message_new_error_printf (
- mc->message,
- DBUS_ERROR_INVALID_ARGS,
- "String is not a valid base32 encoded ECDSA public key for argument
'%s'",
- arg_name);
- }
- GNUNET_DBUS_client_set_prefers_pretty_encodings (mc->client, true);
- return NULL;
- case DBUS_TYPE_ARRAY:
- element_type = dbus_message_iter_get_element_type (&iter_sub);
- if (DBUS_TYPE_BYTE == element_type)
- {
- dbus_message_iter_recurse (&iter_sub, &iter_sub_sub);
- dbus_message_iter_get_fixed_array (&iter_sub_sub, &marshalled_array,
&n_elements);
- if (sizeof (value->q_y) == n_elements)
- {
- memcpy (value->q_y, marshalled_array, n_elements);
- return NULL;
- };
- return dbus_message_new_error_printf (
- mc->message,
- DBUS_ERROR_INVALID_ARGS,
- "ECDSA public key consists of 32 bytes (256 bits). Array given for
argument '%s' contains %d bytes.",
- arg_name,
- n_elements);
- };
- return dbus_message_new_error_printf (
- mc->message,
- DBUS_ERROR_INVALID_ARGS,
- "Invalid type for argument '%s'. Variant contains an array of '%s'.
Should contain a base32 encoded ECDSA public key in the form of a string or an
array of 32 bytes (256 bits).",
- arg_name,
- GNUNET_DBUS_signature_typecode_to_string (element_type));
- default:
- return dbus_message_new_error_printf (
- mc->message,
- DBUS_ERROR_INVALID_ARGS,
- "Invalid type in variant for argument '%s'. Should contain a base32
encoded ECDSA public key in the form of a string or an array of 32 bytes (256
bits). Contains '%s'",
- arg_name,
- GNUNET_DBUS_signature_typecode_to_string (arg_type));
- }
-}
-
-#if 0
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_ecdsa_signature (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- struct GNUNET_CRYPTO_EcdsaSignature *value)
-{
- DBusMessage *ret = NULL;
- DBusMessageIter iter_sub;
- DBusMessageIter iter_sub_sub;
- DBusMessageIter iter_sub_sub_sub;
- DBusMessage *ret = GNUNET_DBUS_message_iter_pop_enter_struct (message, iter,
&iter_sub, arg_name);
-
-}
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_ecc_signature_purpose (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- struct GNUNET_CRYPTO_EccSignaturePurpose *value)
-{
- DBusMessageIter iter_sub;
- DBusMessage *ret = NULL;
- ret = ret ? ret : GNUNET_DBUS_message_iter_pop_enter_struct (message, iter,
&iter_sub, arg_name);
- ret = ret ? ret : GNUNET_DBUS_message_iter_pop_uint32 (message, &iter_sub,
"size", &value->size);
- ret = ret ? ret : GNUNET_DBUS_message_iter_pop_uint32 (message, &iter_sub,
"purpose", &value->purpose);
- if (ret)
- return ret;
- GNUNET_DBUS_message_iter_pop_exit_struct (iter);
-
- return NULL;
-}
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_gnsrecord_block (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- struct GNUNET_GNSRECORD_Block *value)
-{
- DBusMessageIter iter_sub;
- DBusMessage *ret = NULL;
- struct GNUNET_TIME_Absolute expiration_time;
- ret = ret ? ret : GNUNET_DBUS_message_iter_pop_enter_struct
(message, iter, &iter_sub, arg_name);
- ret = ret ? ret : GNUNET_DBUS_message_iter_pop_ecdsa_signature
(message, &iter_sub, "signature", &value->signature);
- ret = ret ? ret : GNUNET_DBUS_message_iter_pop_ecdsa_public_key
(message, &iter_sub, "derived_key", &value->derived_key);
- ret = ret ? ret : GNUNET_DBUS_message_iter_pop_ecc_signature_purpose
(message, &iter_sub, "purpose", &value->purpose);
- ret = ret ? ret : GNUNET_DBUS_message_iter_pop_absolute_time
(message, &iter_sub, "expiration_time", &expiration_time);
- if (ret)
- return ret;
- GNUNET_DBUS_message_iter_pop_exit_struct (iter);
- value->expiration_time = GNUNET_TIME_absolute_hton (expiration_time);
-
- return NULL;
-}
-#endif
-
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_pop.h
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_pop.h 2014-02-21
17:05:07 UTC (rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_pop.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -1,154 +0,0 @@
-#ifndef GNUNET_DBUS_LIB_MESSAGE_ITER_POP
-#define GNUNET_DBUS_LIB_MESSAGE_ITER_POP
-
-#include <stdbool.h>
-
-#include <dbus/dbus.h>
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_crypto_lib.h>
-#include <gnunet/gnunet_gnsrecord_lib.h>
-
-#include "gnunet_dbus_lib_method_context.h"
-
-struct GNUNET_DBUS_StringEnumPair
-{
- const char *name;
- int value;
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_basic (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- int expected_type,
- void *value);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_string (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- const char **value);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_int32 (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- dbus_int32_t *value);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_uint32 (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- dbus_uint32_t *value);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_bool (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- dbus_bool_t *value);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_fixed_array (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- int expected_type,
- void *value,
- int *n_elements);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_array_byte (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- const char **value,
- int *n_elements);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_array_string (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- const char ***value,
- int *n_elements);
-
-/*
- * bitfield enums can be sent across the wire in either their integer form (as
- * an array of bit flags) or as an array of strings. Sending an int is more
- * efficient and is what libraries built around the DBus API would use, people
- * using the DBus API directly may want to pass human-readable strings for
- * convenience.
- */
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_bitfield (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- int *value,
- const struct GNUNET_DBUS_StringEnumPair *fields);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_enum (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- int *value,
- const struct GNUNET_DBUS_StringEnumPair *names);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_hashcode (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- struct GNUNET_HashCode *hc);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_socket (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- struct GNUNET_NETWORK_Handle **socket_handle);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_absolute_time (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- struct GNUNET_TIME_Absolute *value);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_ecdsa_public_key (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- struct GNUNET_CRYPTO_EcdsaPublicKey *value);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_ecdsa_signature (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- struct GNUNET_CRYPTO_EcdsaSignature *value);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_ecc_signature_purpose (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- struct GNUNET_CRYPTO_EccSignaturePurpose *value);
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_gnsrecord_block (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *arg_name,
- struct GNUNET_GNSRECORD_Block *value);
-
-#endif
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_push.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_push.c 2014-02-21
17:05:07 UTC (rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_push.c 2014-02-22
07:55:41 UTC (rev 32454)
@@ -1,219 +0,0 @@
-#include "config.h"
-
-#include <stdbool.h>
-
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_strings_lib.h>
-
-#include "gnunet_dbus_lib_signature.h"
-#include "gnunet_dbus_lib_client.h"
-#include "gnunet_dbus_lib_message_iter_push.h"
-
-#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-push", __VA_ARGS__)
-
-void
-GNUNET_DBUS_message_iter_push_basic (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- int type,
- void *value)
-{
- (void)mc;
- bool success = dbus_message_iter_append_basic (iter, type, value);
- if (! success)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Ran out of memory in
dbus_message_iter_append_basic\n");
- GNUNET_abort ();
- }
-}
-
-void
-GNUNET_DBUS_message_iter_push_int32 (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- int32_t value)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing int32\n");
- GNUNET_DBUS_message_iter_push_basic (
- mc,
- iter,
- DBUS_TYPE_INT32,
- &value);
-}
-
-void
-GNUNET_DBUS_message_iter_push_uint32 (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- uint32_t value)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing uint32\n");
- GNUNET_DBUS_message_iter_push_basic (
- mc,
- iter,
- DBUS_TYPE_UINT32,
- &value);
-}
-
-void
-GNUNET_DBUS_message_iter_push_uint64 (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- uint64_t value)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing uint64\n");
- GNUNET_DBUS_message_iter_push_basic (
- mc,
- iter,
- DBUS_TYPE_UINT64,
- &value);
-}
-
-void
-GNUNET_DBUS_message_iter_push_string (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *value)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing string\n");
- GNUNET_DBUS_message_iter_push_basic (
- mc,
- iter,
- DBUS_TYPE_STRING,
- &value);
-}
-
-void
-GNUNET_DBUS_message_iter_push_open_array (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- DBusMessageIter *iter_sub,
- const char *signature)
-{
- (void)mc;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Opening array\n");
- bool success = dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY,
signature, iter_sub);
- if (! success)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Ran out of memory in
dbus_message_iter_open_container\n");
- GNUNET_abort ();
- }
-}
-
-void
-GNUNET_DBUS_message_iter_push_close_container (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- DBusMessageIter *iter_sub)
-{
- (void)mc;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing container\n");
- bool success = dbus_message_iter_close_container (iter, iter_sub);
- if (! success)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Ran out of memory in
dbus_message_iter_close_container\n");
- GNUNET_abort ();
- }
-}
-
-/*
- * Push an array of fixed-size types. The array must be opened with
- * GNUNET_DBUS_message_iter_push_open_array first and closed with
- * GNUNET_DBUS_message_iter_push_close_container afterwards.
- */
-void
-GNUNET_DBUS_message_iter_push_fixed_array (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- int type,
- const void *value,
- size_t value_count)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing fixed array\n");
- bool success = dbus_message_iter_append_fixed_array (iter, type, value,
(int)value_count);
- if (! success)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Ran out of memory in
dbus_message_iter_push_fixed_array\n");
- GNUNET_abort ();
- }
-}
-
-void
-GNUNET_DBUS_message_iter_push_bytes (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const unsigned char *value,
- size_t value_count)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing byte array\n");
- GNUNET_DBUS_message_iter_push_fixed_array (
- mc,
- iter,
- DBUS_TYPE_BYTE,
- &value,
- value_count);
-}
-
-void
-GNUNET_DBUS_message_iter_push_open_variant (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- DBusMessageIter *iter_sub,
- const char *signature)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Opening variant\n");
- bool success = dbus_message_iter_open_container (iter, DBUS_TYPE_VARIANT,
signature, iter_sub);
- if (! success)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Ran out of memory in
dbus_message_iter_open_container when open variant\n");
- GNUNET_abort ();
- }
-}
-
-void
-GNUNET_DBUS_message_iter_push_time_absolute (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const struct GNUNET_TIME_Absolute *value)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing absolute time\n");
- DBusMessageIter iter_sub;
- if (GNUNET_DBUS_client_get_prefers_pretty_encodings (mc->client))
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Encoding time as string\n");
- GNUNET_DBUS_message_iter_push_open_variant (mc, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_STRING);
- GNUNET_DBUS_message_iter_push_string (mc, &iter_sub,
GNUNET_STRINGS_absolute_time_to_string (*value));
- GNUNET_DBUS_message_iter_push_close_variant (mc, iter, &iter_sub);
- }
- else
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Encoding time as uint64\n");
- GNUNET_DBUS_message_iter_push_open_variant (mc, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_UINT64);
- GNUNET_DBUS_message_iter_push_uint64 (mc, &iter_sub, value->abs_value_us);
- GNUNET_DBUS_message_iter_push_close_variant (mc, iter, &iter_sub);
- }
-};
-
-void
-GNUNET_DBUS_message_iter_push_gns_record (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const struct GNUNET_GNSRECORD_Data *value)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing GNUNET_GNSRECORD_Data\n");
- DBusMessageIter iter_sub;
- GNUNET_DBUS_message_iter_push_open_array (mc, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_BYTE);
- GNUNET_DBUS_message_iter_push_bytes (mc, &iter_sub, (const unsigned char
*)value->data, value->data_size);
- GNUNET_DBUS_message_iter_push_close_array (mc, iter, &iter_sub);
-
- struct GNUNET_TIME_Absolute expiration_time;
- expiration_time.abs_value_us = value->expiration_time;
- GNUNET_DBUS_message_iter_push_time_absolute (mc, iter, &expiration_time);
- GNUNET_DBUS_message_iter_push_uint32 (mc, iter, value->record_type);
- GNUNET_DBUS_message_iter_push_uint32 (mc, iter, value->flags);
-}
-
-
-
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_push.h
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_push.h 2014-02-21
17:05:07 UTC (rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_message_iter_push.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -1,92 +0,0 @@
-#ifndef GNUNET_DBUS_LIB_MESSAGE_ITER_PUSH_H
-#define GNUNET_DBUS_LIB_MESSAGE_ITER_PUSH_H
-
-#include <dbus/dbus.h>
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_crypto_lib.h>
-#include <gnunet/gnunet_gnsrecord_lib.h>
-
-#include "gnunet_dbus_lib_method_context.h"
-
-#define GNUNET_DBUS_message_iter_push_close_array
GNUNET_DBUS_message_iter_push_close_container
-#define GNUNET_DBUS_message_iter_push_close_variant
GNUNET_DBUS_message_iter_push_close_container
-
-void
-GNUNET_DBUS_message_iter_push_basic (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- int type,
- void *value);
-
-void
-GNUNET_DBUS_message_iter_push_int32 (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- int32_t value);
-
-void
-GNUNET_DBUS_message_iter_push_uint32 (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- uint32_t value);
-
-void
-GNUNET_DBUS_message_iter_push_uint64 (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- uint64_t value);
-
-void
-GNUNET_DBUS_message_iter_push_string (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const char *value);
-
-void
-GNUNET_DBUS_message_iter_push_open_array (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- DBusMessageIter *iter_sub,
- const char *signature);
-
-void
-GNUNET_DBUS_message_iter_push_close_container (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- DBusMessageIter *iter_sub);
-
-/*
- * Push an array of fixed-size types. The array must be opened with
- * GNUNET_DBUS_message_iter_push_open_array first and closed with
- * GNUNET_DBUS_message_iter_push_close_container afterwards.
- */
-void
-GNUNET_DBUS_message_iter_push_fixed_array (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- int type,
- const void *value,
- size_t value_count);
-
-void
-GNUNET_DBUS_message_iter_push_bytes (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const unsigned char *value,
- size_t value_count);
-
-void
-GNUNET_DBUS_message_iter_push_time_absolute (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const struct GNUNET_TIME_Absolute *value);
-
-void
-GNUNET_DBUS_message_iter_push_gns_record (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessageIter *iter,
- const struct GNUNET_GNSRECORD_Data *value);
-
-#endif
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_method.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_method.c 2014-02-21 17:05:07 UTC
(rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_method.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -1,145 +0,0 @@
-#include "config.h"
-
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_container_lib.h>
-
-#include "gnunet_dbus_lib_method.h"
-#include "gnunet_dbus_lib_arg.h"
-
-#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-method", __VA_ARGS__)
-
-struct GNUNET_DBUS_Method
-{
- struct GNUNET_DBUS_ArgIterator *args_front;
- struct GNUNET_DBUS_ArgIterator *args_back;
-
- struct GNUNET_DBUS_ArgIterator *return_args_front;
- struct GNUNET_DBUS_ArgIterator *return_args_back;
-
- char *name;
-
- void (*underlying_method)(struct GNUNET_DBUS_MethodContext *mc);
-
- unsigned ref_count;
-};
-
-struct GNUNET_DBUS_Method *
-GNUNET_DBUS_method_create (
- const char *name,
- void (*underlying_method)(struct GNUNET_DBUS_MethodContext *mc))
-{
- struct GNUNET_DBUS_Method *method = GNUNET_new (struct GNUNET_DBUS_Method);
- method->name = GNUNET_strdup (name);
- method->underlying_method = underlying_method;
- method->ref_count = 0;
-
- return method;
-};
-
-void
-GNUNET_DBUS_method_destroy (
- struct GNUNET_DBUS_Method *method)
-{
- if (0 != method->ref_count)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to destroy method that still has
references. name == \"%s\", ref_count == %zu\n", method->name,
method->ref_count);
- GNUNET_abort ();
- };
-
- GNUNET_free (method->name);
- GNUNET_free (method);
-};
-
-void
-GNUNET_DBUS_method_ref (
- struct GNUNET_DBUS_Method *method)
-{
- method->ref_count++;
-};
-
-void
-GNUNET_DBUS_method_unref (
- struct GNUNET_DBUS_Method *method)
-{
- if (method->ref_count == 0)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unreference method with ref count
0\n");
- GNUNET_abort ();
- };
- if (--method->ref_count == 0)
- GNUNET_DBUS_method_destroy (method);
-};
-
-void
-GNUNET_DBUS_method_add_arg (
- struct GNUNET_DBUS_Method *method,
- const char *name,
- const char *signature)
-{
- struct GNUNET_DBUS_Arg *arg = GNUNET_DBUS_arg_create (name, signature);
- struct GNUNET_DBUS_ArgIterator *arg_it = GNUNET_new (struct
GNUNET_DBUS_ArgIterator);
- arg_it->arg = arg;
- GNUNET_DBUS_arg_ref (arg);
- GNUNET_CONTAINER_DLL_insert_tail (method->args_front,
- method->args_back,
- arg_it);
-};
-
-void
-GNUNET_DBUS_method_add_return_arg (
- struct GNUNET_DBUS_Method *method,
- const char *name,
- const char *signature)
-{
- struct GNUNET_DBUS_Arg *arg = GNUNET_DBUS_arg_create (name, signature);
- struct GNUNET_DBUS_ArgIterator *arg_it = GNUNET_new (struct
GNUNET_DBUS_ArgIterator);
- arg_it->arg = arg;
- GNUNET_DBUS_arg_ref (arg);
- GNUNET_CONTAINER_DLL_insert_tail (method->return_args_front,
- method->return_args_back,
- arg_it);
-};
-
-const char *
-GNUNET_DBUS_method_get_name (
- const struct GNUNET_DBUS_Method *method)
-{
- return method->name;
-};
-
-const struct GNUNET_DBUS_ArgIterator *
-GNUNET_DBUS_method_iterate_args (
- const struct GNUNET_DBUS_Method *method)
-{
- return method->args_front;
-};
-
-const struct GNUNET_DBUS_ArgIterator *
-GNUNET_DBUS_method_iterate_return_args (
- const struct GNUNET_DBUS_Method *method)
-{
- return method->return_args_front;
-};
-
-void
-GNUNET_DBUS_method_call (
- struct GNUNET_DBUS_Method *method,
- struct GNUNET_DBUS_MethodContext *mc)
-{
- method->underlying_method (mc);
-};
-
-const struct GNUNET_DBUS_MethodIterator *
-GNUNET_DBUS_method_find (
- const struct GNUNET_DBUS_MethodIterator *meth_it,
- const char *name)
-{
- for (; meth_it; meth_it = meth_it->next)
- {
- if (! strcmp (name, meth_it->method->name))
- return meth_it;
- }
- return NULL;
-}
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_method.h
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_method.h 2014-02-21 17:05:07 UTC
(rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_method.h 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -1,72 +0,0 @@
-#ifndef GNUNET_DBUS_LIB_METHOD_H
-#define GNUNET_DBUS_LIB_METHOD_H
-
-#include <stdbool.h>
-
-struct GNUNET_DBUS_Method;
-
-#include "gnunet_dbus_lib_object.h"
-#include "gnunet_dbus_lib_method_context.h"
-
-struct GNUNET_DBUS_MethodIterator
-{
- /* linked list */
- struct GNUNET_DBUS_MethodIterator *next;
- struct GNUNET_DBUS_MethodIterator *prev;
-
- struct GNUNET_DBUS_Method *method;
-};
-
-struct GNUNET_DBUS_Method *
-GNUNET_DBUS_method_create (
- const char *name,
- void (*underlying_method)(struct GNUNET_DBUS_MethodContext *mc));
-
-void
-GNUNET_DBUS_method_destroy (
- struct GNUNET_DBUS_Method *method);
-
-void
-GNUNET_DBUS_method_ref (
- struct GNUNET_DBUS_Method *method);
-
-void
-GNUNET_DBUS_method_unref (
- struct GNUNET_DBUS_Method *method);
-
-void
-GNUNET_DBUS_method_add_arg (
- struct GNUNET_DBUS_Method *method,
- const char *name,
- const char *signature);
-
-void
-GNUNET_DBUS_method_add_return_arg (
- struct GNUNET_DBUS_Method *method,
- const char *name,
- const char *signature);
-
-const char *
-GNUNET_DBUS_method_get_name (
- const struct GNUNET_DBUS_Method *method);
-
-const struct GNUNET_DBUS_ArgIterator *
-GNUNET_DBUS_method_iterate_args (
- const struct GNUNET_DBUS_Method *method);
-
-const struct GNUNET_DBUS_ArgIterator *
-GNUNET_DBUS_method_iterate_return_args (
- const struct GNUNET_DBUS_Method *method);
-
-void
-GNUNET_DBUS_method_call (
- struct GNUNET_DBUS_Method *method,
- struct GNUNET_DBUS_MethodContext *mc);
-
-const struct GNUNET_DBUS_MethodIterator *
-GNUNET_DBUS_method_find (
- const struct GNUNET_DBUS_MethodIterator *meth_it,
- const char *name);
-
-#endif
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_method_context.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_method_context.c 2014-02-21
17:05:07 UTC (rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_method_context.c 2014-02-22
07:55:41 UTC (rev 32454)
@@ -1,86 +0,0 @@
-#include "config.h"
-
-#include <dbus/dbus.h>
-
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_container_lib.h>
-
-#include "gnunet_dbus_lib_service.h"
-#include "gnunet_dbus_lib_method.h"
-#include "gnunet_dbus_lib_arg.h"
-#include "gnunet_dbus_lib_method_context.h"
-
-#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-method-context",
__VA_ARGS__)
-
-struct GNUNET_DBUS_MethodContext *
-GNUNET_DBUS_method_context_create (
- struct GNUNET_DBUS_Client *client,
- struct GNUNET_DBUS_Service *service,
- struct GNUNET_DBUS_Object *object,
- struct GNUNET_DBUS_Interface *interface,
- struct GNUNET_DBUS_Method *method,
- DBusMessage *message)
-{
- struct GNUNET_DBUS_MethodContext *ret = GNUNET_new (struct
GNUNET_DBUS_MethodContext);
- ret->client = client;
- ret->service = service;
- ret->object = object;
- ret->interface = interface;
- ret->method = method;
- ret->message = message;
- ret->expects_reply = ! dbus_message_get_no_reply (message);
-
- ret->replied = false;
- ret->ref_count = 0;
- dbus_message_ref (message);
-
- return ret;
-};
-
-void
-GNUNET_DBUS_method_context_destroy (
- struct GNUNET_DBUS_MethodContext *mc)
-{
- if (0 != mc->ref_count)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to destroy method context with ref
count %u\n", mc->ref_count);
- GNUNET_abort ();
- };
-
- dbus_message_unref (mc->message);
- GNUNET_free (mc);
-};
-
-void
-GNUNET_DBUS_method_context_ref (
- struct GNUNET_DBUS_MethodContext *mc)
-{
- mc->ref_count++;
-};
-
-void
-GNUNET_DBUS_method_context_unref (
- struct GNUNET_DBUS_MethodContext *mc)
-{
- if (0 == mc->ref_count)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unreference method context with
ref count 0\n");
- GNUNET_abort ();
- };
- if (0 == --mc->ref_count)
- GNUNET_DBUS_method_context_destroy (mc);
-};
-
-void
-GNUNET_DBUS_method_context_send_reply (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessage *reply)
-{
- if (! mc->expects_reply)
- return;
-
- GNUNET_DBUS_service_send (mc->service, reply);
- dbus_message_unref (reply);
-};
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_method_context.h
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_method_context.h 2014-02-21
17:05:07 UTC (rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_method_context.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -1,48 +0,0 @@
-#ifndef GNUNET_DBUS_LIB_METHOD_CONTEXT_H
-#define GNUNET_DBUS_LIB_METHOD_CONTEXT_H
-
-#include <stdbool.h>
-
-#include <dbus/dbus.h>
-
-struct GNUNET_DBUS_MethodContext
-{
- struct GNUNET_DBUS_Client *client;
- struct GNUNET_DBUS_Service *service;
- struct GNUNET_DBUS_Object *object;
- struct GNUNET_DBUS_Interface *interface;
- struct GNUNET_DBUS_Method *method;
- DBusMessage *message;
- bool expects_reply;
- bool replied;
- unsigned ref_count;
-};
-
-struct GNUNET_DBUS_MethodContext *
-GNUNET_DBUS_method_context_create (
- struct GNUNET_DBUS_Client *client,
- struct GNUNET_DBUS_Service *service,
- struct GNUNET_DBUS_Object *object,
- struct GNUNET_DBUS_Interface *interface,
- struct GNUNET_DBUS_Method *method,
- DBusMessage *message);
-
-void
-GNUNET_DBUS_method_context_destroy (
- struct GNUNET_DBUS_MethodContext *mc);
-
-void
-GNUNET_DBUS_method_context_ref (
- struct GNUNET_DBUS_MethodContext *mc);
-
-void
-GNUNET_DBUS_method_context_unref (
- struct GNUNET_DBUS_MethodContext *mc);
-
-void
-GNUNET_DBUS_method_context_send_reply (
- struct GNUNET_DBUS_MethodContext *mc,
- DBusMessage *reply);
-
-#endif
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_object.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_object.c 2014-02-21 17:05:07 UTC
(rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_object.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -1,107 +0,0 @@
-#include "config.h"
-
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_container_lib.h>
-
-#include "gnunet_dbus_lib_object.h"
-#include "gnunet_dbus_lib_interface.h"
-
-#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-object", __VA_ARGS__)
-
-struct GNUNET_DBUS_Object
-{
- struct GNUNET_DBUS_InterfaceIterator *interfaces_front;
- struct GNUNET_DBUS_InterfaceIterator *interfaces_back;
-
- char *path;
- void *data;
- unsigned ref_count;
-};
-
-struct GNUNET_DBUS_Object *
-GNUNET_DBUS_object_create (
- const char *path,
- void *data)
-{
- struct GNUNET_DBUS_Object *object = GNUNET_new (struct GNUNET_DBUS_Object);
- object->path = GNUNET_strdup (path);
- object->data = data;
- object->interfaces_front = NULL;
- object->interfaces_back = NULL;
- object->ref_count = 0;
-
- return object;
-};
-
-void
-GNUNET_DBUS_object_destroy (
- struct GNUNET_DBUS_Object *object)
-{
- if (0 != object->ref_count)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to destroy object that still has
references. path == \"%s\", ref_count == %zu\n", object->path,
object->ref_count);
- GNUNET_abort ();
- };
-
- struct GNUNET_DBUS_InterfaceIterator *int_it = object->interfaces_front;
- while (int_it)
- {
- struct GNUNET_DBUS_InterfaceIterator *next = int_it->next;
- GNUNET_DBUS_interface_unref (int_it->interface);
- GNUNET_free (int_it);
- int_it = next;
- };
-
- GNUNET_free (object->path);
- GNUNET_free (object);
-};
-
-void
-GNUNET_DBUS_object_ref (
- struct GNUNET_DBUS_Object *object)
-{
- object->ref_count++;
-};
-
-void
-GNUNET_DBUS_object_unref (
- struct GNUNET_DBUS_Object *object)
-{
- if (object->ref_count == 0)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unreference object with ref count
0\n");
- GNUNET_abort ();
- };
- if (--object->ref_count == 0)
- GNUNET_DBUS_object_destroy (object);
-};
-
-const char *
-GNUNET_DBUS_object_get_path (
- struct GNUNET_DBUS_Object *object)
-{
- return object->path;
-};
-
-void
-GNUNET_DBUS_object_add_interface (
- struct GNUNET_DBUS_Object *object,
- struct GNUNET_DBUS_Interface *interface)
-{
- struct GNUNET_DBUS_InterfaceIterator *int_it = GNUNET_new (struct
GNUNET_DBUS_InterfaceIterator);
- int_it->interface = interface;
- GNUNET_DBUS_interface_ref (interface);
-
- GNUNET_CONTAINER_DLL_insert (object->interfaces_front,
- object->interfaces_back,
- int_it);
-};
-
-const struct GNUNET_DBUS_InterfaceIterator *
-GNUNET_DBUS_object_iterate_interfaces (
- struct GNUNET_DBUS_Object *object)
-{
- return object->interfaces_front;
-};
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_object.h
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_object.h 2014-02-21 17:05:07 UTC
(rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_object.h 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -1,48 +0,0 @@
-#ifndef GNUNET_DBUS_LIB_OBJECT_H
-#define GNUNET_DBUS_LIB_OBJECT_H
-
-struct GNUNET_DBUS_Object;
-
-#include "gnunet_dbus_lib_interface.h"
-
-struct GNUNET_DBUS_ObjectIterator
-{
- /* linked list */
- struct GNUNET_DBUS_ObjectIterator *next;
- struct GNUNET_DBUS_ObjectIterator *prev;
-
- struct GNUNET_DBUS_Object *object;
-};
-
-struct GNUNET_DBUS_Object *
-GNUNET_DBUS_object_create (
- const char *path,
- void *data);
-
-void
-GNUNET_DBUS_object_destroy (
- struct GNUNET_DBUS_Object *object);
-
-void
-GNUNET_DBUS_object_ref (
- struct GNUNET_DBUS_Object *object);
-
-void
-GNUNET_DBUS_object_unref (
- struct GNUNET_DBUS_Object *object);
-
-const char *
-GNUNET_DBUS_object_get_path (
- struct GNUNET_DBUS_Object *object);
-
-void
-GNUNET_DBUS_object_add_interface (
- struct GNUNET_DBUS_Object *object,
- struct GNUNET_DBUS_Interface *interface);
-
-const struct GNUNET_DBUS_InterfaceIterator *
-GNUNET_DBUS_object_iterate_interfaces (
- struct GNUNET_DBUS_Object *object);
-
-#endif
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_service.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_service.c 2014-02-21 17:05:07 UTC
(rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_service.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -1,558 +0,0 @@
-#include "config.h"
-
-#include <stdbool.h>
-#include <dbus/dbus.h>
-
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_scheduler_lib.h>
-#include <gnunet/gnunet_container_lib.h>
-
-#include "gnunet_dbus_lib_service.h"
-#include "gnunet_dbus_lib_object.h"
-#include "gnunet_dbus_lib_arg.h"
-#include "gnunet_dbus_lib_client.h"
-
-#include "watch.h"
-#include "timeout.h"
-
-#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-service", __VA_ARGS__)
-
-struct GNUNET_DBUS_Service
-{
- struct GNUNET_DBUS_ObjectIterator *objects_front;
- struct GNUNET_DBUS_ObjectIterator *objects_back;
-
- DBusConnection *dbus_connection;
- const struct GNUNET_CONFIGURATION_Handle *cfg;
-
- char *gnunet_name;
- char *well_known_name;
-
- /*
- * Linked list of watches
- */
- struct WatchIter *watches_front;
- struct WatchIter *watches_back;
-
- /*
- * Linked list of timeouts
- */
- struct TimeoutIter *timeouts_front;
- struct TimeoutIter *timeouts_back;
-
- /*
- * Linked list of clients
- */
- struct GNUNET_DBUS_ClientIterator *clients_front;
- struct GNUNET_DBUS_ClientIterator *clients_back;
-
- GNUNET_DBUS_ClientConnectsHandler client_connects;
- GNUNET_DBUS_ClientDisconnectsHandler client_disconnects;
-};
-
-static dbus_int32_t service_slot_id ()
-{
- static dbus_int32_t id = -1;
- if (-1 == id)
- {
- dbus_bool_t succ = dbus_connection_allocate_data_slot (&id);
- if (! succ || -1 == id)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "dbus_connection_allocate_data_slot
failed. id == %lld\n", (long long)id);
- GNUNET_abort ();
- };
- };
-
- return id;
-};
-
-/*
- * Called by DBus when it has a new watch that it wants us to watch.
- *
- * @param watch The DBus watch, created and passed to us by DBus.
- * @param data the GNUNET_DBUS_Service we passed to
dbus_connection_set_watch_functions
- * @return true on success, false on an unrecoverable error.
- */
-static dbus_bool_t
-watch_add (
- DBusWatch *watch,
- void *data)
-{
- struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
- struct Watch *w = watch_create (watch);
-
- if (dbus_watch_get_enabled (watch))
- watch_schedule (w);
-
- struct WatchIter *wi = GNUNET_new (struct WatchIter);
- wi->w = w;
- GNUNET_CONTAINER_DLL_insert (service->watches_front,
- service->watches_back,
- wi);
- watch_ref (w);
- return true;
-};
-
-/*
- * Called by DBus when it want to permanently disable and remove a watch
- *
- * @param watch The DBus watch, passed to us by DBus.
- * @param data the GNUNET_DBUS_Service we passed to
dbus_connection_set_watch_functions
- */
-static void
-watch_remove (
- DBusWatch *watch,
- void *data)
-{
- struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
- struct WatchIter *wi = watch_find (service->watches_front, watch);
-
- if (NULL == wi)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Asked to remove watch that has not been
added\n");
- GNUNET_abort ();
- };
-
- struct Watch *w = wi->w;
- watch_unschedule (w);
- GNUNET_CONTAINER_DLL_remove (service->watches_front,
- service->watches_back,
- wi);
- watch_unref (w);
-};
-
-/*
- * Called by DBus when it wants to enable or disable a watch.
- * Schedules or unschedules the scheduler to monitor this watch as appropriate.
- *
- * @param watch The DBus watch, passed to us by DBus.
- * @param data the GNUNET_DBUS_Service we passed to
dbus_connection_set_watch_functions
- */
-static void
-watch_toggle (
- DBusWatch *watch,
- void *data)
-{
- struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
- struct WatchIter *wi = watch_find (service->watches_front, watch);
-
- if (NULL == wi)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Asked to toggle watch that has not been
added\n");
- GNUNET_abort ();
- };
-
- struct Watch *w = wi->w;
- if (dbus_watch_get_enabled (watch))
- watch_unschedule (w);
- else
- watch_schedule (w);
-};
-
-static dbus_bool_t
-timeout_add (
- DBusTimeout *timeout,
- void *data)
-{
- struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
- struct Timeout *t = timeout_create (timeout);
-
- if (dbus_timeout_get_enabled (timeout))
- timeout_schedule (t);
-
- struct TimeoutIter *ti = GNUNET_new (struct TimeoutIter);
- ti->t = t;
- GNUNET_CONTAINER_DLL_insert (service->timeouts_front,
- service->timeouts_back,
- ti);
- timeout_ref (t);
- return true;
-};
-
-static void
-timeout_remove (
- DBusTimeout *timeout,
- void *data)
-{
- struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
- struct TimeoutIter *ti = timeout_find (service->timeouts_front, timeout);
-
- if (NULL == ti)
- {
- LOG (GNUNET_ERROR_TYPE_WARNING, "Asked to remove timeout that has not been
added\n");
- return;
- };
-
- struct Timeout *t = ti->t;
- timeout_unschedule (t);
- GNUNET_CONTAINER_DLL_remove (service->timeouts_front,
- service->timeouts_back,
- ti);
- timeout_unref (t);
-};
-
-static void
-timeout_toggle (
- DBusTimeout *timeout,
- void *data)
-{
- struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
- struct TimeoutIter *ti = timeout_find (service->timeouts_front, timeout);
-
- if (NULL == ti)
- {
- LOG (GNUNET_ERROR_TYPE_WARNING, "asked to toggle timeout that has not been
added\n");
- return;
- };
-
- struct Timeout *t = ti->t;
- if (dbus_timeout_get_enabled (timeout))
- timeout_unschedule (t);
- else
- timeout_schedule (t);
-};
-
-static void
-dispatch (
- void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc);
-
-static void
-handle_dispatch (
- DBusConnection *dbus_connection,
- DBusDispatchStatus status)
-{
- switch (status)
- {
- case DBUS_DISPATCH_DATA_REMAINS:
- GNUNET_SCHEDULER_add_continuation (
- dispatch,
- dbus_connection,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
- break;
- case DBUS_DISPATCH_COMPLETE:
- break;
- case DBUS_DISPATCH_NEED_MEMORY:
- LOG (GNUNET_ERROR_TYPE_ERROR, "Out of memory!\n");
- GNUNET_abort ();
- break;
- default:
- LOG (GNUNET_ERROR_TYPE_ERROR, "Unrecognized dispatch status\n");
- break;
- };
-};
-
-static void
-dispatch (
- void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct DBusConnection *dbus_connection = (struct DBusConnection *)cls;
- dbus_connection_dispatch (dbus_connection);
- handle_dispatch (dbus_connection, dbus_connection_get_dispatch_status
(dbus_connection));
-};
-
-static void
-dispatch_status_changed (
- DBusConnection *dbus_connection,
- DBusDispatchStatus new_status,
- void *data)
-{
- (void)data;
- handle_dispatch (dbus_connection, new_status);
-};
-
-struct GNUNET_DBUS_Service *
-GNUNET_DBUS_service_create (
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- const char *name)
-{
- struct GNUNET_DBUS_Service *service = GNUNET_new (struct
GNUNET_DBUS_Service);
- service->cfg = cfg;
- service->gnunet_name = GNUNET_strdup (name);
- service->watches_front = NULL;
- service->watches_back = NULL;
- service->timeouts_front = NULL;
- service->timeouts_back = NULL;
- service->objects_front = NULL;
- service->objects_back = NULL;
- service->client_connects = NULL;
- service->client_disconnects = NULL;
-
- DBusError err;
- dbus_error_init(&err);
-
- service->dbus_connection = dbus_bus_get_private (DBUS_BUS_SYSTEM, &err);
- if (! service->dbus_connection)
- LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to connect to dbus system bus
(%s)\n", dbus_error_is_set (&err) ? err.message : "dbus_bus_get_private
returned NULL");
- else
- {
- dbus_connection_set_exit_on_disconnect (service->dbus_connection,
- false);
- dbus_bool_t succ = dbus_connection_set_data (service->dbus_connection,
- service_slot_id (),
- service,
- NULL);
- if (! succ)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "dbus_connection_set_data returned false.
Out of memory.\n");
- GNUNET_abort ();
- };
-
- succ = dbus_connection_set_watch_functions (service->dbus_connection,
watch_add, watch_remove, watch_toggle, service, NULL);
- if(! succ)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "dbus_connection_set_watch_functions
returned false. Out of memory.\n");
- GNUNET_abort ();
- };
-
- dbus_connection_set_dispatch_status_function (service->dbus_connection,
dispatch_status_changed, service, NULL);
- handle_dispatch (service->dbus_connection,
dbus_connection_get_dispatch_status (service->dbus_connection));
-
- succ = dbus_connection_set_timeout_functions (service->dbus_connection,
timeout_add, timeout_remove, timeout_toggle, service, NULL);
- if (! succ)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "dbus_connection_set_timeout_functions
returned false. Out of memory.\n");
- GNUNET_abort ();
- };
-
- service->well_known_name = NULL;
- GNUNET_asprintf (&service->well_known_name, "gnu.gnunet.%s", name);
- int request_result = dbus_bus_request_name (service->dbus_connection,
service->well_known_name, DBUS_NAME_FLAG_DO_NOT_QUEUE, &err);
- if (dbus_error_is_set (&err))
- LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to request the bus name (%s)\n",
err.message);
- else
- {
- switch(request_result)
- {
- case DBUS_REQUEST_NAME_REPLY_EXISTS:
- LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to request the bus name \"%s\";
name is already taken.\n", service->well_known_name);
- break;
- default:
- LOG (GNUNET_ERROR_TYPE_ERROR, "Unable to interpret result of
dbus_request_name (%d)\n", request_result);
- break;
- case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
-
- /* Success! */
- return service;
-
- }
- }
- dbus_connection_close (service->dbus_connection);
- dbus_connection_unref (service->dbus_connection);
- }
- GNUNET_free (service->well_known_name);
- GNUNET_free (service->gnunet_name);
- GNUNET_free (service);
- LOG (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DBUS_service create failed.\n");
- return NULL;
-};
-
-void
-GNUNET_DBUS_service_destroy (
- struct GNUNET_DBUS_Service *service)
-{
- struct GNUNET_DBUS_ObjectIterator *objects_it = service->objects_front;
- while (objects_it)
- {
- struct GNUNET_DBUS_ObjectIterator *next = objects_it->next;
- GNUNET_DBUS_object_unref (objects_it->object);
- GNUNET_free (objects_it);
- objects_it = next;
- };
-
- GNUNET_free (service->well_known_name);
- GNUNET_free (service->gnunet_name);
- GNUNET_free (service);
-};
-
-const struct GNUNET_CONFIGURATION_Handle *
-GNUNET_DBUS_service_get_config (
- struct GNUNET_DBUS_Service *service)
-{
- return service->cfg;
-};
-
-/*
- * Called whenever a message arrives from DBus
- *
- * @param conn The connection it arrived on.
- * @param message The message
- * @param cls The closure passed to dbus_connection_try_register_object_path
- * in our case this is the GNUNET_DBUS_Object that the message was
- * sent to.
- *
- * @return DBUS_HANDLER_RESULT_NEED_MEMORY if anything failed due to lack of
- * memory.
- * DBUS_HANDLER_RESULT_HANDLED if any method returned a reply.
- * DBUS_HANDLER_RESULT_NOT_YET_HANDLED otherwise.
- */
-DBusHandlerResult
-handle_object_message (
- DBusConnection *connection,
- DBusMessage *dbus_message,
- void *cls)
-{
- struct GNUNET_DBUS_Object *object = (struct GNUNET_DBUS_Object *)cls;
-
- const char *object_path = dbus_message_get_path (dbus_message);
- const char *type_string = dbus_message_type_to_string
(dbus_message_get_type (dbus_message));
- const char *interface_name = dbus_message_get_interface (dbus_message);
- const char *member_name = dbus_message_get_member (dbus_message);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Recieved DBus message for %s\n", object_path);
- LOG (GNUNET_ERROR_TYPE_DEBUG, " type == %s\n", type_string ?
type_string : "(none)");
- LOG (GNUNET_ERROR_TYPE_DEBUG, " interface == %s\n", interface_name ?
interface_name : "(none)");
- LOG (GNUNET_ERROR_TYPE_DEBUG, " member == %s\n", member_name ?
member_name : "(none)");
-
- struct GNUNET_DBUS_Service *service = dbus_connection_get_data (connection,
service_slot_id ());
-
- const char *unique_name = dbus_message_get_sender (dbus_message);
- struct GNUNET_DBUS_ClientIterator *client_it = service->clients_front;
- struct GNUNET_DBUS_Client *client = NULL;
- for (; client_it; client_it = client_it->next)
- {
- client = client_it->client;
- const char *this_unique_name = GNUNET_DBUS_client_get_unique_name (client);
- if (! strcmp (unique_name, this_unique_name))
- break;
- };
- if (! client_it)
- {
- client = GNUNET_DBUS_client_create (unique_name);
- client_it = GNUNET_new (struct GNUNET_DBUS_ClientIterator);
- client_it->client = client;
- GNUNET_CONTAINER_DLL_insert (service->clients_front,
- service->clients_back,
- client_it);
- if (service->client_connects)
- service->client_connects (service, client);
- /*
-
- ** TODO **
-
- detect when a client is no longer on the bus and
- destroy the client object. At the moment this will slowly
- leak memory as clients come and go.
-
- */
- };
-
- if (! member_name)
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
- if (! interface_name)
- interface_name = service->well_known_name;
-
- int dbus_message_type = dbus_message_get_type (dbus_message);
- if (dbus_message_type != DBUS_MESSAGE_TYPE_METHOD_CALL)
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
- const struct GNUNET_DBUS_InterfaceIterator *int_it = \
- GNUNET_DBUS_interface_find ( \
- GNUNET_DBUS_object_iterate_interfaces (object),
- interface_name);
- if (! int_it)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG, "No such interface: %s\n", interface_name);
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- };
- struct GNUNET_DBUS_Interface *interface = int_it->interface;
-
- const struct GNUNET_DBUS_MethodIterator *meth_it = \
- GNUNET_DBUS_method_find ( \
- GNUNET_DBUS_interface_iterate_methods (interface),
- member_name);
- if (! meth_it)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG, "No such method: %s\n", member_name);
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- };
- struct GNUNET_DBUS_Method *method = meth_it->method;
-
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Found method.\n");
-
- struct GNUNET_DBUS_MethodContext *mc = GNUNET_DBUS_method_context_create (
- client,
- service,
- object,
- interface,
- method,
- dbus_message
- );
- GNUNET_DBUS_method_context_ref (mc);
- GNUNET_DBUS_method_call (method, mc);
- GNUNET_DBUS_method_context_unref (mc);
- return DBUS_HANDLER_RESULT_HANDLED;
-};
-
-int
-GNUNET_DBUS_service_add_object (
- struct GNUNET_DBUS_Service *service,
- struct GNUNET_DBUS_Object *object)
-{
- DBusError err;
- dbus_error_init(&err);
-
- const char *path = GNUNET_DBUS_object_get_path (object);
-
- DBusObjectPathVTable vtable;
- vtable.message_function = handle_object_message;
- vtable.unregister_function = NULL;
- dbus_bool_t succ = dbus_connection_try_register_object_path (
- service->dbus_connection,
- path,
- &vtable,
- object,
- &err);
- if (dbus_error_is_set (&err))
- {
- LOG (
- GNUNET_ERROR_TYPE_ERROR,
- "dbus_connection_try_register failed to register path \"%s\": %s\n",
- path,
- err.message);
- return GNUNET_SYSERR;
- };
- if (! succ)
- {
- LOG (
- GNUNET_ERROR_TYPE_ERROR,
- "dbus_connection_try_register returned false when registering path
\"%s\"\n",
- path);
- return GNUNET_SYSERR;
- };
-
- struct GNUNET_DBUS_ObjectIterator *object_it = GNUNET_new (struct
GNUNET_DBUS_ObjectIterator);
- object_it->object = object;
- GNUNET_DBUS_object_ref (object);
- GNUNET_CONTAINER_DLL_insert (service->objects_front,
- service->objects_back,
- object_it);
-
- return GNUNET_OK;
-};
-
-void
-GNUNET_DBUS_service_send (
- struct GNUNET_DBUS_Service *service,
- DBusMessage *dbus_message)
-{
- dbus_bool_t succ = dbus_connection_send (service->dbus_connection,
dbus_message, NULL);
- if (! succ)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "dbus_connection_send failed. Out of
memory.\n");
- GNUNET_abort ();
- };
-};
-
-void
-GNUNET_DBUS_service_set_client_handlers (
- struct GNUNET_DBUS_Service *service,
- GNUNET_DBUS_ClientConnectsHandler client_connects,
- GNUNET_DBUS_ClientDisconnectsHandler client_disconnects)
-{
- service->client_connects = client_connects;
- service->client_disconnects = client_disconnects;
-};
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_service.h
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_service.h 2014-02-21 17:05:07 UTC
(rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_service.h 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -1,51 +0,0 @@
-#ifndef GNUNET_DBUS_LIB_SERVICE_H
-#define GNUNET_DBUS_LIB_SERVICE_H
-
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_configuration_lib.h>
-
-struct GNUNET_DBUS_Service;
-
-#include "gnunet_dbus_lib_object.h"
-#include "gnunet_dbus_lib_client.h"
-
-typedef void (*GNUNET_DBUS_ClientConnectsHandler)(
- struct GNUNET_DBUS_Service *service,
- struct GNUNET_DBUS_Client *client);
-typedef void (*GNUNET_DBUS_ClientDisconnectsHandler)(
- struct GNUNET_DBUS_Service *service,
- struct GNUNET_DBUS_Client *client);
-
-struct GNUNET_DBUS_Service *
-GNUNET_DBUS_service_create (
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- const char *name);
-
-void
-GNUNET_DBUS_service_destroy (
- struct GNUNET_DBUS_Service *service);
-
-const struct GNUNET_CONFIGURATION_Handle *
-GNUNET_DBUS_service_get_config (
- struct GNUNET_DBUS_Service *service);
-
-int
-GNUNET_DBUS_service_add_object (
- struct GNUNET_DBUS_Service *service,
- struct GNUNET_DBUS_Object *object)
- __attribute__((warn_unused_result));
-
-void
-GNUNET_DBUS_service_send (
- struct GNUNET_DBUS_Service *service,
- DBusMessage *dbus_message);
-
-void
-GNUNET_DBUS_service_set_client_handlers (
- struct GNUNET_DBUS_Service *service,
- GNUNET_DBUS_ClientConnectsHandler client_connects,
- GNUNET_DBUS_ClientDisconnectsHandler client_disconnects);
-
-#endif
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_signature.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_signature.c 2014-02-21 17:05:07 UTC
(rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_signature.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -1,60 +0,0 @@
-#include "config.h"
-
-#include "gnunet_dbus_lib_signature.h"
-
-const char *
-GNUNET_DBUS_signature_typecode_to_string (
- int typecode)
-{
- switch (typecode)
- {
- case DBUS_TYPE_INVALID:
- return "invalid";
- case DBUS_TYPE_BOOLEAN:
- return "boolean";
- case DBUS_TYPE_BYTE:
- return "byte";
- case DBUS_TYPE_INT16:
- return "int16";
- case DBUS_TYPE_UINT16:
- return "uint16";
- case DBUS_TYPE_INT32:
- return "int32";
- case DBUS_TYPE_UINT32:
- return "uint32";
- case DBUS_TYPE_INT64:
- return "int64";
- case DBUS_TYPE_UINT64:
- return "uint64";
- case DBUS_TYPE_DOUBLE:
- return "double";
- case DBUS_TYPE_STRING:
- return "string";
- case DBUS_TYPE_OBJECT_PATH:
- return "object_path";
- case DBUS_TYPE_SIGNATURE:
- return "signature";
- case DBUS_TYPE_STRUCT:
- return "struct";
- case DBUS_TYPE_DICT_ENTRY:
- return "dict_entry";
- case DBUS_TYPE_ARRAY:
- return "array";
- case DBUS_TYPE_VARIANT:
- return "variant";
- case DBUS_STRUCT_BEGIN_CHAR:
- return "begin_struct";
- case DBUS_STRUCT_END_CHAR:
- return "end_struct";
- case DBUS_DICT_ENTRY_BEGIN_CHAR:
- return "begin_dict_entry";
- case DBUS_DICT_ENTRY_END_CHAR:
- return "end_dict_entry";
- case DBUS_TYPE_UNIX_FD:
- return "unix_fd";
- default:
- return "unknown";
- }
-}
-
-
Deleted: gnunet-dbus/src/lib/gnunet_dbus_lib_signature.h
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_signature.h 2014-02-21 17:05:07 UTC
(rev 32453)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_signature.h 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -1,62 +0,0 @@
-#ifndef GNUNET_DBUS_LIB_SIGNATURE_H
-#define GNUNET_DBUS_LIB_SIGNATURE_H
-
-#include <dbus/dbus.h>
-
-#define GNUNET_DBUS_SIGNATURE_BYTE DBUS_TYPE_BYTE_AS_STRING
-#define GNUNET_DBUS_SIGNATURE_BOOLEAN DBUS_TYPE_BOOLEAN_AS_STRING
-#define GNUNET_DBUS_SIGNATURE_INT16 DBUS_TYPE_INT16_AS_STRING
-#define GNUNET_DBUS_SIGNATURE_UINT16 DBUS_TYPE_UINT16_AS_STRING
-#define GNUNET_DBUS_SIGNATURE_INT32 DBUS_TYPE_INT32_AS_STRING
-#define GNUNET_DBUS_SIGNATURE_UINT32 DBUS_TYPE_UINT32_AS_STRING
-#define GNUNET_DBUS_SIGNATURE_INT64 DBUS_TYPE_INT64_AS_STRING
-#define GNUNET_DBUS_SIGNATURE_UINT64 DBUS_TYPE_UINT64_AS_STRING
-#define GNUNET_DBUS_SIGNATURE_DOUBLE DBUS_TYPE_DOUBLE_AS_STRING
-#define GNUNET_DBUS_SIGNATURE_STRING DBUS_TYPE_STRING_AS_STRING
-#define GNUNET_DBUS_SIGNATURE_OBJECT_PATH DBUS_TYPE_OBJECT_PATH_AS_STRING
-#define GNUNET_DBUS_SIGNATURE_SIGNATURE DBUS_TYPE_SIGNATURE_AS_STRING
-#define GNUNET_DBUS_SIGNATURE_UNIX_FD DBUS_TYPE_UNIX_FD_AS_STRING
-#define GNUNET_DBUS_SIGNATURE_VARIANT DBUS_TYPE_VARIANT_AS_STRING
-
-#define GNUNET_DBUS_SIGNATURE_ARRAY(s) DBUS_TYPE_ARRAY_AS_STRING s
-#define GNUNET_DBUS_SIGNATURE_DICT(s) DBUS_TYPE_ARRAY_AS_STRING
DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING s DBUS_DICT_ENTRY_END_CHAR_AS_STRING
-#define GNUNET_DBUS_SIGNATURE_STRUCT(s) DBUS_STRUCT_BEGIN_CHAR_AS_STRING s
DBUS_STRUCT_END_CHAR_AS_STRING
-
-#define GNUNET_DBUS_SIGNATURE_ABSOLUTE_TIME GNUNET_DBUS_SIGNATURE_VARIANT
-
-#define GNUNET_DBUS_SIGNATURE_GNSRECORD_DATA \
- GNUNET_DBUS_SIGNATURE_STRUCT ( \
- GNUNET_DBUS_SIGNATURE_ARRAY (GNUNET_DBUS_SIGNATURE_BYTE) \
- GNUNET_DBUS_SIGNATURE_ABSOLUTE_TIME \
- GNUNET_DBUS_SIGNATURE_UINT32 \
- GNUNET_DBUS_SIGNATURE_UINT32 \
- )
-
-#define GNUNET_DBUS_SIGNATURE_ECDSA_SIGNATURE \
- GNUNET_DBUS_SIGNATURE_STRUCT ( \
- GNUNET_DBUS_SIGNATURE_VARIANT \
- GNUNET_DBUS_SIGNATURE_VARIANT \
- )
-
-#define GNUNET_DBUS_SIGNATURE_ECC_SIGNATURE_PURPOSE \
- GNUNET_DBUS_SIGNATURE_STRUCT ( \
- GNUNET_DBUS_SIGNATURE_UINT32 \
- GNUNET_DBUS_SIGNATURE_UINT32 \
- )
-
-#define GNUNET_DBUS_SIGNATURE_GNSRECORD_BLOCK \
- GNUNET_DBUS_SIGNATURE_STRUCT ( \
- GNUNET_DBUS_SIGNATURE_ECDSA_SIGNATURE \
- GNUNET_DBUS_SIGNATURE_ECDSA_PUBLIC_KEY \
- GNUNET_DBUS_SIGNATURE_ECC_SIGNATURE_PURPOSE \
- GNUNET_DBUS_SIGNATURE_ABSOLUTE_TIME \
- )
-
-#define GNUNET_DBUS_SIGNATURE_ECDSA_PUBLIC_KEY GNUNET_DBUS_SIGNATURE_VARIANT
-
-const char *
-GNUNET_DBUS_signature_typecode_to_string (
- int typecode);
-
-#endif
-
Added: gnunet-dbus/src/lib/include/gnunet_block_dbus_lib.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_block_dbus_lib.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_block_dbus_lib.h 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,13 @@
+#ifndef GNUNET_BLOCK_DBUS_LIB_H
+#define GNUNET_BLOCK_DBUS_LIB_H
+
+#include <gnunet_dbus_lib.h>
+
+extern const struct GNUNET_DBUS_StringEnumPair
GNUNET_BLOCK_DBUS_type_description[];
+
+#include "gnunet_block_dbus_lib_pop.h"
+#include "gnunet_block_dbus_lib_push.h"
+#include "gnunet_block_dbus_lib_signature.h"
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_block_dbus_lib_pop.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_block_dbus_lib_pop.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_block_dbus_lib_pop.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,19 @@
+#ifndef GNUNET_BLOCK_DBUS_LIB_POP_H
+#define GNUNET_BLOCK_DBUS_LIB_POP_H
+
+#include <dbus/dbus.h>
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_block_lib.h>
+
+#include "gnunet_dbus_lib_method_context.h"
+
+DBusMessage *
+GNUNET_BLOCK_DBUS_pop_type (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ enum GNUNET_BLOCK_Type *value);
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_block_dbus_lib_push.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_block_dbus_lib_push.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_block_dbus_lib_push.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,13 @@
+#ifndef GNUNET_BLOCK_DBUS_LIB_PUSH_H
+#define GNUNET_BLOCK_DBUS_LIB_PUSH_H
+
+#include "gnunet_block_dbus_lib.h"
+
+void
+GNUNET_BLOCK_DBUS_push_type (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const enum GNUNET_BLOCK_Type *value);
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_block_dbus_lib_signature.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_block_dbus_lib_signature.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_block_dbus_lib_signature.h
2014-02-22 07:55:41 UTC (rev 32454)
@@ -0,0 +1,7 @@
+#ifndef GNUNET_BLOCK_DBUS_LIB_SIGNATURE_H
+#define GNUNET_BLOCK_DBUS_LIB_SIGNATURE_H
+
+#define GNUNET_BLOCK_DBUS_SIGNATURE_TYPE GNUNET_DBUS_SIGNATURE_VARIANT
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_crypto_dbus_lib.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_crypto_dbus_lib.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_crypto_dbus_lib.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,10 @@
+#ifndef GNUNET_CRYPTO_DBUS_LIB_H
+#define GNUNET_CRYPTO_DBUS_LIB_H
+
+#include <gnunet_dbus_lib.h>
+
+#include "gnunet_crypto_dbus_lib_pop.h"
+#include "gnunet_crypto_dbus_lib_signature.h"
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_crypto_dbus_lib_pop.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_crypto_dbus_lib_pop.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_crypto_dbus_lib_pop.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,12 @@
+#ifndef GNUNET_CRYPTO_DBUS_LIB_POP_H
+#define GNUNET_CRYPTO_DBUS_LIB_POP_H
+
+DBusMessage *
+GNUNET_CRYPTO_DBUS_pop_ecdsa_public_key (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ struct GNUNET_CRYPTO_EcdsaPublicKey *value);
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_crypto_dbus_lib_signature.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_crypto_dbus_lib_signature.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_crypto_dbus_lib_signature.h
2014-02-22 07:55:41 UTC (rev 32454)
@@ -0,0 +1,21 @@
+#ifndef GNUNET_CRYPTO_DBUS_LIB_SIGNATURE_H
+#define GNUNET_CRYPTO_DBUS_LIB_SIGNATURE_H
+
+#include "gnunet_dbus_lib.h"
+
+#define GNUNET_CRYPTO_DBUS_SIGNATURE_ECDSA_SIGNATURE \
+ GNUNET_DBUS_SIGNATURE_STRUCT ( \
+ GNUNET_DBUS_SIGNATURE_VARIANT \
+ GNUNET_DBUS_SIGNATURE_VARIANT \
+ )
+
+#define GNUNET_CRYPTO_DBUS_SIGNATURE_ECC_SIGNATURE_PURPOSE \
+ GNUNET_DBUS_SIGNATURE_STRUCT ( \
+ GNUNET_DBUS_SIGNATURE_UINT32 \
+ GNUNET_DBUS_SIGNATURE_UINT32 \
+ )
+
+#define GNUNET_CRYPTO_DBUS_SIGNATURE_ECDSA_PUBLIC_KEY
GNUNET_DBUS_SIGNATURE_VARIANT
+
+#endif
+
Copied: gnunet-dbus/src/lib/include/gnunet_dbus_lib.h (from rev 32345,
gnunet-dbus/src/lib/gnunet_dbus_lib.h)
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dbus_lib.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dbus_lib.h 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,22 @@
+#ifndef GNUNET_DBUS_LIB_H
+#define GNUNET_DBUS_LIB_H
+
+struct GNUNET_DBUS_StringEnumPair {
+ const char *name;
+ const int value;
+};
+
+#include "gnunet_dbus_lib_service.h"
+#include "gnunet_dbus_lib_object.h"
+#include "gnunet_dbus_lib_interface.h"
+#include "gnunet_dbus_lib_method.h"
+#include "gnunet_dbus_lib_arg.h"
+#include "gnunet_dbus_lib_message.h"
+#include "gnunet_dbus_lib_method_context.h"
+#include "gnunet_dbus_lib_client.h"
+#include "gnunet_dbus_lib_signature.h"
+#include "gnunet_dbus_lib_push.h"
+#include "gnunet_dbus_lib_pop.h"
+
+#endif
+
Copied: gnunet-dbus/src/lib/include/gnunet_dbus_lib_arg.h (from rev 32345,
gnunet-dbus/src/lib/gnunet_dbus_lib_arg.h)
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dbus_lib_arg.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dbus_lib_arg.h 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,55 @@
+#ifndef GNUNET_DBUS_LIB_ARG_H
+#define GNUNET_DBUS_LIB_ARG_H
+
+struct GNUNET_DBUS_Arg;
+
+struct GNUNET_DBUS_ArgIterator
+{
+ /* linked list */
+ struct GNUNET_DBUS_ArgIterator *next;
+ struct GNUNET_DBUS_ArgIterator *prev;
+
+ struct GNUNET_DBUS_Arg *arg;
+};
+
+struct GNUNET_DBUS_Arg *
+GNUNET_DBUS_arg_create (
+ const char *name,
+ const char *signature);
+
+void
+GNUNET_DBUS_arg_destroy (
+ struct GNUNET_DBUS_Arg *arg);
+
+void
+GNUNET_DBUS_arg_ref (
+ struct GNUNET_DBUS_Arg *arg);
+
+void
+GNUNET_DBUS_arg_unref (
+ struct GNUNET_DBUS_Arg *arg);
+
+const char *
+GNUNET_DBUS_arg_get_name (
+ const struct GNUNET_DBUS_Arg *arg);
+
+const char *
+GNUNET_DBUS_arg_get_signature (
+ const struct GNUNET_DBUS_Arg *arg);
+
+#if 0
+void
+GNUNET_DBUS_arg_pop_message (
+ const struct GNUNET_DBUS_Arg *arg,
+ DBusMessageIter *dbus_message_iter,
+ void *value);
+
+void
+GNUNET_DBUS_arg_push_message (
+ const struct GNUNET_DBUS_Arg *arg,
+ DBusMessageIter *dbus_message_iter,
+ va_list vl);
+#endif
+
+#endif
+
Copied: gnunet-dbus/src/lib/include/gnunet_dbus_lib_client.h (from rev 32345,
gnunet-dbus/src/lib/gnunet_dbus_lib_client.h)
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dbus_lib_client.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dbus_lib_client.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,47 @@
+#ifndef GNUNET_DBUS_CLIENT_H
+#define GNUNET_DBUS_CLIENT_H
+
+#include <stdbool.h>
+
+struct GNUNET_DBUS_Client;
+
+struct GNUNET_DBUS_ClientIterator
+{
+ struct GNUNET_DBUS_ClientIterator *next;
+ struct GNUNET_DBUS_ClientIterator *prev;
+
+ struct GNUNET_DBUS_Client *client;
+};
+
+struct GNUNET_DBUS_Client *
+GNUNET_DBUS_client_create (
+ const char *unique_name);
+
+void
+GNUNET_DBUS_client_destroy (
+ struct GNUNET_DBUS_Client *client);
+
+const char *
+GNUNET_DBUS_client_get_unique_name (
+ const struct GNUNET_DBUS_Client *client);
+
+void
+GNUNET_DBUS_client_set_data (
+ struct GNUNET_DBUS_Client *client,
+ void *data);
+
+void *
+GNUNET_DBUS_client_get_data (
+ const struct GNUNET_DBUS_Client *client);
+
+void
+GNUNET_DBUS_client_set_prefers_pretty_encodings (
+ struct GNUNET_DBUS_Client *client,
+ bool prefers_pretty_encodings);
+
+bool
+GNUNET_DBUS_client_get_prefers_pretty_encodings (
+ const struct GNUNET_DBUS_Client *client);
+
+#endif
+
Copied: gnunet-dbus/src/lib/include/gnunet_dbus_lib_interface.h (from rev
32345, gnunet-dbus/src/lib/gnunet_dbus_lib_interface.h)
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dbus_lib_interface.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dbus_lib_interface.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,59 @@
+#ifndef GNUNET_DBUS_LIB_INTERFACE_H
+#define GNUNET_DBUS_LIB_INTERFACE_H
+
+#include <stdbool.h>
+
+struct GNUNET_DBUS_Interface;
+
+#include "gnunet_dbus_lib_object.h"
+#include "gnunet_dbus_lib_method.h"
+#include "gnunet_dbus_lib_method_context.h"
+
+struct GNUNET_DBUS_InterfaceIterator
+{
+ /* linked list */
+ struct GNUNET_DBUS_InterfaceIterator *next;
+ struct GNUNET_DBUS_InterfaceIterator *prev;
+
+ struct GNUNET_DBUS_Interface *interface;
+};
+
+struct GNUNET_DBUS_Interface *
+GNUNET_DBUS_interface_create (
+ const char *name);
+
+void
+GNUNET_DBUS_interface_destroy (
+ struct GNUNET_DBUS_Interface *interface);
+
+void
+GNUNET_DBUS_interface_ref (
+ struct GNUNET_DBUS_Interface *interface);
+
+void
+GNUNET_DBUS_interface_unref (
+ struct GNUNET_DBUS_Interface *interface);
+
+void
+GNUNET_DBUS_interface_add_method (
+ struct GNUNET_DBUS_Interface *interface,
+ struct GNUNET_DBUS_Method *method);
+
+const char *
+GNUNET_DBUS_interface_get_name (
+ const struct GNUNET_DBUS_Interface *interface);
+
+const struct GNUNET_DBUS_MethodIterator *
+GNUNET_DBUS_interface_iterate_methods (
+ const struct GNUNET_DBUS_Interface *interface);
+
+struct GNUNET_DBUS_Interface *
+GNUNET_DBUS_interface_introspectable ();
+
+const struct GNUNET_DBUS_InterfaceIterator *
+GNUNET_DBUS_interface_find (
+ const struct GNUNET_DBUS_InterfaceIterator *int_it,
+ const char *name);
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_dbus_lib_message.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dbus_lib_message.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dbus_lib_message.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,17 @@
+#ifndef GNUNET_DBUS_LIB_MESSAGE_H
+#define GNUNET_DBUS_LIB_MESSAGE_H
+
+#include <stdbool.h>
+#include <dbus/dbus.h>
+
+bool
+GNUNET_DBUS_message_get_pretty (
+ DBusMessage *message);
+
+void
+GNUNET_DBUS_message_set_pretty (
+ DBusMessage *message,
+ bool pretty);
+
+#endif
+
Copied: gnunet-dbus/src/lib/include/gnunet_dbus_lib_method.h (from rev 32345,
gnunet-dbus/src/lib/gnunet_dbus_lib_method.h)
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dbus_lib_method.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dbus_lib_method.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,72 @@
+#ifndef GNUNET_DBUS_LIB_METHOD_H
+#define GNUNET_DBUS_LIB_METHOD_H
+
+#include <stdbool.h>
+
+struct GNUNET_DBUS_Method;
+
+#include "gnunet_dbus_lib_object.h"
+#include "gnunet_dbus_lib_method_context.h"
+
+struct GNUNET_DBUS_MethodIterator
+{
+ /* linked list */
+ struct GNUNET_DBUS_MethodIterator *next;
+ struct GNUNET_DBUS_MethodIterator *prev;
+
+ struct GNUNET_DBUS_Method *method;
+};
+
+struct GNUNET_DBUS_Method *
+GNUNET_DBUS_method_create (
+ const char *name,
+ void (*underlying_method)(struct GNUNET_DBUS_MethodContext *mc));
+
+void
+GNUNET_DBUS_method_destroy (
+ struct GNUNET_DBUS_Method *method);
+
+void
+GNUNET_DBUS_method_ref (
+ struct GNUNET_DBUS_Method *method);
+
+void
+GNUNET_DBUS_method_unref (
+ struct GNUNET_DBUS_Method *method);
+
+void
+GNUNET_DBUS_method_add_arg (
+ struct GNUNET_DBUS_Method *method,
+ const char *name,
+ const char *signature);
+
+void
+GNUNET_DBUS_method_add_return_arg (
+ struct GNUNET_DBUS_Method *method,
+ const char *name,
+ const char *signature);
+
+const char *
+GNUNET_DBUS_method_get_name (
+ const struct GNUNET_DBUS_Method *method);
+
+const struct GNUNET_DBUS_ArgIterator *
+GNUNET_DBUS_method_iterate_args (
+ const struct GNUNET_DBUS_Method *method);
+
+const struct GNUNET_DBUS_ArgIterator *
+GNUNET_DBUS_method_iterate_return_args (
+ const struct GNUNET_DBUS_Method *method);
+
+void
+GNUNET_DBUS_method_call (
+ struct GNUNET_DBUS_Method *method,
+ struct GNUNET_DBUS_MethodContext *mc);
+
+const struct GNUNET_DBUS_MethodIterator *
+GNUNET_DBUS_method_find (
+ const struct GNUNET_DBUS_MethodIterator *meth_it,
+ const char *name);
+
+#endif
+
Copied: gnunet-dbus/src/lib/include/gnunet_dbus_lib_method_context.h (from rev
32345, gnunet-dbus/src/lib/gnunet_dbus_lib_method_context.h)
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dbus_lib_method_context.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dbus_lib_method_context.h
2014-02-22 07:55:41 UTC (rev 32454)
@@ -0,0 +1,52 @@
+#ifndef GNUNET_DBUS_LIB_METHOD_CONTEXT_H
+#define GNUNET_DBUS_LIB_METHOD_CONTEXT_H
+
+#include <stdbool.h>
+
+#include <dbus/dbus.h>
+
+struct GNUNET_DBUS_MethodContext
+{
+ struct GNUNET_DBUS_Client *client;
+ struct GNUNET_DBUS_Service *service;
+ struct GNUNET_DBUS_Object *object;
+ struct GNUNET_DBUS_Interface *interface;
+ struct GNUNET_DBUS_Method *method;
+ DBusMessage *message;
+ bool expects_reply;
+ bool replied;
+ unsigned ref_count;
+};
+
+struct GNUNET_DBUS_MethodContext *
+GNUNET_DBUS_method_context_create (
+ struct GNUNET_DBUS_Client *client,
+ struct GNUNET_DBUS_Service *service,
+ struct GNUNET_DBUS_Object *object,
+ struct GNUNET_DBUS_Interface *interface,
+ struct GNUNET_DBUS_Method *method,
+ DBusMessage *message);
+
+void
+GNUNET_DBUS_method_context_destroy (
+ struct GNUNET_DBUS_MethodContext *mc);
+
+void
+GNUNET_DBUS_method_context_ref (
+ struct GNUNET_DBUS_MethodContext *mc);
+
+void
+GNUNET_DBUS_method_context_unref (
+ struct GNUNET_DBUS_MethodContext *mc);
+
+void
+GNUNET_DBUS_method_context_send_reply (
+ struct GNUNET_DBUS_MethodContext *mc,
+ DBusMessage *reply);
+
+DBusMessage *
+GNUNET_DBUS_method_context_create_reply (
+ struct GNUNET_DBUS_MethodContext *mc);
+
+#endif
+
Copied: gnunet-dbus/src/lib/include/gnunet_dbus_lib_object.h (from rev 32345,
gnunet-dbus/src/lib/gnunet_dbus_lib_object.h)
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dbus_lib_object.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dbus_lib_object.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,52 @@
+#ifndef GNUNET_DBUS_LIB_OBJECT_H
+#define GNUNET_DBUS_LIB_OBJECT_H
+
+struct GNUNET_DBUS_Object;
+
+#include "gnunet_dbus_lib_interface.h"
+
+struct GNUNET_DBUS_ObjectIterator
+{
+ /* linked list */
+ struct GNUNET_DBUS_ObjectIterator *next;
+ struct GNUNET_DBUS_ObjectIterator *prev;
+
+ struct GNUNET_DBUS_Object *object;
+};
+
+struct GNUNET_DBUS_Object *
+GNUNET_DBUS_object_create (
+ const char *path,
+ void *data);
+
+void
+GNUNET_DBUS_object_destroy (
+ struct GNUNET_DBUS_Object *object);
+
+void
+GNUNET_DBUS_object_ref (
+ struct GNUNET_DBUS_Object *object);
+
+void
+GNUNET_DBUS_object_unref (
+ struct GNUNET_DBUS_Object *object);
+
+const char *
+GNUNET_DBUS_object_get_path (
+ struct GNUNET_DBUS_Object *object);
+
+void
+GNUNET_DBUS_object_add_interface (
+ struct GNUNET_DBUS_Object *object,
+ struct GNUNET_DBUS_Interface *interface);
+
+const struct GNUNET_DBUS_InterfaceIterator *
+GNUNET_DBUS_object_iterate_interfaces (
+ struct GNUNET_DBUS_Object *object);
+
+void *
+GNUNET_DBUS_object_get_data (
+ struct GNUNET_DBUS_Object *object);
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_dbus_lib_pop.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dbus_lib_pop.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dbus_lib_pop.h 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,218 @@
+#ifndef GNUNET_DBUS_LIB_POP_H
+#define GNUNET_DBUS_LIB_POP_H
+
+DBusMessage *
+GNUNET_DBUS_pop_byte (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ unsigned char *value);
+
+DBusMessage *
+GNUNET_DBUS_pop_boolean (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ dbus_bool_t *value);
+
+DBusMessage *
+GNUNET_DBUS_pop_int16 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ dbus_int16_t *value);
+
+DBusMessage *
+GNUNET_DBUS_pop_uint16 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ dbus_uint16_t *value);
+
+DBusMessage *
+GNUNET_DBUS_pop_int32 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ dbus_int32_t *value);
+
+DBusMessage *
+GNUNET_DBUS_pop_uint32 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ dbus_uint32_t *value);
+
+DBusMessage *
+GNUNET_DBUS_pop_int64 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ dbus_int64_t *value);
+
+DBusMessage *
+GNUNET_DBUS_pop_uint64 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ dbus_uint64_t *value);
+
+DBusMessage *
+GNUNET_DBUS_pop_double (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ double *value);
+
+DBusMessage *
+GNUNET_DBUS_pop_string (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const char **value);
+
+DBusMessage *
+GNUNET_DBUS_pop_object_path (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const char **value);
+
+DBusMessage *
+GNUNET_DBUS_pop_signature (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const char **value);
+
+DBusMessage *
+GNUNET_DBUS_pop_unix_fd (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ int *value);
+
+DBusMessage *
+GNUNET_DBUS_pop_enter_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub,
+ const char *arg_name);
+
+DBusMessage *
+GNUNET_DBUS_pop_enter_struct (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub,
+ const char *arg_name);
+
+DBusMessage *
+GNUNET_DBUS_pop_enter_variant (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub,
+ const char *arg_name);
+
+DBusMessage *
+GNUNET_DBUS_pop_enter_dict_entry (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub,
+ const char *arg_name);
+
+DBusMessage *
+GNUNET_DBUS_pop_byte_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const unsigned char **value,
+ int *n_elements);
+
+DBusMessage *
+GNUNET_DBUS_pop_boolean_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const dbus_bool_t **value,
+ int *n_elements);
+
+DBusMessage *
+GNUNET_DBUS_pop_int16_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const int16_t **value,
+ int *n_elements);
+
+DBusMessage *
+GNUNET_DBUS_pop_uint16_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const uint16_t **value,
+ int *n_elements);
+
+DBusMessage *
+GNUNET_DBUS_pop_int32_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const int32_t **value,
+ int *n_elements);
+
+DBusMessage *
+GNUNET_DBUS_pop_uint32_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const uint32_t **value,
+ int *n_elements);
+
+DBusMessage *
+GNUNET_DBUS_pop_int64_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const int64_t **value,
+ int *n_elements);
+
+DBusMessage *
+GNUNET_DBUS_pop_uint64_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ const uint64_t **value,
+ int *n_elements);
+
+/*
+ * bitfield enums can be sent across the wire in either their integer form (as
+ * an array of bit flags) or as an array of strings. Sending an int is more
+ * efficient and is what libraries built around the DBus API would use, people
+ * using the DBus API directly may want to pass human-readable strings for
+ * convenience.
+ */
+DBusMessage *
+GNUNET_DBUS_pop_bitfield (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ int *value,
+ const struct GNUNET_DBUS_StringEnumPair *fields);
+
+DBusMessage *
+GNUNET_DBUS_pop_enum (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ int *value,
+ const struct GNUNET_DBUS_StringEnumPair *names);
+
+DBusMessage *
+GNUNET_DBUS_pop_hashcode (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ struct GNUNET_HashCode *value);
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_dbus_lib_push.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dbus_lib_push.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dbus_lib_push.h 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,229 @@
+#ifndef GNUNET_DBUS_LIB_PUSH_H
+#define GNUNET_DBUS_LIB_PUSH_H
+
+#include <dbus/dbus.h>
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_crypto_lib.h>
+
+void
+GNUNET_DBUS_push_byte (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const unsigned char *value);
+
+void
+GNUNET_DBUS_push_boolean (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_bool_t *value);
+
+void
+GNUNET_DBUS_push_int16 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_int16_t *value);
+
+void
+GNUNET_DBUS_push_uint16 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_uint16_t *value);
+
+void
+GNUNET_DBUS_push_int32 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_int32_t *value);
+
+void
+GNUNET_DBUS_push_uint32 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_uint32_t *value);
+
+void
+GNUNET_DBUS_push_int64 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_int64_t *value);
+
+void
+GNUNET_DBUS_push_uint64 (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_uint64_t *value);
+
+void
+GNUNET_DBUS_push_double (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const double *value);
+
+void
+GNUNET_DBUS_push_string (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *const *value);
+
+void
+GNUNET_DBUS_push_object_path (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *const *value);
+
+void
+GNUNET_DBUS_push_signature (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *const *value);
+
+void
+GNUNET_DBUS_push_unix_fd (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const int *value);
+
+void
+GNUNET_DBUS_push_open_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub,
+ const char *signature);
+
+void
+GNUNET_DBUS_push_open_struct (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub);
+
+void
+GNUNET_DBUS_push_open_variant (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub,
+ const char *signature);
+
+void
+GNUNET_DBUS_push_open_dict_entry (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub);
+
+void
+GNUNET_DBUS_push_close_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub);
+
+void
+GNUNET_DBUS_push_close_struct (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub);
+
+void
+GNUNET_DBUS_push_close_variant (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub);
+
+void
+GNUNET_DBUS_push_close_dict_entry (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ DBusMessageIter *iter_sub);
+
+void
+GNUNET_DBUS_push_byte_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const unsigned char *value,
+ size_t value_count);
+
+void
+GNUNET_DBUS_push_boolean_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_bool_t *value,
+ size_t value_count);
+
+void
+GNUNET_DBUS_push_int16_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_int16_t *value,
+ size_t value_count);
+
+void
+GNUNET_DBUS_push_uint16_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const dbus_uint16_t *value,
+ size_t value_count);
+
+void
+GNUNET_DBUS_push_int32_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const unsigned char *value,
+ size_t value_count);
+
+void
+GNUNET_DBUS_push_uint32_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const unsigned char *value,
+ size_t value_count);
+
+void
+GNUNET_DBUS_push_int64_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const unsigned char *value,
+ size_t value_count);
+
+void
+GNUNET_DBUS_push_uint64_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const unsigned char *value,
+ size_t value_count);
+
+void
+GNUNET_DBUS_push_double_array (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const unsigned char *value,
+ size_t value_count);
+
+void
+GNUNET_DBUS_push_data (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const void *value,
+ size_t value_size);
+
+void
+GNUNET_DBUS_push_bitfield (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const int *value,
+ const struct GNUNET_DBUS_StringEnumPair *fields);
+
+void
+GNUNET_DBUS_push_enum (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const int *value,
+ const struct GNUNET_DBUS_StringEnumPair *names);
+
+void
+GNUNET_DBUS_push_hashcode (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const struct GNUNET_HashCode *value);
+
+#endif
+
+
Copied: gnunet-dbus/src/lib/include/gnunet_dbus_lib_service.h (from rev 32345,
gnunet-dbus/src/lib/gnunet_dbus_lib_service.h)
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dbus_lib_service.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dbus_lib_service.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,51 @@
+#ifndef GNUNET_DBUS_LIB_SERVICE_H
+#define GNUNET_DBUS_LIB_SERVICE_H
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_configuration_lib.h>
+
+struct GNUNET_DBUS_Service;
+
+#include "gnunet_dbus_lib_object.h"
+#include "gnunet_dbus_lib_client.h"
+
+typedef void (*GNUNET_DBUS_ClientConnectsHandler)(
+ struct GNUNET_DBUS_Service *service,
+ struct GNUNET_DBUS_Client *client);
+typedef void (*GNUNET_DBUS_ClientDisconnectsHandler)(
+ struct GNUNET_DBUS_Service *service,
+ struct GNUNET_DBUS_Client *client);
+
+struct GNUNET_DBUS_Service *
+GNUNET_DBUS_service_create (
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *name);
+
+void
+GNUNET_DBUS_service_destroy (
+ struct GNUNET_DBUS_Service *service);
+
+const struct GNUNET_CONFIGURATION_Handle *
+GNUNET_DBUS_service_get_config (
+ struct GNUNET_DBUS_Service *service);
+
+int
+GNUNET_DBUS_service_add_object (
+ struct GNUNET_DBUS_Service *service,
+ struct GNUNET_DBUS_Object *object)
+ __attribute__((warn_unused_result));
+
+void
+GNUNET_DBUS_service_send (
+ struct GNUNET_DBUS_Service *service,
+ DBusMessage *dbus_message);
+
+void
+GNUNET_DBUS_service_set_client_handlers (
+ struct GNUNET_DBUS_Service *service,
+ GNUNET_DBUS_ClientConnectsHandler client_connects,
+ GNUNET_DBUS_ClientDisconnectsHandler client_disconnects);
+
+#endif
+
Copied: gnunet-dbus/src/lib/include/gnunet_dbus_lib_signature.h (from rev
32345, gnunet-dbus/src/lib/gnunet_dbus_lib_signature.h)
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dbus_lib_signature.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dbus_lib_signature.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,35 @@
+#ifndef GNUNET_DBUS_LIB_SIGNATURE_H
+#define GNUNET_DBUS_LIB_SIGNATURE_H
+
+#include <dbus/dbus.h>
+
+#define GNUNET_DBUS_SIGNATURE_BYTE DBUS_TYPE_BYTE_AS_STRING
+#define GNUNET_DBUS_SIGNATURE_BOOLEAN DBUS_TYPE_BOOLEAN_AS_STRING
+#define GNUNET_DBUS_SIGNATURE_INT16 DBUS_TYPE_INT16_AS_STRING
+#define GNUNET_DBUS_SIGNATURE_UINT16 DBUS_TYPE_UINT16_AS_STRING
+#define GNUNET_DBUS_SIGNATURE_INT32 DBUS_TYPE_INT32_AS_STRING
+#define GNUNET_DBUS_SIGNATURE_UINT32 DBUS_TYPE_UINT32_AS_STRING
+#define GNUNET_DBUS_SIGNATURE_INT64 DBUS_TYPE_INT64_AS_STRING
+#define GNUNET_DBUS_SIGNATURE_UINT64 DBUS_TYPE_UINT64_AS_STRING
+#define GNUNET_DBUS_SIGNATURE_DOUBLE DBUS_TYPE_DOUBLE_AS_STRING
+#define GNUNET_DBUS_SIGNATURE_STRING DBUS_TYPE_STRING_AS_STRING
+#define GNUNET_DBUS_SIGNATURE_OBJECT_PATH DBUS_TYPE_OBJECT_PATH_AS_STRING
+#define GNUNET_DBUS_SIGNATURE_SIGNATURE DBUS_TYPE_SIGNATURE_AS_STRING
+#define GNUNET_DBUS_SIGNATURE_UNIX_FD DBUS_TYPE_UNIX_FD_AS_STRING
+#define GNUNET_DBUS_SIGNATURE_VARIANT DBUS_TYPE_VARIANT_AS_STRING
+
+#define GNUNET_DBUS_SIGNATURE_ARRAY(s) DBUS_TYPE_ARRAY_AS_STRING s
+#define GNUNET_DBUS_SIGNATURE_DICT(s) DBUS_TYPE_ARRAY_AS_STRING
DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING s DBUS_DICT_ENTRY_END_CHAR_AS_STRING
+#define GNUNET_DBUS_SIGNATURE_STRUCT(s) DBUS_STRUCT_BEGIN_CHAR_AS_STRING s
DBUS_STRUCT_END_CHAR_AS_STRING
+
+#define GNUNET_DBUS_SIGNATURE_BITFIELD GNUNET_DBUS_SIGNATURE_VARIANT
+#define GNUNET_DBUS_SIGNATURE_ENUM GNUNET_DBUS_SIGNATURE_VARIANT
+
+#define GNUNET_DBUS_SIGNATURE_HASHCODE GNUNET_DBUS_SIGNATURE_VARIANT
+
+const char *
+GNUNET_DBUS_signature_typecode_to_string (
+ int typecode);
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib.h 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,18 @@
+#ifndef GNUNET_DHT_DBUS_LIB_H
+#define GNUNET_DHT_DBUS_LIB_H
+
+#include <dbus/dbus.h>
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_dht_service.h>
+
+#include <gnunet_dbus_lib.h>
+
+extern const struct GNUNET_DBUS_StringEnumPair
GNUNET_DHT_DBUS_route_option_description[];
+
+#include "gnunet_dht_dbus_lib_push.h"
+#include "gnunet_dht_dbus_lib_pop.h"
+#include "gnunet_dht_dbus_lib_signature.h"
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib_pop.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib_pop.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib_pop.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,14 @@
+#ifndef GNUNET_DHT_DBUS_LIB_POP_H
+#define GNUNET_DHT_DBUS_LIB_POP_H
+
+#include "gnunet_dht_dbus_lib.h"
+
+DBusMessage *
+GNUNET_DHT_DBUS_pop_route_option (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ enum GNUNET_DHT_RouteOption *value);
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib_push.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib_push.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib_push.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,13 @@
+#ifndef GNUNET_DHT_DBUS_LIB_PUSH_H
+#define GNUNET_DHT_DBUS_LIB_PUSH_H
+
+#include "gnunet_dht_dbus_lib.h"
+
+void
+GNUNET_DHT_DBUS_push_route_option (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const enum GNUNET_DHT_RouteOption *value);
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib_signature.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib_signature.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_dht_dbus_lib_signature.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,9 @@
+#ifndef GNUNET_DHT_DBUS_LIB_SIGNATURE_H
+#define GNUNET_DHT_DBUS_LIB_SIGNATURE_H
+
+#include "gnunet_dbus_lib.h"
+
+#define GNUNET_DHT_DBUS_SIGNATURE_ROUTE_OPTION GNUNET_DBUS_SIGNATURE_VARIANT
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,13 @@
+#ifndef GNUNET_GNSRECORD_DBUS_LIB_H
+#define GNUNET_GNSRECORD_DBUS_LIB_H
+
+#include <gnunet_dbus_lib.h>
+
+const struct GNUNET_DBUS_StringEnumPair
*GNUNET_GNSRECORD_DBUS_describe_flags();
+
+#include "gnunet_gnsrecord_dbus_lib_push.h"
+#include "gnunet_gnsrecord_dbus_lib_pop.h"
+#include "gnunet_gnsrecord_dbus_lib_signature.h"
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib_pop.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib_pop.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib_pop.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,19 @@
+#ifndef GNUNET_GNSRECORD_DBUS_LIB_POP_H
+#define GNUNET_GNSRECORD_DBUS_LIB_POP_H
+
+DBusMessage *
+GNUNET_GNSRECORD_DBUS_pop_type (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ uint32_t *value);
+
+DBusMessage *
+GNUNET_GNSRECORD_DBUS_pop_flags (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ enum GNUNET_GNSRECORD_Flags *value);
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib_push.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib_push.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib_push.h
2014-02-22 07:55:41 UTC (rev 32454)
@@ -0,0 +1,29 @@
+#ifndef GNUNET_GNSRECORD_DBUS_LIB_PUSH_H
+#define GNUNET_GNSRECORD_DBUS_LIB_PUSH_H
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_gnsrecord_lib.h>
+
+#include "gnunet_gnsrecord_dbus_lib.h"
+
+void
+GNUNET_GNSRECORD_DBUS_push_type (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const uint32_t *value);
+
+void
+GNUNET_GNSRECORD_DBUS_push_flags (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const enum GNUNET_GNSRECORD_Flags *value);
+
+void
+GNUNET_GNSRECORD_DBUS_push_data (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const struct GNUNET_GNSRECORD_Data *value);
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib_signature.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib_signature.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_gnsrecord_dbus_lib_signature.h
2014-02-22 07:55:41 UTC (rev 32454)
@@ -0,0 +1,27 @@
+#ifndef GNUNET_GNSRECORD_DBUS_LIB_SIGNATURE_H
+#define GNUNET_GNSRECORD_DBUS_LIB_SIGNATURE_H
+
+#include "gnunet_time_dbus_lib_signature.h"
+#include "gnunet_crypto_dbus_lib_signature.h"
+
+#define GNUNET_GNSRECORD_DBUS_SIGNATURE_TYPE GNUNET_DBUS_SIGNATURE_VARIANT
+#define GNUNET_GNSRECORD_DBUS_SIGNATURE_FLAGS GNUNET_DBUS_SIGNATURE_BITFIELD
+
+#define GNUNET_GNSRECORD_DBUS_SIGNATURE_DATA \
+ GNUNET_DBUS_SIGNATURE_STRUCT ( \
+ GNUNET_GNSRECORD_DBUS_SIGNATURE_TYPE \
+ GNUNET_GNSRECORD_DBUS_SIGNATURE_FLAGS \
+ GNUNET_DBUS_SIGNATURE_VARIANT \
+ GNUNET_DBUS_SIGNATURE_VARIANT \
+ )
+
+#define GNUNET_GNSRECORD_DBUS_SIGNATURE_BLOCK \
+ GNUNET_DBUS_SIGNATURE_STRUCT ( \
+ GNUNET_CRYPTO_DBUS_SIGNATURE_ECDSA_SIGNATURE \
+ GNUNET_CRYPTO_DBUS_SIGNATURE_ECDSA_PUBLIC_KEY \
+ GNUNET_CRYPTO_DBUS_SIGNATURE_ECC_SIGNATURE_PURPOSE \
+ GNUNET_TIME_DBUS_SIGNATURE_ABSOLUTE \
+ )
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_time_dbus_lib.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_time_dbus_lib.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_time_dbus_lib.h 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,11 @@
+#ifndef GNUNET_TIME_DBUS_LIB_H
+#define GNUNET_TIME_DBUS_LIB_H
+
+#include <gnunet_dbus_lib.h>
+
+#include "gnunet_time_dbus_lib_push.h"
+#include "gnunet_time_dbus_lib_pop.h"
+#include "gnunet_time_dbus_lib_signature.h"
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_time_dbus_lib_pop.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_time_dbus_lib_pop.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_time_dbus_lib_pop.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,12 @@
+#ifndef GNUNET_TIME_DBUS_LIB_POP_H
+#define GNUNET_TIME_DBUS_LIB_POP_H
+
+DBusMessage *
+GNUNET_TIME_DBUS_pop_absolute (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ struct GNUNET_TIME_Absolute *value);
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_time_dbus_lib_push.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_time_dbus_lib_push.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_time_dbus_lib_push.h 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,17 @@
+#ifndef GNUNET_TIME_DBUS_LIB_PUSH_H
+#define GNUNET_TIME_DBUS_LIB_PUSH_H
+
+void
+GNUNET_TIME_DBUS_push_absolute (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const struct GNUNET_TIME_Absolute *value);
+
+void
+GNUNET_TIME_DBUS_push_relative (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const struct GNUNET_TIME_Relative *value);
+
+#endif
+
Added: gnunet-dbus/src/lib/include/gnunet_time_dbus_lib_signature.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_time_dbus_lib_signature.h
(rev 0)
+++ gnunet-dbus/src/lib/include/gnunet_time_dbus_lib_signature.h
2014-02-22 07:55:41 UTC (rev 32454)
@@ -0,0 +1,10 @@
+#ifndef GNUNET_TIME_DBUS_LIB_SIGNATURE_H
+#define GNUNET_TIME_DBUS_LIB_SIGNATURE_H
+
+#include "gnunet_dbus_lib.h"
+
+#define GNUNET_TIME_DBUS_SIGNATURE_ABSOLUTE GNUNET_DBUS_SIGNATURE_VARIANT
+#define GNUNET_TIME_DBUS_SIGNATURE_RELATIVE GNUNET_DBUS_SIGNATURE_VARIANT
+
+#endif
+
Deleted: gnunet-dbus/src/lib/timeout.c
===================================================================
--- gnunet-dbus/src/lib/timeout.c 2014-02-21 17:05:07 UTC (rev 32453)
+++ gnunet-dbus/src/lib/timeout.c 2014-02-22 07:55:41 UTC (rev 32454)
@@ -1,141 +0,0 @@
-#include "timeout.h"
-
-#include <stdbool.h>
-
-#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-timeout", __VA_ARGS__)
-
-struct Timeout
-{
- /* doubly-linked list */
- struct Timeout *next;
- struct Timeout *prev;
-
- DBusTimeout *timeout;
-
- bool scheduled;
-
- GNUNET_SCHEDULER_TaskIdentifier task;
-
- unsigned ref_count;
-};
-
-struct Timeout *
-timeout_create (
- DBusTimeout *timeout)
-{
- struct Timeout *t = GNUNET_new (struct Timeout);
-
- t->timeout = timeout;
- t->scheduled = false;
-
- return t;
-}
-
-void
-timeout_destroy (
- struct Timeout *t)
-{
- if (0 != t->ref_count)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to destroy timeout with ref_count ==
%u\n", t->ref_count);
- GNUNET_abort ();
- };
-
- GNUNET_free (t);
-}
-
-void
-timeout_ref (
- struct Timeout *t)
-{
- t->ref_count++;
-}
-
-void
-timeout_unref (
- struct Timeout *t)
-{
- if (0 == t->ref_count)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unref timeout with ref_count ==
0\n");
- GNUNET_abort ();
- };
-
- if (0 == --t->ref_count)
- timeout_destroy (t);
-}
-
-static void
-handle_timeout (
- void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct Timeout *t = (struct Timeout *)cls;
-
- t->scheduled = false;
-
- if (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)
- dbus_timeout_handle (t->timeout);
-
- if (t->ref_count > 1 && ! (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- timeout_schedule (t);
- timeout_unref (t);
-};
-
-void
-timeout_schedule (
- struct Timeout *t)
-{
- if (! dbus_timeout_get_enabled (t->timeout))
- {
- LOG (GNUNET_ERROR_TYPE_WARNING, "Tried to schedule timeout that is
disabled!\n");
- return;
- };
-
- if (t->scheduled)
- return;
-
- int interval = dbus_timeout_get_interval (t->timeout);
- struct GNUNET_TIME_Relative delay;
- delay.rel_value_us = interval * 1000;
- t->task = GNUNET_SCHEDULER_add_delayed (
- delay,
- handle_timeout,
- t);
- t->scheduled = true;
- timeout_ref (t);
-}
-
-void
-do_timeout_unschedule (
- void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- (void)tc;
- struct Timeout *t = (struct Timeout *)cls;
-
- if (! t->scheduled)
- return;
-
- void *ret = GNUNET_SCHEDULER_cancel (t->task);
- if ((struct Timeout *)ret != t)
- LOG (GNUNET_ERROR_TYPE_WARNING, "Weird result unscheduling task. t == %p,
GNUNET_SCHEDULER_cancel returned %p\n", t, ret);
-
- timeout_unref (t);
-}
-
-void
-timeout_unschedule (
- struct Timeout *t)
-{
- GNUNET_SCHEDULER_add_now (do_timeout_unschedule, t);
-}
-
-struct TimeoutIter *
-timeout_find (struct TimeoutIter *ti, DBusTimeout *timeout)
-{
- while (ti && ti->t->timeout != timeout)
- ti = ti->next;
- return ti;
-}
-
Deleted: gnunet-dbus/src/lib/timeout.h
===================================================================
--- gnunet-dbus/src/lib/timeout.h 2014-02-21 17:05:07 UTC (rev 32453)
+++ gnunet-dbus/src/lib/timeout.h 2014-02-22 07:55:41 UTC (rev 32454)
@@ -1,32 +0,0 @@
-#ifndef TIMEOUT_H
-#define TIMEOUT_H
-
-#include <dbus/dbus.h>
-
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_scheduler_lib.h>
-
-struct Timeout;
-
-struct TimeoutIter
-{
- struct TimeoutIter *next;
- struct TimeoutIter *prev;
-
- struct Timeout *t;
-};
-
-struct Timeout *timeout_create (DBusTimeout *timeout);
-void timeout_destroy (struct Timeout *t);
-void timeout_ref (struct Timeout *t);
-void timeout_unref (struct Timeout *t);
-
-void timeout_schedule (struct Timeout *t);
-void timeout_unschedule (struct Timeout *t);
-void do_timeout_unschedule (void *cls, const struct
GNUNET_SCHEDULER_TaskContext *tc);
-
-struct TimeoutIter *timeout_find (struct TimeoutIter *, DBusTimeout *timeout);
-
-#endif
-
Added: gnunet-dbus/src/lib/util/Makefile.am
===================================================================
--- gnunet-dbus/src/lib/util/Makefile.am (rev 0)
+++ gnunet-dbus/src/lib/util/Makefile.am 2014-02-22 07:55:41 UTC (rev
32454)
@@ -0,0 +1,26 @@
+lib_LTLIBRARIES = \
+ libgnunettimedbus.la \
+ libgnunetcryptodbus.la
+
+libgnunettimedbus_la_SOURCES = \
+ gnunet_time_dbus_lib_pop.c \
+ gnunet_time_dbus_lib_push.c
+
+libgnunettimedbus_la_CFLAGS = \
+ -I$(top_builddir)/src/lib/include \
+ $(DBUS_CFLAGS)
+
+libgnunettimedbus_la_LDFLAGS = \
+ $(DBUS_LIBS)
+
+libgnunetcryptodbus_la_SOURCES = \
+ gnunet_crypto_dbus_lib_pop.c \
+ gnunet_crypto_dbus_lib_push.c
+
+libgnunetcryptodbus_la_CFLAGS = \
+ -I$(top_builddir)/src/lib/include \
+ $(DBUS_CFLAGS)
+
+libgnunetcryptodbus_la_LDFLAGS = \
+ $(DBUS_LIBS)
+
Added: gnunet-dbus/src/lib/util/gnunet_crypto_dbus_lib_pop.c
===================================================================
--- gnunet-dbus/src/lib/util/gnunet_crypto_dbus_lib_pop.c
(rev 0)
+++ gnunet-dbus/src/lib/util/gnunet_crypto_dbus_lib_pop.c 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,75 @@
+#include "config.h"
+
+#include "gnunet_dbus_lib.h"
+
+DBusMessage *
+GNUNET_CRYPTO_DBUS_pop_ecdsa_public_key (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ struct GNUNET_CRYPTO_EcdsaPublicKey *value)
+{
+ DBusMessage *ret = NULL;
+ DBusMessageIter iter_sub;
+ DBusMessageIter iter_sub_sub;
+
+ ret = GNUNET_DBUS_pop_enter_variant (message, iter, &iter_sub, arg_name);
+ if (ret)
+ return ret;
+
+ const char *encoded;
+ int success;
+ int arg_type = dbus_message_iter_get_arg_type (&iter_sub);
+ int element_type;
+ int n_elements;
+ unsigned char *marshalled_array;
+ switch (arg_type)
+ {
+ case DBUS_TYPE_STRING:
+ dbus_message_iter_get_basic (&iter_sub, &encoded);
+ success = GNUNET_CRYPTO_ecdsa_public_key_from_string (encoded, strlen
(encoded), value);
+ if (GNUNET_OK != success)
+ {
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "String is not a valid base32 encoded ECDSA public key for argument
'%s'",
+ arg_name);
+ }
+ GNUNET_DBUS_message_set_pretty (message, true);
+ return NULL;
+ case DBUS_TYPE_ARRAY:
+ element_type = dbus_message_iter_get_element_type (&iter_sub);
+ if (DBUS_TYPE_BYTE == element_type)
+ {
+ dbus_message_iter_recurse (&iter_sub, &iter_sub_sub);
+ dbus_message_iter_get_fixed_array (&iter_sub_sub, &marshalled_array,
&n_elements);
+ if (sizeof (value->q_y) == n_elements)
+ {
+ memcpy (value->q_y, marshalled_array, n_elements);
+ return NULL;
+ };
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "ECDSA public key consists of 32 bytes (256 bits). Array given for
argument '%s' contains %d bytes.",
+ arg_name,
+ n_elements);
+ };
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Invalid type for argument '%s'. Variant contains an array of '%s'.
Should contain an ECDSA public key in the form of a base32 encoded string or an
array of 32 bytes (256 bits).",
+ arg_name,
+ GNUNET_DBUS_signature_typecode_to_string (element_type));
+ default:
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Invalid type in variant for argument '%s'. Should contain an ECDSA
public key in the form of a base32 encoded string or an array of 32 bytes (256
bits). Contains '%s'",
+ arg_name,
+ GNUNET_DBUS_signature_typecode_to_string (arg_type));
+ }
+}
+
+
Added: gnunet-dbus/src/lib/util/gnunet_crypto_dbus_lib_push.c
===================================================================
Added: gnunet-dbus/src/lib/util/gnunet_time_dbus_lib_pop.c
===================================================================
--- gnunet-dbus/src/lib/util/gnunet_time_dbus_lib_pop.c
(rev 0)
+++ gnunet-dbus/src/lib/util/gnunet_time_dbus_lib_pop.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,52 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_strings_lib.h>
+
+#include "gnunet_time_dbus_lib.h"
+
+DBusMessage *
+GNUNET_TIME_DBUS_pop_absolute (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const char *arg_name,
+ struct GNUNET_TIME_Absolute *value)
+{
+ DBusMessageIter iter_sub;
+ DBusMessage *ret = GNUNET_DBUS_pop_enter_variant (message, iter, &iter_sub,
arg_name);
+ if (ret)
+ return ret;
+
+ int arg_type = dbus_message_iter_get_arg_type (&iter_sub);
+ switch (arg_type)
+ {
+ case DBUS_TYPE_STRING: {
+ const char *time;
+ dbus_message_iter_get_basic (&iter_sub, &time);
+ int err = GNUNET_STRINGS_fancy_time_to_absolute (time, value);
+ if (GNUNET_OK != err)
+ {
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. Malformed time string.
GNUNET_STRINGS_fancy_time_to_absolute returned %d",
+ arg_name,
+ err);
+ };
+ return NULL;
+ };
+ case DBUS_TYPE_UINT64:
+ dbus_message_iter_get_basic (&iter_sub, &value->abs_value_us);
+ return NULL;
+ default:
+ return dbus_message_new_error_printf (
+ message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Bad argument for '%s'. Variant must contain a time encoded as a human
readable string or a uint64 representing the number of microseconds since
epoch. Contains %s.",
+ arg_name,
+ GNUNET_DBUS_signature_typecode_to_string (arg_type));
+ };
+};
+
+
Added: gnunet-dbus/src/lib/util/gnunet_time_dbus_lib_push.c
===================================================================
--- gnunet-dbus/src/lib/util/gnunet_time_dbus_lib_push.c
(rev 0)
+++ gnunet-dbus/src/lib/util/gnunet_time_dbus_lib_push.c 2014-02-22
07:55:41 UTC (rev 32454)
@@ -0,0 +1,61 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_strings_lib.h>
+
+#include "gnunet_time_dbus_lib.h"
+
+#define LOG(kind, ...) GNUNET_log_from (kind, "time-dbus-push", __VA_ARGS__)
+
+void
+GNUNET_TIME_DBUS_push_absolute (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const struct GNUNET_TIME_Absolute *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing absolute time\n");
+ DBusMessageIter iter_sub;
+ if (GNUNET_DBUS_message_get_pretty (message))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Encoding time as string\n");
+ GNUNET_DBUS_push_open_variant (message, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_STRING);
+ const char *stringified = GNUNET_STRINGS_absolute_time_to_string (*value);
+ GNUNET_DBUS_push_string (message, &iter_sub, &stringified);
+ GNUNET_DBUS_push_close_variant (message, iter, &iter_sub);
+ }
+ else
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Encoding time as uint64\n");
+ GNUNET_DBUS_push_open_variant (message, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_UINT64);
+ GNUNET_DBUS_push_uint64 (message, &iter_sub, &value->abs_value_us);
+ GNUNET_DBUS_push_close_variant (message, iter, &iter_sub);
+ }
+}
+
+void
+GNUNET_TIME_DBUS_push_relative (
+ DBusMessage *message,
+ DBusMessageIter *iter,
+ const struct GNUNET_TIME_Relative *value)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Pushing relative time\n");
+ DBusMessageIter iter_sub;
+ if (GNUNET_DBUS_message_get_pretty (message))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Encoding time as string\n");
+ GNUNET_DBUS_push_open_variant (message, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_STRING);
+ const char *stringified = GNUNET_STRINGS_relative_time_to_string (*value,
0);
+ GNUNET_DBUS_push_string (message, &iter_sub, &stringified);
+ GNUNET_DBUS_push_close_variant (message, iter, &iter_sub);
+ }
+ else
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Encoding time as uint64\n");
+ GNUNET_DBUS_push_open_variant (message, iter, &iter_sub,
GNUNET_DBUS_SIGNATURE_UINT64);
+ GNUNET_DBUS_push_uint64 (message, &iter_sub, &value->rel_value_us);
+ GNUNET_DBUS_push_close_variant (message, iter, &iter_sub);
+ }
+}
+
+
Deleted: gnunet-dbus/src/lib/watch.c
===================================================================
--- gnunet-dbus/src/lib/watch.c 2014-02-21 17:05:07 UTC (rev 32453)
+++ gnunet-dbus/src/lib/watch.c 2014-02-22 07:55:41 UTC (rev 32454)
@@ -1,245 +0,0 @@
-#include "watch.h"
-
-#include <stdbool.h>
-
-#define LOG(kind, ...) GNUNET_log_from (kind, "dbus-watch", __VA_ARGS__)
-
-/*
- * Wraps a file descriptor that needs to be watched
- * for activity with select()
- */
-struct Watch
-{
- /*
- * DBus watch data. Contains the actual file descritor wrapped by libdbus
- */
- DBusWatch *watch;
-
- /*
- * Have we asked the scheduler to watch this?
- * Will be false if the associated task has not been
- * re-scheduled yet after execution or because dbus has asked
- * us to disable this watch.
- */
- bool scheduled;
-
- /*
- * The task that is watching our file descriptor.
- * Only valid if scheduled is true.
- */
- GNUNET_SCHEDULER_TaskIdentifier task;
-
- struct GNUNET_NETWORK_Handle *net_handle;
- struct GNUNET_DISK_FileHandle *file_handle;
-
- unsigned ref_count;
-};
-
-struct Watch *
-watch_create (
- DBusWatch *watch)
-{
- struct Watch *w = GNUNET_new (struct Watch);
-
- w->watch = watch;
- w->scheduled = false;
- w->net_handle = NULL;
- w->file_handle = NULL;
-
- SOCKTYPE sock = dbus_watch_get_socket (watch);
- if (-1 != sock)
- {
- w->net_handle = GNUNET_NETWORK_socket_box_native (sock);
- if (NULL == w->net_handle)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to box network socket passed in
from dbus.\n");
- GNUNET_abort ();
- };
- }
- else {
- int fd = dbus_watch_get_unix_fd (watch);
- if (-1 != fd)
- {
- w->file_handle = GNUNET_DISK_get_handle_from_int_fd (fd);
- if (NULL == w->file_handle)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to box file handle passed in
from dbus.\n");
- GNUNET_abort ();
- };
- };
- };
-
- if (! w->net_handle && ! w->file_handle)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to create watch.
dbus_watch_get_socket returned %d\n", (int)sock);
- GNUNET_abort ();
- };
-
- return w;
-};
-
-void
-watch_destroy (
- struct Watch *w)
-{
- if (0 != w->ref_count)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to destroy watch with ref_count ==
%zu\n", w->ref_count);
- GNUNET_abort ();
- };
-
- if (w->net_handle)
- GNUNET_free (w->net_handle);
- if (w->file_handle)
- GNUNET_free (w->file_handle);
-
- GNUNET_free (w);
-};
-
-void
-watch_ref (
- struct Watch *w)
-{
- w->ref_count++;
-};
-
-void
-watch_unref (
- struct Watch *w)
-{
- if (0 == w->ref_count)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unref watch with ref_count ==
0\n");
- GNUNET_abort ();
- };
-
- if (0 == --w->ref_count)
- watch_destroy (w);
-};
-
-/*
- * Callback called by the scheduler to tell libdbus that there is activity on
- * one of its file descriptors.
- *
- * @param cls The watch
- * @param tc the context given to us by the scheduler for this execution
- */
-void
-handle_watch (
- void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct Watch *w = (struct Watch *)cls;
-
- w->scheduled = false;
-
- unsigned flags = 0;
- if (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)
- flags |= DBUS_WATCH_READABLE;
- if (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)
- flags |= DBUS_WATCH_WRITABLE;
- if (flags)
- {
- dbus_watch_handle(w->watch, flags);
- };
-
- if(w->ref_count > 1 && ! (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- watch_schedule (w);
- watch_unref (w);
-};
-
-/*
- * Ask the scheduler to watch this watch for activity.
- *
- * @param w The watch
- * @return GNUNET_OK or GNUNET_SYSERR
- */
-void
-watch_schedule (
- struct Watch *w)
-{
- unsigned flags = dbus_watch_get_flags (w->watch);
-
- if (! dbus_watch_get_enabled (w->watch))
- {
- LOG (GNUNET_ERROR_TYPE_WARNING, "Tried to schedule watch that is
disabled!\n");
- return;
- };
-
- if (w->scheduled)
- return;
-
- if (w->net_handle)
- {
- w->task = GNUNET_SCHEDULER_add_net_with_priority(
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_SCHEDULER_PRIORITY_DEFAULT,
- w->net_handle,
- flags & DBUS_WATCH_READABLE,
- flags & DBUS_WATCH_WRITABLE,
- handle_watch,
- w);
- w->scheduled = true;
- watch_ref (w);
- return;
- };
-
- if (w->file_handle)
- {
- w->task = GNUNET_SCHEDULER_add_file_with_priority(
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_SCHEDULER_PRIORITY_DEFAULT,
- w->file_handle,
- flags & DBUS_WATCH_READABLE,
- flags & DBUS_WATCH_WRITABLE,
- handle_watch,
- w);
- w->scheduled = true;
- watch_ref (w);
- return;
- };
-
- LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to schedule watch.\n");
- GNUNET_abort ();
-};
-
-/*
- * Ask the scheduler to stop monitoring a watch either because we are shutting
- * down or dbus has asked us to disable this watch.
- *
- * @param w The watch
- * @return GNUNET_OK or GNUNET_SYSERR
- */
-void
-do_watch_unschedule (
- void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- (void)tc;
- struct Watch *w = (struct Watch *)cls;
-
- if (! w->scheduled)
- return;
-
- void *ret = GNUNET_SCHEDULER_cancel (w->task);
- if ((struct Watch *)ret != w)
- LOG (GNUNET_ERROR_TYPE_WARNING, "Weird result unscheduling task. w == %p,
GNUNET_SCHEDULER_cancel returned %p\n", w, ret);
-
- watch_unref (w);
-};
-
-void
-watch_unschedule (
- struct Watch *w)
-{
- GNUNET_SCHEDULER_add_now (do_watch_unschedule, w);
-};
-
-struct WatchIter *
-watch_find (struct WatchIter *wi, DBusWatch *watch)
-{
- while (wi && wi->w->watch != watch)
- wi = wi->next;
- return wi;
-};
-
Deleted: gnunet-dbus/src/lib/watch.h
===================================================================
--- gnunet-dbus/src/lib/watch.h 2014-02-21 17:05:07 UTC (rev 32453)
+++ gnunet-dbus/src/lib/watch.h 2014-02-22 07:55:41 UTC (rev 32454)
@@ -1,35 +0,0 @@
-#ifndef WATCH_H
-#define WATCH_H
-
-#include <dbus/dbus.h>
-
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_scheduler_lib.h>
-
-struct Watch;
-
-struct WatchIter
-{
- struct WatchIter *next;
- struct WatchIter *prev;
-
- struct Watch *w;
-};
-
-struct Watch *watch_create (DBusWatch *watch);
-void watch_destroy (struct Watch *w);
-void watch_ref (struct Watch *w);
-void watch_unref (struct Watch *w);
-
-/*
- * Schedule or schedule the scheduler to monitor dbus file descriptors.
- */
-void watch_schedule (struct Watch *w);
-void watch_unschedule (struct Watch *w);
-void do_watch_unschedule (void *cls, const struct GNUNET_SCHEDULER_TaskContext
*tc);
-
-struct WatchIter *watch_find (struct WatchIter *, DBusWatch *watch);
-
-#endif
-
Modified: gnunet-dbus/src/services/Makefile.am
===================================================================
--- gnunet-dbus/src/services/Makefile.am 2014-02-21 17:05:07 UTC (rev
32453)
+++ gnunet-dbus/src/services/Makefile.am 2014-02-22 07:55:41 UTC (rev
32454)
@@ -1,14 +1,26 @@
AM_CFLAGS = \
- -I$(top_builddir)/src/lib
+ -I$(top_builddir)/src/lib/include
bin_PROGRAMS = \
gnunet-service-gns-dbus
+ ##gnunet-service-dht-dbus
gnunet_service_gns_dbus_SOURCES = \
gnunet-service-gns-dbus.c
gnunet_service_gns_dbus_LDADD = \
- $(top_builddir)/src/lib/libgnunetdbus.la \
+ $(top_builddir)/src/lib/common/libgnunetdbus.la \
+ $(top_builddir)/src/lib/util/libgnunettimedbus.la \
+ $(top_builddir)/src/lib/util/libgnunetcryptodbus.la \
+ $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecorddbus.la \
-lgnunetgns \
-lgnunetutil
+##gnunet_service_dht_dbus_SOURCES = \
+ ##gnunet-service-dht-dbus.c
+
+##gnunet_service_dht_dbus_LDADD = \
+ ##$(top_builddir)/src/lib/libgnunetdbus.la \
+ ##-lgnunetdht \
+ ##-lgnunetutil
+
Added: gnunet-dbus/src/services/gnunet-service-dht-dbus.c
===================================================================
--- gnunet-dbus/src/services/gnunet-service-dht-dbus.c
(rev 0)
+++ gnunet-dbus/src/services/gnunet-service-dht-dbus.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -0,0 +1,315 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_configuration_lib.h>
+#include <gnunet/gnunet_getopt_lib.h>
+#include <gnunet/gnunet_strings_lib.h>
+#include <gnunet/gnunet_program_lib.h>
+#include <gnunet/gnunet_dht_service.h>
+
+#include "gnunet_dbus_lib.h"
+
+#define LOG(kind, ...) GNUNET_log_from (kind, "dht-dbus", __VA_ARGS__)
+
+struct GetRequest
+{
+ struct GNUNET_DBUS_Service *service;
+ struct GNUNET_DBUS_Client *client;
+ struct GNUNET_DHT_GetHandle *handle;
+ char *results_dest;
+};
+
+static void
+put_return (
+ void *cls,
+ int success)
+{
+ struct GNUNET_DBUS_MethodContext *mc = (struct GNUNET_DBUS_MethodContext
*)cls;
+ unsigned msg_serial = dbus_message_get_serial (mc->message);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Received reply from DHT. Method call id
%u\n", msg_serial);
+ DBusMessage *reply;
+ switch (success)
+ {
+ case GNUNET_OK:
+ reply = dbus_message_new_method_return (mc->message);
+ break;
+ case GNUNET_NO:
+ reply = dbus_message_new_error (mc->message, DBUS_ERROR_FAILED, "DHT
service timed out.");
+ break;
+ case GNUNET_SYSERR:
+ reply = dbus_message_new_error (mc->message, DBUS_ERROR_FAILED, "DHT DBus
proxy was disconnected from DHT service.");
+ break;
+ default:
+ reply = dbus_message_new_error_printf (mc->message, DBUS_ERROR_FAILED,
"Unabled to interpret response from DHT service. Service returned code %d.",
success);
+ };
+
+ GNUNET_DBUS_method_context_send_reply (mc, reply);
+ GNUNET_DBUS_method_context_unref (mc);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Received reply from DHT. Method call id
%u\n", msg_serial);
+};
+
+static void
+put (
+ struct GNUNET_DBUS_MethodContext *mc)
+{
+ struct GNUNET_HashCode key;
+ uint32_t desired_replication_level;
+ enum GNUNET_DHT_RouteOption options;
+ enum GNUNET_BLOCK_Type type;
+ int size;
+ const void *data;
+ struct GNUNET_TIME_Absolute expiry;
+
+ unsigned msg_serial = dbus_message_get_serial (mc->message);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Recieved put from dbus. Method call id %u\n",
msg_serial);
+
+ DBusMessageIter iter;
+ dbus_message_iter_init (mc->message, &iter);
+
+ DBusMessage *reply = NULL;
+ reply = reply ? reply : GNUNET_DBUS_message_iter_pop_hashcode (mc, &iter,
"key", &key);
+ reply = reply ? reply : GNUNET_DBUS_message_iter_pop_uint32 (mc, &iter,
"desired_replication_level", &desired_replication_level);
+ reply = reply ? reply : GNUNET_DBUS_message_iter_pop_dht_route_option (mc,
&iter, "options", &options);
+ reply = reply ? reply : GNUNET_DBUS_message_iter_pop_block_type (mc, &iter,
"type", &type);
+ reply = reply ? reply : GNUNET_DBUS_message_iter_pop_bytes (mc, &iter,
"data", (const unsigned char **)&data, &size);
+ reply = reply ? reply : GNUNET_DBUS_message_iter_pop_time_absolute (mc,
&iter, "expiry", &expiry);
+ if (reply)
+ {
+ GNUNET_DBUS_method_context_send_reply (mc, reply);
+ return;
+ };
+
+ GNUNET_DBUS_method_context_ref (mc);
+ struct GNUNET_DHT_Handle *handle = GNUNET_DBUS_client_get_data (mc->client);
+
+ GNUNET_DHT_put (
+ handle,
+ &key,
+ desired_replication_level,
+ options,
+ type,
+ size,
+ data,
+ expiry,
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100),
+ put_return,
+ mc);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Forwarded put to dht. Method call id %u\n",
msg_serial);
+};
+
+static void
+get_iter_return (
+ void *cls,
+ struct GNUNET_TIME_Absolute expiry,
+ const struct GNUNET_HashCode *key,
+ const struct GNUNET_PeerIdentity *get_path,
+ unsigned get_path_len,
+ const struct GNUNET_PeerIdentity *put_path,
+ unsigned put_path_len,
+ enum GNUNET_BLOCK_Type type,
+ size_t size,
+ const void *data)
+{
+ unsigned i;
+ struct GNUNET_DBUS_Object *request_object = (struct GNUNET_DBUS_Object *)cls;
+ struct GetRequest *get_request = (struct GetRequest
*)GNUNET_DBUS_object_get_data (request_object);
+ DBusMessage *msg = dbus_message_new_method_call (
+ GNUNET_DBUS_client_get_unique_name (get_request->client),
+ get_request->results_dest,
+ "gnu.gnunet.dht.GetReceiver",
+ "ReceiveResult");
+ DBusMessageIter msg_iter;
+ dbus_message_iter_init_append (msg, &msg_iter);
+
+ GNUNET_DBUS_message_iter_push_time_absolute (mc, &msg_iter, &expiry);
+ GNUNET_DBUS_message_iter_push_hash_code (mc, &msg_iter, key);
+ GNUNET_DBUS_message_iter_push_open_array (mc, &msg_iter, &msg_iter_sub,
GNUNET_DBUS_SIGNATURE_PEER_IDENTITY);
+ for (i = 0; i < get_path_len; i++)
+ GNUNET_DBUS_message_iter_push_peer_identity (mc, &msg_iter_sub, get_path +
i);
+ GNUNET_DBUS_message_iter_push_close_array (mc, &msg_iter, &msg_iter_sub);
+ GNUNET_DBUS_message_iter_push_open_array (mc, &msg_iter, &msg_iter_sub,
GNUNET_DBUS_SIGNATURE_PEER_IDENTITY);
+ for (i = 0; i < put_path_len; i++)
+ GNUNET_DBUS_message_iter_push_peer_identity (mc, &msg_iter_sub, put_path +
i);
+ GNUNET_DBUS_message_iter_push_close_array (mc, &msg_iter, &msg_iter_sub);
+ GNUNET_DBUS_message_iter_push_block_type (mc, &msg_iter, &type);
+ GNUNET_DBUS_message_iter_push_bytes (mc, &msg_iter, data, size);
+ dbus_message_set_no_reply (msg, true);
+
+ GNUNET_DBUS_service_send (get_request->service, msg);
+}
+
+static void
+get_start (
+ struct GNUNET_DBUS_MethodContext *mc)
+{
+ enum GNUNET_BLOCK_Type type;
+ struct GNUNET_HashCode key;
+ uint32_t desired_replication_level;
+ enum GNUNET_DHT_RouteOption options;
+ char *results_dest;
+
+ unsigned msg_serial = dbus_message_get_serial (mc->message);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Recieved get_start from dbus. Method call id
%u\n", msg_serial);
+
+ DBusMessageIter iter;
+ dbus_message_iter_init (mc->message, &iter);
+
+ DBusMessage *reply = NULL;
+ reply = reply ? reply : GNUNET_DBUS_message_iter_pop_block_type (mc, &iter,
"type", &type);
+ reply = reply ? reply : GNUNET_DBUS_message_iter_pop_hashcode (mc, &iter,
"key", &key);
+ reply = reply ? reply : GNUNET_DBUS_message_iter_pop_uint32 (mc, &iter,
"desired_replication_level", &desired_replication_level);
+ reply = reply ? reply : GNUNET_DBUS_message_iter_pop_dht_route_option (mc,
&iter, "options", &options);
+ reply = reply ? reply : GNUNET_DBUS_message_iter_pop_object_path (mc, &iter,
"results_dest", &results_dest);
+ if (reply)
+ {
+ GNUNET_DBUS_method_context_send_reply (mc, reply);
+ return;
+ };
+
+ GNUNET_DBUS_method_context_ref (mc);
+ struct GNUNET_DHT_Handle *handle = GNUNET_DBUS_client_get_data (mc->client);
+
+ uint32_t request_id = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
0xffffffff);
+ char *request_obj_path = GNUNET_asprintf ("/get/%08x", request__id);
+ struct GetRequest *get_request = GNUNET_new (struct GetRequest);
+ get_request->service = mc->service;
+ get_request->client = mc->client;
+ GNUNET_DBUT_client_ref (mc->client);
+ get_request->results_dest = strdup (results_dest);
+ struct GNUNET_DBUS_Object *request_object = GNUNET_DBUS_object_create
(request_obj_path, get_request);
+ get_request->handle = GNUNET_DHT_get_start (
+ handle,
+ type,
+ key,
+ desired_replication_level,
+ options,
+ NULL,
+ 0,
+ get_iter_return,
+ request_object);
+
+ reply = dbus_message_new_method_return (mc->message);
+ DBusMessageIter reply_iter;
+ dbus_message_iter_init (reply, &reply_iter);
+ GNUNET_DBUS_message_iter_push_object_path (&reply_iter, request_obj_path);
+
+ GNUNET_DBUS_method_context_send_reply (mc, reply);
+ GNUNET_free (obj_path);
+};
+
+static void
+client_connects (
+ struct GNUNET_DBUS_Service *service,
+ struct GNUNET_DBUS_Client *client)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Creating dht client for %s\n",
GNUNET_DBUS_client_get_unique_name (client));
+ const struct GNUNET_CONFIGURATION_Handle *cfg =
GNUNET_DBUS_service_get_config (service);
+ struct GNUNET_DHT_Handle *handle = GNUNET_DHT_connect (cfg, 32);
+ GNUNET_DBUS_client_set_data (client, handle);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished creating DHT client for %s\n",
GNUNET_DBUS_client_get_unique_name (client));
+};
+
+static void
+client_disconnects (
+ struct GNUNET_DBUS_Service *service,
+ struct GNUNET_DBUS_Client *client)
+{
+ (void)service;
+ GNUNET_DHT_disconnect (GNUNET_DBUS_client_get_data (client));
+};
+
+static void
+shutdown_task (
+ void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ (void)tc;
+
+ struct GNUNET_DBUS_Service *dht_service = (struct GNUNET_DBUS_Service *)cls;
+ GNUNET_DBUS_service_destroy (dht_service);
+
+ LOG (GNUNET_ERROR_TYPE_INFO, "Exiting.\n");
+};
+
+static void
+run (
+ void *cls,
+ char *const *args,
+ const char *configfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Running.\n");
+
+ struct GNUNET_DBUS_Service *dht_service = GNUNET_DBUS_service_create (cfg,
"dht");
+ if (! dht_service)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to create dht service.\n");
+ GNUNET_abort ();
+ };
+ GNUNET_DBUS_service_set_client_handlers (dht_service, client_connects,
client_disconnects);
+
+ struct GNUNET_DBUS_Object *dht_object = GNUNET_DBUS_object_create ("/",
NULL);
+ int err = GNUNET_DBUS_service_add_object (dht_service, dht_object);
+ if (GNUNET_OK != err)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to add / object.
GNUNET_DBUS_service_add_object returned %d\n", err);
+ GNUNET_abort();
+ };
+
+ struct GNUNET_DBUS_Interface *dht_interface = GNUNET_DBUS_interface_create
("gnu.gnunet.dht");
+ GNUNET_DBUS_object_add_interface (dht_object,
GNUNET_DBUS_interface_introspectable ());
+ GNUNET_DBUS_object_add_interface (dht_object, dht_interface);
+
+ struct GNUNET_DBUS_Method *method_put = GNUNET_DBUS_method_create ("put",
put);
+ GNUNET_DBUS_interface_add_method (dht_interface, method_put);
+ GNUNET_DBUS_method_add_arg (method_put, "key",
GNUNET_DBUS_SIGNATURE_HASHCODE);
+ GNUNET_DBUS_method_add_arg (method_put, "desired_replication_level",
GNUNET_DBUS_SIGNATURE_UINT32);
+ GNUNET_DBUS_method_add_arg (method_put, "options",
GNUNET_DBUS_SIGNATURE_DHT_ROUTE_OPTION);
+ GNUNET_DBUS_method_add_arg (method_put, "type",
GNUNET_DBUS_SIGNATURE_BLOCK_TYPE);
+ GNUNET_DBUS_method_add_arg (method_put, "data", GNUNET_DBUS_SIGNATURE_ARRAY
(GNUNET_DBUS_SIGNATURE_BYTE));
+ GNUNET_DBUS_method_add_arg (method_put, "expiry",
GNUNET_DBUS_SIGNATURE_TIME_ABSOLUTE);
+
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, shutdown_task,
dht_service);
+};
+
+int
+main (
+ int argc,
+ char *const *argv)
+{
+ int ret;
+
+ static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_END
+ };
+ static const char bin_name[] = "gnunet-service-dht-dbus [OPTIONS]";
+ static const char bin_help[] = gettext_noop ("DBus proxy for
gnunet-service-dht");
+
+ ret = GNUNET_log_setup ("gnunet-service-dht-dbus", "DEBUG", NULL);
+ if (GNUNET_OK != ret)
+ {
+ fprintf (stderr, "ERROR: Failed to setup logging. GNUNET_log_setup
returned %d\n", ret);
+ return 1;
+ }
+
+ ret = GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv);
+ if (GNUNET_OK != ret)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to parse command line options.
GNUNET_STRINGS_get_utf8_args returned %d\n", ret);
+ return 1;
+ };
+
+ ret = GNUNET_PROGRAM_run (argc, argv, bin_name, bin_help, options, run,
NULL);
+ if (GNUNET_OK != ret)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to run program. GNUNET_PROGRAM_run
returned %d\n", ret);
+ return 1;
+ };
+
+ GNUNET_free ((void *)argv);
+ return 0;
+};
+
+
Modified: gnunet-dbus/src/services/gnunet-service-gns-dbus.c
===================================================================
--- gnunet-dbus/src/services/gnunet-service-gns-dbus.c 2014-02-21 17:05:07 UTC
(rev 32453)
+++ gnunet-dbus/src/services/gnunet-service-gns-dbus.c 2014-02-22 07:55:41 UTC
(rev 32454)
@@ -9,6 +9,8 @@
#include <gnunet/gnunet_gns_service.h>
#include "gnunet_dbus_lib.h"
+#include "gnunet_crypto_dbus_lib.h"
+#include "gnunet_gnsrecord_dbus_lib.h"
#define LOG(kind, ...) GNUNET_log_from (kind, "gns-dbus", __VA_ARGS__)
@@ -19,22 +21,22 @@
const struct GNUNET_GNSRECORD_Data *rd)
{
struct GNUNET_DBUS_MethodContext *mc = (struct GNUNET_DBUS_MethodContext
*)cls;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Received reply from GNS. Method call id
%u\n", dbus_message_get_serial (mc->message));
- DBusMessage *message = mc->message;
- DBusMessage *reply = dbus_message_new_method_return (message);
+ unsigned msg_serial = dbus_message_get_serial (mc->message);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Received reply from GNS. Method call id
%u\n", msg_serial);
+ DBusMessage *reply = GNUNET_DBUS_method_context_create_reply (mc);
DBusMessageIter reply_iter;
dbus_message_iter_init_append (reply, &reply_iter);
DBusMessageIter reply_iter_sub;
- GNUNET_DBUS_message_iter_push_open_array (mc, &reply_iter, &reply_iter_sub,
GNUNET_DBUS_SIGNATURE_GNSRECORD_DATA);
+ GNUNET_DBUS_push_open_array (reply, &reply_iter, &reply_iter_sub,
GNUNET_GNSRECORD_DBUS_SIGNATURE_DATA);
uint32_t i;
for (i = 0; i < rd_count; i++)
- GNUNET_DBUS_message_iter_push_gns_record (mc, &reply_iter_sub, rd + i);
- GNUNET_DBUS_message_iter_push_close_container (mc, &reply_iter,
&reply_iter_sub);
+ GNUNET_GNSRECORD_DBUS_push_data (reply, &reply_iter_sub, rd + i);
+ GNUNET_DBUS_push_close_array (reply, &reply_iter, &reply_iter_sub);
GNUNET_DBUS_method_context_send_reply (mc, reply);
GNUNET_DBUS_method_context_unref (mc);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Forwarded reply to dbus. Method call id
%u\n", dbus_message_get_serial (mc->message));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Forwarded reply to dbus. Method call id
%u\n", msg_serial);
};
#if 0
@@ -59,14 +61,15 @@
LOG (GNUNET_ERROR_TYPE_DEBUG, "Received lookup request from dbus. Method
call id %u\n", dbus_message_get_serial (mc->message));
+ DBusMessage *message = mc->message;
DBusMessageIter message_iter;
- dbus_message_iter_init (mc->message, &message_iter);
+ dbus_message_iter_init (message, &message_iter);
DBusMessage *reply = NULL;
- reply = reply ? reply : GNUNET_DBUS_message_iter_pop_string (mc,
&message_iter, "name", &name);
- reply = reply ? reply : GNUNET_DBUS_message_iter_pop_ecdsa_public_key (mc,
&message_iter, "zone", &zone);
- reply = reply ? reply : GNUNET_DBUS_message_iter_pop_uint32 (mc,
&message_iter, "type", &type);
- reply = reply ? reply : GNUNET_DBUS_message_iter_pop_bool (mc,
&message_iter, "only_cached", &only_cached);
+ reply = reply ? reply : GNUNET_DBUS_pop_string (message, &message_iter,
"name", &name);
+ reply = reply ? reply : GNUNET_CRYPTO_DBUS_pop_ecdsa_public_key (message,
&message_iter, "zone", &zone);
+ reply = reply ? reply : GNUNET_DBUS_pop_uint32 (message, &message_iter,
"type", &type);
+ reply = reply ? reply : GNUNET_DBUS_pop_boolean (message, &message_iter,
"only_cached", &only_cached);
if (reply)
{
GNUNET_DBUS_method_context_send_reply (mc, reply);
@@ -116,7 +119,7 @@
struct GNUNET_DBUS_Service *gns_service = (struct GNUNET_DBUS_Service *)cls;
GNUNET_DBUS_service_destroy (gns_service);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Exiting.\n");
+ LOG (GNUNET_ERROR_TYPE_INFO, "Exiting.\n");
};
static void
@@ -126,16 +129,21 @@
const char *configfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running.\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Running.\n");
struct GNUNET_DBUS_Service *gns_service = GNUNET_DBUS_service_create (cfg,
"gns");
+ if (! gns_service)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to create gns service.\n");
+ GNUNET_abort ();
+ };
GNUNET_DBUS_service_set_client_handlers (gns_service, client_connects,
client_disconnects);
struct GNUNET_DBUS_Object *gns_object = GNUNET_DBUS_object_create ("/",
NULL);
int err = GNUNET_DBUS_service_add_object (gns_service, gns_object);
if (GNUNET_OK != err)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to add / object.
GNUNET_DBUS_service_add_object returned %d\n", err);
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to add / object.
GNUNET_DBUS_service_add_object returned %d\n", err);
GNUNET_abort();
};
@@ -146,11 +154,11 @@
struct GNUNET_DBUS_Method *gns_method_lookup = GNUNET_DBUS_method_create
("lookup", lookup);
GNUNET_DBUS_interface_add_method (gns_interface, gns_method_lookup);
GNUNET_DBUS_method_add_arg (gns_method_lookup, "name",
GNUNET_DBUS_SIGNATURE_STRING);
- GNUNET_DBUS_method_add_arg (gns_method_lookup, "zone",
GNUNET_DBUS_SIGNATURE_ECDSA_PUBLIC_KEY);
+ GNUNET_DBUS_method_add_arg (gns_method_lookup, "zone",
GNUNET_CRYPTO_DBUS_SIGNATURE_ECDSA_PUBLIC_KEY);
GNUNET_DBUS_method_add_arg (gns_method_lookup, "type",
GNUNET_DBUS_SIGNATURE_UINT32);
GNUNET_DBUS_method_add_arg (gns_method_lookup, "only_cached",
GNUNET_DBUS_SIGNATURE_BOOLEAN);
- GNUNET_DBUS_method_add_return_arg (gns_method_lookup, "records",
GNUNET_DBUS_SIGNATURE_ARRAY (GNUNET_DBUS_SIGNATURE_GNSRECORD_DATA));
+ GNUNET_DBUS_method_add_return_arg (gns_method_lookup, "records",
GNUNET_DBUS_SIGNATURE_ARRAY (GNUNET_GNSRECORD_DBUS_SIGNATURE_DATA));
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, shutdown_task,
gns_service);
};
@@ -178,14 +186,14 @@
ret = GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv);
if (GNUNET_OK != ret)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to parse command line
options. GNUNET_STRINGS_get_utf8_args returned %d\n", ret);
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to parse command line options.
GNUNET_STRINGS_get_utf8_args returned %d\n", ret);
return 1;
};
ret = GNUNET_PROGRAM_run (argc, argv, bin_name, bin_help, options, run,
NULL);
if (GNUNET_OK != ret)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to run program.
GNUNET_PROGRAM_run returned %d\n", ret);
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to run program. GNUNET_PROGRAM_run
returned %d\n", ret);
return 1;
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32454 - in gnunet-dbus: . src/lib src/lib/block src/lib/common src/lib/dht src/lib/gnsrecord src/lib/include src/lib/util src/services,
gnunet <=