evolution-data-server r8386 - trunk/servers/google/libgdata-google
- From: kmaraas svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r8386 - trunk/servers/google/libgdata-google
- Date: Thu, 17 Jan 2008 13:16:37 +0000 (GMT)
Author: kmaraas
Date: Thu Jan 17 13:16:33 2008
New Revision: 8386
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8386&view=rev
Log:
2008-01-15 Dan Winship <danw gnome org>
* gdata-google-service.c: Update for libsoup 2.4
(service_authenticate): Use soup-forms methods.
Modified:
trunk/servers/google/libgdata-google/ChangeLog
trunk/servers/google/libgdata-google/gdata-google-service.c
trunk/servers/google/libgdata-google/libgdata-google.pc.in
Modified: trunk/servers/google/libgdata-google/gdata-google-service.c
==============================================================================
--- trunk/servers/google/libgdata-google/gdata-google-service.c (original)
+++ trunk/servers/google/libgdata-google/gdata-google-service.c Thu Jan 17 13:16:33 2008
@@ -66,7 +66,6 @@
};
static const gchar *GOOGLE_CLIENT_LOGIN = "https://www.google.com/accounts/ClientLogin";
-static const gchar *GOOGLE_CLIENT_LOGIN_MSG = "Email=%s&Passwd=%s&service=%s&source=%s&accountType=HOSTED_OR_GOOGLE";
void
gdata_google_service_set_credentials (GDataService *service, const gchar *username, const gchar *password)
@@ -105,8 +104,8 @@
GDataGoogleServicePrivate *priv;
GDataGoogleServiceAuth *auth;
SoupMessage *msg;
+ GHashTable *request_form;
gchar *request_body;
- gchar *request_body_encoded;
gchar *token = NULL;
gchar *auth_begin = NULL;
gchar *auth_end = NULL;
@@ -114,24 +113,25 @@
priv = GDATA_GOOGLE_SERVICE_GET_PRIVATE(service);
auth = (GDataGoogleServiceAuth *)priv->auth;
- msg = soup_message_new(SOUP_METHOD_POST, GOOGLE_CLIENT_LOGIN);
- request_body = g_strdup_printf(GOOGLE_CLIENT_LOGIN_MSG, auth->username,
- auth->password,
- priv->name,
- priv->agent);
+ request_form = g_hash_table_new (g_str_hash, g_str_equal);
+ g_hash_table_insert (request_form, "Email", auth->username);
+ g_hash_table_insert (request_form, "Passwd", auth->password);
+ g_hash_table_insert (request_form, "service", priv->name);
+ g_hash_table_insert (request_form, "source", priv->agent);
+ g_hash_table_insert (request_form, "accountType", "HOSTED_OR_GOOGLE");
+ request_body = soup_form_encode_urlencoded (request_form);
+ g_hash_table_destroy (request_form);
- request_body_encoded = soup_uri_encode(request_body,NULL);
+ msg = soup_message_new(SOUP_METHOD_POST, GOOGLE_CLIENT_LOGIN);
soup_message_set_http_version(msg, SOUP_HTTP_1_0);
-
soup_message_set_request (msg, "application/x-www-form-urlencoded",
- SOUP_BUFFER_USER_OWNED,
- request_body_encoded,
- strlen(request_body_encoded));
+ SOUP_MEMORY_TAKE,
+ request_body, strlen(request_body));
soup_session_send_message(priv->soup_session, msg);
- if (msg->response.length) {
- auth_begin = strstr(msg->response.body, "Auth=");
+ if (msg->response_body->length) {
+ auth_begin = strstr(msg->response_body->data, "Auth=");
if (!auth_begin)
return "FAILURE";
@@ -148,11 +148,7 @@
if (!token)
return "FAILURE";
- g_free(request_body);
- g_free(request_body_encoded);
-
- if(SOUP_IS_MESSAGE(msg))
- g_object_unref(msg);
+ g_object_unref(msg);
return "SUCCESS";
}
@@ -194,16 +190,16 @@
msg = NULL;
msg = soup_message_new(SOUP_METHOD_GET, feed_url);
- soup_message_add_header(msg->request_headers,
+ soup_message_headers_append(msg->request_headers,
"Authorization", (gchar *)g_strdup_printf("GoogleLogin auth=%s", auth->token));
soup_session_send_message(soup_session, msg);
- if (msg->response.length) {
- feed = gdata_feed_new_from_xml(msg->response.body, msg->response.length);
+ if (msg->response_body->length) {
+ feed = gdata_feed_new_from_xml(msg->response_body->data,
+ msg->response_body->length);
}
- if (SOUP_IS_MESSAGE(msg))
- g_object_unref(msg);
+ g_object_unref(msg);
return feed;
}
@@ -247,35 +243,31 @@
msg = soup_message_new(SOUP_METHOD_POST, feed_url);
soup_message_set_http_version (msg, SOUP_HTTP_1_0);
- soup_message_add_header(msg->request_headers,
- "Authorization",
- (gchar *)g_strdup_printf("GoogleLogin auth=%s",
- auth->token));
+ soup_message_headers_append(msg->request_headers,
+ "Authorization",
+ (gchar *)g_strdup_printf("GoogleLogin auth=%s",
+ auth->token));
soup_message_set_request (msg,
"application/atom+xml",
- SOUP_BUFFER_USER_OWNED,
+ SOUP_MEMORY_TAKE,
entry_xml,
strlen(entry_xml));
soup_session_send_message(soup_session, msg);
- if (!msg->response.length) {
+ if (!msg->response_body->length) {
g_message ("\n %s, %s, Response Length NULL when inserting entry", G_STRLOC, G_STRFUNC);
return NULL;
}
- updated_entry = gdata_entry_new_from_xml (msg->response.body);
+ updated_entry = gdata_entry_new_from_xml (msg->response_body->data);
if (!GDATA_IS_ENTRY(entry)) {
g_critical ("\n %s, %s, Error During Insert Entry ", G_STRLOC, G_STRFUNC);
return NULL;
}
- if (SOUP_IS_MESSAGE(msg))
- g_object_unref (msg);
-
- if (entry_xml)
- g_free (entry_xml);
+ g_object_unref (msg);
return updated_entry;
}
@@ -315,14 +307,13 @@
soup_session = (SoupSession *)priv->soup_session;
msg = soup_message_new (SOUP_METHOD_DELETE, entry_edit_url);
- soup_message_add_header (msg->request_headers,
- "Authorization",
- (gchar *)g_strdup_printf ("GoogleLogin auth=%s",
- auth->token));
+ soup_message_headers_append (msg->request_headers,
+ "Authorization",
+ (gchar *)g_strdup_printf ("GoogleLogin auth=%s",
+ auth->token));
soup_session_send_message (soup_session, msg);
- if (SOUP_IS_MESSAGE(msg))
- g_object_unref (msg);
+ g_object_unref (msg);
}
/**
@@ -367,22 +358,19 @@
return;
}
- soup_message_add_header (msg->request_headers,
- "Authorization",
- (gchar *)g_strdup_printf ("GoogleLogin auth=%s",
- auth->token));
+ soup_message_headers_append (msg->request_headers,
+ "Authorization",
+ (gchar *)g_strdup_printf ("GoogleLogin auth=%s",
+ auth->token));
soup_message_set_request (msg,
"application/atom+xml",
- SOUP_BUFFER_USER_OWNED,
+ SOUP_MEMORY_TAKE,
entry_xml,
strlen(entry_xml));
soup_session_send_message (soup_session, msg);
- if (SOUP_IS_MESSAGE(msg))
- g_object_unref (msg);
- if (entry_xml)
- g_free (entry_xml);
+ g_object_unref (msg);
}
@@ -426,23 +414,20 @@
return;
}
- soup_message_add_header (msg->request_headers,
- "Authorization",
- (gchar *)g_strdup_printf ("GoogleLogin auth=%s",
- auth->token));
+ soup_message_headers_append (msg->request_headers,
+ "Authorization",
+ (gchar *)g_strdup_printf ("GoogleLogin auth=%s",
+ auth->token));
soup_message_set_request (msg,
"application/atom+xml",
- SOUP_BUFFER_USER_OWNED,
+ SOUP_MEMORY_TAKE,
entry_xml,
strlen(entry_xml));
soup_session_send_message (soup_session, msg);
- if (SOUP_IS_MESSAGE(msg))
- g_object_unref (msg);
- if (entry_xml)
- g_free (entry_xml);
+ g_object_unref (msg);
}
static void gdata_google_service_iface_init(gpointer g_iface, gpointer iface_data)
Modified: trunk/servers/google/libgdata-google/libgdata-google.pc.in
==============================================================================
--- trunk/servers/google/libgdata-google/libgdata-google.pc.in (original)
+++ trunk/servers/google/libgdata-google/libgdata-google.pc.in Thu Jan 17 13:16:33 2008
@@ -13,6 +13,6 @@
Name: libgdata-google
Description: Client library for accessing google POA through SOAP interface
Version: @VERSION@
-Requires: @LIBSOUP@ >= @LIBSOUP_REQUIRED@
+Requires: libsoup-2.4 >= @LIBSOUP_REQUIRED@
Libs: -L${libdir} -lgdata-google-1.2
Cflags: -I${privincludedir}/gdata-google
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]