~ubuntu-branches/ubuntu/oneiric/libgdata/oneiric-backports

« back to all changes in this revision

Viewing changes to gdata/services/documents/gdata-documents-document.c

  • Committer: Package Import Robot
  • Author(s): Evan Broder
  • Date: 2011-11-15 21:59:48 UTC
  • mfrom: (4.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20111115215948-e17s889ocgu5fv4f
Tags: 0.10.1-1~oneiric1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
252
252
                                   GError **error)
253
253
{
254
254
        gchar *download_uri;
255
 
        GDataService *_service;
 
255
        GDataAuthorizationDomain *domain;
256
256
        GDataDownloadStream *download_stream;
257
257
 
258
258
        g_return_val_if_fail (GDATA_IS_DOCUMENTS_DOCUMENT (self), NULL);
261
261
        g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
262
262
        g_return_val_if_fail (error == NULL || *error == NULL, NULL);
263
263
 
264
 
        /* Horrible hack to force use of the spreadsheet service if the document we're downloading is a spreadsheet. This is necessary because it's
265
 
         * in a different authentication domain. */
266
 
        if (GDATA_IS_DOCUMENTS_SPREADSHEET (self))
267
 
                _service = _gdata_documents_service_get_spreadsheet_service (service);
268
 
        else
269
 
                _service = GDATA_SERVICE (service);
 
264
        /* If we're downloading a spreadsheet we have to use a different authorization domain. */
 
265
        if (GDATA_IS_DOCUMENTS_SPREADSHEET (self)) {
 
266
                domain = gdata_documents_service_get_spreadsheet_authorization_domain ();
 
267
        } else {
 
268
                domain = gdata_documents_service_get_primary_authorization_domain ();
 
269
        }
270
270
 
271
271
        /* Ensure we're authenticated first */
272
 
        if (gdata_service_is_authenticated (_service) == FALSE) {
 
272
        if (gdata_authorizer_is_authorized_for_domain (gdata_service_get_authorizer (GDATA_SERVICE (service)), domain) == FALSE) {
273
273
                g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED,
274
274
                                     _("You must be authenticated to download documents."));
275
275
                return NULL;
277
277
 
278
278
        /* Get the download URI and create a stream for it */
279
279
        download_uri = gdata_documents_document_get_download_uri (self, export_format);
280
 
        download_stream = GDATA_DOWNLOAD_STREAM (gdata_download_stream_new (_service, download_uri, cancellable));
 
280
        download_stream = GDATA_DOWNLOAD_STREAM (gdata_download_stream_new (GDATA_SERVICE (service), domain, download_uri, cancellable));
281
281
        g_free (download_uri);
282
282
 
283
283
        return download_stream;
305
305
        g_return_val_if_fail (GDATA_IS_DOCUMENTS_DOCUMENT (self), NULL);
306
306
        g_return_val_if_fail (export_format != NULL && *export_format != '\0', NULL);
307
307
 
308
 
        return _gdata_service_build_uri (FALSE, "%p&exportFormat=%s", gdata_entry_get_content_uri (GDATA_ENTRY (self)), export_format);
 
308
        return _gdata_service_build_uri ("%p&exportFormat=%s", gdata_entry_get_content_uri (GDATA_ENTRY (self)), export_format);
309
309
}