summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-08-14 22:49:13 +0000
committerHavoc Pennington <hp@redhat.com>2003-08-14 22:49:13 +0000
commita6c8a71b1bcba04b63812a61f668e87af0922e5e (patch)
tree7ca780d7d39545e1f23f7cc63e6a22c68e067bf2
parent9d1c3a0f8428f4b052899ab12c706961efb003d4 (diff)
downloaddbus-a6c8a71b1bcba04b63812a61f668e87af0922e5e.tar.gz
2003-08-14 Havoc Pennington <hp@redhat.com>
* dbus/dbus-pending-call.c: start on new object that will replace DBusMessageHandler and ReplyHandlerData for tracking outstanding replies * dbus/dbus-gproxy.c: start on proxy object used to communicate with remote interfaces * dbus/dbus-gidl.c: do the boring boilerplate in here
-rw-r--r--ChangeLog11
-rw-r--r--dbus/dbus-pending-call.c225
-rw-r--r--dbus/dbus-pending-call.h55
-rw-r--r--glib/Makefile.am15
-rw-r--r--glib/dbus-compiler-main.c48
-rw-r--r--glib/dbus-gidl.c331
-rw-r--r--glib/dbus-gidl.h19
-rw-r--r--glib/dbus-glib.h4
-rw-r--r--glib/dbus-gproxy.c170
-rw-r--r--glib/dbus-gproxy.h79
10 files changed, 951 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 4396c9a5..e379f432 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2003-08-14 Havoc Pennington <hp@redhat.com>
+
+ * dbus/dbus-pending-call.c: start on new object that will replace
+ DBusMessageHandler and ReplyHandlerData for tracking outstanding
+ replies
+
+ * dbus/dbus-gproxy.c: start on proxy object used to communicate
+ with remote interfaces
+
+ * dbus/dbus-gidl.c: do the boring boilerplate in here
+
2003-08-12 Havoc Pennington <hp@pobox.com>
* bus/dispatch.c (bus_dispatch): make this return proper
diff --git a/dbus/dbus-pending-call.c b/dbus/dbus-pending-call.c
new file mode 100644
index 00000000..7a65ad62
--- /dev/null
+++ b/dbus/dbus-pending-call.c
@@ -0,0 +1,225 @@
+/* -*- mode: C; c-file-style: "gnu" -*- */
+/* dbus-pending-call.c Object representing a call in progress.
+ *
+ * Copyright (C) 2002, 2003 Red Hat Inc.
+ *
+ * Licensed under the Academic Free License version 1.2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "dbus-internals.h"
+#include "dbus-message-pending.h"
+#include "dbus-list.h"
+#include "dbus-threads.h"
+#include "dbus-test.h"
+#include "dbus-connection-internal.h"
+
+/**
+ * @defgroup DBusPendingCallInternals DBusPendingCall implementation details
+ * @ingroup DBusInternals
+ * @brief DBusPendingCall private implementation details.
+ *
+ * The guts of DBusPendingCall and its methods.
+ *
+ * @{
+ */
+
+/**
+ * @brief Internals of DBusPendingCall
+ *
+ * Object representing a reply message that we're waiting for.
+ */
+struct DBusPendingCall
+{
+ DBusAtomic refcount; /**< reference count */
+
+ DBusPendingCallNotifyFunction function; /**< Notifier when reply arrives. */
+ void *user_data; /**< user data for function */
+ DBusFreeFunction free_user_data; /**< free the user data */
+
+ DBusConnection *connection; /**< Connections we're associated with */
+ DBusMessage *reply; /**< Reply (after we've received it) */
+ DBusTimeout *timeout; /**< Timeout */
+
+ DBusList *timeout_link; /**< Preallocated timeout response */
+
+ dbus_uint32_t reply_serial; /**< Expected serial of reply */
+
+ unsigned int completed : 1; /**< TRUE if completed */
+ unsigned int timeout_added : 1; /**< Have added the timeout */
+};
+
+/**
+ * Creates a new pending reply object.
+ *
+ * @param connection connection where reply will arrive
+ * @param reply_serial reply serial of the expected reply
+ * @returns a new #DBusPendingCall or #NULL if no memory.
+ */
+DBusPendingCall*
+_dbus_pending_call_new (DBusConnection *connection,
+ dbus_uint32_t reply_serial)
+{
+ DBusPendingCall *pending;
+
+ pending = dbus_new (DBusPendingCall, 1);
+
+ if (pending == NULL)
+ return NULL;
+
+ pending->refcount.value = 1;
+ pending->connection = connection;
+ pending->reply_serial = reply_serial;
+
+ return pending;
+}
+
+/** @} */
+
+/**
+ * @defgroup DBusPendingCall DBusPendingCall
+ * @ingroup DBus
+ * @brief Pending reply to a method call message
+ *
+ * A DBusPendingCall is an object representing an
+ * expected reply. A #DBusPendingCall can be created
+ * when you send a message that should have a reply.
+ *
+ * @{
+ */
+
+/**
+ * @typedef DBusPendingCall
+ *
+ * Opaque data type representing a message pending.
+ */
+
+/**
+ * Increments the reference count on a pending call.
+ *
+ * @param pending the pending call object
+ */
+void
+dbus_pending_call_ref (DBusPendingCall *pending)
+{
+ _dbus_return_if_fail (pending != NULL);
+
+ _dbus_atomic_inc (&pending->refcount);
+}
+
+/**
+ * Decrements the reference count on a pending call,
+ * freeing it if the count reaches 0.
+ *
+ * @param pending the pending call object
+ */
+void
+dbus_pending_call_unref (DBusPendingCall *pending)
+{
+ dbus_bool_t last_unref;
+
+ _dbus_return_if_fail (pending != NULL);
+
+ last_unref = (_dbus_atomic_dec (&pending->refcount) == 1);
+
+ if (last_unref)
+ {
+ if (pending->free_user_data)
+ (* pending->free_user_data) (pending->user_data);
+
+
+ if (pending->connection != NULL)
+ {
+ _dbus_connection_pending_destroyed_locked (connection, pending);
+ pending->connection = NULL;
+ }
+
+ if (pending->reply)
+ {
+ dbus_message_unref (pending->reply);
+ pending->reply = NULL;
+ }
+
+ dbus_free (pending);
+ }
+}
+
+/**
+ * Sets a notification function to be called when the reply is
+ * received or the pending call times out.
+ *
+ * @param pending the pending call
+ * @param function notifier function
+ * @param user_data data to pass to notifier function
+ * @param free_user_data function to free the user data
+ *
+ */
+void
+dbus_pending_call_set_notify (DBusPendingCall *pending,
+ DBusPendingCallNotifyFunction function,
+ void *user_data,
+ DBusFreeFunction free_user_data)
+{
+ DBusFreeFunction old_free_func;
+ void *old_user_data;
+
+ _dbus_return_if_fail (pending != NULL);
+
+ _DBUS_LOCK (pending_call);
+ old_free_func = pending->free_user_data;
+ old_user_data = pending->user_data;
+
+ pending->user_data = user_data;
+ pending->free_user_data = free_user_data;
+ pending->function = function;
+ _DBUS_UNLOCK (pending_call);
+
+ if (old_free_func)
+ (* old_free_func) (old_user_data);
+}
+
+/** @} */
+
+#ifdef DBUS_BUILD_TESTS
+static DBusPendingResult
+test_pending (DBusPendingCall *pending,
+ DBusConnection *connection,
+ DBusMessage *message,
+ void *user_data)
+{
+ return DBUS_PENDING_RESULT_NOT_YET_HANDLED;
+}
+
+static void
+free_test_data (void *data)
+{
+ /* does nothing */
+}
+
+/**
+ * @ingroup DBusPendingCallInternals
+ * Unit test for DBusPendingCall.
+ *
+ * @returns #TRUE on success.
+ */
+dbus_bool_t
+_dbus_pending_call_test (const char *test_data_dir)
+{
+
+ return TRUE;
+}
+#endif /* DBUS_BUILD_TESTS */
diff --git a/dbus/dbus-pending-call.h b/dbus/dbus-pending-call.h
new file mode 100644
index 00000000..ff2c176a
--- /dev/null
+++ b/dbus/dbus-pending-call.h
@@ -0,0 +1,55 @@
+/* -*- mode: C; c-file-style: "gnu" -*- */
+/* dbus-pending-call.h Object representing a call in progress.
+ *
+ * Copyright (C) 2002, 2003 Red Hat Inc.
+ *
+ * Licensed under the Academic Free License version 1.2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION)
+#error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef DBUS_PENDING_CALL_H
+#define DBUS_PENDING_CALL_H
+
+#include <dbus/dbus-macros.h>
+#include <dbus/dbus-types.h>
+#include <dbus/dbus-connection.h>
+
+DBUS_BEGIN_DECLS;
+
+typedef void (* DBusPendingCallNotifyFunction) (DBusPendingCall *pending,
+ void *user_data);
+
+DBusPendingCall* _dbus_pending_call_new (DBusConnection *connection,
+ dbus_uint32_t reply_serial);
+
+void dbus_pending_call_ref (DBusPendingCall *pending);
+void dbus_pending_call_unref (DBusPendingCall *pending);
+void dbus_pending_call_set_notify (DBusPendingCall *pending,
+ DBusPendingCallNotifyFunction function,
+ void *user_data,
+ DBusFreeFunction free_user_data);
+dbus_bool_t dbus_pending_call_get_completed (DBusPendingCall *pending);
+DBusMessage* dbus_pending_call_get_reply (DBusPendingCall *pending);
+
+
+
+DBUS_END_DECLS;
+
+#endif /* DBUS_PENDING_CALL_H */
diff --git a/glib/Makefile.am b/glib/Makefile.am
index ebdb932f..8cc09eb7 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -1,18 +1,29 @@
-INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_GLIB_CFLAGS)
+INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_GLIB_CFLAGS) -DDBUS_COMPILATION=1
dbusincludedir=$(includedir)/dbus-1.0/dbus
lib_LTLIBRARIES=libdbus-glib-1.la
dbusinclude_HEADERS= \
- dbus-glib.h
+ dbus-glib.h \
+ dbus-gproxy.h
libdbus_glib_1_la_SOURCES = \
dbus-gmain.c \
+ dbus-gproxy.c \
dbus-gthread.c
libdbus_glib_1_la_LIBADD= $(DBUS_GLIB_LIBS) $(top_builddir)/dbus/libdbus-1.la
+bin_PROGRAMS=dbus-glib-compiler
+
+dbus_glib_compiler_SOURCES = \
+ dbus-gidl.c \
+ dbus-gidl.h \
+ dbus-compiler-main.c
+
+dbus_glib_compiler_LDADD= libdbus-glib-1.la $(DBUS_GLIB_LIBS) $(top_builddir)/dbus/libdbus-1.la
+
if DBUS_BUILD_TESTS
if HAVE_GLIB_THREADS
diff --git a/glib/dbus-compiler-main.c b/glib/dbus-compiler-main.c
new file mode 100644
index 00000000..d8bf7bde
--- /dev/null
+++ b/glib/dbus-compiler-main.c
@@ -0,0 +1,48 @@
+/* -*- mode: C; c-file-style: "gnu" -*- */
+/* dbus-compiler-main.c main() for GLib stubs/skels generator
+ *
+ * Copyright (C) 2003 Red Hat, Inc.
+ *
+ * Licensed under the Academic Free License version 1.2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "dbus-gidl.h"
+
+int
+main (int argc, char **argv)
+{
+
+
+ return 0;
+}
+
+#ifdef DBUS_BUILD_TESTS
+
+/**
+ * @ingroup DBusGCompiler
+ * Unit test for GLib stubs/skels compiler
+ * @returns #TRUE on success.
+ */
+dbus_bool_t
+_dbus_gcompiler_test (void)
+{
+
+ return TRUE;
+}
+
+#endif /* DBUS_BUILD_TESTS */
diff --git a/glib/dbus-gidl.c b/glib/dbus-gidl.c
new file mode 100644
index 00000000..b6e0fb8c
--- /dev/null
+++ b/glib/dbus-gidl.c
@@ -0,0 +1,331 @@
+/* -*- mode: C; c-file-style: "gnu" -*- */
+/* dbus-gidl.c data structure describing an interface, to be generated from IDL
+ * or something
+ *
+ * Copyright (C) 2003 Red Hat, Inc.
+ *
+ * Licensed under the Academic Free License version 1.2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "dbus-gidl.h"
+
+struct InterfaceInfo
+{
+ int refcount;
+ char *name;
+ GSList *methods;
+ GSList *signals;
+};
+
+struct MethodInfo
+{
+ int refcount;
+ GSList *args;
+ char *name;
+ MethodStyle style;
+};
+
+struct SignalInfo
+{
+ int refcount;
+ GSList *args;
+ char *name;
+};
+
+struct ArgInfo
+{
+ int refcount;
+ char *name;
+ int type;
+ ArgDirection direction;
+};
+
+static void
+free_method_list (GSList **methods_p)
+{
+ GSList *tmp;
+ tmp = *methods_p;
+ while (tmp != NULL)
+ {
+ method_info_unref (tmp->data);
+ tmp = tmp->next;
+ }
+ g_slist_free (*methods_p);
+ *methods_p = NULL;
+}
+
+static void
+free_signal_list (GSList **signals_p)
+{
+ GSList *tmp;
+ tmp = *signals_p;
+ while (tmp != NULL)
+ {
+ signal_info_unref (tmp->data);
+ tmp = tmp->next;
+ }
+ g_slist_free (*signals_p);
+ *signals_p = NULL;
+}
+
+InterfaceInfo*
+interface_info_new (const char *name)
+{
+ InterfaceInfo *info;
+
+ info = g_new0 (InterfaceInfo, 1);
+ info->refcount = 1;
+ info->name = g_strdup (name);
+
+ return info;
+}
+
+void
+interface_info_ref (InterfaceInfo *info)
+{
+ info->refcount += 1;
+}
+
+void
+interface_info_unref (InterfaceInfo *info)
+{
+ info->refcount -= 1;
+ if (info->refcount == 0)
+ {
+ free_method_list (&info->methods);
+ free_signal_list (&info->signals);
+ g_free (info->name);
+ g_free (info);
+ }
+}
+
+GSList*
+interface_info_get_methods (InterfaceInfo *info)
+{
+ return info->methods;
+}
+
+GSList*
+interface_info_get_signals (InterfaceInfo *info)
+{
+ return info->signals;
+}
+
+void
+interface_info_add_method (InterfaceInfo *info,
+ MethodInfo *method)
+{
+ method_info_ref (method);
+ info->methods = g_slist_append (info->methods, method);
+}
+
+void
+interface_info_add_signal (InterfaceInfo *info,
+ SignalInfo *signal)
+{
+ signal_info_ref (signal);
+ info->signals = g_slist_append (info->signals, signal);
+}
+
+static void
+free_arg_list (GSList **args_p)
+{
+ GSList *tmp;
+ tmp = *args_p;
+ while (tmp != NULL)
+ {
+ arg_info_unref (tmp->data);
+ tmp = tmp->next;
+ }
+ g_slist_free (*args_p);
+ *args_p = NULL;
+}
+
+MethodInfo*
+method_info_new (const char *name,
+ MethodStyle style)
+{
+ MethodInfo *info;
+
+ info = g_new0 (MethodInfo, 1);
+ info->refcount = 1;
+ info->name = g_strdup (name);
+ info->style = style;
+
+ return info;
+}
+
+void
+method_info_ref (MethodInfo *info)
+{
+ info->refcount += 1;
+}
+
+void
+method_info_unref (MethodInfo *info)
+{
+ info->refcount -= 1;
+ if (info->refcount == 0)
+ {
+ free_arg_list (&info->args);
+ g_free (info->name);
+ g_free (info);
+ }
+}
+
+const char*
+method_info_get_name (MethodInfo *info)
+{
+ return info->name;
+}
+
+GSList*
+method_info_get_args (MethodInfo *info)
+{
+ return info->args;
+}
+
+MethodStyle
+method_info_get_style (MethodInfo *info)
+{
+ return info->style;
+}
+
+void
+method_info_add_arg (MethodInfo *info,
+ ArgInfo *arg)
+{
+ arg_info_ref (arg);
+ info->args = g_slist_append (info->args, arg);
+}
+
+SignalInfo*
+signal_info_new (const char *name)
+{
+ SignalInfo *info;
+
+ info = g_new0 (SignalInfo, 1);
+ info->refcount = 1;
+ info->name = g_strdup (name);
+
+ return info;
+}
+
+void
+signal_info_ref (SignalInfo *info)
+{
+ info->refcount += 1;
+}
+
+void
+signal_info_unref (SignalInfo *info)
+{
+ info->refcount -= 1;
+ if (info->refcount == 0)
+ {
+ free_arg_list (&info->args);
+ g_free (info->name);
+ g_free (info);
+ }
+}
+
+const char*
+signal_info_get_name (SignalInfo *info)
+{
+ return info->name;
+}
+
+GSList*
+signal_info_get_args (SignalInfo *info)
+{
+ return info->args;
+}
+
+void
+signal_info_add_arg (SignalInfo *info,
+ ArgInfo *arg)
+{
+ arg_info_ref (arg);
+ info->args = g_slist_append (info->args, arg);
+}
+
+ArgInfo*
+arg_info_new (const char *name,
+ ArgDirection direction,
+ int type)
+{
+ ArgInfo *info;
+
+ info = g_new0 (ArgInfo, 1);
+ info->refcount = 1;
+ info->name = g_strdup (name);
+ info->direction = direction;
+ info->type = type;
+
+ return info;
+}
+
+void
+arg_info_ref (ArgInfo *info)
+{
+ info->refcount += 1;
+}
+
+void
+arg_info_unref (ArgInfo *info)
+{
+ info->refcount -= 1;
+ if (info->refcount == 0)
+ {
+ g_free (info->name);
+ g_free (info);
+ }
+}
+const char*
+arg_info_get_name (ArgInfo *info)
+{
+ return info->name;
+}
+
+int
+arg_info_get_type (ArgInfo *info)
+{
+ return info->type;
+}
+
+ArgDirection
+arg_info_get_direction (ArgInfo *info)
+{
+ return info->direction;
+}
+
+#ifdef DBUS_BUILD_TESTS
+
+/**
+ * @ingroup DBusGIDL
+ * Unit test for GLib IDL internals
+ * @returns #TRUE on success.
+ */
+dbus_bool_t
+_dbus_gidl_test (void)
+{
+
+ return TRUE;
+}
+
+#endif /* DBUS_BUILD_TESTS */
diff --git a/glib/dbus-gidl.h b/glib/dbus-gidl.h
index a5dc6cb0..c3c72d61 100644
--- a/glib/dbus-gidl.h
+++ b/glib/dbus-gidl.h
@@ -47,28 +47,39 @@ typedef enum
METHOD_CANCELLABLE
} MethodStyle;
-InterfaceInfo* interface_info_new (void);
+InterfaceInfo* interface_info_new (const char *name);
void interface_info_ref (InterfaceInfo *info);
void interface_info_unref (InterfaceInfo *info);
GSList* interface_info_get_methods (InterfaceInfo *info);
GSList* interface_info_get_signals (InterfaceInfo *info);
+void interface_info_add_method (InterfaceInfo *info,
+ MethodInfo *method);
+void interface_info_add_signal (InterfaceInfo *info,
+ SignalInfo *signal);
-MethodInfo* method_info_new (void);
+MethodInfo* method_info_new (const char *name,
+ MethodStyle style);
void method_info_ref (MethodInfo *info);
void method_info_unref (MethodInfo *info);
const char* method_info_get_name (MethodInfo *info);
GSList* method_info_get_args (MethodInfo *info);
MethodStyle method_info_get_style (MethodInfo *info);
+void method_info_add_arg (MethodInfo *info,
+ ArgInfo *arg);
-SignalInfo* signal_info_new (void);
+SignalInfo* signal_info_new (const char *name);
void signal_info_ref (SignalInfo *info);
void signal_info_unref (SignalInfo *info);
const char* signal_info_get_name (SignalInfo *info);
GSList* signal_info_get_args (SignalInfo *info);
+void signal_info_add_arg (SignalInfo *info,
+ ArgInfo *arg);
-ArgInfo* arg_info_new (void);
+ArgInfo* arg_info_new (const char *name,
+ ArgDirection direction,
+ int type);
void arg_info_ref (ArgInfo *info);
void arg_info_unref (ArgInfo *info);
const char* arg_info_get_name (ArgInfo *info);
diff --git a/glib/dbus-glib.h b/glib/dbus-glib.h
index c6116c52..7ca22417 100644
--- a/glib/dbus-glib.h
+++ b/glib/dbus-glib.h
@@ -28,12 +28,16 @@
G_BEGIN_DECLS
+#define DBUS_INSIDE_DBUS_GLIB_H 1
+
void dbus_gthread_init (void);
void dbus_connection_setup_with_g_main (DBusConnection *connection,
GMainContext *context);
void dbus_server_setup_with_g_main (DBusServer *server,
GMainContext *context);
+#undef DBUS_INSIDE_DBUS_GLIB_H
+
G_END_DECLS
#endif /* DBUS_GLIB_H */
diff --git a/glib/dbus-gproxy.c b/glib/dbus-gproxy.c
new file mode 100644
index 00000000..4326057a
--- /dev/null
+++ b/glib/dbus-gproxy.c
@@ -0,0 +1,170 @@
+/* -*- mode: C; c-file-style: "gnu" -*- */
+/* dbus-gcall.c convenience routines for calling methods, etc.
+ *
+ * Copyright (C) 2003 Red Hat, Inc.
+ *
+ * Licensed under the Academic Free License version 1.2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#include "dbus-gproxy.h"
+
+/**
+ * @addtogroup DBusGLibInternals
+ *
+ * @{
+ */
+
+struct DBusGProxy
+{
+ int refcount;
+ DBusConnection *connection;
+ char *service;
+ char *interface;
+ DBusObjectID object_id;
+};
+
+static DBusGProxy*
+_dbus_gproxy_new (DBusConnection *connection)
+{
+ DBusGProxy *proxy;
+
+ proxy = g_new0 (DBusGProxy, 1);
+
+ proxy->refcount = 1;
+ proxy->connection = connection;
+ dbus_connection_ref (connection);
+
+ return proxy;
+}
+
+/** @} End of DBusGLibInternals */
+
+/** @addtogroup DBusGLib
+ * @{
+ */
+
+/**
+ * Creates a new proxy for a remote interface. Method calls and signal
+ * connections over this proxy will go to the service owner; the
+ * service owner is expected to support the given interface name. THE
+ * SERVICE OWNER MAY CHANGE OVER TIME, for example between two
+ * different method calls. If you need a fixed owner, you need to
+ * request the current owner and bind a proxy to that rather than to
+ * the generic service name; see dbus_gproxy_new_for_service_owner().
+ *
+ * A service-associated proxy only makes sense with a message bus,
+ * not for app-to-app direct dbus connections.
+ *
+ * @param connection the connection to the remote bus or app
+ * @param service_name name of the service on the message bus
+ * @param interface_name name of the interface to call methods on
+ * @returns new proxy object
+ */
+DBusGProxy*
+dbus_gproxy_new_for_service (DBusConnection *connection,
+ const char *service_name,
+ const char *interface_name)
+{
+ DBusGProxy *proxy;
+
+ g_return_val_if_fail (connection != NULL, NULL);
+ g_return_val_if_fail (service_name != NULL, NULL);
+ g_return_val_if_fail (interface_name != NULL, NULL);
+
+ proxy = _dbus_gproxy_new (connection);
+
+ proxy->service = g_strdup (service_name);
+ proxy->interface = g_strdup (interface_name);
+
+ return proxy;
+}
+
+/**
+ * Increment reference count on proxy object.
+ *
+ * @param proxy the proxy
+ */
+void
+dbus_gproxy_ref (DBusGProxy *proxy)
+{
+ g_return_if_fail (proxy != NULL);
+
+ proxy->refcount += 1;
+}
+
+/**
+ * Decrement reference count on proxy object.
+ *
+ * @param proxy the proxy
+ */
+void
+dbus_gproxy_unref (DBusGProxy *proxy)
+{
+ g_return_if_fail (proxy != NULL);
+
+ proxy->refcount -= 1;
+ if (proxy->refcount == 0)
+ {
+ dbus_connection_unref (proxy->connection);
+ g_free (proxy->interface);
+ g_free (proxy->service);
+ g_free (proxy);
+ }
+}
+
+/**
+ * Invokes a method on a remote interface. This function does not
+ * block; instead it returns an opaque #DBusGPendingCall object that
+ * tracks the pending call. The method call will not be sent over the
+ * wire until the application returns to the main loop, or blocks in
+ * dbus_connection_flush() to write out pending data. The call will
+ * be completed after a timeout, or when a reply is received.
+ *
+ * @param proxy a proxy for a remote interface
+ * @param method the name of the method to invoke
+ * @param first_arg_type type of the first argument
+ *
+ * @returns opaque pending call object
+ *
+ */
+DBusGPendingCall*
+dbus_gproxy_begin_call (DBusGProxy *proxy,
+ const char *method,
+ int first_arg_type,
+ ...)
+{
+
+
+}
+
+/** @} End of DBusGLib public */
+
+#ifdef DBUS_BUILD_TESTS
+
+/**
+ * @ingroup DBusGLibInternals
+ * Unit test for GLib proxy functions
+ * @returns #TRUE on success.
+ */
+dbus_bool_t
+_dbus_gproxy_test (void)
+{
+
+ return TRUE;
+}
+
+#endif /* DBUS_BUILD_TESTS */
diff --git a/glib/dbus-gproxy.h b/glib/dbus-gproxy.h
new file mode 100644
index 00000000..bebcd1ce
--- /dev/null
+++ b/glib/dbus-gproxy.h
@@ -0,0 +1,79 @@
+/* -*- mode: C; c-file-style: "gnu" -*- */
+/* dbus-gproxy.h convenience routines for calling methods, etc.
+ *
+ * Copyright (C) 2003 Red Hat, Inc.
+ *
+ * Licensed under the Academic Free License version 1.2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef DBUS_GPROXY_H
+#define DBUS_GPROXY_H
+
+#if !defined (DBUS_INSIDE_DBUS_GLIB_H) && !defined (DBUS_COMPILATION)
+#error "Only <dbus/dbus-glib.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#include <dbus/dbus.h>
+#include <glib.h>
+#include <glib-object.h> /* for GCallback at the moment, we don't link to it */
+
+G_BEGIN_DECLS
+
+typedef struct DBusGProxy DBusGProxy;
+typedef struct DBusGPendingCall DBusGPendingCall;
+
+DBusGProxy* dbus_gproxy_new_for_service (DBusConnection *connection,
+ const char *service_name,
+ const char *interface_name);
+DBusGProxy* dbus_gproxy_new_for_service_owner (DBusConnection *connection,
+ const char *service_name,
+ const char *interface_name,
+ GError **error);
+DBusGProxy* dbus_gproxy_new_for_object_id (DBusConnection *connection,
+ const DBusObjectID *object_id,
+ const char *interface_name);
+DBusGProxy* dbus_gproxy_new_for_interface (DBusConnection *connection,
+ const char *interface_name);
+void dbus_gproxy_ref (DBusGProxy *proxy);
+void dbus_gproxy_unref (DBusGProxy *proxy);
+gboolean dbus_gproxy_connect_signal (DBusGProxy *proxy,
+ const char *signal_name,
+ GCallback callback,
+ void *data,
+ GFreeFunc free_data_func,
+ GError **error);
+DBusGPendingCall* dbus_gproxy_begin_call (DBusGProxy *proxy,
+ const char *method,
+ int first_arg_type,
+ ...);
+void dbus_gproxy_oneway_call (DBusGProxy *proxy,
+ const char *method,
+ int first_arg_type,
+ ...);
+
+gboolean dbus_gpending_call_is_complete (DBusGPendingCall *call);
+void dbus_gpending_call_cancel_and_free (DBusGPendingCall *call);
+gboolean dbus_gpending_call_block_and_free (DBusGPendingCall *call,
+ GError **error,
+ int first_arg_type,
+ ...);
+
+
+
+G_END_DECLS
+
+#endif /* DBUS_GPROXY_H */