aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/conduits
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/conduits')
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c168
-rw-r--r--calendar/conduits/todo/todo-conduit.c77
2 files changed, 121 insertions, 124 deletions
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index 5358605826..4cb47e49ea 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -23,6 +23,8 @@
#include <config.h>
+#include <bonobo.h>
+#include <bonobo-conf/bonobo-config-database.h>
#include <cal-client/cal-client-types.h>
#include <cal-client/cal-client.h>
#include <cal-util/timeutil.h>
@@ -37,7 +39,6 @@
#include <e-pilot-map.h>
#include <e-pilot-settings.h>
#include <e-pilot-util.h>
-#include <e-config-listener.h>
GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
@@ -85,7 +86,7 @@ struct _ECalLocalRecord {
static void
calconduit_destroy_record (ECalLocalRecord *local)
{
- g_object_unref (local->comp);
+ gtk_object_unref (GTK_OBJECT (local->comp));
free_Appointment (local->appt);
g_free (local->appt);
g_free (local);
@@ -118,11 +119,7 @@ calconduit_load_configuration (guint32 pilot_id)
/* Sync Type */
management = gnome_pilot_conduit_management_new ("e_calendar_conduit", GNOME_PILOT_CONDUIT_MGMT_ID);
- gtk_object_ref (GTK_OBJECT (management));
- gtk_object_sink (GTK_OBJECT (management));
config = gnome_pilot_conduit_config_new (management, pilot_id);
- gtk_object_ref (GTK_OBJECT (config));
- gtk_object_sink (GTK_OBJECT (config));
if (!gnome_pilot_conduit_config_is_enabled (config, &c->sync_type))
c->sync_type = GnomePilotConduitSyncTypeNotSet;
gtk_object_unref (GTK_OBJECT (config));
@@ -310,9 +307,9 @@ e_calendar_context_destroy (ECalConduitContext *ctxt)
e_cal_gui_destroy (ctxt->gui);
if (ctxt->client != NULL)
- g_object_unref (ctxt->client);
- if (ctxt->default_comp != NULL)
- g_object_unref (ctxt->default_comp);
+ gtk_object_unref (GTK_OBJECT (ctxt->client));
+ if (ctxt->default_comp != NULL)
+ gtk_object_unref (GTK_OBJECT (ctxt->default_comp));
if (ctxt->uids != NULL)
cal_obj_uid_list_free (ctxt->uids);
@@ -412,8 +409,8 @@ start_calendar_server (ECalConduitContext *ctxt)
ctxt->client = cal_client_new ();
- g_signal_connect (ctxt->client, "cal_opened",
- G_CALLBACK (start_calendar_server_cb), &success);
+ gtk_signal_connect (GTK_OBJECT (ctxt->client), "cal_opened",
+ start_calendar_server_cb, &success);
if (!cal_client_open_default_calendar (ctxt->client, FALSE))
return -1;
@@ -444,14 +441,24 @@ get_timezone (CalClient *client, const char *tzid)
static icaltimezone *
get_default_timezone (void)
{
- EConfigListener *listener;
+ Bonobo_ConfigDatabase db;
icaltimezone *timezone = NULL;
char *location;
+ CORBA_Environment ev;
- listener = e_config_listener_new ();
+ CORBA_exception_init (&ev);
+
+ db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
+
+ if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+
+ CORBA_exception_free (&ev);
- location = e_config_listener_get_string_with_default (listener,
- "/apps/evolution/calendar/display/timezone", "UTC", NULL);
+ location = bonobo_config_get_string_with_default (db,
+ "/Calendar/Display/Timezone", "UTC", NULL);
if (!location || !location[0]) {
g_free (location);
location = g_strdup ("UTC");
@@ -460,7 +467,7 @@ get_default_timezone (void)
timezone = icaltimezone_get_builtin_timezone (location);
g_free (location);
- g_object_unref (listener);
+ bonobo_object_release_unref (db, NULL);
return timezone;
}
@@ -701,33 +708,6 @@ compute_status (ECalConduitContext *ctxt, ECalLocalRecord *local, const char *ui
}
}
-static gboolean
-rrules_mostly_equal (struct icalrecurrencetype *a, struct icalrecurrencetype *b)
-{
- struct icalrecurrencetype acopy, bcopy;
-
- acopy = *a;
- bcopy = *b;
-
- acopy.until = bcopy.until = icaltime_null_time ();
- acopy.count = bcopy.count = 0;
-
- if (!memcmp (&acopy, &bcopy, sizeof (struct icalrecurrencetype)))
- return TRUE;
-
- return FALSE;
-}
-
-static gboolean
-find_last_cb (CalComponent *comp, time_t start, time_t end, gpointer data)
-{
- time_t *last = data;
-
- *last = start;
-
- return TRUE;
-}
-
static GnomePilotRecord
local_record_to_pilot_record (ECalLocalRecord *local,
ECalConduitContext *ctxt)
@@ -770,7 +750,7 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC
g_return_if_fail (comp != NULL);
local->comp = comp;
- g_object_ref (comp);
+ gtk_object_ref (GTK_OBJECT (comp));
cal_component_get_uid (local->comp, &uid);
local->local.ID = e_pilot_map_lookup_pid (ctxt->map, uid, TRUE);
@@ -906,24 +886,14 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC
local->appt->repeatFrequency = recur->interval;
}
- if (!icaltime_is_null_time (recur->until)) {
- local->appt->repeatForever = 0;
- local->appt->repeatEnd = icaltimetype_to_tm_with_zone (&recur->until,
- icaltimezone_get_utc_timezone (),
- default_tz);
- } else if (recur->count > 0) {
- time_t last = -1;
- struct icaltimetype itt;
-
- /* The palm does not support count recurrences */
- local->appt->repeatForever = 0;
- cal_recur_generate_instances (comp, -1, -1, find_last_cb, &last,
- cal_client_resolve_tzid_cb, ctxt->client,
- default_tz);
- itt = icaltime_from_timet_with_zone (last, TRUE, default_tz);
- local->appt->repeatEnd = icaltimetype_to_tm (&itt);
- } else {
+ if (icaltime_is_null_time (recur->until)) {
local->appt->repeatForever = 1;
+ } else {
+ local->appt->repeatForever = 0;
+ icaltimezone_convert_time (&recur->until,
+ icaltimezone_get_utc_timezone (),
+ default_tz);
+ local->appt->repeatEnd = icaltimetype_to_tm (&recur->until);
}
cal_component_free_recur_list (list);
@@ -1016,13 +986,13 @@ local_record_from_uid (ECalLocalRecord *local,
if (status == CAL_CLIENT_GET_SUCCESS) {
local_record_from_comp (local, comp, ctxt);
- g_object_unref (comp);
+ gtk_object_unref (GTK_OBJECT (comp));
} else if (status == CAL_CLIENT_GET_NOT_FOUND) {
comp = cal_component_new ();
cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT);
cal_component_set_uid (comp, uid);
local_record_from_comp (local, comp, ctxt);
- g_object_unref (comp);
+ gtk_object_unref (GTK_OBJECT (comp));
} else {
INFO ("Object did not exist");
}
@@ -1032,7 +1002,6 @@ static CalComponent *
comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
GnomePilotRecord *remote,
CalComponent *in_comp,
- CalClient *client,
icaltimezone *timezone)
{
CalComponent *comp;
@@ -1153,47 +1122,17 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
}
if (recur.freq != ICAL_NO_RECURRENCE) {
- GSList *list = NULL, *existing;
- struct icalrecurrencetype *erecur;
+ GSList *list = NULL;
/* recurrence start of week */
recur.week_start = get_ical_day (appt.repeatWeekstart);
if (!appt.repeatForever) {
- recur.until = tm_to_icaltimetype (&appt.repeatEnd, TRUE);
+ recur.until = tm_to_icaltimetype (&appt.repeatEnd, TRUE);
}
list = g_slist_append (list, &recur);
cal_component_set_rrule_list (comp, list);
-
- /* If the desktop uses count and rrules are
- * equivalent, use count still on the desktop */
- if (!appt.repeatForever && cal_component_has_rrules (in_comp)) {
- cal_component_get_rrule_list (in_comp, &existing);
- erecur = existing->data;
-
- /* If the rules are otherwise the same and the existing uses count,
- see if they end at the same point */
- if (rrules_mostly_equal (&recur, erecur) &&
- icaltime_is_null_time (erecur->until) && erecur->count > 0) {
- time_t last, elast;
-
- cal_recur_generate_instances (comp, -1, -1, find_last_cb, &last,
- cal_client_resolve_tzid_cb, client,
- timezone);
- cal_recur_generate_instances (in_comp, -1, -1, find_last_cb, &elast,
- cal_client_resolve_tzid_cb, client,
- timezone);
-
-
- if (last == elast) {
- recur.until = icaltime_null_time ();
- recur.count = erecur->count;
- cal_component_set_rrule_list (comp, list);
- }
- }
- }
-
g_slist_free (list);
} else {
cal_component_set_rrule_list (comp, NULL);
@@ -1264,7 +1203,7 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
cal_component_set_transparency (comp, CAL_COMPONENT_TRANSP_NONE);
- if (remote->secret)
+ if (remote->attr & dlpRecAttrSecret)
cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PRIVATE);
else
cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PUBLIC);
@@ -1396,7 +1335,7 @@ pre_sync (GnomePilotConduit *conduit,
cal_component_get_uid (ccc->comp, &uid);
if (e_pilot_map_lookup_pid (ctxt->map, uid, FALSE) == 0) {
ctxt->changed = g_list_remove (ctxt->changed, ccc);
- g_object_unref (ccc->comp);
+ gtk_object_unref (GTK_OBJECT (ccc->comp));
g_free (ccc);
}
}
@@ -1662,7 +1601,7 @@ add_record (GnomePilotConduitSyncAbs *conduit,
LOG ("add_record: adding %s to desktop\n", print_remote (remote));
- comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->client, ctxt->timezone);
+ comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->timezone);
/* Give it a new UID otherwise it will be the uid of the default comp */
uid = cal_component_gen_uid ();
@@ -1673,7 +1612,7 @@ add_record (GnomePilotConduitSyncAbs *conduit,
g_free (uid);
- g_object_unref (comp);
+ gtk_object_unref (GTK_OBJECT (comp));
return retval;
}
@@ -1692,8 +1631,8 @@ replace_record (GnomePilotConduitSyncAbs *conduit,
LOG ("replace_record: replace %s with %s\n",
print_local (local), print_remote (remote));
- new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->client, ctxt->timezone);
- g_object_unref (local->comp);
+ new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->timezone);
+ gtk_object_unref (GTK_OBJECT (local->comp));
local->comp = new_comp;
update_comp (conduit, local->comp, ctxt);
@@ -1851,6 +1790,16 @@ revert_settings (GnomePilotConduit *conduit, ECalConduitContext *ctxt)
ctxt->new_cfg = calconduit_dupe_configuration (ctxt->cfg);
}
+static ORBit_MessageValidationResult
+accept_all_cookies (CORBA_unsigned_long request_id,
+ CORBA_Principal *principal,
+ CORBA_char *operation)
+{
+ /* allow ALL cookies */
+ return ORBIT_MESSAGE_ALLOW_ALL;
+}
+
+
GnomePilotConduit *
conduit_get_gpilot_conduit (guint32 pilot_id)
{
@@ -1859,6 +1808,21 @@ conduit_get_gpilot_conduit (guint32 pilot_id)
LOG ("in calendar's conduit_get_gpilot_conduit\n");
+ /* we need to find wombat with oaf, so make sure oaf
+ is initialized here. once the desktop is converted
+ to oaf and gpilotd is built with oaf, this can go away */
+ if (!oaf_is_initialized ()) {
+ char *argv[ 1 ] = {"hi"};
+ oaf_init (1, argv);
+
+ if (bonobo_init (CORBA_OBJECT_NIL,
+ CORBA_OBJECT_NIL,
+ CORBA_OBJECT_NIL) == FALSE)
+ g_error (_("Could not initialize Bonobo"));
+
+ ORBit_set_request_validation_handler (accept_all_cookies);
+ }
+
retval = gnome_pilot_conduit_sync_abs_new ("DatebookDB", 0x64617465);
g_assert (retval != NULL);
diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c
index a07ed35706..7f834921ca 100644
--- a/calendar/conduits/todo/todo-conduit.c
+++ b/calendar/conduits/todo/todo-conduit.c
@@ -23,6 +23,9 @@
#include <config.h>
+#include <liboaf/liboaf.h>
+#include <bonobo.h>
+#include <bonobo-conf/bonobo-config-database.h>
#include <cal-client/cal-client-types.h>
#include <cal-client/cal-client.h>
#include <cal-util/timeutil.h>
@@ -38,7 +41,6 @@
#include <e-pilot-map.h>
#include <e-pilot-settings.h>
#include <e-pilot-util.h>
-#include <e-config-listener.h>
GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
@@ -84,7 +86,7 @@ struct _EToDoLocalRecord {
static void
todoconduit_destroy_record (EToDoLocalRecord *local)
{
- g_object_unref (local->comp);
+ gtk_object_unref (GTK_OBJECT (local->comp));
free_ToDo (local->todo);
g_free (local->todo);
g_free (local);
@@ -117,11 +119,7 @@ todoconduit_load_configuration (guint32 pilot_id)
c->pilot_id = pilot_id;
management = gnome_pilot_conduit_management_new ("e_todo_conduit", GNOME_PILOT_CONDUIT_MGMT_ID);
- gtk_object_ref (GTK_OBJECT (management));
- gtk_object_sink (GTK_OBJECT (management));
config = gnome_pilot_conduit_config_new (management, pilot_id);
- gtk_object_ref (GTK_OBJECT (config));
- gtk_object_sink (GTK_OBJECT (config));
if (!gnome_pilot_conduit_config_is_enabled (config, &c->sync_type))
c->sync_type = GnomePilotConduitSyncTypeNotSet;
gtk_object_unref (GTK_OBJECT (config));
@@ -309,10 +307,10 @@ e_todo_context_destroy (EToDoConduitContext *ctxt)
e_todo_gui_destroy (ctxt->gui);
if (ctxt->client != NULL)
- g_object_unref (ctxt->client);
+ gtk_object_unref (GTK_OBJECT (ctxt->client));
if (ctxt->default_comp != NULL)
- g_object_unref (ctxt->default_comp);
+ gtk_object_unref (GTK_OBJECT (ctxt->default_comp));
if (ctxt->uids != NULL)
cal_obj_uid_list_free (ctxt->uids);
@@ -419,8 +417,8 @@ start_calendar_server (EToDoConduitContext *ctxt)
ctxt->client = cal_client_new ();
- g_signal_connect (ctxt->client, "cal_opened",
- G_CALLBACK (start_calendar_server_cb), &success);
+ gtk_signal_connect (GTK_OBJECT (ctxt->client), "cal_opened",
+ start_calendar_server_cb, &success);
if (!cal_client_open_default_tasks (ctxt->client, FALSE))
return -1;
@@ -451,14 +449,24 @@ get_timezone (CalClient *client, const char *tzid)
static icaltimezone *
get_default_timezone (void)
{
- EConfigListener *listener;
+ Bonobo_ConfigDatabase db;
icaltimezone *timezone = NULL;
char *location;
+ CORBA_Environment ev;
- listener = e_config_listener_new ();
+ CORBA_exception_init (&ev);
+
+ db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
+
+ if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+
+ CORBA_exception_free (&ev);
- location = e_config_listener_get_string_with_default (listener,
- "/apps/evolution/calendar/display/timezone", "UTC", NULL);
+ location = bonobo_config_get_string_with_default (db,
+ "/Calendar/Display/Timezone", "UTC", NULL);
if (!location || !location[0]) {
g_free (location);
location = g_strdup ("UTC");
@@ -467,7 +475,7 @@ get_default_timezone (void)
timezone = icaltimezone_get_builtin_timezone (location);
g_free (location);
- g_object_unref (listener);
+ bonobo_object_release_unref (db, NULL);
return timezone;
}
@@ -586,7 +594,7 @@ local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoCondui
g_return_if_fail (comp != NULL);
local->comp = comp;
- g_object_ref (comp);
+ gtk_object_ref (GTK_OBJECT (comp));
cal_component_get_uid (local->comp, &uid);
local->local.ID = e_pilot_map_lookup_pid (ctxt->map, uid, TRUE);
@@ -685,13 +693,13 @@ local_record_from_uid (EToDoLocalRecord *local,
if (status == CAL_CLIENT_GET_SUCCESS) {
local_record_from_comp (local, comp, ctxt);
- g_object_unref (comp);
+ gtk_object_unref (GTK_OBJECT (comp));
} else if (status == CAL_CLIENT_GET_NOT_FOUND) {
comp = cal_component_new ();
cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO);
cal_component_set_uid (comp, uid);
local_record_from_comp (local, comp, ctxt);
- g_object_unref (comp);
+ gtk_object_unref (GTK_OBJECT (comp));
} else {
INFO ("Object did not exist");
}
@@ -780,7 +788,7 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
}
if (!is_empty_time (todo.due)) {
- due = tm_to_icaltimetype (&todo.due, TRUE);
+ due = tm_to_icaltimetype (&todo.due, FALSE);
dt.value = &due;
cal_component_set_due (comp, &dt);
}
@@ -805,7 +813,7 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
cal_component_set_priority (comp, &priority);
cal_component_set_transparency (comp, CAL_COMPONENT_TRANSP_NONE);
- if (remote->secret)
+ if (remote->attr & dlpRecAttrSecret)
cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PRIVATE);
else
cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PUBLIC);
@@ -1185,7 +1193,7 @@ add_record (GnomePilotConduitSyncAbs *conduit,
update_comp (conduit, comp, ctxt);
e_pilot_map_insert (ctxt->map, remote->ID, uid, FALSE);
- g_object_unref (comp);
+ gtk_object_unref (GTK_OBJECT (comp));
return retval;
}
@@ -1205,7 +1213,7 @@ replace_record (GnomePilotConduitSyncAbs *conduit,
print_local (local), print_remote (remote));
new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->timezone);
- g_object_unref (local->comp);
+ gtk_object_unref (GTK_OBJECT (local->comp));
local->comp = new_comp;
update_comp (conduit, local->comp, ctxt);
@@ -1362,6 +1370,16 @@ revert_settings (GnomePilotConduit *conduit, EToDoConduitContext *ctxt)
ctxt->new_cfg = todoconduit_dupe_configuration (ctxt->cfg);
}
+static ORBit_MessageValidationResult
+accept_all_cookies (CORBA_unsigned_long request_id,
+ CORBA_Principal *principal,
+ CORBA_char *operation)
+{
+ /* allow ALL cookies */
+ return ORBIT_MESSAGE_ALLOW_ALL;
+}
+
+
GnomePilotConduit *
conduit_get_gpilot_conduit (guint32 pilot_id)
{
@@ -1370,6 +1388,21 @@ conduit_get_gpilot_conduit (guint32 pilot_id)
LOG ("in todo's conduit_get_gpilot_conduit\n");
+ /* we need to find wombat with oaf, so make sure oaf
+ is initialized here. once the desktop is converted
+ to oaf and gpilotd is built with oaf, this can go away */
+ if (!oaf_is_initialized ()) {
+ char *argv[ 1 ] = {"hi"};
+ oaf_init (1, argv);
+
+ if (bonobo_init (CORBA_OBJECT_NIL,
+ CORBA_OBJECT_NIL,
+ CORBA_OBJECT_NIL) == FALSE)
+ g_error (_("Could not initialize Bonobo"));
+
+ ORBit_set_request_validation_handler (accept_all_cookies);
+ }
+
retval = gnome_pilot_conduit_sync_abs_new ("ToDoDB", 0x746F646F);
g_assert (retval != NULL);