[couchdb-glib] Use 'session' instead of 'couchdb' for CouchdbSession variables
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [couchdb-glib] Use 'session' instead of 'couchdb' for CouchdbSession variables
- Date: Wed, 12 May 2010 08:46:59 +0000 (UTC)
commit aa7a5c41648cc9c219e3982298e26cd188a42ea3
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Wed May 12 10:42:26 2010 +0200
Use 'session' instead of 'couchdb' for CouchdbSession variables
couchdb-glib/couchdb-session.c | 221 ++++++++++++++++++++--------------------
couchdb-glib/couchdb-session.h | 2 +
2 files changed, 114 insertions(+), 109 deletions(-)
---
diff --git a/couchdb-glib/couchdb-session.c b/couchdb-glib/couchdb-session.c
index dbe36f5..e1aef2d 100644
--- a/couchdb-glib/couchdb-session.c
+++ b/couchdb-glib/couchdb-session.c
@@ -84,17 +84,17 @@ static gboolean _session_authenticate(SoupSession *session,
static void
couchdb_session_finalize (GObject *object)
{
- CouchdbSession *couchdb = COUCHDB_SESSION (object);
+ CouchdbSession *session = COUCHDB_SESSION (object);
- g_hash_table_destroy (couchdb->priv->db_watchlist);
+ g_hash_table_destroy (session->priv->db_watchlist);
- g_free (couchdb->priv->uri);
- g_object_unref (couchdb->priv->http_session);
+ g_free (session->priv->uri);
+ g_object_unref (session->priv->http_session);
- if (couchdb->priv->credentials)
- g_object_unref (G_OBJECT (couchdb->priv->credentials));
+ if (session->priv->credentials)
+ g_object_unref (G_OBJECT (session->priv->credentials));
- g_free (couchdb->priv);
+ g_free (session->priv);
G_OBJECT_CLASS (couchdb_session_parent_class)->finalize (object);
}
@@ -106,12 +106,12 @@ couchdb_session_set_property (GObject *object,
GParamSpec *pspec)
{
- CouchdbSession *couchdb = COUCHDB_SESSION (object);
+ CouchdbSession *session = COUCHDB_SESSION (object);
switch (prop_id) {
case PROP_URI:
- g_free(couchdb->priv->uri);
- couchdb->priv->uri = g_value_dup_string (value);
+ g_free(session->priv->uri);
+ session->priv->uri = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -125,11 +125,11 @@ couchdb_session_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- CouchdbSession *couchdb = COUCHDB_SESSION (object);
+ CouchdbSession *session = COUCHDB_SESSION (object);
switch (prop_id) {
case PROP_URI:
- g_value_set_string (value, couchdb->priv->uri);
+ g_value_set_string (value, session->priv->uri);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -215,21 +215,21 @@ couchdb_session_class_init (CouchdbSessionClass *klass)
}
static void
-couchdb_session_init (CouchdbSession *couchdb)
+couchdb_session_init (CouchdbSession *session)
{
- couchdb->priv = g_new0 (CouchdbSessionPrivate, 1);
+ session->priv = g_new0 (CouchdbSessionPrivate, 1);
- couchdb->priv->db_watchlist = g_hash_table_new_full (g_str_hash, g_str_equal,
+ session->priv->db_watchlist = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) dbwatch_free);
- if (couchdb->priv->uri == NULL)
- couchdb->priv->uri = g_strdup("http://127.0.0.1:5984");
+ if (session->priv->uri == NULL)
+ session->priv->uri = g_strdup("http://127.0.0.1:5984");
- couchdb->priv->http_session = soup_session_sync_new_with_options (
+ session->priv->http_session = soup_session_sync_new_with_options (
SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_GNOME_FEATURES_2_26,
NULL);
- couchdb->priv->credentials = NULL;
+ session->priv->credentials = NULL;
#ifdef DEBUG_MESSAGES
g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_message, NULL);
@@ -256,23 +256,23 @@ couchdb_session_new (const char *uri)
/**
* couchdb_session_get_uri:
- * @couchdb: A #CouchdbSession object
+ * @session: A #CouchdbSession object
*
* Retrieve the URI of the CouchDB instance a #CouchdbSession object is bound to.
*
* Return value: the URI of the CouchDB instance used by this #CouchdbSession object.
*/
const char *
-couchdb_session_get_uri (CouchdbSession *couchdb)
+couchdb_session_get_uri (CouchdbSession *session)
{
- g_return_val_if_fail (COUCHDB_IS_SESSION (couchdb), NULL);
+ g_return_val_if_fail (COUCHDB_IS_SESSION (session), NULL);
- return (const char *) couchdb->priv->uri;
+ return (const char *) session->priv->uri;
}
/**
* couchdb_session_list_databases:
- * @couchdb: A #CouchdbSession object
+ * @session: A #CouchdbSession object
* @error: Placeholder for error information
*
* Retrieve the list of databases that exist in the CouchDB instance being used.
@@ -282,18 +282,18 @@ couchdb_session_get_uri (CouchdbSession *couchdb)
* list can be freed by calling #couchdb_session_free_database_list.
*/
GSList *
-couchdb_session_list_databases (CouchdbSession *couchdb, GError **error)
+couchdb_session_list_databases (CouchdbSession *session, GError **error)
{
char *url;
GSList *dblist = NULL;
JsonParser *parser;
- g_return_val_if_fail (COUCHDB_IS_SESSION (couchdb), NULL);
+ g_return_val_if_fail (COUCHDB_IS_SESSION (session), NULL);
/* Prepare request */
- url = g_strdup_printf ("%s/_all_dbs", couchdb->priv->uri);
+ url = g_strdup_printf ("%s/_all_dbs", session->priv->uri);
parser = json_parser_new ();
- if (couchdb_session_send_message (couchdb, SOUP_METHOD_GET, url, NULL, parser, error)) {
+ if (couchdb_session_send_message (session, SOUP_METHOD_GET, url, NULL, parser, error)) {
JsonNode *root_node;
root_node = json_parser_get_root (parser);
@@ -318,7 +318,7 @@ couchdb_session_list_databases (CouchdbSession *couchdb, GError **error)
/**
* couchdb_session_get_database_info:
- * @couchdb: A #CouchdbSession object
+ * @session: A #CouchdbSession object
* @dbname: Name of the database for which to retrieve the information
* @error: Placeholder for error information
*
@@ -328,18 +328,18 @@ couchdb_session_list_databases (CouchdbSession *couchdb, GError **error)
* all the information returned by CouchDB about this database.
*/
CouchdbDatabaseInfo *
-couchdb_session_get_database_info (CouchdbSession *couchdb, const char *dbname, GError **error)
+couchdb_session_get_database_info (CouchdbSession *session, const char *dbname, GError **error)
{
char *url;
JsonParser *parser;
CouchdbDatabaseInfo *result = NULL;
- g_return_val_if_fail (COUCHDB_IS_SESSION (couchdb), NULL);
+ g_return_val_if_fail (COUCHDB_IS_SESSION (session), NULL);
g_return_val_if_fail (dbname != NULL, NULL);
- url = g_strdup_printf ("%s/%s/", couchdb->priv->uri, dbname);
+ url = g_strdup_printf ("%s/%s/", session->priv->uri, dbname);
parser = json_parser_new ();
- if (couchdb_session_send_message (couchdb, SOUP_METHOD_GET, url, NULL, parser, error)) {
+ if (couchdb_session_send_message (session, SOUP_METHOD_GET, url, NULL, parser, error)) {
JsonNode *root_node;
root_node = json_parser_get_root (parser);
@@ -361,7 +361,7 @@ couchdb_session_get_database_info (CouchdbSession *couchdb, const char *dbname,
/**
* couchdb_session_create_database
- * @couchdb: A #CouchdbSession object
+ * @session: A #CouchdbSession object
* @dbname: Name of the database to be created
* @error: Placeholder for error information
*
@@ -370,18 +370,18 @@ couchdb_session_get_database_info (CouchdbSession *couchdb, const char *dbname,
* Return value: TRUE if successful, FALSE otherwise.
*/
gboolean
-couchdb_session_create_database (CouchdbSession *couchdb, const char *dbname, GError **error)
+couchdb_session_create_database (CouchdbSession *session, const char *dbname, GError **error)
{
char *url;
JsonParser *parser;
gboolean result = FALSE;
- g_return_val_if_fail (COUCHDB_IS_SESSION (couchdb), FALSE);
+ g_return_val_if_fail (COUCHDB_IS_SESSION (session), FALSE);
g_return_val_if_fail (dbname != NULL, FALSE);
- url = g_strdup_printf ("%s/%s/", couchdb->priv->uri, dbname);
+ url = g_strdup_printf ("%s/%s/", session->priv->uri, dbname);
parser = json_parser_new ();
- if (couchdb_session_send_message (couchdb, SOUP_METHOD_PUT, url, NULL, parser, error)) {
+ if (couchdb_session_send_message (session, SOUP_METHOD_PUT, url, NULL, parser, error)) {
JsonNode *root_node;
root_node = json_parser_get_root (parser);
@@ -394,14 +394,14 @@ couchdb_session_create_database (CouchdbSession *couchdb, const char *dbname, GE
g_free (url);
if (result)
- g_signal_emit_by_name (couchdb, "database_created", dbname);
+ g_signal_emit_by_name (session, "database_created", dbname);
return result;
}
/**
* couchdb_session_delete_database
- * @couchdb: A #CouchdbSession object
+ * @session: A #CouchdbSession object
* @dbname: Name of the database to be deleted
* @error: Placeholder for error information
*
@@ -410,18 +410,18 @@ couchdb_session_create_database (CouchdbSession *couchdb, const char *dbname, GE
* Return value: TRUE if successful, FALSE otherwise.
*/
gboolean
-couchdb_session_delete_database (CouchdbSession *couchdb, const char *dbname, GError **error)
+couchdb_session_delete_database (CouchdbSession *session, const char *dbname, GError **error)
{
char *url;
JsonParser *parser;
gboolean result = FALSE;
- g_return_val_if_fail (COUCHDB_IS_SESSION (couchdb), FALSE);
+ g_return_val_if_fail (COUCHDB_IS_SESSION (session), FALSE);
g_return_val_if_fail (dbname != NULL, FALSE);
- url = g_strdup_printf ("%s/%s/", couchdb->priv->uri, dbname);
+ url = g_strdup_printf ("%s/%s/", session->priv->uri, dbname);
parser = json_parser_new ();
- if (couchdb_session_send_message (couchdb, SOUP_METHOD_DELETE, url, NULL, parser, error)) {
+ if (couchdb_session_send_message (session, SOUP_METHOD_DELETE, url, NULL, parser, error)) {
JsonNode *root_node;
root_node = json_parser_get_root (parser);
@@ -435,10 +435,10 @@ couchdb_session_delete_database (CouchdbSession *couchdb, const char *dbname, GE
if (result) {
/* If we're listening for changes on this database, stop doing so */
- if (g_hash_table_lookup (couchdb->priv->db_watchlist, dbname))
- g_hash_table_remove (couchdb->priv->db_watchlist, dbname);
+ if (g_hash_table_lookup (session->priv->db_watchlist, dbname))
+ g_hash_table_remove (session->priv->db_watchlist, dbname);
- g_signal_emit_by_name (couchdb, "database_deleted", dbname);
+ g_signal_emit_by_name (session, "database_deleted", dbname);
}
return result;
@@ -446,7 +446,7 @@ couchdb_session_delete_database (CouchdbSession *couchdb, const char *dbname, GE
/**
* couchdb_session_compact_database:
- * @couchdb: A #CouchdbSession object
+ * @session: A #CouchdbSession object
* @dbname: Name of the database to be compacted
* @error: Placeholder for error information
*
@@ -456,19 +456,19 @@ couchdb_session_delete_database (CouchdbSession *couchdb, const char *dbname, GE
* Return value: TRUE if successful, FALSE otherwise.
*/
gboolean
-couchdb_session_compact_database (CouchdbSession *couchdb, const char *dbname, GError **error)
+couchdb_session_compact_database (CouchdbSession *session, const char *dbname, GError **error)
{
char *url;
JsonParser *output;
gboolean result = FALSE;
- g_return_val_if_fail (COUCHDB_IS_SESSION (couchdb), FALSE);
+ g_return_val_if_fail (COUCHDB_IS_SESSION (session), FALSE);
g_return_val_if_fail (dbname != NULL, FALSE);
- url = g_strdup_printf ("%s/%s/_compact", couchdb_session_get_uri (couchdb), dbname);
+ url = g_strdup_printf ("%s/%s/_compact", couchdb_session_get_uri (session), dbname);
output = json_parser_new ();
- if (couchdb_session_send_message (couchdb, SOUP_METHOD_POST, url, NULL, output, error)) {
+ if (couchdb_session_send_message (session, SOUP_METHOD_POST, url, NULL, output, error)) {
JsonNode *root_node;
root_node = json_parser_get_root (output);
@@ -573,7 +573,7 @@ couchdb_session_list_documents (CouchdbSession *session, const char *dbname, GEr
/**
* couchdb_session_get_all_documents:
- * @couchdb: A #CouchdbSession object
+ * @session: A #CouchdbSession object
* @dbname: Name of the databases to retrieve documents from
* @error: Placeholder for error information
*
@@ -652,7 +652,7 @@ couchdb_session_free_document_list (GSList *doclist)
/**
* couchdb_session_listen_for_changes:
- * @couchdb: A #CouchdbSession object
+ * @session: A #CouchdbSession object
* @dbname: Name of the database to poll changes for
*
* Setup a listener to get information about changes done to a specific database. Please
@@ -665,23 +665,23 @@ couchdb_session_free_document_list (GSList *doclist)
* so applications just have to connect to those signals before calling this function.
*/
void
-couchdb_session_listen_for_changes (CouchdbSession *couchdb, const char *dbname)
+couchdb_session_listen_for_changes (CouchdbSession *session, const char *dbname)
{
DBWatch *watch;
CouchdbDatabaseInfo *db_info;
GError *error = NULL;
- g_return_if_fail (COUCHDB_IS_SESSION (couchdb));
+ g_return_if_fail (COUCHDB_IS_SESSION (session));
g_return_if_fail (dbname != NULL);
- watch = g_hash_table_lookup (couchdb->priv->db_watchlist, dbname);
+ watch = g_hash_table_lookup (session->priv->db_watchlist, dbname);
if (watch) {
g_warning ("Already listening for changes in '%s' database", dbname);
return;
}
/* Retrieve information for database, to know the last_update_sequence */
- db_info = couchdb_session_get_database_info (couchdb, dbname, &error);
+ db_info = couchdb_session_get_database_info (session, dbname, &error);
if (!db_info) {
g_warning ("Could not retrieve information for '%s' database: %s",
dbname, error->message);
@@ -690,11 +690,11 @@ couchdb_session_listen_for_changes (CouchdbSession *couchdb, const char *dbname)
return;
}
- watch = dbwatch_new (couchdb,
+ watch = dbwatch_new (session,
dbname,
couchdb_database_info_get_update_sequence (db_info));
if (watch)
- g_hash_table_insert (couchdb->priv->db_watchlist, g_strdup (dbname), watch);
+ g_hash_table_insert (session->priv->db_watchlist, g_strdup (dbname), watch);
/* Free memory */
couchdb_database_info_unref (db_info);
@@ -702,90 +702,90 @@ couchdb_session_listen_for_changes (CouchdbSession *couchdb, const char *dbname)
/**
* couchdb_session_enable_authentication:
- * @couchdb: A #CouchdbSession object
+ * @session: A #CouchdbSession object
* @credentials: A #CouchdbCredentials object
*
* Enables authentication for the given #CouchdbSession object. The authentication
* mechanism should be specificied when creating the #CouchdbCredentials object.
*/
void
-couchdb_session_enable_authentication (CouchdbSession *couchdb,
+couchdb_session_enable_authentication (CouchdbSession *session,
CouchdbCredentials *credentials)
{
- g_return_if_fail (COUCHDB_IS_SESSION (couchdb));
+ g_return_if_fail (COUCHDB_IS_SESSION (session));
- if (couchdb->priv->credentials)
- g_object_unref (G_OBJECT (couchdb->priv->credentials));
+ if (session->priv->credentials)
+ g_object_unref (G_OBJECT (session->priv->credentials));
- couchdb->priv->credentials = COUCHDB_CREDENTIALS (g_object_ref (G_OBJECT (credentials)));
- if (couchdb_credentials_get_auth_type (couchdb->priv->credentials) == COUCHDB_CREDENTIALS_TYPE_USERNAME_AND_PASSWORD) {
- g_signal_connect (couchdb->priv->http_session,
+ session->priv->credentials = COUCHDB_CREDENTIALS (g_object_ref (G_OBJECT (credentials)));
+ if (couchdb_credentials_get_auth_type (session->priv->credentials) == COUCHDB_CREDENTIALS_TYPE_USERNAME_AND_PASSWORD) {
+ g_signal_connect (session->priv->http_session,
"authenticate",
G_CALLBACK (_session_authenticate),
- couchdb);
+ session);
}
}
/**
* couchdb_session_disable_authentication:
- * @couchdb: A #CouchdbSession object
+ * @session: A #CouchdbSession object
*
* Disables authentication for the given #CouchdbSession object.
*/
void
-couchdb_session_disable_authentication (CouchdbSession *couchdb)
+couchdb_session_disable_authentication (CouchdbSession *session)
{
- g_return_if_fail (COUCHDB_IS_SESSION (couchdb));
+ g_return_if_fail (COUCHDB_IS_SESSION (session));
- if (couchdb_credentials_get_auth_type (couchdb->priv->credentials) == COUCHDB_CREDENTIALS_TYPE_USERNAME_AND_PASSWORD) {
- g_signal_handlers_disconnect_by_func (couchdb->priv->http_session,
+ if (couchdb_credentials_get_auth_type (session->priv->credentials) == COUCHDB_CREDENTIALS_TYPE_USERNAME_AND_PASSWORD) {
+ g_signal_handlers_disconnect_by_func (session->priv->http_session,
G_CALLBACK (_session_authenticate),
- couchdb);
+ session);
}
- if (couchdb->priv->credentials) {
- g_object_unref (G_OBJECT (couchdb->priv->credentials));
- couchdb->priv->credentials = NULL;
+ if (session->priv->credentials) {
+ g_object_unref (G_OBJECT (session->priv->credentials));
+ session->priv->credentials = NULL;
}
}
/**
* couchdb_session_is_authentication_enabled:
- * @couchdb: A #CouchdbSession object
+ * @session: A #CouchdbSession object
*
* Gets whether the given #CouchdbSession object has authentication enabled.
*
* Return value: TRUE if authentication is enabled, FALSE otherwise.
*/
gboolean
-couchdb_session_is_authentication_enabled (CouchdbSession *couchdb)
+couchdb_session_is_authentication_enabled (CouchdbSession *session)
{
- g_return_val_if_fail (COUCHDB_IS_SESSION (couchdb), FALSE);
+ g_return_val_if_fail (COUCHDB_IS_SESSION (session), FALSE);
- return couchdb->priv->credentials != NULL;
+ return session->priv->credentials != NULL;
}
static gboolean
-_session_authenticate(SoupSession *session, SoupMessage *msg,
+_session_authenticate(SoupSession *http_session, SoupMessage *msg,
SoupAuth *auth, gboolean retrying,
gpointer callback_data)
{
- CouchdbSession *couchdb;
+ CouchdbSession *session;
g_return_val_if_fail (COUCHDB_IS_SESSION (callback_data), FALSE);
- couchdb = COUCHDB_SESSION (callback_data);
+ session = COUCHDB_SESSION (callback_data);
if (retrying) {
- g_signal_emit_by_name (couchdb, COUCHDB_SIGNAL_AUTHENTICATION_FAILED, NULL);
+ g_signal_emit_by_name (session, COUCHDB_SIGNAL_AUTHENTICATION_FAILED, NULL);
g_debug ("Authentication failed!");
return FALSE;
}
- if (couchdb_credentials_get_auth_type (couchdb->priv->credentials) == COUCHDB_CREDENTIALS_TYPE_USERNAME_AND_PASSWORD) {
- const char *username = couchdb_credentials_get_item (couchdb->priv->credentials,
+ if (couchdb_credentials_get_auth_type (session->priv->credentials) == COUCHDB_CREDENTIALS_TYPE_USERNAME_AND_PASSWORD) {
+ const char *username = couchdb_credentials_get_item (session->priv->credentials,
COUCHDB_CREDENTIALS_ITEM_USERNAME);
- const char *password = couchdb_credentials_get_item (couchdb->priv->credentials,
+ const char *password = couchdb_credentials_get_item (session->priv->credentials,
COUCHDB_CREDENTIALS_ITEM_PASSWORD);
soup_auth_authenticate (auth, username, password);
@@ -795,7 +795,7 @@ _session_authenticate(SoupSession *session, SoupMessage *msg,
}
static void
-add_oauth_signature (CouchdbSession *couchdb, SoupMessage *http_message, const char *method, const char *url)
+add_oauth_signature (CouchdbSession *session, SoupMessage *http_message, const char *method, const char *url)
{
#ifdef HAVE_OAUTH
/* This method is a no-op if we are configured without OAUTH */
@@ -803,10 +803,10 @@ add_oauth_signature (CouchdbSession *couchdb, SoupMessage *http_message, const c
signed_url = oauth_sign_url2 (
url, NULL, OA_HMAC, method,
- couchdb_credentials_get_item (couchdb->priv->credentials, COUCHDB_CREDENTIALS_ITEM_OAUTH_CONSUMER_KEY),
- couchdb_credentials_get_item (couchdb->priv->credentials, COUCHDB_CREDENTIALS_ITEM_OAUTH_CONSUMER_SECRET),
- couchdb_credentials_get_item (couchdb->priv->credentials, COUCHDB_CREDENTIALS_ITEM_OAUTH_TOKEN_KEY),
- couchdb_credentials_get_item (couchdb->priv->credentials, COUCHDB_CREDENTIALS_ITEM_OAUTH_TOKEN_SECRET));
+ couchdb_credentials_get_item (session->priv->credentials, COUCHDB_CREDENTIALS_ITEM_OAUTH_CONSUMER_KEY),
+ couchdb_credentials_get_item (session->priv->credentials, COUCHDB_CREDENTIALS_ITEM_OAUTH_CONSUMER_SECRET),
+ couchdb_credentials_get_item (session->priv->credentials, COUCHDB_CREDENTIALS_ITEM_OAUTH_TOKEN_KEY),
+ couchdb_credentials_get_item (session->priv->credentials, COUCHDB_CREDENTIALS_ITEM_OAUTH_TOKEN_SECRET));
if (signed_url != NULL) {
char **parsed_url;
GString *header = NULL;
@@ -863,7 +863,7 @@ add_oauth_signature (CouchdbSession *couchdb, SoupMessage *http_message, const c
}
static gboolean
-parse_json_response (CouchdbSession *couchdb, JsonParser *json_parser, SoupMessage *http_message, GError **error)
+parse_json_response (CouchdbSession *session, JsonParser *json_parser, SoupMessage *http_message, GError **error)
{
SoupBuffer *buffer;
GString *str = NULL;
@@ -898,7 +898,7 @@ parse_json_response (CouchdbSession *couchdb, JsonParser *json_parser, SoupMessa
/**
* couchdb_session_send_message:
- * @couchdb: A #CouchdbSession object
+ * @session: A #CouchdbSession object
* @method: HTTP method to use
* @url: URL to send the message to
* @body: Body of the HTTP request
@@ -912,13 +912,13 @@ parse_json_response (CouchdbSession *couchdb, JsonParser *json_parser, SoupMessa
* Return value: TRUE if successful, FALSE otherwise.
*/
gboolean
-couchdb_session_send_message (CouchdbSession *couchdb, const char *method, const char *url, const char *body, JsonParser *output, GError **error)
+couchdb_session_send_message (CouchdbSession *session, const char *method, const char *url, const char *body, JsonParser *output, GError **error)
{
SoupMessage *http_message;
guint status;
GError **real_error;
- g_return_val_if_fail (COUCHDB_IS_SESSION (couchdb), FALSE);
+ g_return_val_if_fail (COUCHDB_IS_SESSION (session), FALSE);
g_return_val_if_fail (method != NULL, FALSE);
if (error != NULL)
@@ -932,10 +932,10 @@ couchdb_session_send_message (CouchdbSession *couchdb, const char *method, const
body, strlen (body));
}
- if (couchdb_session_is_authentication_enabled (couchdb)) {
- switch (couchdb_credentials_get_auth_type (couchdb->priv->credentials)) {
+ if (couchdb_session_is_authentication_enabled (session)) {
+ switch (couchdb_credentials_get_auth_type (session->priv->credentials)) {
case COUCHDB_CREDENTIALS_TYPE_OAUTH:
- add_oauth_signature (couchdb, http_message, method, url);
+ add_oauth_signature (session, http_message, method, url);
break;
default:
g_warning ("Got unknown credentials object, not authenticating message");
@@ -948,10 +948,10 @@ couchdb_session_send_message (CouchdbSession *couchdb, const char *method, const
(SoupMessageHeadersForeachFunc) debug_print_headers,
NULL);
#endif
- status = soup_session_send_message (couchdb->priv->http_session, http_message);
+ status = soup_session_send_message (session->priv->http_session, http_message);
if (SOUP_STATUS_IS_SUCCESSFUL (status)) {
if (output != NULL)
- parse_json_response (couchdb, output, http_message, real_error);
+ parse_json_response (session, output, http_message, real_error);
return TRUE;
} else {
if (error != NULL)
@@ -981,8 +981,11 @@ debug_message (const gchar *log_domain, GLogLevelFlags log_level,
#endif
/**
+ * couchdb_session_list_view_documents:
+ * @session:
+/**
* couchdb_session_replicate:
- * @couchdb: A #CouchdbSession object
+ * @session: A #CouchdbSession object
* @source: Source database
* @target: Target database
* @continous: Whether to replicate once or keep replicating
@@ -999,7 +1002,7 @@ debug_message (const gchar *log_domain, GLogLevelFlags log_level,
* parameter will be set to contain information about the error.
*/
gboolean
-couchdb_session_replicate (CouchdbSession *couchdb,
+couchdb_session_replicate (CouchdbSession *session,
const gchar *source,
const gchar *target,
gboolean continous,
@@ -1010,23 +1013,23 @@ couchdb_session_replicate (CouchdbSession *couchdb,
JsonParser *output;
gboolean send_ok;
- g_return_val_if_fail (COUCHDB_IS_SESSION (couchdb), FALSE);
+ g_return_val_if_fail (COUCHDB_IS_SESSION (session), FALSE);
g_return_val_if_fail (source != NULL, FALSE);
g_return_val_if_fail (target != NULL, FALSE);
/* Build the input document */
- input = couchdb_document_new (couchdb);
+ input = couchdb_document_new (session);
couchdb_document_set_string_field (input, "source", source);
couchdb_document_set_string_field (input, "target", target);
if (continous)
couchdb_document_set_boolean_field (input, "continous", TRUE);
/* Send message */
- url = g_strdup_printf ("%s/_replicate", couchdb_session_get_uri (couchdb));
+ url = g_strdup_printf ("%s/_replicate", couchdb_session_get_uri (session));
body = couchdb_document_to_string (input);
output = json_parser_new ();
- send_ok = couchdb_session_send_message (couchdb, SOUP_METHOD_POST, url, body, output, error);
+ send_ok = couchdb_session_send_message (session, SOUP_METHOD_POST, url, body, output, error);
/* FIXME: what to do with the information returned? -> http://books.couchdb.org/relax/reference/replication */
/* Free memory */
diff --git a/couchdb-glib/couchdb-session.h b/couchdb-glib/couchdb-session.h
index 8abb283..66bd44e 100644
--- a/couchdb-glib/couchdb-session.h
+++ b/couchdb-glib/couchdb-session.h
@@ -84,6 +84,8 @@ GSList *couchdb_session_list_documents (CouchdbSession *session, co
GSList *couchdb_session_get_all_documents (CouchdbSession *session, const char *dbname, GError **error);
void couchdb_session_free_document_list (GSList *doclist);
+GSList *couchdb_session_list_view_documents (CouchdbSession *session, const char *dbname);
+
gboolean couchdb_session_replicate (CouchdbSession *session,
const gchar *source,
const gchar *target,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]