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

« back to all changes in this revision

Viewing changes to calendar/backends/http/e-cal-backend-http.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:
39
39
#include <libsoup/soup.h>
40
40
#include "e-cal-backend-http.h"
41
41
 
 
42
G_DEFINE_TYPE (ECalBackendHttp, e_cal_backend_http, E_TYPE_CAL_BACKEND_SYNC)
 
43
 
42
44
 
43
45
 
44
46
/* Private part of the ECalBackendHttp structure */
208
210
static ECalBackendSyncStatus
209
211
e_cal_backend_http_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities)
210
212
{
211
 
        *capabilities = g_strdup (CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS);
 
213
        *capabilities = g_strdup (
 
214
                CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS ","
 
215
                CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED
 
216
                );
212
217
 
213
218
        return GNOME_Evolution_Calendar_Success;
214
219
}
284
289
        icalcomponent *icalcomp, *subcomp;
285
290
        icalcomponent_kind kind;
286
291
        const gchar *newuri;
287
 
        SoupURI *uri_parsed;
 
292
        SoupURI *uri_parsed;
288
293
        GHashTable *old_cache;
289
294
        GSList *comps_in_cache;
290
295
 
688
693
}
689
694
 
690
695
static ECalBackendSyncStatus
 
696
e_cal_backend_http_refresh (ECalBackendSync *backend, EDataCal *cal)
 
697
{
 
698
        ECalBackendHttp *cbhttp;
 
699
        ECalBackendHttpPrivate *priv;
 
700
 
 
701
        cbhttp = E_CAL_BACKEND_HTTP (backend);
 
702
        priv = cbhttp->priv;
 
703
 
 
704
        if (!priv->opened ||
 
705
            priv->is_loading)
 
706
                return GNOME_Evolution_Calendar_Success;
 
707
 
 
708
        if (priv->reload_timeout_id)
 
709
                g_source_remove (priv->reload_timeout_id);
 
710
        priv->reload_timeout_id = 0;
 
711
 
 
712
        /* wait a second, then start reloading */
 
713
        priv->reload_timeout_id = g_timeout_add (1000, (GSourceFunc) reload_cb, cbhttp);
 
714
 
 
715
        return GNOME_Evolution_Calendar_Success;
 
716
}
 
717
 
 
718
static ECalBackendSyncStatus
691
719
e_cal_backend_http_remove (ECalBackendSync *backend, EDataCal *cal)
692
720
{
693
721
        ECalBackendHttp *cbhttp;
740
768
        ECalBackendHttpPrivate *priv;
741
769
        GNOME_Evolution_Calendar_CalMode set_mode;
742
770
        gboolean loaded;
 
771
 
743
772
        cbhttp = E_CAL_BACKEND_HTTP (backend);
744
773
        priv = cbhttp->priv;
745
774
 
746
775
        loaded = e_cal_backend_http_is_loaded (backend);
747
776
 
748
 
        switch (mode) {
749
 
                case CAL_MODE_LOCAL:
750
 
                        priv->mode = mode;
751
 
                        set_mode = cal_mode_to_corba (mode);
752
 
                        if (loaded && priv->reload_timeout_id) {
753
 
                                g_source_remove (priv->reload_timeout_id);
754
 
                                priv->reload_timeout_id = 0;
755
 
                        }
756
 
                        break;
757
 
                case CAL_MODE_REMOTE:
758
 
                case CAL_MODE_ANY:
759
 
                        priv->mode = mode;
760
 
                        set_mode = cal_mode_to_corba (mode);
761
 
                        if (loaded)
762
 
                                g_idle_add ((GSourceFunc) begin_retrieval_cb, backend);
763
 
                        break;
 
777
        if (priv->mode != mode) {
 
778
                switch (mode) {
 
779
                        case CAL_MODE_LOCAL:
 
780
                                priv->mode = mode;
 
781
                                set_mode = cal_mode_to_corba (mode);
 
782
                                if (loaded && priv->reload_timeout_id) {
 
783
                                        g_source_remove (priv->reload_timeout_id);
 
784
                                        priv->reload_timeout_id = 0;
 
785
                                }
 
786
                                break;
 
787
                        case CAL_MODE_REMOTE:
 
788
                        case CAL_MODE_ANY:
 
789
                                priv->mode = mode;
 
790
                                set_mode = cal_mode_to_corba (mode);
 
791
                                if (loaded)
 
792
                                        g_idle_add ((GSourceFunc) begin_retrieval_cb, backend);
 
793
                                break;
764
794
 
765
 
                        priv->mode = CAL_MODE_REMOTE;
766
 
                        set_mode = GNOME_Evolution_Calendar_MODE_REMOTE;
767
 
                        break;
768
 
                default:
769
 
                        set_mode = GNOME_Evolution_Calendar_MODE_ANY;
770
 
                        break;
 
795
                                priv->mode = CAL_MODE_REMOTE;
 
796
                                set_mode = GNOME_Evolution_Calendar_MODE_REMOTE;
 
797
                                break;
 
798
                        default:
 
799
                                set_mode = GNOME_Evolution_Calendar_MODE_ANY;
 
800
                                break;
 
801
                }
 
802
        } else {
 
803
                set_mode = cal_mode_to_corba (priv->mode);
771
804
        }
772
805
 
773
806
        if (loaded) {
828
861
        return GNOME_Evolution_Calendar_Success;
829
862
}
830
863
 
831
 
/* Get_timezone_object handler for the file backend */
832
 
static ECalBackendSyncStatus
833
 
e_cal_backend_http_get_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object)
834
 
{
835
 
        ECalBackendHttp *cbhttp;
836
 
        ECalBackendHttpPrivate *priv;
837
 
        const icaltimezone *zone;
838
 
        icalcomponent *icalcomp;
839
 
 
840
 
        cbhttp = E_CAL_BACKEND_HTTP (backend);
841
 
        priv = cbhttp->priv;
842
 
 
843
 
        g_return_val_if_fail (tzid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
844
 
 
845
 
        /* first try to get the timezone from the cache */
846
 
        zone = e_cal_backend_store_get_timezone (priv->store, tzid);
847
 
        if (!zone) {
848
 
                zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
849
 
                if (!zone)
850
 
                        return GNOME_Evolution_Calendar_ObjectNotFound;
851
 
        }
852
 
 
853
 
        icalcomp = icaltimezone_get_component ((icaltimezone *)zone);
854
 
        if (!icalcomp)
855
 
                return GNOME_Evolution_Calendar_InvalidObject;
856
 
 
857
 
        *object = icalcomponent_as_ical_string_r (icalcomp);
858
 
 
859
 
        return GNOME_Evolution_Calendar_Success;
860
 
}
861
 
 
862
864
/* Add_timezone handler for the file backend */
863
865
static ECalBackendSyncStatus
864
866
e_cal_backend_http_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
1256
1258
e_cal_backend_http_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj)
1257
1259
{
1258
1260
        ECalBackendHttp *cbhttp;
1259
 
        ECalBackendHttpPrivate *priv;
1260
1261
 
1261
1262
        cbhttp = E_CAL_BACKEND_HTTP (backend);
1262
 
        priv = cbhttp->priv;
1263
1263
 
1264
1264
        g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_InvalidObject);
1265
1265
 
1307
1307
        cbhttp = E_CAL_BACKEND_HTTP (backend);
1308
1308
        priv = cbhttp->priv;
1309
1309
 
 
1310
        g_return_val_if_fail (tzid != NULL, NULL);
 
1311
 
1310
1312
        if (!strcmp (tzid, "UTC"))
1311
1313
                zone = icaltimezone_get_utc_timezone ();
1312
1314
        else {
1313
 
                zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
 
1315
                /* first try to get the timezone from the cache */
 
1316
                zone = (icaltimezone *) e_cal_backend_store_get_timezone (priv->store, tzid);
1314
1317
 
1315
1318
                if (!zone && E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone)
1316
1319
                        zone = E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone (backend, tzid);
1321
1324
 
1322
1325
/* Object initialization function for the file backend */
1323
1326
static void
1324
 
e_cal_backend_http_init (ECalBackendHttp *cbhttp, ECalBackendHttpClass *class)
 
1327
e_cal_backend_http_init (ECalBackendHttp *cbhttp)
1325
1328
{
1326
1329
        ECalBackendHttpPrivate *priv;
1327
1330
 
1358
1361
        sync_class->get_ldap_attribute_sync = e_cal_backend_http_get_ldap_attribute;
1359
1362
        sync_class->get_static_capabilities_sync = e_cal_backend_http_get_static_capabilities;
1360
1363
        sync_class->open_sync = e_cal_backend_http_open;
 
1364
        sync_class->refresh_sync = e_cal_backend_http_refresh;
1361
1365
        sync_class->remove_sync = e_cal_backend_http_remove;
1362
1366
        sync_class->create_object_sync = e_cal_backend_http_create_object;
1363
1367
        sync_class->modify_object_sync = e_cal_backend_http_modify_object;
1368
1372
        sync_class->get_default_object_sync = e_cal_backend_http_get_default_object;
1369
1373
        sync_class->get_object_sync = e_cal_backend_http_get_object;
1370
1374
        sync_class->get_object_list_sync = e_cal_backend_http_get_object_list;
1371
 
        sync_class->get_timezone_sync = e_cal_backend_http_get_timezone;
1372
1375
        sync_class->add_timezone_sync = e_cal_backend_http_add_timezone;
1373
1376
        sync_class->set_default_zone_sync = e_cal_backend_http_set_default_zone;
1374
1377
        sync_class->get_freebusy_sync = e_cal_backend_http_get_free_busy;
1382
1385
        backend_class->internal_get_default_timezone = e_cal_backend_http_internal_get_default_timezone;
1383
1386
        backend_class->internal_get_timezone = e_cal_backend_http_internal_get_timezone;
1384
1387
}
1385
 
 
1386
 
/**
1387
 
 * e_cal_backend_http_get_type:
1388
 
 * @void:
1389
 
 *
1390
 
 * Registers the #ECalBackendHttp class if necessary, and returns the type ID
1391
 
 * associated to it.
1392
 
 *
1393
 
 * Return value: The type ID of the #ECalBackendHttp class.
1394
 
 **/
1395
 
GType
1396
 
e_cal_backend_http_get_type (void)
1397
 
{
1398
 
        static GType e_cal_backend_http_type = 0;
1399
 
 
1400
 
        if (!e_cal_backend_http_type) {
1401
 
                static GTypeInfo info = {
1402
 
                        sizeof (ECalBackendHttpClass),
1403
 
                        (GBaseInitFunc) NULL,
1404
 
                        (GBaseFinalizeFunc) NULL,
1405
 
                        (GClassInitFunc) e_cal_backend_http_class_init,
1406
 
                        NULL, NULL,
1407
 
                        sizeof (ECalBackendHttp),
1408
 
                        0,
1409
 
                        (GInstanceInitFunc) e_cal_backend_http_init
1410
 
                };
1411
 
                e_cal_backend_http_type = g_type_register_static (E_TYPE_CAL_BACKEND_SYNC,
1412
 
                                                                  "ECalBackendHttp", &info, 0);
1413
 
        }
1414
 
 
1415
 
        return e_cal_backend_http_type;
1416
 
}