~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to calendar/backends/caldav/e-cal-backend-caldav.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
518
518
 
519
519
        if (priv->mode == CAL_MODE_LOCAL) {
520
520
 
521
 
                if (! priv->do_offline) {
 
521
                if (!priv->do_offline) {
522
522
                        return GNOME_Evolution_Calendar_RepositoryOffline;
523
523
                }
524
524
 
949
949
 
950
950
        send_and_handle_redirection (priv->session, message, NULL);
951
951
 
952
 
        if (! SOUP_STATUS_IS_SUCCESSFUL (message->status_code)) {
 
952
        if (!SOUP_STATUS_IS_SUCCESSFUL (message->status_code)) {
953
953
                guint status_code = message->status_code;
954
954
 
955
955
                g_object_unref (message);
980
980
        g_object_unref (message);
981
981
 
982
982
        if (calendar_access) {
983
 
                priv->read_only = ! (put_allowed && delete_allowed);
 
983
                priv->read_only = !(put_allowed && delete_allowed);
984
984
                return GNOME_Evolution_Calendar_Success;
985
985
        }
986
986
 
2110
2110
 
2111
2111
        if (priv && priv->is_google)
2112
2112
                *capabilities = g_strdup (CAL_STATIC_CAPABILITY_NO_THISANDFUTURE ","
2113
 
                                          CAL_STATIC_CAPABILITY_NO_THISANDPRIOR);
 
2113
                                          CAL_STATIC_CAPABILITY_NO_THISANDPRIOR ","
 
2114
                                          CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED);
2114
2115
        else
2115
2116
                *capabilities = g_strdup (CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS ","
2116
2117
                                          CAL_STATIC_CAPABILITY_NO_THISANDFUTURE ","
2117
 
                                          CAL_STATIC_CAPABILITY_NO_THISANDPRIOR);
 
2118
                                          CAL_STATIC_CAPABILITY_NO_THISANDPRIOR ","
 
2119
                                          CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED);
2118
2120
 
2119
2121
        return GNOME_Evolution_Calendar_Success;
2120
2122
}
2175
2177
 
2176
2178
                /* properly encode uri */
2177
2179
                if (suri && suri->path) {
2178
 
                        gchar *tmp = soup_uri_encode (suri->path, NULL);
2179
 
                        gchar *path = soup_uri_normalize (tmp, "/");
 
2180
                        gchar *tmp, *path;
 
2181
 
 
2182
                        if (suri->path && strchr (suri->path, '%')) {
 
2183
                                /* If path contains anything already encoded, then decode it first,
 
2184
                                   thus it'll be managed properly. For example, the '#' in a path
 
2185
                                   is in URI shown as %23 and not doing this decode makes it being
 
2186
                                   like %2523, which is not what is wanted here. */
 
2187
                                tmp = soup_uri_decode (suri->path);
 
2188
                                soup_uri_set_path (suri, tmp);
 
2189
                                g_free (tmp);
 
2190
                        }
 
2191
 
 
2192
                        tmp = soup_uri_encode (suri->path, NULL);
 
2193
                        path = soup_uri_normalize (tmp, "/");
2180
2194
 
2181
2195
                        soup_uri_set_path (suri, path);
2182
2196
 
2380
2394
}
2381
2395
 
2382
2396
static ECalBackendSyncStatus
 
2397
caldav_refresh (ECalBackendSync *backend, EDataCal *cal)
 
2398
{
 
2399
        ECalBackendCalDAV        *cbdav;
 
2400
        ECalBackendCalDAVPrivate *priv;
 
2401
        gboolean                  online;
 
2402
 
 
2403
        cbdav = E_CAL_BACKEND_CALDAV (backend);
 
2404
        priv  = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
 
2405
 
 
2406
        g_mutex_lock (priv->busy_lock);
 
2407
 
 
2408
        if (!priv->loaded
 
2409
            || priv->slave_cmd != SLAVE_SHOULD_SLEEP
 
2410
            || check_state (cbdav, &online) != GNOME_Evolution_Calendar_Success
 
2411
            || !online) {
 
2412
                g_mutex_unlock (priv->busy_lock);
 
2413
                return GNOME_Evolution_Calendar_Success;
 
2414
        }
 
2415
 
 
2416
        priv->slave_cmd = SLAVE_SHOULD_WORK;
 
2417
 
 
2418
        /* wake it up */
 
2419
        g_cond_signal (priv->cond);
 
2420
        g_mutex_unlock (priv->busy_lock);
 
2421
 
 
2422
        return GNOME_Evolution_Calendar_Success;
 
2423
}
 
2424
 
 
2425
static ECalBackendSyncStatus
2383
2426
caldav_remove (ECalBackendSync *backend,
2384
2427
               EDataCal        *cal)
2385
2428
{
2716
2759
                         * be embedded in a soap message
2717
2760
                         */
2718
2761
                        encoded = g_base64_encode ((guchar *) content, len);
2719
 
                        attach = icalattach_new_from_data ((guchar *) encoded, 0, 0);
 
2762
                        attach = icalattach_new_from_data ((guchar *) encoded, NULL, NULL);
2720
2763
                        g_free(content);
2721
2764
                        g_free(encoded);
2722
2765
 
3912
3955
}
3913
3956
 
3914
3957
static ECalBackendSyncStatus
3915
 
caldav_get_timezone (ECalBackendSync  *backend,
3916
 
                     EDataCal         *cal,
3917
 
                     const gchar       *tzid,
3918
 
                     gchar            **object)
3919
 
{
3920
 
        ECalBackendCalDAV        *cbdav;
3921
 
        ECalBackendCalDAVPrivate *priv;
3922
 
        const icaltimezone       *zone;
3923
 
        icalcomponent            *icalcomp;
3924
 
 
3925
 
        cbdav = E_CAL_BACKEND_CALDAV (backend);
3926
 
        priv  = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
3927
 
 
3928
 
        g_return_val_if_fail (tzid, GNOME_Evolution_Calendar_ObjectNotFound);
3929
 
 
3930
 
        /* first try to get the timezone from the cache */
3931
 
        zone = e_cal_backend_store_get_timezone (priv->store, tzid);
3932
 
 
3933
 
        if (!zone) {
3934
 
                zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
3935
 
                if (!zone) {
3936
 
                        return GNOME_Evolution_Calendar_ObjectNotFound;
3937
 
                }
3938
 
        }
3939
 
 
3940
 
        icalcomp = icaltimezone_get_component ((icaltimezone *) zone);
3941
 
 
3942
 
        if (!icalcomp) {
3943
 
                return GNOME_Evolution_Calendar_InvalidObject;
3944
 
        }
3945
 
 
3946
 
        *object = icalcomponent_as_ical_string_r (icalcomp);
3947
 
 
3948
 
        return GNOME_Evolution_Calendar_Success;
3949
 
}
3950
 
 
3951
 
static ECalBackendSyncStatus
3952
3958
caldav_add_timezone (ECalBackendSync *backend,
3953
3959
                     EDataCal        *cal,
3954
3960
                     const gchar      *tzobj)
4177
4183
        e_cal_component_set_dtend (comp, &dt);
4178
4184
 
4179
4185
        if (priv->username) {
4180
 
                ECalComponentOrganizer organizer = {0};
 
4186
                ECalComponentOrganizer organizer = {NULL};
4181
4187
 
4182
4188
                organizer.value = priv->username;
4183
4189
                e_cal_component_set_organizer (comp, &organizer);
4392
4398
                              const gchar *tzid)
4393
4399
{
4394
4400
        icaltimezone *zone;
4395
 
 
4396
 
        zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
4397
 
 
4398
 
        if (!zone) {
4399
 
                ECalBackendCalDAV *cbdav;
4400
 
                ECalBackendCalDAVPrivate *priv;
4401
 
 
4402
 
                cbdav = E_CAL_BACKEND_CALDAV (backend);
4403
 
                priv  = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
4404
 
 
4405
 
                if (priv->store)
4406
 
                        zone = (icaltimezone *) e_cal_backend_store_get_timezone (priv->store, tzid);
4407
 
        }
 
4401
        ECalBackendCalDAV *cbdav;
 
4402
        ECalBackendCalDAVPrivate *priv;
 
4403
 
 
4404
        cbdav = E_CAL_BACKEND_CALDAV (backend);
 
4405
        priv  = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
 
4406
        zone = NULL;
 
4407
 
 
4408
        if (priv->store)
 
4409
                zone = (icaltimezone *) e_cal_backend_store_get_timezone (priv->store, tzid);
4408
4410
 
4409
4411
        if (!zone && E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone)
4410
4412
                zone = E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone (backend, tzid);
4411
4413
 
4412
 
        if (!zone) {
4413
 
                zone = icaltimezone_get_utc_timezone ();
4414
 
        }
4415
 
 
4416
4414
        return zone;
4417
4415
}
4418
4416
 
4601
4599
        sync_class->get_static_capabilities_sync = caldav_get_static_capabilities;
4602
4600
 
4603
4601
        sync_class->open_sync                    = caldav_do_open;
 
4602
        sync_class->refresh_sync                 = caldav_refresh;
4604
4603
        sync_class->remove_sync                  = caldav_remove;
4605
4604
 
4606
4605
        sync_class->create_object_sync = caldav_create_object;
4613
4612
        sync_class->get_default_object_sync   = caldav_get_default_object;
4614
4613
        sync_class->get_object_sync           = caldav_get_object;
4615
4614
        sync_class->get_object_list_sync      = caldav_get_object_list;
4616
 
        sync_class->get_timezone_sync         = caldav_get_timezone;
4617
4615
        sync_class->add_timezone_sync         = caldav_add_timezone;
4618
4616
        sync_class->set_default_zone_sync = caldav_set_default_zone;
4619
4617
        sync_class->get_freebusy_sync         = caldav_get_free_busy;