ga-entry-group.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. #ifndef __GA_ENTRY_GROUP_H__
  20. #define __GA_ENTRY_GROUP_H__
  21. #include <glib-object.h>
  22. #include <avahi-client/publish.h>
  23. #include <avahi-client/client.h>
  24. #include "ga-client.h"
  25. G_BEGIN_DECLS
  26. typedef enum {
  27. GA_ENTRY_GROUP_STATE_UNCOMMITED = AVAHI_ENTRY_GROUP_UNCOMMITED,
  28. GA_ENTRY_GROUP_STATE_REGISTERING = AVAHI_ENTRY_GROUP_REGISTERING,
  29. GA_ENTRY_GROUP_STATE_ESTABLISHED = AVAHI_ENTRY_GROUP_ESTABLISHED,
  30. GA_ENTRY_GROUP_STATE_COLLISTION = AVAHI_ENTRY_GROUP_COLLISION,
  31. GA_ENTRY_GROUP_STATE_FAILURE = AVAHI_ENTRY_GROUP_FAILURE
  32. } GaEntryGroupState;
  33. typedef struct _GaEntryGroupService GaEntryGroupService;
  34. typedef struct _GaEntryGroup GaEntryGroup;
  35. typedef struct _GaEntryGroupClass GaEntryGroupClass;
  36. struct _GaEntryGroupService {
  37. AvahiIfIndex interface;
  38. AvahiProtocol protocol;
  39. AvahiPublishFlags flags;
  40. gchar *name;
  41. gchar *type;
  42. gchar *domain;
  43. gchar *host;
  44. guint16 port;
  45. };
  46. struct _GaEntryGroupClass {
  47. GObjectClass parent_class;
  48. };
  49. struct _GaEntryGroup {
  50. GObject parent;
  51. };
  52. GType ga_entry_group_get_type(void);
  53. /* TYPE MACROS */
  54. #define GA_TYPE_ENTRY_GROUP \
  55. (ga_entry_group_get_type())
  56. #define GA_ENTRY_GROUP(obj) \
  57. (G_TYPE_CHECK_INSTANCE_CAST((obj), GA_TYPE_ENTRY_GROUP, GaEntryGroup))
  58. #define GA_ENTRY_GROUP_CLASS(klass) \
  59. (G_TYPE_CHECK_CLASS_CAST((klass), GA_TYPE_ENTRY_GROUP, GaEntryGroupClass))
  60. #define IS_GA_ENTRY_GROUP(obj) \
  61. (G_TYPE_CHECK_INSTANCE_TYPE((obj), GA_TYPE_ENTRY_GROUP))
  62. #define IS_GA_ENTRY_GROUP_CLASS(klass) \
  63. (G_TYPE_CHECK_CLASS_TYPE((klass), GA_TYPE_ENTRY_GROUP))
  64. #define GA_ENTRY_GROUP_GET_CLASS(obj) \
  65. (G_TYPE_INSTANCE_GET_CLASS ((obj), GA_TYPE_ENTRY_GROUP, GaEntryGroupClass))
  66. GaEntryGroup *ga_entry_group_new(void);
  67. gboolean ga_entry_group_attach(GaEntryGroup * group,
  68. GaClient * client, GError ** error);
  69. GaEntryGroupService *ga_entry_group_add_service_strlist(GaEntryGroup * group,
  70. const gchar * name,
  71. const gchar * type,
  72. guint16 port,
  73. GError ** error,
  74. AvahiStringList *
  75. txt);
  76. GaEntryGroupService *ga_entry_group_add_service_full_strlist(GaEntryGroup *
  77. group,
  78. AvahiIfIndex
  79. interface,
  80. AvahiProtocol
  81. protocol,
  82. AvahiPublishFlags
  83. flags,
  84. const gchar *
  85. name,
  86. const gchar *
  87. type,
  88. const gchar *
  89. domain,
  90. const gchar *
  91. host,
  92. guint16 port,
  93. GError ** error,
  94. AvahiStringList *
  95. txt);
  96. GaEntryGroupService *ga_entry_group_add_service(GaEntryGroup * group,
  97. const gchar * name,
  98. const gchar * type,
  99. guint16 port, GError ** error,
  100. ...);
  101. GaEntryGroupService *ga_entry_group_add_service_full(GaEntryGroup * group,
  102. AvahiIfIndex interface,
  103. AvahiProtocol protocol,
  104. AvahiPublishFlags flags,
  105. const gchar * name,
  106. const gchar * type,
  107. const gchar * domain,
  108. const gchar * host,
  109. guint16 port,
  110. GError ** error, ...);
  111. /* Add raw record */
  112. gboolean ga_entry_group_add_record(GaEntryGroup * group,
  113. AvahiPublishFlags flags,
  114. const gchar * name,
  115. guint16 type,
  116. guint32 ttl,
  117. const void *rdata, gsize size, GError ** error);
  118. gboolean ga_entry_group_add_record_full(GaEntryGroup * group,
  119. AvahiIfIndex interface,
  120. AvahiProtocol protocol,
  121. AvahiPublishFlags flags,
  122. const gchar * name,
  123. guint16 clazz,
  124. guint16 type,
  125. guint32 ttl,
  126. const void *rdata,
  127. gsize size, GError ** error);
  128. void ga_entry_group_service_freeze(GaEntryGroupService * service);
  129. /* Set a key in the service record. If the service isn't frozen it's committed
  130. * immediately */
  131. gboolean ga_entry_group_service_set(GaEntryGroupService * service,
  132. const gchar * key, const gchar * value,
  133. GError ** error);
  134. gboolean ga_entry_group_service_set_arbitrary(GaEntryGroupService * service,
  135. const gchar * key, const guint8 * value,
  136. gsize size, GError ** error);
  137. /* Remove one key from the service record */
  138. gboolean ga_entry_group_service_remove_key(GaEntryGroupService * service,
  139. const gchar * key, GError ** error);
  140. /* Update the txt record of the frozen service */
  141. gboolean ga_entry_group_service_thaw(GaEntryGroupService * service, GError ** error);
  142. /* Commit all newly added services */
  143. gboolean ga_entry_group_commit(GaEntryGroup * group, GError ** error);
  144. /* Invalidated all GaEntryGroupServices */
  145. gboolean ga_entry_group_reset(GaEntryGroup * group, GError ** error);
  146. G_END_DECLS
  147. #endif /* #ifndef __GA_ENTRY_GROUP_H__ */