2 * Copyright (C) 2010 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 #include "strongswan-connection.h"
20 #define STRONGSWAN_CONNECTION_GET_PRIVATE(object) \
21 (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
22 STRONGSWAN_TYPE_CONNECTION, \
23 StrongswanConnectionPrivate))
25 struct _StrongswanConnectionPrivate
44 G_DEFINE_TYPE (StrongswanConnection
, strongswan_connection
, G_TYPE_OBJECT
);
47 strongswan_connection_get_property (GObject
*object
,
52 StrongswanConnectionPrivate
*priv
= STRONGSWAN_CONNECTION (object
)->priv
;
56 g_value_set_string (value
, priv
->name
);
59 g_value_set_string (value
, priv
->host
);
62 g_value_set_string (value
, priv
->cert
);
65 g_value_set_string (value
, priv
->user
);
68 g_value_set_string (value
, priv
->pass
);
71 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
77 strongswan_connection_set_property (GObject
*object
,
82 StrongswanConnectionPrivate
*priv
= STRONGSWAN_CONNECTION (object
)->priv
;
87 priv
->name
= g_value_dup_string (value
);
90 priv
->host
= g_value_dup_string (value
);
94 priv
->cert
= g_value_dup_string (value
);
98 priv
->user
= g_value_dup_string (value
);
102 priv
->pass
= g_value_dup_string (value
);
105 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
111 strongswan_connection_init (StrongswanConnection
*connection
)
113 connection
->priv
= STRONGSWAN_CONNECTION_GET_PRIVATE (connection
);
117 strongswan_connection_constructed (GObject
*object
)
119 if (G_OBJECT_CLASS (strongswan_connection_parent_class
)->constructed
)
121 G_OBJECT_CLASS (strongswan_connection_parent_class
)->constructed (object
);
126 strongswan_connection_dispose (GObject
*object
)
128 G_OBJECT_CLASS (strongswan_connection_parent_class
)->dispose (object
);
132 strongswan_connection_finalize (GObject
*object
)
134 StrongswanConnectionPrivate
*priv
= STRONGSWAN_CONNECTION (object
)->priv
;
140 G_OBJECT_CLASS (strongswan_connection_parent_class
)->finalize (object
);
144 strongswan_connection_class_init (StrongswanConnectionClass
*klass
)
146 GObjectClass
*object_class
= G_OBJECT_CLASS (klass
);
148 object_class
->constructed
= strongswan_connection_constructed
;
149 object_class
->get_property
= strongswan_connection_get_property
;
150 object_class
->set_property
= strongswan_connection_set_property
;
151 object_class
->dispose
= strongswan_connection_dispose
;
152 object_class
->finalize
= strongswan_connection_finalize
;
154 g_object_class_install_property (object_class
, PROP_NAME
,
155 g_param_spec_string ("name", "Connection name",
156 "The unique name of a connection",
158 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
160 g_object_class_install_property (object_class
, PROP_HOST
,
161 g_param_spec_string ("host", "Hostname or IP address",
162 "The hostname or IP address of the Gateway",
164 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
166 g_object_class_install_property (object_class
, PROP_CERT
,
167 g_param_spec_string ("cert", "Gateway or CA certificate",
168 "The certificate of the gateway or the CA",
171 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
173 g_object_class_install_property (object_class
, PROP_USER
,
174 g_param_spec_string ("user", "Username",
175 "The username for EAP authentication",
177 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
179 g_object_class_install_property (object_class
, PROP_PASS
,
180 g_param_spec_string ("pass", "Password",
181 "The password for EAP authentication",
183 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
185 g_type_class_add_private (klass
, sizeof (StrongswanConnectionPrivate
));
188 StrongswanConnection
*
189 strongswan_connection_new (const gchar
*name
)
191 StrongswanConnection
*conn
;
192 conn
= g_object_new (STRONGSWAN_TYPE_CONNECTION
,
195 g_return_val_if_fail (conn
->priv
!= NULL
, NULL
);