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*
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*
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*
/** 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*);
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 (
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 (
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
return NULL;
}
+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)
{
#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
"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)
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 */
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);