Home | History | Annotate | Download | only in avahi-gobject
      1 /*
      2  * ga-entry-group.h - Header for GaEntryGroup
      3  * Copyright (C) 2006-2007 Collabora Ltd.
      4  *
      5  * This library is free software; you can redistribute it and/or
      6  * modify it under the terms of the GNU Lesser General Public
      7  * License as published by the Free Software Foundation; either
      8  * version 2.1 of the License, or (at your option) any later version.
      9  *
     10  * This library is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13  * Lesser General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU Lesser General Public
     16  * License along with this library; if not, write to the Free Software
     17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     18  */
     19 
     20 #ifndef __GA_ENTRY_GROUP_H__
     21 #define __GA_ENTRY_GROUP_H__
     22 
     23 #include <glib-object.h>
     24 #include <avahi-client/publish.h>
     25 #include <avahi-client/client.h>
     26 
     27 #include "ga-client.h"
     28 
     29 G_BEGIN_DECLS
     30 
     31 typedef enum {
     32     GA_ENTRY_GROUP_STATE_UNCOMMITED = AVAHI_ENTRY_GROUP_UNCOMMITED,
     33     GA_ENTRY_GROUP_STATE_REGISTERING = AVAHI_ENTRY_GROUP_REGISTERING,
     34     GA_ENTRY_GROUP_STATE_ESTABLISHED = AVAHI_ENTRY_GROUP_ESTABLISHED,
     35     GA_ENTRY_GROUP_STATE_COLLISTION = AVAHI_ENTRY_GROUP_COLLISION,
     36     GA_ENTRY_GROUP_STATE_FAILURE = AVAHI_ENTRY_GROUP_FAILURE
     37 } GaEntryGroupState;
     38 
     39 typedef struct _GaEntryGroupService GaEntryGroupService;
     40 typedef struct _GaEntryGroup GaEntryGroup;
     41 typedef struct _GaEntryGroupClass GaEntryGroupClass;
     42 
     43 struct _GaEntryGroupService {
     44     AvahiIfIndex interface;
     45     AvahiProtocol protocol;
     46     AvahiPublishFlags flags;
     47     gchar *name;
     48     gchar *type;
     49     gchar *domain;
     50     gchar *host;
     51     guint16 port;
     52 };
     53 
     54 struct _GaEntryGroupClass {
     55     GObjectClass parent_class;
     56 };
     57 
     58 struct _GaEntryGroup {
     59     GObject parent;
     60 };
     61 
     62 GType ga_entry_group_get_type(void);
     63 
     64 /* TYPE MACROS */
     65 #define GA_TYPE_ENTRY_GROUP \
     66   (ga_entry_group_get_type())
     67 #define GA_ENTRY_GROUP(obj) \
     68   (G_TYPE_CHECK_INSTANCE_CAST((obj), GA_TYPE_ENTRY_GROUP, GaEntryGroup))
     69 #define GA_ENTRY_GROUP_CLASS(klass) \
     70   (G_TYPE_CHECK_CLASS_CAST((klass), GA_TYPE_ENTRY_GROUP, GaEntryGroupClass))
     71 #define IS_GA_ENTRY_GROUP(obj) \
     72   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GA_TYPE_ENTRY_GROUP))
     73 #define IS_GA_ENTRY_GROUP_CLASS(klass) \
     74   (G_TYPE_CHECK_CLASS_TYPE((klass), GA_TYPE_ENTRY_GROUP))
     75 #define GA_ENTRY_GROUP_GET_CLASS(obj) \
     76   (G_TYPE_INSTANCE_GET_CLASS ((obj), GA_TYPE_ENTRY_GROUP, GaEntryGroupClass))
     77 
     78 GaEntryGroup *ga_entry_group_new(void);
     79 
     80 gboolean ga_entry_group_attach(GaEntryGroup * group,
     81                       GaClient * client, GError ** error);
     82 
     83 GaEntryGroupService *ga_entry_group_add_service_strlist(GaEntryGroup * group,
     84                                                         const gchar * name,
     85                                                         const gchar * type,
     86                                                         guint16 port,
     87                                                         GError ** error,
     88                                                         AvahiStringList *
     89                                                         txt);
     90 
     91 GaEntryGroupService *ga_entry_group_add_service_full_strlist(GaEntryGroup *
     92                                                              group,
     93                                                              AvahiIfIndex
     94                                                              interface,
     95                                                              AvahiProtocol
     96                                                              protocol,
     97                                                              AvahiPublishFlags
     98                                                              flags,
     99                                                              const gchar *
    100                                                              name,
    101                                                              const gchar *
    102                                                              type,
    103                                                              const gchar *
    104                                                              domain,
    105                                                              const gchar *
    106                                                              host,
    107                                                              guint16 port,
    108                                                              GError ** error,
    109                                                              AvahiStringList *
    110                                                              txt);
    111 GaEntryGroupService *ga_entry_group_add_service(GaEntryGroup * group,
    112                                                 const gchar * name,
    113                                                 const gchar * type,
    114                                                 guint16 port, GError ** error,
    115                                                 ...);
    116 
    117 GaEntryGroupService *ga_entry_group_add_service_full(GaEntryGroup * group,
    118                                                      AvahiIfIndex interface,
    119                                                      AvahiProtocol protocol,
    120                                                      AvahiPublishFlags flags,
    121                                                      const gchar * name,
    122                                                      const gchar * type,
    123                                                      const gchar * domain,
    124                                                      const gchar * host,
    125                                                      guint16 port,
    126                                                      GError ** error, ...);
    127 
    128 /* Add raw record */
    129 gboolean ga_entry_group_add_record(GaEntryGroup * group,
    130                           AvahiPublishFlags flags,
    131                           const gchar * name,
    132                           guint16 type,
    133                           guint32 ttl,
    134                           const void *rdata, gsize size, GError ** error);
    135 gboolean ga_entry_group_add_record_full(GaEntryGroup * group,
    136                                AvahiIfIndex interface,
    137                                AvahiProtocol protocol,
    138                                AvahiPublishFlags flags,
    139                                const gchar * name,
    140                                guint16 clazz,
    141                                guint16 type,
    142                                guint32 ttl,
    143                                const void *rdata,
    144                                gsize size, GError ** error);
    145 
    146 
    147 
    148 void ga_entry_group_service_freeze(GaEntryGroupService * service);
    149 
    150 /* Set a key in the service record. If the service isn't frozen it's committed
    151  * immediately */
    152 gboolean ga_entry_group_service_set(GaEntryGroupService * service,
    153                            const gchar * key, const gchar * value,
    154                            GError ** error);
    155 
    156 gboolean ga_entry_group_service_set_arbitrary(GaEntryGroupService * service,
    157                                      const gchar * key, const guint8 * value,
    158                                      gsize size, GError ** error);
    159 
    160 /* Remove one key from the service record */
    161 gboolean ga_entry_group_service_remove_key(GaEntryGroupService * service,
    162                                   const gchar * key, GError ** error);
    163 
    164 /* Update the txt record of the frozen service */
    165 gboolean ga_entry_group_service_thaw(GaEntryGroupService * service, GError ** error);
    166 
    167 /* Commit all newly added services */
    168 gboolean ga_entry_group_commit(GaEntryGroup * group, GError ** error);
    169 
    170 /* Invalidated all GaEntryGroupServices */
    171 gboolean ga_entry_group_reset(GaEntryGroup * group, GError ** error);
    172 
    173 G_END_DECLS
    174 #endif /* #ifndef __GA_ENTRY_GROUP_H__ */
    175