From 368ed1a2a0d95964b3f88c70c9a8c5516367f3f7 Mon Sep 17 00:00:00 2001 From: Trent Lloyd Date: Fri, 29 Jul 2005 02:03:26 +0000 Subject: [PATCH] * Move dbus service #defines to avahi-common/dbus.h * Move cdecl.h to installed common headers * Remove glib use from avahi-client * Only build avahi-client if dbus is enabled git-svn-id: file:///home/lennart/svn/public/avahi/trunk@190 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-client/Makefile.am | 8 ++++++++ avahi-client/client-test.c | 10 +++++++--- avahi-client/client.c | 13 ++++++++++--- avahi-client/client.h | 13 ++++++++++--- avahi-common/Makefile.am | 7 +++---- avahi-common/dbus.h | 35 +++++++++++++++++++++++++++++++++++ avahi-daemon/dbus-protocol.c | 9 +-------- 7 files changed, 74 insertions(+), 21 deletions(-) create mode 100644 avahi-common/dbus.h diff --git a/avahi-client/Makefile.am b/avahi-client/Makefile.am index 8f9dce0..2d5a654 100644 --- a/avahi-client/Makefile.am +++ b/avahi-client/Makefile.am @@ -23,9 +23,15 @@ AM_CFLAGS=-I$(top_srcdir) AM_CFLAGS+=$(GLIB20_CFLAGS) AM_LDADD=$(GLIB20_LIBS) +# DBUS +AM_CFLAGS+=$(DBUS_CFLAGS) +AM_LDADD+=$(DBUS_LIBS) + # This cool debug trap works on i386/gcc only AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' +if ENABLE_DBUS + avahi_clientincludedir=$(includedir)/avahi-client avahi_clientinclude_HEADERS = \ @@ -44,3 +50,5 @@ client_test_SOURCES = \ client-test.c client_test_CFLAGS = $(AM_CFLAGS) client_test_LDADD = $(AM_LDADD) libavahi-client.la + +endif diff --git a/avahi-client/client-test.c b/avahi-client/client-test.c index 72a8e65..71d5096 100644 --- a/avahi-client/client-test.c +++ b/avahi-client/client-test.c @@ -1,11 +1,15 @@ #include +#include int main (int argc, char *argv[]) { - AvahiClient *avahi; + AvahiClient *avahi; + + avahi = avahi_client_new (); - avahi = avahi_client_new (); + if (avahi != NULL) + free (avahi); - g_message ("Got server ID %d", avahi->serverid); + return 0; } diff --git a/avahi-client/client.c b/avahi-client/client.c index 949e5ef..3643403 100644 --- a/avahi-client/client.c +++ b/avahi-client/client.c @@ -1,11 +1,18 @@ #include +#include +#include + +#define DBUS_API_SUBJECT_TO_CHANGE +#include + +#include AvahiClient * avahi_client_new () { - AvahiClient *tmp; + AvahiClient *tmp; - tmp = g_new0 (AvahiClient, 1); + tmp = malloc (sizeof (AvahiClient)); - return tmp; + return tmp; } diff --git a/avahi-client/client.h b/avahi-client/client.h index a33f1d2..91f5af5 100644 --- a/avahi-client/client.h +++ b/avahi-client/client.h @@ -22,12 +22,19 @@ USA. ***/ -#include +#include -typedef struct AvahiClient { - gint serverid; +/** \file client.h Definitions and functions for the client API over D-Bus */ + +AVAHI_C_DECL_BEGIN + +typedef struct { + int serverid; } AvahiClient; +/** Creates a new client instance */ AvahiClient* avahi_client_new (); +AVAHI_C_DECL_END + #endif diff --git a/avahi-common/Makefile.am b/avahi-common/Makefile.am index 208aa94..b4125d6 100644 --- a/avahi-common/Makefile.am +++ b/avahi-common/Makefile.am @@ -33,10 +33,9 @@ avahi_commoninclude_HEADERS = \ address.h \ alternative.h \ rr.h \ - util.h - -noinst_HEADERS = \ - cdecl.h + util.h \ + cdecl.h \ + dbus.h noinst_PROGRAMS = \ strlst-test \ diff --git a/avahi-common/dbus.h b/avahi-common/dbus.h new file mode 100644 index 0000000..27ee40a --- /dev/null +++ b/avahi-common/dbus.h @@ -0,0 +1,35 @@ +#ifndef foodbushfoo +/* $Id$ */ + +/*** + This file is part of avahi. + + avahi is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + avahi 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 Lesser General + Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with avahi; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#define AVAHI_DBUS_NAME "org.freedesktop.Avahi" +#define AVAHI_DBUS_INTERFACE_SERVER AVAHI_DBUS_NAME".Server" +#define AVAHI_DBUS_PATH_SERVER "/org/freedesktop/Avahi/Server" +#define AVAHI_DBUS_INTERFACE_ENTRY_GROUP AVAHI_DBUS_NAME".EntryGroup" +#define AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER AVAHI_DBUS_NAME".DomainBrowser" +#define AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER AVAHI_DBUS_NAME".ServiceTypeBrowser" +#define AVAHI_DBUS_INTERFACE_SERVICE_BROWSER AVAHI_DBUS_NAME".ServiceBrowser" + +#endif diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c index ced746c..f2d34d1 100644 --- a/avahi-daemon/dbus-protocol.c +++ b/avahi-daemon/dbus-protocol.c @@ -33,18 +33,11 @@ #include #include #include +#include #include "dbus-protocol.h" #include "main.h" -#define AVAHI_DBUS_NAME "org.freedesktop.Avahi" -#define AVAHI_DBUS_INTERFACE_SERVER AVAHI_DBUS_NAME".Server" -#define AVAHI_DBUS_PATH_SERVER "/org/freedesktop/Avahi/Server" -#define AVAHI_DBUS_INTERFACE_ENTRY_GROUP AVAHI_DBUS_NAME".EntryGroup" -#define AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER AVAHI_DBUS_NAME".DomainBrowser" -#define AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER AVAHI_DBUS_NAME".ServiceTypeBrowser" -#define AVAHI_DBUS_INTERFACE_SERVICE_BROWSER AVAHI_DBUS_NAME".ServiceBrowser" - typedef struct Server Server; typedef struct Client Client; typedef struct EntryGroupInfo EntryGroupInfo; -- 2.39.5