enum {
PROP_0,
- PROP_SOURCE,
PROP_CAPABILITIES,
- PROP_READONLY,
PROP_ONLINE,
- PROP_OPENED
+ PROP_OPENED,
+ PROP_READONLY,
+ PROP_SOURCE
};
enum {
return g_error_new_literal (E_CLIENT_ERROR, code, custom_msg ? custom_msg : e_client_error_to_string (code));
}
-static void client_set_source (EClient *client, ESource *source);
-
-static void
-e_client_init (EClient *client)
-{
- client->priv = E_CLIENT_GET_PRIVATE (client);
-
- client->priv->readonly = TRUE;
-
- g_rec_mutex_init (&client->priv->prop_mutex);
-}
-
static void
-client_finalize (GObject *object)
+client_set_source (EClient *client,
+ ESource *source)
{
- EClient *client;
- EClientPrivate *priv;
-
- client = E_CLIENT (object);
-
- priv = client->priv;
-
- g_rec_mutex_lock (&priv->prop_mutex);
-
- if (priv->source) {
- g_object_unref (priv->source);
- priv->source = NULL;
- }
-
- if (priv->capabilities) {
- g_slist_foreach (priv->capabilities, (GFunc) g_free, NULL);
- g_slist_free (priv->capabilities);
- priv->capabilities = NULL;
- }
-
- g_rec_mutex_unlock (&priv->prop_mutex);
- g_rec_mutex_clear (&priv->prop_mutex);
+ g_return_if_fail (E_IS_SOURCE (source));
+ g_return_if_fail (client->priv->source == NULL);
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_client_parent_class)->finalize (object);
+ client->priv->source = g_object_ref (source);
}
static void
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_SOURCE:
- client_set_source (
- E_CLIENT (object),
- g_value_get_object (value));
- return;
-
case PROP_ONLINE:
e_client_set_online (
E_CLIENT (object),
g_value_get_boolean (value));
return;
+
+ case PROP_SOURCE:
+ client_set_source (
+ E_CLIENT (object),
+ g_value_get_object (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_SOURCE:
- g_value_set_object (
- value,
- e_client_get_source (
- E_CLIENT (object)));
- return;
-
case PROP_CAPABILITIES:
g_value_set_pointer (
value,
E_CLIENT (object)));
return;
- case PROP_READONLY:
+ case PROP_ONLINE:
g_value_set_boolean (
value,
- e_client_is_readonly (
+ e_client_is_online (
E_CLIENT (object)));
return;
- case PROP_ONLINE:
+ case PROP_OPENED:
g_value_set_boolean (
value,
- e_client_is_online (
+ e_client_is_opened (
E_CLIENT (object)));
return;
- case PROP_OPENED:
+ case PROP_READONLY:
g_value_set_boolean (
value,
- e_client_is_opened (
+ e_client_is_readonly (
+ E_CLIENT (object)));
+ return;
+
+ case PROP_SOURCE:
+ g_value_set_object (
+ value,
+ e_client_get_source (
E_CLIENT (object)));
return;
}
}
static void
+client_dispose (GObject *object)
+{
+ EClientPrivate *priv;
+
+ priv = E_CLIENT_GET_PRIVATE (object);
+
+ g_clear_object (&priv->source);
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_client_parent_class)->dispose (object);
+}
+
+static void
+client_finalize (GObject *object)
+{
+ EClientPrivate *priv;
+
+ priv = E_CLIENT_GET_PRIVATE (object);
+
+ g_slist_free_full (priv->capabilities, (GDestroyNotify) g_free);
+
+ g_rec_mutex_clear (&priv->prop_mutex);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_client_parent_class)->finalize (object);
+}
+
+static void
client_unwrap_dbus_error (EClient *client,
GError *dbus_error,
GError **out_error)
object_class = G_OBJECT_CLASS (class);
object_class->set_property = client_set_property;
object_class->get_property = client_get_property;
+ object_class->dispose = client_dispose;
object_class->finalize = client_finalize;
class->unwrap_dbus_error = client_unwrap_dbus_error;
g_object_class_install_property (
object_class,
- PROP_SOURCE,
- g_param_spec_object (
- "source",
- NULL,
- NULL,
- E_TYPE_SOURCE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
PROP_CAPABILITIES,
g_param_spec_pointer (
"capabilities",
g_object_class_install_property (
object_class,
- PROP_READONLY,
+ PROP_ONLINE,
g_param_spec_boolean (
- "readonly",
+ "online",
NULL,
NULL,
FALSE,
- G_PARAM_READABLE |
+ G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (
object_class,
- PROP_ONLINE,
+ PROP_OPENED,
g_param_spec_boolean (
- "online",
+ "opened",
NULL,
NULL,
FALSE,
- G_PARAM_READWRITE |
+ G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (
object_class,
- PROP_OPENED,
+ PROP_READONLY,
g_param_spec_boolean (
- "opened",
+ "readonly",
NULL,
NULL,
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (
+ object_class,
+ PROP_SOURCE,
+ g_param_spec_object (
+ "source",
+ NULL,
+ NULL,
+ E_TYPE_SOURCE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
/**
* EClient::opened:
*
}
static void
-client_set_source (EClient *client,
- ESource *source)
+e_client_init (EClient *client)
{
- g_return_if_fail (E_IS_CLIENT (client));
- g_return_if_fail (E_IS_SOURCE (source));
-
- g_object_ref (source);
+ client->priv = E_CLIENT_GET_PRIVATE (client);
- if (client->priv->source)
- g_object_unref (client->priv->source);
+ client->priv->readonly = TRUE;
- client->priv->source = source;
+ g_rec_mutex_init (&client->priv->prop_mutex);
}
/**