## EpcServiceType

EpcServiceType — service type details

## Stability Level

Unstable, unless otherwise indicated

## Synopsis

    #include <libepc/service-type.h>

    #define             EPC_SERVICE_TYPE_HTTP
    #define             EPC_SERVICE_TYPE_HTTPS
    const gchar *       epc_service_type_get_base           (const gchar *type);
    EpcProtocol         epc_service_type_get_protocol       (const gchar *service_type);
    gchar **            epc_service_type_list_supported     (const gchar *application);
    gchar *             epc_service_type_new                (EpcProtocol protocol,
                                                             const gchar *application);

## Description

DNS-SD uses well-known services types to discover service providers. The following macros describe the service types uses by this library.

Example 9. Find an Easy-Publish server

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17

    dialog = aui_service_dialog_new ("Choose an Easy Publish Server", NULL,
                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                     GTK_STOCK_CONNECT, GTK_RESPONSE_ACCEPT,
                                     NULL);
    aui_service_dialog_set_browse_service_types (AUI_SERVICE_DIALOG (dialog),
                                                 EPC_SERVICE_TYPE_HTTPS,
                                                 EPC_SERVICE_TYPE_HTTP,
                                                 NULL);

    if (GTK_RESPONSE_ACCEPT == gtk_dialog_run (GTK_DIALOG (dialog)))
      {
        const gint port = aui_service_dialog_get_port (AUI_SERVICE_DIALOG (dialog));
        const gchar *host = aui_service_dialog_get_host_name (AUI_SERVICE_DIALOG (dialog));
        const gchar *type = aui_service_dialog_get_service_type (AUI_SERVICE_DIALOG (dialog));
        EpcProtocol protocol = epc_service_type_get_protocol (type);
        ...
      }

## Details

### EPC_SERVICE_TYPE_HTTP

    #define EPC_SERVICE_TYPE_HTTP   "_easy-publish-http._tcp"

The well-known DNS-SD service type for EpcPublisher servers providing unencrypted HTTP access.

### EPC_SERVICE_TYPE_HTTPS

    #define EPC_SERVICE_TYPE_HTTPS  "_easy-publish-https._tcp"

The well-known DNS-SD service type for EpcPublisher servers providing encrypted HTTPS access.

### epc_service_type_get_base ()

    const gchar *       epc_service_type_get_base           (const gchar *type);

Extracts the base service-type of a DNS-SD service-type.

DNS-SD service types may contain a sub service type, for instance the service-type "_anon._sub._ftp._tcp" contains the base-type "_ftp._tcp" and the sub-type "_anon". This function extracts extracts the base-type. The service type is returned unmodifed if it doesn't contain a sub-type.

`type` : | a DNS-SD service-type
Returns : | The base-service-type.

### epc_service_type_get_protocol ()

    EpcProtocol         epc_service_type_get_protocol       (const gchar *service_type);

Queries the EpcProtocol associated with a DNS-SD service type. See EPC_SERVICE_TYPE_HTTP, EPC_SERVICE_TYPE_HTTPS.

`service_type` : | a DNS-SD service type
Returns : | Returns the EpcProtocol associated with `service_type`, or EPC_PROTOCOL_UNKNOWN for unrecognized or unsupported service types.

### epc_service_type_list_supported ()

    gchar **            epc_service_type_list_supported     (const gchar *application);

Lists all service types supported by the library. When `application` is `NULL` just the generic types, otherwise the service-subtypes for that application are returned. The returned list is terminated by `NULL` and must be released by the caller with `g_strfreev()`.

See also: `epc_service_type_new()`.

`application` : | an application name, or `NULL`
Returns : | The `NULL` terminated list of all supported service types.

### epc_service_type_new ()

    gchar *             epc_service_type_new                (EpcProtocol protocol,
                                                             const gchar *application);

Builds the DNS-SD service type for the given transport `protocol` and application. When `application` is `NULL`, the application name is retrieved by calling `g_get_prgname()`. `NULL` is returned in that case if `g_get_prgname()` returns `NULL`.

The string returned should be released when no longer needed.

`protocol` : | a EpcProtocol
`application` : | the application name, or `NULL`
Returns : | A newly allocated string holding the requested service-type, or `NULL` when `application` is `NULL` and `g_get_prgname()` fails.

## See Also

EpcConsumer, EpcPublisher