Logo Search packages:      
Sourcecode: avahi version File versions

int avahi_entry_group_add_service_subtype ( AvahiEntryGroup group,
AvahiIfIndex  interface,
AvahiProtocol  protocol,
AvahiPublishFlags  flags,
const char *  name,
const char *  type,
const char *  domain,
const char *  subtype 
)

Add a subtype for a service. The service should already be existent in the entry group. You may add as many subtypes for a service as you wish.

Parameters:
interface  The interface this subtype shall be announced on. This should match the value passed for the original avahi_entry_group_add_service() call.
protocol  The protocol this subtype shall be announced with. This should match the value passed for the original avahi_entry_group_add_service() call.
flags  Only != 0 if you really know what you do
name  The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL.
type  The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL.
domain  The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL.
subtype  The new subtype to register for the specified service. May not be NULL.

Definition at line 524 of file entrygroup.c.

References AVAHI_ERR_BAD_STATE, AVAHI_ERR_DBUS_ERROR, AVAHI_ERR_NO_MEMORY, and AVAHI_OK.

                         {

    DBusMessage *message = NULL, *reply = NULL;
    int r = AVAHI_OK;
    DBusError error;
    AvahiClient *client;
    int32_t i_interface, i_protocol;
    uint32_t u_flags;

    assert(group);
    assert(name);
    assert(type);
    assert(subtype);

    client = group->client;

    if (!group->path || !avahi_client_is_connected(group->client))
        return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);

    if (!domain)
        domain = "";

    dbus_error_init(&error);
    
    if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddServiceSubtype"))) {
        r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
        goto fail;
    }

    i_interface = (int32_t) interface;
    i_protocol = (int32_t) protocol;
    u_flags = (uint32_t) flags;

    if (!dbus_message_append_args(
            message,
            DBUS_TYPE_INT32, &i_interface,
            DBUS_TYPE_INT32, &i_protocol,
            DBUS_TYPE_UINT32, &u_flags,
            DBUS_TYPE_STRING, &name,
            DBUS_TYPE_STRING, &type,
            DBUS_TYPE_STRING, &domain,
            DBUS_TYPE_STRING, &subtype,
            DBUS_TYPE_INVALID)) {
        r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY);
        goto fail;
    }
    
    if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) ||
        dbus_error_is_set (&error)) {
        r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
        goto fail;
    }
    
    if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) ||
        dbus_error_is_set (&error)) {
        r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
        goto fail;
    }

    dbus_message_unref(message);
    dbus_message_unref(reply);

    return AVAHI_OK;

fail:
    
    if (dbus_error_is_set(&error)) {
        r = avahi_client_set_dbus_error(client, &error);
        dbus_error_free(&error);
    }

    if (message)
        dbus_message_unref(message);

    if (reply)
        dbus_message_unref(reply);

    return r;

}


Generated by  Doxygen 1.6.0   Back to index