| 1 |
|
| 2 |
|
| 3 |
. |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#include "config.h" |
| 21 |
|
| 22 |
#include <glib-object.h> |
| 23 |
|
| 24 |
#include "goaserviceconfig.h" |
| 25 |
|
| 26 |
typedef struct |
| 27 |
{ |
| 28 |
GObject parent_instance; |
| 29 |
|
| 30 |
char *service; |
| 31 |
} GoaServiceConfigPrivate; |
| 32 |
|
| 33 |
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GoaServiceConfig, goa_service_config, G_TYPE_OBJECT) |
| 34 |
|
| 35 |
typedef enum |
| 36 |
{ |
| 37 |
PROP_SERVICE = 1, |
| 38 |
} GoaServiceConfigProperty; |
| 39 |
|
| 40 |
static GParamSpec *properties[PROP_SERVICE + 1] = { NULL, }; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
static void |
| 45 |
goa_service_config_finalize (GObject *object) |
| 46 |
{ |
| 47 |
GoaServiceConfig *self = GOA_SERVICE_CONFIG (object); |
| 48 |
GoaServiceConfigPrivate *priv = goa_service_config_get_instance_private (self); |
| 49 |
|
| 50 |
g_clear_pointer (&priv->service, g_free); |
| 51 |
|
| 52 |
G_OBJECT_CLASS (goa_service_config_parent_class)->finalize (object); |
| 53 |
} |
| 54 |
|
| 55 |
static void |
| 56 |
goa_service_config_get_property (GObject *object, |
| 57 |
guint prop_id, |
| 58 |
GValue *value, |
| 59 |
GParamSpec *pspec) |
| 60 |
{ |
| 61 |
GoaServiceConfig *self = GOA_SERVICE_CONFIG (object); |
| 62 |
GoaServiceConfigPrivate *priv = goa_service_config_get_instance_private (self); |
| 63 |
|
| 64 |
switch ((GoaServiceConfigProperty) prop_id) |
| 65 |
{ |
| 66 |
case PROP_SERVICE: |
| 67 |
g_value_set_string (value, priv->service); |
| 68 |
break; |
| 69 |
|
| 70 |
default: |
| 71 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
| 72 |
break; |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
static void |
| 77 |
goa_service_config_set_property (GObject *object, |
| 78 |
guint prop_id, |
| 79 |
const GValue *value, |
| 80 |
GParamSpec *pspec) |
| 81 |
{ |
| 82 |
GoaServiceConfig *self = GOA_SERVICE_CONFIG (object); |
| 83 |
GoaServiceConfigPrivate *priv = goa_service_config_get_instance_private (self); |
| 84 |
|
| 85 |
switch ((GoaServiceConfigProperty) prop_id) |
| 86 |
{ |
| 87 |
case PROP_SERVICE: |
| 88 |
g_assert (priv->service == NULL); |
| 89 |
priv->service = g_value_dup_string (value); |
| 90 |
break; |
| 91 |
|
| 92 |
default: |
| 93 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
| 94 |
break; |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
static void |
| 101 |
goa_service_config_init (GoaServiceConfig *self) |
| 102 |
{ |
| 103 |
} |
| 104 |
|
| 105 |
static void |
| 106 |
goa_service_config_class_init (GoaServiceConfigClass *klass) |
| 107 |
{ |
| 108 |
GObjectClass *object_class = G_OBJECT_CLASS (klass); |
| 109 |
|
| 110 |
object_class->finalize = goa_service_config_finalize; |
| 111 |
object_class->get_property = goa_service_config_get_property; |
| 112 |
object_class->set_property = goa_service_config_set_property; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
properties[PROP_SERVICE] = |
| 120 |
g_param_spec_string ("service", NULL, NULL, |
| 121 |
"unknown", |
| 122 |
(G_PARAM_READWRITE | |
| 123 |
G_PARAM_CONSTRUCT_ONLY | |
| 124 |
G_PARAM_STATIC_STRINGS | |
| 125 |
G_PARAM_EXPLICIT_NOTIFY)); |
| 126 |
|
| 127 |
g_object_class_install_properties (object_class, G_N_ELEMENTS (properties), properties); |
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
const char * |
| 141 |
goa_service_config_get_service (GoaServiceConfig *config) |
| 142 |
{ |
| 143 |
GoaServiceConfigPrivate *priv = goa_service_config_get_instance_private (config); |
| 144 |
|
| 145 |
g_return_val_if_fail (GOA_IS_SERVICE_CONFIG (config), "unknown"); |
| 146 |
|
| 147 |
return priv->service; |
| 148 |
} |
| 149 |
|