summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--avahi-client/browser.c38
-rw-r--r--avahi-client/client.h9
-rw-r--r--avahi-client/entrygroup.c22
-rw-r--r--avahi-common/dbus.h1
-rw-r--r--avahi-common/error.c1
-rw-r--r--avahi-common/error.h11
-rw-r--r--avahi-daemon/dbus-protocol.c3
7 files changed, 63 insertions, 22 deletions
diff --git a/avahi-client/browser.c b/avahi-client/browser.c
index 6e0ed5d..ab7a921 100644
--- a/avahi-client/browser.c
+++ b/avahi-client/browser.c
@@ -88,25 +88,29 @@ dbus_error:
return NULL;
}
-void
+int
avahi_domain_browser_free (AvahiDomainBrowser *b)
{
+ AvahiClient *client = b->client;
DBusMessage *message = NULL;
if (b == NULL || b->path == NULL)
- return;
+ return avahi_client_set_errno (client, AVAHI_ERR_INVALID_OBJECT);
message = dbus_message_new_method_call (AVAHI_DBUS_NAME,
b->path,
AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Free");
- dbus_connection_send (b->client->bus, message, NULL);
+ if (message == NULL)
+ return avahi_client_set_errno (client, AVAHI_ERR_DBUS_ERROR);
+
+ dbus_connection_send (client->bus, message, NULL);
- AVAHI_LLIST_REMOVE(AvahiDomainBrowser, domain_browsers, b->client->domain_browsers, b);
+ AVAHI_LLIST_REMOVE(AvahiDomainBrowser, domain_browsers, client->domain_browsers, b);
free (b);
- return;
+ return avahi_client_set_errno (client, AVAHI_OK);
}
char*
@@ -207,25 +211,29 @@ dbus_error:
return NULL;
}
-void
+int
avahi_service_type_browser_free (AvahiServiceTypeBrowser *b)
{
+ AvahiClient *client = b->client;
DBusMessage *message = NULL;
if (b == NULL || b->path == NULL)
- return;
+ return avahi_client_set_errno (client, AVAHI_ERR_INVALID_OBJECT);
message = dbus_message_new_method_call (AVAHI_DBUS_NAME,
b->path,
AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Free");
+ if (message == NULL)
+ return avahi_client_set_errno (client, AVAHI_ERR_DBUS_ERROR);
+
dbus_connection_send (b->client->bus, message, NULL);
AVAHI_LLIST_REMOVE(AvahiServiceTypeBrowser, service_type_browsers, b->client->service_type_browsers, b);
free (b);
- return;
+ return avahi_client_set_errno (client, AVAHI_OK);
}
char*
@@ -334,27 +342,29 @@ dbus_error:
return NULL;
}
-void
+int
avahi_service_browser_free (AvahiServiceBrowser *b)
{
+ AvahiClient *client = b->client;
DBusMessage *message = NULL;
-
+
if (b == NULL || b->path == NULL)
- return;
-
- printf ("Freeing %s\n", b->path);
+ return avahi_client_set_errno (client, AVAHI_ERR_INVALID_OBJECT);
message = dbus_message_new_method_call (AVAHI_DBUS_NAME,
b->path,
AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Free");
+ if (message == NULL)
+ return avahi_client_set_errno (client, AVAHI_ERR_DBUS_ERROR);
+
dbus_connection_send (b->client->bus, message, NULL);
AVAHI_LLIST_REMOVE(AvahiServiceBrowser, service_browsers, b->client->service_browsers, b);
free (b);
- return;
+ return avahi_client_set_errno (client, AVAHI_OK);
}
char*
diff --git a/avahi-client/client.h b/avahi-client/client.h
index 824f1e9..16e9998 100644
--- a/avahi-client/client.h
+++ b/avahi-client/client.h
@@ -84,6 +84,9 @@ char* avahi_client_get_host_name_fqdn (AvahiClient*);
/** Create a new AvahiEntryGroup object */
AvahiEntryGroup* avahi_entry_group_new (AvahiClient*, AvahiEntryGroupCallback callback, void *user_data);
+/** Clean up and free an AvahiEntryGroup object */
+int avahi_entry_group_free (AvahiEntryGroup *);
+
/** Commit an AvahiEntryGroup */
int avahi_entry_group_commit (AvahiEntryGroup*);
@@ -130,7 +133,7 @@ AvahiDomainBrowser* avahi_domain_browser_new (AvahiClient *client,
char* avahi_domain_browser_path (AvahiDomainBrowser *);
/** Cleans up and frees an AvahiDomainBrowser object */
-void avahi_domain_browser_free (AvahiDomainBrowser *);
+int avahi_domain_browser_free (AvahiDomainBrowser *);
/** Browse for service types on the local network */
AvahiServiceTypeBrowser* avahi_service_type_browser_new (
@@ -145,7 +148,7 @@ AvahiServiceTypeBrowser* avahi_service_type_browser_new (
char* avahi_service_type_browser_path (AvahiServiceTypeBrowser *);
/** Cleans up and frees an AvahiServiceTypeBrowser object */
-void avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
+int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
/** Browse for services of a type on the local network */
AvahiServiceBrowser* avahi_service_browser_new (
@@ -161,7 +164,7 @@ AvahiServiceBrowser* avahi_service_browser_new (
char* avahi_service_browser_path (AvahiServiceBrowser *);
/* Cleans up and frees an AvahiServiceBrowser object */
-void avahi_service_browser_free (AvahiServiceBrowser *);
+int avahi_service_browser_free (AvahiServiceBrowser *);
#ifndef DOXYGEN_SHOULD_SKIP_THIS
AVAHI_C_DECL_END
diff --git a/avahi-client/entrygroup.c b/avahi-client/entrygroup.c
index ea56ee2..8120e49 100644
--- a/avahi-client/entrygroup.c
+++ b/avahi-client/entrygroup.c
@@ -114,6 +114,28 @@ fail:
}
int
+avahi_entry_group_free (AvahiEntryGroup *group)
+{
+ AvahiClient *client = group->client;
+ DBusMessage *message;
+
+ if (group == NULL || group->path == NULL)
+ return avahi_client_set_errno (client, AVAHI_ERR_INVALID_OBJECT);
+
+ message = dbus_message_new_method_call (AVAHI_DBUS_NAME,
+ group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "Free");
+
+ if (message == NULL)
+ return avahi_client_set_errno (client, AVAHI_ERR_DBUS_ERROR);
+
+ dbus_connection_send (client->bus, message, NULL);
+
+ free (group);
+
+ return avahi_client_set_errno (client, AVAHI_OK);
+}
+
+int
avahi_entry_group_commit (AvahiEntryGroup *group)
{
DBusMessage *message;
diff --git a/avahi-common/dbus.h b/avahi-common/dbus.h
index fc8dc02..e3aef6c 100644
--- a/avahi-common/dbus.h
+++ b/avahi-common/dbus.h
@@ -60,6 +60,7 @@ AVAHI_C_DECL_BEGIN
#define AVAHI_DBUS_ERR_DBUS_ERROR "org.freedesktop.Avahi.DBusError"
#define AVAHI_DBUS_ERR_NOT_CONNECTED "org.freedesktop.Avahi.NotConnectedError"
#define AVAHI_DBUS_ERR_NO_MEMORY "org.freedesktop.Avahi.NoMemoryError"
+#define AVAHI_DBUS_ERR_INVALID_OBJECT "org.freedesktop.Avahi.InvalidObject"
AVAHI_C_DECL_END
diff --git a/avahi-common/error.c b/avahi-common/error.c
index b845793..0635161 100644
--- a/avahi-common/error.c
+++ b/avahi-common/error.c
@@ -49,6 +49,7 @@ const char *avahi_strerror(int error) {
"An unexpected DBUS error occured",
"Could not get a connection to the daemon",
"Memory exhausted"
+ "The object passed in was not valid"
};
if (-error < 0 || -error >= -AVAHI_ERR_MAX)
diff --git a/avahi-common/error.h b/avahi-common/error.h
index c949466..2cdda5f 100644
--- a/avahi-common/error.h
+++ b/avahi-common/error.h
@@ -55,15 +55,18 @@ enum {
AVAHI_ERR_DBUS_ERROR = -22, /**< An unexpected DBUS error occured */
AVAHI_ERR_NOT_CONNECTED = -23, /**< Could not get a connection to the daemon */
AVAHI_ERR_NO_MEMORY = -24, /**< Memory exhausted */
+ AVAHI_ERR_INVALID_OBJECT = -25, /**< The object passed to this function was invalid */
/****
**** IF YOU ADD A NEW ERROR CODE HERE, PLEASE DON'T FORGET TO ADD
- **** IT TO THE STRING ARRAY IN avahi_strerror() AND TO THE ARRAY
- **** IN respond_error() IN dbus-protocol.c AND FINALLY TO
- **** dbus.h!
+ **** IT TO THE STRING ARRAY IN avahi_strerror() IN error.c AND
+ **** TO THE ARRAY IN respond_error() IN dbus-protocol.c
+ **** AND FINALLY TO dbus.h!
+ ****
+ **** Also remember to update the MAX value below.
****/
- AVAHI_ERR_MAX = -25
+ AVAHI_ERR_MAX = -26
};
/** Return a human readable error string for the specified error code */
diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c
index c30873e..9b83da9 100644
--- a/avahi-daemon/dbus-protocol.c
+++ b/avahi-daemon/dbus-protocol.c
@@ -349,7 +349,8 @@ static DBusHandlerResult respond_error(DBusConnection *c, DBusMessage *m, gint e
AVAHI_DBUS_ERR_INVALID_OPERATION,
AVAHI_DBUS_ERR_DBUS_ERROR,
AVAHI_DBUS_ERR_NOT_CONNECTED,
- AVAHI_DBUS_ERR_NO_MEMORY
+ AVAHI_DBUS_ERR_NO_MEMORY,
+ AVAHI_DBUS_ERR_INVALID_OBJECT
};
g_assert(-error > -AVAHI_OK);