aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/conduits/calendar/calendar-conduit.c
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/conduits/calendar/calendar-conduit.c')
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c328
1 files changed, 74 insertions, 254 deletions
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index f86e753232..a320e9bb8d 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -23,6 +23,7 @@
#include <config.h>
+#include <liboaf/liboaf.h>
#include <bonobo.h>
#include <bonobo-conf/bonobo-config-database.h>
#include <cal-client/cal-client-types.h>
@@ -30,16 +31,22 @@
#include <cal-util/timeutil.h>
#include <pi-source.h>
#include <pi-socket.h>
+#include <pi-file.h>
#include <pi-dlp.h>
-#include <pi-datebook.h>
-#include <gpilotd/gnome-pilot-conduit.h>
-#include <gpilotd/gnome-pilot-conduit-sync-abs.h>
-#include <libgpilotdCM/gnome-pilot-conduit-management.h>
-#include <libgpilotdCM/gnome-pilot-conduit-config.h>
-#include <e-pilot-map.h>
-#include <e-pilot-settings.h>
+#include <libical/src/libical/icaltypes.h>
#include <e-pilot-util.h>
+#define CAL_CONFIG_LOAD 1
+#define CAL_CONFIG_SAVE 1
+#define CAL_CONFIG_DESTROY 1
+#include <calendar-conduit-config.h>
+#undef CAL_CONFIG_LOAD
+#undef CAL_CONFIG_SAVE
+#undef CAL_CONFIG_DESTROY
+
+#include <calendar-conduit.h>
+
+static void free_local (ECalLocalRecord *local);
GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
@@ -63,157 +70,69 @@ void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
#define PILOT_MAX_ADVANCE 99
-typedef struct _ECalLocalRecord ECalLocalRecord;
-typedef struct _ECalConduitCfg ECalConduitCfg;
-typedef struct _ECalConduitContext ECalConduitContext;
-
-/* Local Record */
-struct _ECalLocalRecord {
- /* The stuff from gnome-pilot-conduit-standard-abs.h
- Must be first in the structure, or instances of this
- structure cannot be used by gnome-pilot-conduit-standard-abs.
- */
- GnomePilotDesktopRecord local;
-
- /* The corresponding Comp object */
- CalComponent *comp;
-
- /* pilot-link appointment structure */
- struct Appointment *appt;
-};
-
-static void
-calconduit_destroy_record (ECalLocalRecord *local)
-{
- gtk_object_unref (GTK_OBJECT (local->comp));
- free_Appointment (local->appt);
- g_free (local->appt);
- g_free (local);
-}
-
-/* Configuration */
-struct _ECalConduitCfg {
- guint32 pilot_id;
- GnomePilotConduitSyncType sync_type;
-
- gboolean secret;
- gchar *last_uri;
-};
-
-static ECalConduitCfg *
-calconduit_load_configuration (guint32 pilot_id)
+/* Debug routines */
+static char *
+print_local (ECalLocalRecord *local)
{
- ECalConduitCfg *c;
- GnomePilotConduitManagement *management;
- GnomePilotConduitConfig *config;
- gchar prefix[256];
-
- c = g_new0 (ECalConduitCfg, 1);
- g_assert (c != NULL);
-
- /* Pilot ID */
- c->pilot_id = pilot_id;
-
- /* Sync Type */
- management = gnome_pilot_conduit_management_new ("e_calendar_conduit", GNOME_PILOT_CONDUIT_MGMT_ID);
- config = gnome_pilot_conduit_config_new (management, pilot_id);
- if (!gnome_pilot_conduit_config_is_enabled (config, &c->sync_type))
- c->sync_type = GnomePilotConduitSyncTypeNotSet;
- gtk_object_unref (GTK_OBJECT (config));
- gtk_object_unref (GTK_OBJECT (management));
-
- /* Custom settings */
- g_snprintf (prefix, 255, "/gnome-pilot.d/e-calendar-conduit/Pilot_%u/", pilot_id);
- gnome_config_push_prefix (prefix);
+ static char buff[ 4096 ];
- c->secret = gnome_config_get_bool ("secret=FALSE");
- c->last_uri = gnome_config_get_string ("last_uri");
+ if (local == NULL) {
+ sprintf (buff, "[NULL]");
+ return buff;
+ }
- gnome_config_pop_prefix ();
+ if (local->appt && local->appt->description) {
+ g_snprintf (buff, 4096, "[%ld %ld '%s' '%s']",
+ mktime (&local->appt->begin),
+ mktime (&local->appt->end),
+ local->appt->description ?
+ local->appt->description : "",
+ local->appt->note ?
+ local->appt->note : "");
+ return buff;
+ }
- return c;
+ return "";
}
-static void
-calconduit_save_configuration (ECalConduitCfg *c)
+static char *print_remote (GnomePilotRecord *remote)
{
- gchar prefix[256];
-
- g_snprintf (prefix, 255, "/gnome-pilot.d/e-calendar-conduit/Pilot_%u/", c->pilot_id);
- gnome_config_push_prefix (prefix);
-
- gnome_config_set_bool ("secret", c->secret);
- gnome_config_set_string ("last_uri", c->last_uri);
-
- gnome_config_pop_prefix ();
-
- gnome_config_sync ();
- gnome_config_drop_all ();
-}
+ static char buff[ 4096 ];
+ struct Appointment appt;
-static ECalConduitCfg*
-calconduit_dupe_configuration (ECalConduitCfg *c)
-{
- ECalConduitCfg *retval;
+ if (remote == NULL) {
+ sprintf (buff, "[NULL]");
+ return buff;
+ }
- g_return_val_if_fail (c != NULL, NULL);
+ memset (&appt, 0, sizeof (struct Appointment));
+ unpack_Appointment (&appt, remote->record, remote->length);
- retval = g_new0 (ECalConduitCfg, 1);
- retval->pilot_id = c->pilot_id;
- retval->sync_type = c->sync_type;
- retval->secret = c->secret;
- retval->last_uri = g_strdup (c->last_uri);
-
- return retval;
-}
+ g_snprintf (buff, 4096, "[%ld %ld '%s' '%s']",
+ mktime (&appt.begin),
+ mktime (&appt.end),
+ appt.description ?
+ appt.description : "",
+ appt.note ?
+ appt.note : "");
-static void
-calconduit_destroy_configuration (ECalConduitCfg *c)
-{
- g_return_if_fail (c != NULL);
+ free_Appointment (&appt);
- g_free (c->last_uri);
- g_free (c);
+ return buff;
}
-/* Context */
-struct _ECalConduitContext {
- ECalConduitCfg *cfg;
- GnomePilotDBInfo *dbi;
-
- ECalConduitCfg *new_cfg;
- GtkWidget *ps;
-
- struct AppointmentAppInfo ai;
-
- CalClient *client;
-
- icaltimezone *timezone;
- GList *uids;
- GList *changed;
- GHashTable *changed_hash;
- GList *locals;
-
- EPilotMap *map;
-};
-
+/* Context Routines */
static ECalConduitContext *
e_calendar_context_new (guint32 pilot_id)
{
- ECalConduitContext *ctxt;
+ ECalConduitContext *ctxt = g_new0 (ECalConduitContext, 1);
+
+ calconduit_load_configuration (&ctxt->cfg, pilot_id);
- ctxt = g_new0 (ECalConduitContext, 1);
- g_assert (ctxt != NULL);
-
- ctxt->cfg = calconduit_load_configuration (pilot_id);
- ctxt->new_cfg = calconduit_dupe_configuration (ctxt->cfg);
- ctxt->ps = NULL;
- ctxt->dbi = NULL;
ctxt->client = NULL;
- ctxt->timezone = NULL;
ctxt->uids = NULL;
- ctxt->changed = NULL;
ctxt->changed_hash = NULL;
+ ctxt->changed = NULL;
ctxt->locals = NULL;
ctxt->map = NULL;
@@ -236,17 +155,14 @@ e_calendar_context_destroy (ECalConduitContext *ctxt)
g_return_if_fail (ctxt != NULL);
if (ctxt->cfg != NULL)
- calconduit_destroy_configuration (ctxt->cfg);
+ calconduit_destroy_configuration (&ctxt->cfg);
if (ctxt->client != NULL)
gtk_object_unref (GTK_OBJECT (ctxt->client));
-
+
if (ctxt->uids != NULL)
cal_obj_uid_list_free (ctxt->uids);
-
- if (ctxt->changed != NULL)
- cal_client_change_list_free (ctxt->changed);
-
+
if (ctxt->changed_hash != NULL) {
g_hash_table_foreach_remove (ctxt->changed_hash, e_calendar_context_foreach_change, NULL);
g_hash_table_destroy (ctxt->changed_hash);
@@ -254,63 +170,17 @@ e_calendar_context_destroy (ECalConduitContext *ctxt)
if (ctxt->locals != NULL) {
for (l = ctxt->locals; l != NULL; l = l->next)
- calconduit_destroy_record (l->data);
+ free_local (l->data);
g_list_free (ctxt->locals);
}
+
+ if (ctxt->changed != NULL)
+ cal_client_change_list_free (ctxt->changed);
if (ctxt->map != NULL)
e_pilot_map_destroy (ctxt->map);
-}
-
-/* Debug routines */
-static char *
-print_local (ECalLocalRecord *local)
-{
- static char buff[ 4096 ];
-
- if (local == NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
-
- if (local->appt && local->appt->description) {
- g_snprintf (buff, 4096, "[%ld %ld '%s' '%s']",
- mktime (&local->appt->begin),
- mktime (&local->appt->end),
- local->appt->description ?
- local->appt->description : "",
- local->appt->note ?
- local->appt->note : "");
- return buff;
- }
-
- return "";
-}
-
-static char *print_remote (GnomePilotRecord *remote)
-{
- static char buff[ 4096 ];
- struct Appointment appt;
-
- if (remote == NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
-
- memset (&appt, 0, sizeof (struct Appointment));
- unpack_Appointment (&appt, remote->record, remote->length);
-
- g_snprintf (buff, 4096, "[%ld %ld '%s' '%s']",
- mktime (&appt.begin),
- mktime (&appt.end),
- appt.description ?
- appt.description : "",
- appt.note ?
- appt.note : "");
-
- free_Appointment (&appt);
- return buff;
+ g_free (ctxt);
}
/* Calendar Server routines */
@@ -635,6 +505,15 @@ compute_status (ECalConduitContext *ctxt, ECalLocalRecord *local, const char *ui
}
}
+static void
+free_local (ECalLocalRecord *local)
+{
+ gtk_object_unref (GTK_OBJECT (local->comp));
+ free_Appointment (local->appt);
+ g_free (local->appt);
+ g_free (local);
+}
+
static GnomePilotRecord
local_record_to_pilot_record (ECalLocalRecord *local,
ECalConduitContext *ctxt)
@@ -1626,7 +1505,7 @@ free_match (GnomePilotConduitSyncAbs *conduit,
g_return_val_if_fail (local != NULL, -1);
- calconduit_destroy_record (local);
+ free_local (local);
return 0;
}
@@ -1644,58 +1523,6 @@ prepare (GnomePilotConduitSyncAbs *conduit,
return 0;
}
-/* Pilot Settings Callbacks */
-static void
-fill_widgets (ECalConduitContext *ctxt)
-{
- e_pilot_settings_set_secret (E_PILOT_SETTINGS (ctxt->ps),
- ctxt->cfg->secret);
-}
-
-static gint
-create_settings_window (GnomePilotConduit *conduit,
- GtkWidget *parent,
- ECalConduitContext *ctxt)
-{
- LOG ("create_settings_window");
-
- ctxt->ps = e_pilot_settings_new ();
- gtk_container_add (GTK_CONTAINER (parent), ctxt->ps);
- gtk_widget_show (ctxt->ps);
-
- fill_widgets (ctxt);
-
- return 0;
-}
-static void
-display_settings (GnomePilotConduit *conduit, ECalConduitContext *ctxt)
-{
- LOG ("display_settings");
-
- fill_widgets (ctxt);
-}
-
-static void
-save_settings (GnomePilotConduit *conduit, ECalConduitContext *ctxt)
-{
- LOG ("save_settings");
-
- ctxt->new_cfg->secret =
- e_pilot_settings_get_secret (E_PILOT_SETTINGS (ctxt->ps));
-
- calconduit_save_configuration (ctxt->new_cfg);
-}
-
-static void
-revert_settings (GnomePilotConduit *conduit, ECalConduitContext *ctxt)
-{
- LOG ("revert_settings");
-
- calconduit_save_configuration (ctxt->cfg);
- calconduit_destroy_configuration (ctxt->new_cfg);
- ctxt->new_cfg = calconduit_dupe_configuration (ctxt->cfg);
-}
-
static ORBit_MessageValidationResult
accept_all_cookies (CORBA_unsigned_long request_id,
CORBA_Principal *principal,
@@ -1735,7 +1562,6 @@ conduit_get_gpilot_conduit (guint32 pilot_id)
ctxt = e_calendar_context_new (pilot_id);
gtk_object_set_data (GTK_OBJECT (retval), "calconduit_context", ctxt);
- /* Sync signals */
gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, ctxt);
gtk_signal_connect (retval, "post_sync", (GtkSignalFunc) post_sync, ctxt);
@@ -1756,12 +1582,6 @@ conduit_get_gpilot_conduit (guint32 pilot_id)
gtk_signal_connect (retval, "prepare", (GtkSignalFunc) prepare, ctxt);
- /* Gui Settings */
- gtk_signal_connect (retval, "create_settings_window", (GtkSignalFunc) create_settings_window, ctxt);
- gtk_signal_connect (retval, "display_settings", (GtkSignalFunc) display_settings, ctxt);
- gtk_signal_connect (retval, "save_settings", (GtkSignalFunc) save_settings, ctxt);
- gtk_signal_connect (retval, "revert_settings", (GtkSignalFunc) revert_settings, ctxt);
-
return GNOME_PILOT_CONDUIT (retval);
}