aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeth Alves <alves@src.gnome.org>2000-07-11 06:54:56 +0800
committerSeth Alves <alves@src.gnome.org>2000-07-11 06:54:56 +0800
commit1cee3b488744c43c8d0ee9ba46a8b291d9f0e8e5 (patch)
tree9c02b94d6644aaeb46a3e3a1306670fbcd642ef3
parentcc36af075b8badaf3b13377fc16ba53f38017980 (diff)
downloadgsoc2013-evolution-1cee3b488744c43c8d0ee9ba46a8b291d9f0e8e5.tar.gz
gsoc2013-evolution-1cee3b488744c43c8d0ee9ba46a8b291d9f0e8e5.tar.zst
gsoc2013-evolution-1cee3b488744c43c8d0ee9ba46a8b291d9f0e8e5.zip
updated calendar conduit to use oaf and wombat
svn path=/trunk/; revision=4061
-rw-r--r--calendar/conduits/calendar/.cvsignore2
-rw-r--r--calendar/conduits/calendar/calendar-conduit-control-applet.c322
-rw-r--r--calendar/conduits/calendar/calendar-conduit-control-applet.desktop2
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c399
-rw-r--r--calendar/conduits/calendar/calendar-conduit.h23
-rw-r--r--calendar/conduits/calendar/calendar.conduit.in8
6 files changed, 417 insertions, 339 deletions
diff --git a/calendar/conduits/calendar/.cvsignore b/calendar/conduits/calendar/.cvsignore
index 0a6c584a7a..425e76ba76 100644
--- a/calendar/conduits/calendar/.cvsignore
+++ b/calendar/conduits/calendar/.cvsignore
@@ -2,3 +2,5 @@ Makefile.in
Makefile
.deps
calendar.conduit
+*.lo
+.libs
diff --git a/calendar/conduits/calendar/calendar-conduit-control-applet.c b/calendar/conduits/calendar/calendar-conduit-control-applet.c
index 2d6fb60ef5..861dec82c3 100644
--- a/calendar/conduits/calendar/calendar-conduit-control-applet.c
+++ b/calendar/conduits/calendar/calendar-conduit-control-applet.c
@@ -1,23 +1,41 @@
-/* Control applet ("capplet") for the gnome-pilot calendar conduit, */
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* Control applet ("capplet") for the gnome-pilot calendar conduit, */
/* based on */
/* gpilotd control applet ('capplet') for use with the GNOME control center */
-/* $Id$ */
#include <pwd.h>
#include <sys/types.h>
#include <signal.h>
#include <gnome.h>
-#include <ctype.h>
#include <config.h>
#include <capplet-widget.h>
-#include <gpilotd/gpilotd-conduit-mgmt.h>
-#include <gpilotd/gpilotd-app.h>
-#include <gpilotd/gpilotd-app-dummy-callbacks.h>
+#include <libgpilotdCM/gnome-pilot-conduit-management.h>
+#include <libgpilotdCM/gnome-pilot-conduit-config.h>
+#include <gpilotd/gnome-pilot-client.h>
#include "calendar-conduit.h"
+/*
+typedef struct ConduitCfg {
+ guint32 pilotId;
+ pid_t child;
+} ConduitCfg;
+
+typedef struct db {
+ char name[256];
+ int flags;
+ unsigned long creator;
+ unsigned long type;
+ int maxblock;
+} db;
+
+#define CONDUIT_CFG(s) ((ConduitCfg*)(s))
+*/
+
+
+
/* tell changes callbacks to ignore changes or not */
static gboolean ignore_changes=FALSE;
@@ -29,20 +47,24 @@ GtkWidget *cfgOptionsWindow=NULL;
GtkWidget *cfgStateWindow=NULL;
GtkWidget *dialogWindow=NULL;
-GnomePilotConduitMgmt *conduit;
-
-static void doTrySettings(GtkWidget *widget, gpointer);
-static void doRevertSettings(GtkWidget *widget, gpointer);
-static void doSaveSettings(GtkWidget *widget, gpointer);
-
-static void readStateCfg(GtkWidget *w,GCalConduitCfg *cfg);
-static void setStateCfg(GtkWidget *w,GCalConduitCfg *cfg);
-void about_cb (GtkWidget *, gpointer);
+gboolean activated,org_activation_state;
+GnomePilotConduitManagement *conduit;
+GnomePilotConduitConfig *conduit_config;
GCalConduitCfg *origState = NULL;
GCalConduitCfg *curState = NULL;
+static void doTrySettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg);
+static void doRevertSettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg);
+static void doSaveSettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg);
+
+//static void readStateCfg (GtkWidget *w, GCalConduitCfg *c);
+static void setStateCfg (GtkWidget *w, GCalConduitCfg *c);
+
gint pilotId;
CORBA_Environment ev;
+static GnomePilotClient *gpc;
+
+
/* This array must be in the same order as enumerations
in GnomePilotConduitSyncType as they are used as index.
@@ -56,104 +78,68 @@ static gchar* sync_options[] ={ N_("Disabled"),
N_("Merge To Pilot")};
#define SYNC_OPTIONS_COUNT 6
-static void
-setSettings(GCalConduitCfg* conduitCfg)
+
+static void
+doTrySettings(GtkWidget *widget, GCalConduitCfg *c)
{
- if(conduitCfg->sync_type!=GnomePilotConduitSyncTypeCustom)
- gpilotd_conduit_mgmt_enable_with_first_sync(conduit,pilotId,
- conduitCfg->sync_type,
- conduitCfg->sync_type,
- TRUE);
+ /*
+ readStateCfg (cfgStateWindow, curState);
+ if (activated)
+ gnome_pilot_conduit_config_enable (conduit_config, GnomePilotConduitSyncTypeCustom);
else
- gpilotd_conduit_mgmt_disable(conduit,pilotId);
+ gnome_pilot_conduit_config_disable (conduit_config);
+ */
+
+ if (c->sync_type!=GnomePilotConduitSyncTypeCustom)
+ gnome_pilot_conduit_config_enable_with_first_sync (conduit_config,
+ c->sync_type,
+ c->sync_type,
+ TRUE);
+ else
+ gnome_pilot_conduit_config_disable (conduit_config);
- gcalconduit_save_configuration(conduitCfg);
+ gcalconduit_save_configuration (c);
}
-static void
-doTrySettings(GtkWidget *widget, gpointer whatever)
-{
- readStateCfg(cfgStateWindow,curState);
- setSettings(curState);
-}
static void
-doSaveSettings(GtkWidget *widget, gpointer whatever)
+doSaveSettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg)
{
- doTrySettings(widget,whatever);
+ doTrySettings(widget, GCalConduitCfg);
+ gcalconduit_save_configuration(GCalConduitCfg);
}
-static void
-doCancelSettings(GtkWidget *widget, gpointer whatever)
-{
- setSettings(origState);
-}
static void
-doRevertSettings(GtkWidget *widget, gpointer whatever)
+doCancelSettings(GtkWidget *widget, GCalConduitCfg *c)
{
- gcalconduit_destroy_configuration(&curState);
- curState = gcalconduit_dupe_configuration(origState);
- setStateCfg(cfgStateWindow,curState);
- setSettings(curState);
+ doSaveSettings (widget, c);
}
+
static void
-insert_dir_callback (GtkEditable *editable, const gchar *text,
- gint len, gint *position, void *data)
-{
- gint i;
- gchar *curname;
-
- curname = gtk_entry_get_text(GTK_ENTRY(editable));
- if (*curname == '\0' && len > 0) {
- if (isspace(text[0])) {
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text");
- return;
- }
- } else {
- for (i=0; i<len; i++) {
- if (isspace(text[i])) {
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable),
- "insert_text");
- return;
- }
- }
- }
-}
-static void
-insert_dir_callback2(GtkEditable *editable, const gchar *text,
- gint length, gint *position,
- void *data)
+doRevertSettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg)
{
- if (!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
+ activated = org_activation_state;
+ setStateCfg (cfgStateWindow, curState);
}
-static void
-clist_changed(GtkWidget *widget, gpointer data)
+static void
+about_cb (GtkWidget *widget, gpointer data)
{
- if (!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-void about_cb (GtkWidget *widget, gpointer data) {
- GtkWidget *about;
- const gchar *authors[] = {_("Eskil Heyn Olsen <deity@eskil.dk>"),NULL};
+ GtkWidget *about;
+ const gchar *authors[] = {_("Eskil Heyn Olsen <deity@eskil.dk>"),NULL};
- about = gnome_about_new(_("GnomeCalendar Conduit"), VERSION,
- _("(C) 1998"),
- authors,
- _("Configuration utility for the calendar conduit.\n"),
- _("gnome-calendar-conduit.png"));
- gtk_widget_show (about);
+ about = gnome_about_new (_("Gpilotd calendar conduit"), VERSION,
+ _("(C) 1998 the Free Software Foundation"),
+ authors,
+ _("Configuration utility for the calendar conduit.\n"),
+ _("gnome-unknown.xpm"));
+ gtk_widget_show (about);
- return;
+ return;
}
-static void toggled_cb(GtkWidget *widget, gpointer data) {
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
/* called by the sync_type GtkOptionMenu */
static void
@@ -164,6 +150,7 @@ sync_action_selection(GtkMenuShell *widget, gpointer unused)
}
}
+
/* called by the sync_type GtkOptionMenu */
static void
activate_sync_type(GtkMenuItem *widget, gpointer data)
@@ -173,6 +160,7 @@ activate_sync_type(GtkMenuItem *widget, gpointer data)
capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
}
+
static GtkWidget
*createStateCfgWindow(void)
{
@@ -214,38 +202,38 @@ static GtkWidget
return vbox;
}
+
static void
-setStateCfg(GtkWidget *widget,GCalConduitCfg *cfg)
+setStateCfg (GtkWidget *w, GCalConduitCfg *c)
{
GtkOptionMenu *optionMenu;
GtkMenu *menu;
- optionMenu = gtk_object_get_data(GTK_OBJECT(widget), "conduit_state");
- g_assert(optionMenu!=NULL);
- menu = GTK_MENU(gtk_option_menu_get_menu(optionMenu));
-
+ optionMenu = gtk_object_get_data (GTK_OBJECT(w), "conduit_state");
+ g_assert (optionMenu != NULL);
+ menu = GTK_MENU (gtk_option_menu_get_menu (optionMenu));
ignore_changes = TRUE;
/* Here were are relying on the items in menu being the same
order as in GnomePilotConduitSyncType. */
- gtk_option_menu_set_history(optionMenu,(int)cfg->sync_type);
+ gtk_option_menu_set_history (optionMenu, (int) c->sync_type);
ignore_changes = FALSE;
}
+#if 0
static void
-readStateCfg(GtkWidget *w,GCalConduitCfg *cfg)
+readStateCfg (GtkWidget *w, GCalConduitCfg *c)
{
-/*
- GtkWidget *button;
-
- button = gtk_object_get_data(GTK_OBJECT(w), "conduit_on_off");
-
- g_assert(button!=NULL);
-
- activated = GTK_TOGGLE_BUTTON(button)->active;
-*/
+ /*
+ GtkWidget *button;
+ button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off");
+ g_assert(button!=NULL);
+ activated = GTK_TOGGLE_BUTTON(button)->active;
+ */
}
+#endif /* 0 */
+
static void
pilot_capplet_setup(void)
@@ -265,27 +253,29 @@ pilot_capplet_setup(void)
gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow);
gtk_signal_connect(GTK_OBJECT(capplet), "try",
- GTK_SIGNAL_FUNC(doTrySettings), NULL);
+ GTK_SIGNAL_FUNC(doTrySettings), curState);
gtk_signal_connect(GTK_OBJECT(capplet), "revert",
- GTK_SIGNAL_FUNC(doRevertSettings), NULL);
+ GTK_SIGNAL_FUNC(doRevertSettings), curState);
gtk_signal_connect(GTK_OBJECT(capplet), "ok",
- GTK_SIGNAL_FUNC(doSaveSettings), NULL);
+ GTK_SIGNAL_FUNC(doSaveSettings), curState);
gtk_signal_connect(GTK_OBJECT(capplet), "cancel",
- GTK_SIGNAL_FUNC(doCancelSettings), NULL);
+ GTK_SIGNAL_FUNC(doCancelSettings), curState);
gtk_signal_connect(GTK_OBJECT(capplet), "help",
GTK_SIGNAL_FUNC(about_cb), NULL);
- setStateCfg(cfgStateWindow,curState);
+ setStateCfg (cfgStateWindow, curState);
- gtk_widget_show_all(capplet);
+ gtk_widget_show_all (capplet);
}
+
static void
-run_error_dialog(gchar *mesg,...) {
+run_error_dialog(gchar *mesg,...)
+{
char tmp[80];
va_list ap;
-
+
va_start(ap,mesg);
vsnprintf(tmp,79,mesg,ap);
dialogWindow = gnome_message_box_new(mesg,GNOME_MESSAGE_BOX_ERROR,GNOME_STOCK_BUTTON_OK,NULL);
@@ -293,68 +283,92 @@ run_error_dialog(gchar *mesg,...) {
va_end(ap);
}
-gint get_pilot_id_from_gpilotd() {
- gint *pilots;
- int i;
+
+static gint
+get_pilot_id_from_gpilotd()
+{
+ GList *pilots=NULL;
+ gint pilot;
+ int i,err;
i=0;
- gpilotd_get_pilot_ids(&pilots);
- if(pilots) {
- while(pilots[i]!=-1) { g_message("pilot %d = \"%d\"",i,pilots[i]); i++; }
- if(i==0) {
+ /* we don't worry about leaking here, so pilots isn't freed */
+ switch(err = gnome_pilot_client_get_pilots(gpc,&pilots)) {
+ case GPILOTD_OK: {
+ if(pilots) {
+ for(i=0;i<g_list_length(pilots);i++) {
+ g_message("pilot %d = \"%s\"",i,(gchar*)g_list_nth(pilots,i)->data);
+ }
+ if(i==0) {
+ run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
+ return -1;
+ } else {
+ gnome_pilot_client_get_pilot_id_by_name(gpc,
+ pilots->data, /* this is the first pilot */
+ &pilot);
+ if(i>1) {
+ g_message("too many pilots...");
+ /* need a choose here */
+ }
+ return pilot;
+ }
+ } else {
run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
return -1;
- } else {
- if(i==1)
- return pilots[0];
- else {
- g_message("too many pilots...");
- return pilots[0];
- }
- }
- } else {
- run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
+ }
+ break;
+ }
+ case GPILOTD_ERR_NOT_CONNECTED:
+ run_error_dialog(_("Not connected to the gnome-pilot daemon"));
+ return -1;
+ break;
+ default:
+ g_warning("gnome_pilot_client_get_pilot_ids(...) = %d",err);
+ run_error_dialog(_("An error occured when trying to fetch\npilot list from the gnome-pilot daemon"));
return -1;
- }
+ break;
+ }
}
+
int
-main( int argc, char *argv[] )
+main (int argc, char *argv[])
{
+ g_log_set_always_fatal (G_LOG_LEVEL_ERROR |
+ G_LOG_LEVEL_CRITICAL |
+ G_LOG_LEVEL_WARNING);
+
/* we're a capplet */
gnome_capplet_init ("calendar conduit control applet", NULL, argc, argv,
- NULL,
- 0, NULL);
-
- /* get pilot name from gpilotd */
- /* 1. initialize the gpilotd connection */
- if (gpilotd_init(&argc,argv)!=0) {
- run_error_dialog(_("Cannot initialze the GnomePilot Daemon"));
- g_error(_("Cannot initialze the GnomePilot Daemon"));
- return -1;
- }
-
- /* 2 connect to gpilotd */
- if (gpilotd_connect()!=0) {
- run_error_dialog(_("Cannot connect to the GnomePilot Daemon"));
- g_error(_("Cannot connect to the GnomePilot Daemon"));
- return -1;
- }
-
+ NULL, 0, NULL);
+
+
+ gpc = gnome_pilot_client_new();
+ gnome_pilot_client_connect_to_daemon(gpc);
pilotId = get_pilot_id_from_gpilotd();
if(!pilotId) return -1;
/* put all code to set things up in here */
- conduit = gpilotd_conduit_mgmt_new("calendar_conduit",pilotId);
- gcalconduit_load_configuration(&origState,pilotId);
- gpilotd_conduit_mgmt_get_sync_type(conduit,pilotId,&origState->sync_type);
+ gcalconduit_load_configuration (&origState, pilotId);
+
+ conduit = gnome_pilot_conduit_management_new ("Calendar", GNOME_PILOT_CONDUIT_MGMT_ID);
+ if (conduit == NULL) return -1;
+ conduit_config = gnome_pilot_conduit_config_new (conduit, pilotId);
+ org_activation_state = gnome_pilot_conduit_config_is_enabled (conduit_config,
+ &origState->sync_type);
+ activated = org_activation_state;
+
+ //gpilotd_conduit_mgmt_get_sync_type (conduit, pilotId, &origState->sync_type);
curState = gcalconduit_dupe_configuration(origState);
- pilot_capplet_setup();
+ pilot_capplet_setup ();
/* done setting up, now run main loop */
capplet_gtk_main();
+
+ gnome_pilot_conduit_management_destroy(conduit);
+
return 0;
}
diff --git a/calendar/conduits/calendar/calendar-conduit-control-applet.desktop b/calendar/conduits/calendar/calendar-conduit-control-applet.desktop
index 2a5af4f24e..40e3e21d8f 100644
--- a/calendar/conduits/calendar/calendar-conduit-control-applet.desktop
+++ b/calendar/conduits/calendar/calendar-conduit-control-applet.desktop
@@ -1,5 +1,5 @@
[Desktop Entry]
-Name=GnomeCalendar
+Name=Calendar conduit
Name[da]=Gnome kalender
Name[no]=GNOME kalender
Comment=Configure the GnomeCal conduit
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index 2cddd84186..0e4c713636 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* $Id$ */
#include <config.h>
@@ -7,6 +8,10 @@
#include <pwd.h>
#include <signal.h>
#include <errno.h>
+
+#include <cal-client/cal-client.h>
+#include <cal-util/calobj.h>
+#include <cal-util/timeutil.h>
#include <pi-source.h>
#include <pi-socket.h>
#include <pi-file.h>
@@ -16,22 +21,13 @@
#include <pi-version.h>
#include <gpilotd/gnome-pilot-conduit.h>
#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
+#include <calendar-conduit.h>
-#include "GnomeCal.h"
-#include "calendar-conduit.h"
-
-int debug_alarms = 0; /* needed to satisfy some other part of gncal */
-/* Default values for alarms */ /* needed to satisfy some other part of gncal */
-CalendarAlarm alarm_defaults[4] = {
- { ALARM_MAIL, 0, 15, ALARM_MINUTES },
- { ALARM_PROGRAM, 0, 15, ALARM_MINUTES },
- { ALARM_DISPLAY, 0, 15, ALARM_MINUTES },
- { ALARM_AUDIO, 0, 15, ALARM_MINUTES }
-};
+//#include "GnomeCal.h"
GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
-void local_record_from_icalobject(GCalLocalRecord *local,iCalObject *obj);
+void local_record_from_icalobject (GCalLocalRecord *local, iCalObject *obj);
#define CONDUIT_VERSION "0.8.11"
#ifdef G_LOG_DOMAIN
@@ -61,14 +57,61 @@ void local_record_from_icalobject(GCalLocalRecord *local,iCalObject *obj);
return ret; \
}
+
+gboolean load_success;
+
+
+static void
+gnome_calendar_load_cb (GtkWidget *cal_client,
+ CalClientLoadStatus status,
+ GCalConduitContext *ctxt)
+{
+ CalClient *client = CAL_CLIENT (cal_client);
+ static int tried = 0;
+
+ printf ("intering gnome_calendar_load_cb, tried=%d\n", tried);
+
+ if (status == CAL_CLIENT_LOAD_SUCCESS) {
+ load_success = TRUE;
+ printf (" success\n");
+ } else {
+ if (tried) {
+ printf ("load and create of calendar failed\n");
+ return;
+ }
+
+ cal_client_create_calendar (client, ctxt->calendar_file);
+ tried = 1;
+ }
+}
+
+
+
+
+
static int
start_calendar_server (GnomePilotConduitStandardAbs *conduit,
- GCalConduitContext *ctxt)
+ GCalConduitContext *ctxt)
{
g_return_val_if_fail(conduit!=NULL,-2);
g_return_val_if_fail(ctxt!=NULL,-2);
-
+
+ ctxt->client = cal_client_new ();
+
+ /* FIX ME */
+ ctxt->calendar_file = g_concat_dir_and_file (g_get_home_dir (),
+ "evolution/local/Calendar/calendar.vcf");
+
+ /* hmm. */
+ gtk_signal_connect (GTK_OBJECT (ctxt->client), "cal_loaded",
+ gnome_calendar_load_cb, ctxt);
+
+ load_success = FALSE;
+
+ cal_client_load_calendar (ctxt->client, ctxt->calendar_file);
+
+ /*
ctxt->calendar = goad_server_activate_with_id (NULL,
"IDL:GNOME:Calendar:Repository:1.0",
0, NULL);
@@ -82,89 +125,66 @@ start_calendar_server (GnomePilotConduitStandardAbs *conduit,
CORBA_exception_free(&(ctxt->ev));
return -1;
}
+ */
return 0;
}
/* Just a stub to link with */
+
+void calendar_notify (time_t time, CalendarAlarm *which, void *data);
+
void
calendar_notify (time_t time, CalendarAlarm *which, void *data)
{
}
+
static GSList *
get_calendar_objects(GnomePilotConduitStandardAbs *conduit,
gboolean *status,
GCalConduitContext *ctxt)
{
+ GList *uids;
GSList *result;
- GNOME_Calendar_Repository_String_Sequence *uids;
- g_return_val_if_fail(conduit!=NULL,NULL);
- g_return_val_if_fail(ctxt!=NULL,NULL);
+ g_return_val_if_fail (conduit != NULL, NULL);
+ g_return_val_if_fail (ctxt != NULL, NULL);
- result = NULL;
- uids = GNOME_Calendar_Repository_get_object_id_list (ctxt->calendar, &(ctxt->ev));
+ uids = cal_client_get_uids (ctxt->client, CALOBJ_TYPE_ANY);
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- if(status!=NULL) (*status) = FALSE;
- return NULL;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- if(status!=NULL) (*status) = FALSE;
- return NULL;
- }
+ if (status != NULL)
+ (*status) = TRUE;
- if(status!=NULL) (*status) = TRUE;
- if(uids->_length>0) {
- int i;
- for(i=0;i<uids->_length;i++) {
- result = g_slist_prepend(result,g_strdup(uids->_buffer[i]));
- }
- } else {
+ if (! uids)
INFO ("No entries found");
+ else {
+ GList *c;
+ for (c=uids; c; c=c->next)
+ result = g_slist_prepend (result, (gchar *) c->data);
+ /* FIX ME free uids */
}
-
- CORBA_free(uids);
return result;
}
+
static void
-local_record_from_ical_uid(GCalLocalRecord *local,
- char *uid,
- GCalConduitContext *ctxt)
+local_record_from_ical_uid (GCalLocalRecord *local,
+ char *uid,
+ GCalConduitContext *ctxt)
{
iCalObject *obj;
- char *vcalendar_string;
+ CalClientGetStatus status;
g_assert(local!=NULL);
-
- vcalendar_string = GNOME_Calendar_Repository_get_object(ctxt->calendar, uid, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return;
- }
- g_return_if_fail(vcalendar_string!=NULL);
-
- obj = ical_object_new_from_string (vcalendar_string);
- local_record_from_icalobject(local,obj);
+ status = cal_client_get_object (ctxt->client, uid, &obj);
- return;
+ if (status == CAL_CLIENT_GET_SUCCESS)
+ local_record_from_icalobject(local,obj);
+ else
+ INFO ("Object did not exist");
}
@@ -219,14 +239,35 @@ find_record_in_repository(GnomePilotConduitStandardAbs *conduit,
PilotRecord *remote,
GCalConduitContext *ctxt)
{
- char *vcal_string;
+ char *uid = NULL;
GCalLocalRecord *loc;
+ CalClientGetStatus status;
+ iCalObject *obj;
g_return_val_if_fail(conduit!=NULL,NULL);
g_return_val_if_fail(remote!=NULL,NULL);
LOG ("requesting %ld", remote->ID);
+
+ status = cal_client_get_uid_by_pilot_id (ctxt->client, remote->ID, &uid);
+
+ if (status == CAL_CLIENT_GET_SUCCESS) {
+ status = cal_client_get_object (ctxt->client, uid, &obj);
+ if (status == CAL_CLIENT_GET_SUCCESS) {
+ LOG ("Found");
+ loc = g_new0(GCalLocalRecord,1);
+ /* memory allocated in new_from_string is freed in free_match */
+ local_record_from_icalobject (loc, obj);
+ return loc;
+ }
+ }
+
+ INFO ("Object did not exist");
+ return NULL;
+
+
+#if 0
vcal_string =
GNOME_Calendar_Repository_get_object_by_pilot_id (ctxt->calendar, remote->ID, &(ctxt->ev));
@@ -251,6 +292,7 @@ find_record_in_repository(GnomePilotConduitStandardAbs *conduit,
}
return NULL;
+#endif /* 0 */
}
/*
@@ -261,11 +303,15 @@ update_calendar_entry_in_repository(GnomePilotConduitStandardAbs *conduit,
iCalObject *obj,
GCalConduitContext *ctxt)
{
- char *str;
+ gboolean success;
g_return_if_fail(conduit!=NULL);
g_return_if_fail(obj!=NULL);
+ success = cal_client_update_object (ctxt->client, obj);
+
+
+ /*
str = calendar_string_from_object (obj);
GNOME_Calendar_Repository_update_object (ctxt->calendar, obj->uid, str, &(ctxt->ev));
@@ -283,6 +329,7 @@ update_calendar_entry_in_repository(GnomePilotConduitStandardAbs *conduit,
}
free (str);
+ */
}
static iCalObject *
@@ -476,45 +523,46 @@ update_record (GnomePilotConduitStandardAbs *conduit,
PilotRecord *remote,
GCalConduitContext *ctxt)
{
- char *vcal_string;
iCalObject *obj;
struct Appointment a;
+ CalClientGetStatus status;
+ char *uid;
g_return_val_if_fail(remote!=NULL,-1);
memset(&a,0,sizeof(struct Appointment));
unpack_Appointment(&a,remote->record,remote->length);
-
- obj = ical_new (a.note ? a.note : "",
- g_get_user_name (),
- a.description ? a.description : "");
LOG ("requesting %ld [%s]", remote->ID, a.description);
- vcal_string = GNOME_Calendar_Repository_get_object_by_pilot_id (ctxt->calendar, remote->ID, &(ctxt->ev));
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
+ status = cal_client_get_uid_by_pilot_id(ctxt->client, remote->ID, &uid);
+ if (status == CAL_CLIENT_GET_SUCCESS)
+ status = cal_client_get_object (ctxt->client, uid, &obj);
+
+ if (status != CAL_CLIENT_GET_SUCCESS) {
+ time_t now = time (NULL);
+
LOG ("Object did not exist, creating a new one");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- ical_from_remote_record(conduit,remote,obj);
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- ical_object_unref (obj);
- free_Appointment(&a);
- return -1;
+
+ obj = ical_new (a.note ? a.note : "",
+ g_get_user_name (),
+ a.description ? a.description : "");
+
+ obj->created = now;
+ obj->last_mod = now;
+ obj->priority = 0;
+ obj->transp = 0;
+ obj->related = NULL;
+ obj->pilot_id = remote->ID;
+ obj->pilot_status = ICAL_PILOT_SYNC_NONE;
} else {
- LOG ("Found");
- ical_object_unref (obj);
- obj = ical_object_new_from_string (vcal_string);
- ical_from_remote_record(conduit,remote,obj);
- CORBA_free(vcal_string);
+ LOG ("Found");
+ ical_from_remote_record (conduit, remote, obj);
}
/* update record on server */
- update_calendar_entry_in_repository(conduit,obj,ctxt);
+ update_calendar_entry_in_repository (conduit, obj, ctxt);
/*
* Shutdown
@@ -526,28 +574,20 @@ update_record (GnomePilotConduitStandardAbs *conduit,
}
static void
-check_for_slow_setting(GnomePilotConduit *c,
- GCalConduitContext *ctxt)
+check_for_slow_setting (GnomePilotConduit *c, GCalConduitContext *ctxt)
{
- CORBA_long entry_number;
- entry_number =
- GNOME_Calendar_Repository_get_number_of_objects(ctxt->calendar,
- GNOME_Calendar_Repository_ANY,
- &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- } else {
- LOG (_("Calendar holds %d entries"),entry_number);
- /* If the local base is empty, do a slow sync */
- if ( entry_number <= 0) {
- gnome_pilot_conduit_standard_set_slow(GNOME_PILOT_CONDUIT_STANDARD(c));
- }
+ GList *uids;
+ unsigned long int entry_number;
+
+ uids = cal_client_get_uids (ctxt->client, CALOBJ_TYPE_ANY);
+ entry_number = g_list_length (uids);
+
+ LOG (_("Calendar holds %d entries"),entry_number);
+ /* If the local base is empty, do a slow sync */
+ if (entry_number == 0) {
+ GnomePilotConduitStandard *conduit;
+ conduit = GNOME_PILOT_CONDUIT_STANDARD (c);
+ gnome_pilot_conduit_standard_set_slow (conduit);
}
}
@@ -559,10 +599,15 @@ pre_sync(GnomePilotConduit *c,
int l;
gint num_records;
unsigned char *buf;
+ GList *uids;
+ GnomePilotConduitStandardAbs *conduit;
+
+ conduit = GNOME_PILOT_CONDUIT_STANDARD_ABS(c);
g_message ("GnomeCal Conduit v.%s",CONDUIT_VERSION);
- ctxt->calendar = CORBA_OBJECT_NIL;
+ //ctxt->calendar = CORBA_OBJECT_NIL;
+ ctxt->client = NULL;
if (start_calendar_server(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),ctxt) != 0) {
WARN(_("Could not start gnomecal server"));
@@ -570,24 +615,34 @@ pre_sync(GnomePilotConduit *c,
_("Could not start gnomecal server"));
return -1;
}
-
+
+
+
+ /* FIX ME */
+ uids = cal_client_get_uids (ctxt->client, CALOBJ_TYPE_ANY);
+ num_records = g_list_length (uids);
+
+ gnome_pilot_conduit_standard_abs_set_num_local_records (conduit, num_records);
+ gnome_pilot_conduit_standard_abs_set_num_updated_local_records (conduit, num_records);
+ gnome_pilot_conduit_standard_abs_set_num_new_local_records (conduit, num_records);
+ gnome_pilot_conduit_standard_abs_set_num_deleted_local_records (conduit, num_records);
+
+#if 0
/* Set the counters for the progress bar crap */
num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_ANY, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
+
+ catch_ret_val (ctxt->ev, -1);
+ gnome_pilot_conduit_standard_abs_set_num_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), num_records);
num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_MODIFIED, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_updated_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
+ catch_ret_val (ctxt->ev, -1);
+ gnome_pilot_conduit_standard_abs_set_num_updated_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), num_records);
num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_NEW, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_new_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
+ catch_ret_val (ctxt->ev, -1);
+ gnome_pilot_conduit_standard_abs_set_num_new_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), num_records);
num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_DELETED, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_deleted_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
+ catch_ret_val (ctxt->ev, -1);
+ gnome_pilot_conduit_standard_abs_set_num_deleted_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), num_records);
+#endif /* 0 */
gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi);
@@ -819,6 +874,7 @@ set_status (GnomePilotConduitStandardAbs *conduit,
gint status,
GCalConduitContext *ctxt)
{
+ gboolean success;
LOG ("entering set_status(status=%d)",status);
g_return_val_if_fail(local!=NULL,-1);
@@ -839,27 +895,19 @@ set_status (GnomePilotConduitStandardAbs *conduit,
break;
}
- if ( status == GnomePilotRecordDeleted) {
- GNOME_Calendar_Repository_delete_object(ctxt->calendar,local->ical->uid,&(ctxt->ev));
+ if (status == GnomePilotRecordDeleted) {
+ success = cal_client_remove_object (ctxt->client, local->ical->uid);
} else {
- GNOME_Calendar_Repository_update_pilot_id(ctxt->calendar,
- local->ical->uid,
- local->local.ID,
- local->ical->pilot_status,
- &(ctxt->ev));
+ success = cal_client_update_object (ctxt->client, local->ical);
+ cal_client_update_pilot_id (ctxt->client, local->ical->uid,
+ local->local.ID,
+ local->ical->pilot_status);
}
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- LOG ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
+
+ if (! success) {
WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- }
+ }
+
return 0;
}
@@ -895,23 +943,20 @@ set_pilot_id (GnomePilotConduitStandardAbs *conduit,
local->local.ID = ID;
local->ical->pilot_id = ID;
+
+ cal_client_update_pilot_id (ctxt->client,
+ local->ical->uid,
+ local->local.ID,
+ local->ical->pilot_status);
+
+ /*
GNOME_Calendar_Repository_update_pilot_id(ctxt->calendar,
local->ical->uid,
local->local.ID,
local->ical->pilot_status,
&(ctxt->ev));
+ */
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- LOG ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- }
return 0;
}
@@ -1083,8 +1128,7 @@ compare (GnomePilotConduitStandardAbs *conduit,
int retval;
/* used by the tedious compare */
- struct Appointment a;
- int daycount;
+ //struct Appointment a;
g_message ("entering compare");
@@ -1310,39 +1354,32 @@ compare_backup (GnomePilotConduitStandardAbs *conduit,
return -1;
}
+
static gint
delete_all (GnomePilotConduitStandardAbs *conduit,
GCalConduitContext *ctxt)
{
GSList *events,*it;
gboolean error;
+ gboolean success;
events = get_calendar_objects(conduit,&error,ctxt);
-
+
if (error == FALSE) return -1;
- for (it=events;it;it = g_slist_next(it)) {
- GNOME_Calendar_Repository_delete_object(ctxt->calendar,
- it->data,
- &(ctxt->ev));
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
+ for (it=events; it; it = g_slist_next (it)) {
+ success = cal_client_remove_object (ctxt->client, it->data);
+
+ if (!success)
INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- /* destroy loop, free data */
- for (it=events;it;it = g_slist_next(it)) g_free(it->data);
- g_slist_free(events);
- return -1;
- }
- g_free(it->data);
+
+ g_free (it->data);
}
- g_slist_free(events);
+
+ g_slist_free (events);
return -1;
}
+
GnomePilotConduit *
conduit_get_gpilot_conduit (guint32 pilotId)
{
@@ -1392,15 +1429,15 @@ conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
cc = GET_GCALCONFIG(conduit);
ctxt = GET_GCALCONTEXT(conduit);
- if(ctxt->calendar!=CORBA_OBJECT_NIL)
- GNOME_Calendar_Repository_done (ctxt->calendar, &(ctxt->ev));
+ if (ctxt->client != NULL) {
+ gtk_object_unref (GTK_OBJECT (ctxt->client));
+ //pi_close (link);
+ //GNOME_Calendar_Repository_done (ctxt->calendar, &(ctxt->ev));
+ }
- gcalconduit_destroy_configuration(&cc);
+ gcalconduit_destroy_configuration (&cc);
- gcalconduit_destroy_context(&ctxt);
+ gcalconduit_destroy_context (&ctxt);
gtk_object_destroy (GTK_OBJECT (conduit));
-
}
-
-
diff --git a/calendar/conduits/calendar/calendar-conduit.h b/calendar/conduits/calendar/calendar-conduit.h
index fa8c151d4c..ae10fc79a6 100644
--- a/calendar/conduits/calendar/calendar-conduit.h
+++ b/calendar/conduits/calendar/calendar-conduit.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* $Id$ */
#ifndef __CALENDAR_CONDUIT_H__
@@ -10,9 +11,16 @@
#include <pi-datebook.h>
#include <gpilotd/gnome-pilot-conduit.h>
#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
+#include <cal-client/cal-client.h>
#include <cal-util/calobj.h>
#include <cal-util/timeutil.h>
-#include "GnomeCal.h"
+
+#ifdef USING_OAF
+#include <liboaf/liboaf.h>
+#else
+#include <libgnorba/gnorba.h>
+#endif
+
/* This is the local record structure for the GnomeCal conduit. */
typedef struct _GCalLocalRecord GCalLocalRecord;
@@ -43,12 +51,16 @@ typedef struct _GCalConduitContext GCalConduitContext;
struct _GCalConduitContext {
struct AppointmentAppInfo ai;
GCalConduitCfg *cfg;
- GNOME_Calendar_Repository calendar;
+ //GNOME_Calendar_Repository calendar;
+ CalClient *client;
CORBA_Environment ev;
CORBA_ORB orb;
+
+ char *calendar_file;
};
#define GET_GCALCONTEXT(c) ((GCalConduitContext*)gtk_object_get_data(GTK_OBJECT(c),"gcalconduit_context"))
+
/* Given a GCalConduitCfg*, allocates the structure and
loads the configuration data for the given pilot. */
static void
@@ -68,6 +80,7 @@ gcalconduit_load_configuration(GCalConduitCfg **c,
(*c)->pilotId = pilotId;
}
+
/* Saves the configuration data. */
static void
gcalconduit_save_configuration(GCalConduitCfg *c)
@@ -77,7 +90,7 @@ gcalconduit_save_configuration(GCalConduitCfg *c)
g_snprintf(prefix,255,"/gnome-pilot.d/calendar-conduit/Pilot_%u/",c->pilotId);
gnome_config_push_prefix(prefix);
- gnome_config_set_bool("open_secret",c->open_secret);
+ gnome_config_set_bool ("open_secret", c->open_secret);
gnome_config_pop_prefix();
gnome_config_sync();
@@ -96,6 +109,7 @@ gcalconduit_dupe_configuration(GCalConduitCfg *c) {
return retval;
}
+
/* Destroys any data allocated by gcalconduit_load_configuration
and deallocates the given configuration. */
static void
@@ -107,6 +121,7 @@ gcalconduit_destroy_configuration(GCalConduitCfg **c)
*c = NULL;
}
+
/* Given a GCalConduitContxt*, allocates the structure */
static void
gcalconduit_new_context(GCalConduitContext **ctxt,
@@ -118,6 +133,7 @@ gcalconduit_new_context(GCalConduitContext **ctxt,
CORBA_exception_init (&((*ctxt)->ev));
}
+
/* Destroys any data allocated by gcalconduit_new_context
and deallocates its data. */
static void
@@ -132,4 +148,5 @@ gcalconduit_destroy_context(GCalConduitContext **ctxt)
g_free(*ctxt);
*ctxt = NULL;
}
+
#endif __CALENDAR_CONDUIT_H__
diff --git a/calendar/conduits/calendar/calendar.conduit.in b/calendar/conduits/calendar/calendar.conduit.in
new file mode 100644
index 0000000000..7a25f5b61e
--- /dev/null
+++ b/calendar/conduits/calendar/calendar.conduit.in
@@ -0,0 +1,8 @@
+<gnome-pilot-conduit version="1.0">
+<conduit id="gnomecal" type="shlib" location="@prefix@/lib/gnome-pilot/conduits/libcalendar_conduit.so"/>
+<name value="GnomeCal"/>
+<conduit-attribute name="description" value="Synchronizes with GnomeCal"/>
+<conduit-attribute name="default-synctype" value="synchronize"/>
+<conduit-attribute name="icon" value="@prefix@/share/pixmaps/gnome-calendar-conduit.png"/>
+<conduit-attribute name="settings" value="TRUE"/>
+</gnome-pilot-conduit>