gobject);
}
-static void
-gsignond_secret_storage_class_init (GSignondSecretStorageClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->set_property = _set_property;
- gobject_class->get_property = _get_property;
- gobject_class->dispose = _gsignond_secret_storage_dispose;
-
- properties[PROP_CONFIG] = g_param_spec_object ("config",
- "config",
- "Configuration object",
- GSIGNOND_TYPE_CONFIG,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS);
- g_object_class_install_properties (gobject_class, N_PROPERTIES, properties);
-
- /* virtual methods */
- klass->open_db = gsignond_secret_storage_open_db;
- klass->close_db = gsignond_secret_storage_close_db;
- klass->clear_db = gsignond_secret_storage_clear_db;
- klass->is_open_db = gsignond_secret_storage_is_open_db;
- klass->load_credentials =
- gsignond_secret_storage_load_credentials;
- klass->update_credentials =
- gsignond_secret_storage_update_credentials;
- klass->remove_credentials =
- gsignond_secret_storage_remove_credentials;
- klass->load_data = gsignond_secret_storage_load_data;
- klass->update_data = gsignond_secret_storage_update_data;
- klass->remove_data = gsignond_secret_storage_remove_data;
-
- g_type_class_add_private (klass, sizeof (GSignondSecretStoragePrivate));
-}
-
-static void
-gsignond_secret_storage_init (GSignondSecretStorage *self)
-{
- self->priv = GSIGNOND_SECRET_STORAGE_GET_PRIVATE (self);
- self->priv->database = gsignond_db_secret_database_new ();
- self->config = NULL;
-}
-
-/**
- * gsignond_secret_storage_open_db:
- *
- * @self: instance of #GSignondSecretStorage
- *
- * Opens (and initializes) DB. The implementation should take
- * care of creating the DB, if it doesn't exist.
- *
- * Returns: TRUE if successful, FALSE otherwise.
- */
-gboolean
-gsignond_secret_storage_open_db (GSignondSecretStorage *self)
+static gboolean
+_open_db (GSignondSecretStorage *self)
{
const gchar *dir = NULL;
const gchar *filename = NULL;
return TRUE;
}
+static gboolean
+_close_db (GSignondSecretStorage *self)
+{
+ g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
+
+ if (self->priv->database != NULL) {
+ gsignond_db_sql_database_close (GSIGNOND_DB_SQL_DATABASE (
+ self->priv->database));
+ }
+ return TRUE;
+}
+
+static gboolean
+_clear_db (GSignondSecretStorage *self)
+{
+ g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
+ return gsignond_db_sql_database_clear (GSIGNOND_DB_SQL_DATABASE (
+ self->priv->database));
+}
+
+static gboolean
+_is_open_db (GSignondSecretStorage *self)
+{
+ g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
+ return ((self->priv->database != NULL) &&
+ gsignond_db_sql_database_is_open (GSIGNOND_DB_SQL_DATABASE (
+ self->priv->database)));
+}
+
+static GSignondCredentials*
+_load_credentials (
+ GSignondSecretStorage *self,
+ const guint32 id)
+{
+ g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
+ return gsignond_db_secret_database_load_credentials (self->priv->database,
+ id);
+}
+
+static gboolean
+_update_credentials (
+ GSignondSecretStorage *self,
+ GSignondCredentials *creds)
+{
+ g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
+ return gsignond_db_secret_database_update_credentials (self->priv->database,
+ creds);
+}
+
+static gboolean
+_remove_credentials (
+ GSignondSecretStorage *self,
+ const guint32 id)
+{
+ g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
+ return gsignond_db_secret_database_remove_credentials (self->priv->database,
+ id);
+}
+
+static gboolean
+_check_credentials (
+ GSignondSecretStorage *self,
+ GSignondCredentials *creds)
+{
+ gboolean equal = FALSE;
+ GSignondCredentials *stored_creds = NULL;
+
+ g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
+ g_return_val_if_fail (creds != NULL, FALSE);
+
+ GSignondSecretStorageClass *klass =
+ GSIGNOND_SECRET_STORAGE_GET_CLASS (self);
+
+ stored_creds = klass->load_credentials (self,
+ gsignond_credentials_get_id(creds));
+
+ if (stored_creds) {
+ DBG ("Credentials from DB found");
+ equal = gsignond_credentials_equal(creds, stored_creds);
+ g_object_unref (stored_creds);
+ }
+
+ return equal;
+}
+
+static GHashTable*
+_load_data (
+ GSignondSecretStorage *self,
+ const guint32 id,
+ const guint32 method)
+{
+ g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), NULL);
+ return gsignond_db_secret_database_load_data (self->priv->database,
+ id, method);
+}
+
+static gboolean
+_update_data (
+ GSignondSecretStorage *self,
+ const guint32 id,
+ const guint32 method,
+ GHashTable *data)
+{
+ g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
+ return gsignond_db_secret_database_update_data (self->priv->database,
+ id, method, data);
+}
+
+static gboolean
+_remove_data (
+ GSignondSecretStorage *self,
+ const guint32 id,
+ const guint32 method)
+{
+ g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
+ return gsignond_db_secret_database_remove_data (self->priv->database,
+ id, method);
+}
+
+
+static void
+gsignond_secret_storage_class_init (GSignondSecretStorageClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->set_property = _set_property;
+ gobject_class->get_property = _get_property;
+ gobject_class->dispose = _gsignond_secret_storage_dispose;
+
+ properties[PROP_CONFIG] = g_param_spec_object ("config",
+ "config",
+ "Configuration object",
+ GSIGNOND_TYPE_CONFIG,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
+ g_object_class_install_properties (gobject_class, N_PROPERTIES, properties);
+
+ /* virtual methods */
+ klass->open_db = _open_db;
+ klass->close_db = _close_db;
+ klass->clear_db = _clear_db;
+ klass->is_open_db = _is_open_db;
+ klass->load_credentials = _load_credentials;
+ klass->update_credentials = _update_credentials;
+ klass->remove_credentials = _remove_credentials;
+ klass->check_credentials = _check_credentials;
+ klass->load_data = _load_data;
+ klass->update_data = _update_data;
+ klass->remove_data = _remove_data;
+
+ g_type_class_add_private (klass, sizeof (GSignondSecretStoragePrivate));
+}
+
+static void
+gsignond_secret_storage_init (GSignondSecretStorage *self)
+{
+ self->priv = GSIGNOND_SECRET_STORAGE_GET_PRIVATE (self);
+ self->priv->database = gsignond_db_secret_database_new ();
+ self->config = NULL;
+}
+
+/**
+ * gsignond_secret_storage_open_db:
+ *
+ * @self: instance of #GSignondSecretStorage
+ *
+ * Opens (and initializes) DB. The implementation should take
+ * care of creating the DB, if it doesn't exist.
+ *
+ * Returns: TRUE if successful, FALSE otherwise.
+ */
+gboolean
+gsignond_secret_storage_open_db (GSignondSecretStorage *self)
+{
+ return GSIGNOND_SECRET_STORAGE_GET_CLASS (self)->open_db (self);
+}
+
/**
* gsignond_secret_storage_close_db:
*
gboolean
gsignond_secret_storage_close_db (GSignondSecretStorage *self)
{
- g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
-
- if (self->priv->database != NULL) {
- gsignond_db_sql_database_close (GSIGNOND_DB_SQL_DATABASE (
- self->priv->database));
- }
- return TRUE;
+ return GSIGNOND_SECRET_STORAGE_GET_CLASS (self)->close_db (self);
}
/**
gboolean
gsignond_secret_storage_clear_db (GSignondSecretStorage *self)
{
- g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
- return gsignond_db_sql_database_clear (GSIGNOND_DB_SQL_DATABASE (
- self->priv->database));
+ return GSIGNOND_SECRET_STORAGE_GET_CLASS (self)->clear_db (self);
}
/**
gboolean
gsignond_secret_storage_is_open_db (GSignondSecretStorage *self)
{
- g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
- return ((self->priv->database != NULL) &&
- gsignond_db_sql_database_is_open (GSIGNOND_DB_SQL_DATABASE (
- self->priv->database)));
+ return GSIGNOND_SECRET_STORAGE_GET_CLASS (self)->is_open_db (self);
}
/**
GSignondSecretStorage *self,
const guint32 id)
{
- g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
- return gsignond_db_secret_database_load_credentials (self->priv->database,
- id);
+ return GSIGNOND_SECRET_STORAGE_GET_CLASS (self)->load_credentials (self, id);
}
/**
GSignondSecretStorage *self,
GSignondCredentials *creds)
{
- g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
- return gsignond_db_secret_database_update_credentials (self->priv->database,
- creds);
+ return GSIGNOND_SECRET_STORAGE_GET_CLASS (self)->update_credentials (self, creds);
}
/**
GSignondSecretStorage *self,
const guint32 id)
{
- g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
- return gsignond_db_secret_database_remove_credentials (self->priv->database,
- id);
+ return GSIGNOND_SECRET_STORAGE_GET_CLASS (self)->remove_credentials (self, id);
}
/**
GSignondSecretStorage *self,
GSignondCredentials *creds)
{
- gboolean equal = FALSE;
- GSignondCredentials *stored_creds = NULL;
-
- g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
- g_return_val_if_fail (creds != NULL, FALSE);
-
- GSignondSecretStorageClass *klass =
- GSIGNOND_SECRET_STORAGE_GET_CLASS (self);
-
- stored_creds = klass->load_credentials (self,
- gsignond_credentials_get_id(creds));
-
- if (stored_creds) {
- DBG ("Credentials from DB found");
- equal = gsignond_credentials_equal(creds, stored_creds);
- g_object_unref (stored_creds);
- }
-
- return equal;
+ return GSIGNOND_SECRET_STORAGE_GET_CLASS (self)->check_credentials (self, creds);
}
/**
const guint32 id,
const guint32 method)
{
- g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), NULL);
- return gsignond_db_secret_database_load_data (self->priv->database,
- id, method);
+ return GSIGNOND_SECRET_STORAGE_GET_CLASS (self)->load_data (self, id, method);
}
/**
const guint32 method,
GHashTable *data)
{
- g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
- return gsignond_db_secret_database_update_data (self->priv->database,
- id, method, data);
+ return GSIGNOND_SECRET_STORAGE_GET_CLASS (self)->update_data (self, id, method, data);
}
/**
const guint32 id,
const guint32 method)
{
- g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE);
- return gsignond_db_secret_database_remove_data (self->priv->database,
- id, method);
+ return GSIGNOND_SECRET_STORAGE_GET_CLASS (self)->remove_data (self, id, method);
}
/**