aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorEskil Heyn Olsen <eskil@src.gnome.org>1999-09-08 21:06:07 +0800
committerEskil Heyn Olsen <eskil@src.gnome.org>1999-09-08 21:06:07 +0800
commit8550ca3f28108f315db18a0edc508f6e682b66fd (patch)
treedc34b88b0922da48c1acb8f19eb2f17d3c7846ad /calendar/gui
parent4a3be146661da5d5267af57482ba0a22656166f5 (diff)
downloadgsoc2013-evolution-8550ca3f28108f315db18a0edc508f6e682b66fd.tar
gsoc2013-evolution-8550ca3f28108f315db18a0edc508f6e682b66fd.tar.gz
gsoc2013-evolution-8550ca3f28108f315db18a0edc508f6e682b66fd.tar.bz2
gsoc2013-evolution-8550ca3f28108f315db18a0edc508f6e682b66fd.tar.lz
gsoc2013-evolution-8550ca3f28108f315db18a0edc508f6e682b66fd.tar.xz
gsoc2013-evolution-8550ca3f28108f315db18a0edc508f6e682b66fd.tar.zst
gsoc2013-evolution-8550ca3f28108f315db18a0edc508f6e682b66fd.zip
uses GNOME_PILOT_CHECK
* configure.in: uses GNOME_PILOT_CHECK * gncal/GnomeCal.idl: added a get_objects() call, which returns all the objects in the calendar. * gncal/Makefile.am: added two conduits with control-applets. Compiled only if configure sets HAVE_GNOME_PILOT * gncal/calender-conduit.[ch]: began implementing conduit. * gncal/todo-conduit.[ch]: begin implementing conduit. * gncal/corba-cal.c: implemented the get_objects() call. svn path=/trunk/; revision=1216
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/GnomeCal.idl7
-rw-r--r--calendar/gui/Makefile.am77
-rw-r--r--calendar/gui/calendar-conduit-control-applet.c279
-rw-r--r--calendar/gui/calendar-conduit.c126
-rw-r--r--calendar/gui/calendar-conduit.h52
-rw-r--r--calendar/gui/corba-cal.c29
-rw-r--r--calendar/gui/todo-conduit-control-applet.c278
-rw-r--r--calendar/gui/todo-conduit.c256
-rw-r--r--calendar/gui/todo-conduit.h59
9 files changed, 1142 insertions, 21 deletions
diff --git a/calendar/gui/GnomeCal.idl b/calendar/gui/GnomeCal.idl
index 5c158284a3..036dc55db0 100644
--- a/calendar/gui/GnomeCal.idl
+++ b/calendar/gui/GnomeCal.idl
@@ -53,6 +53,13 @@ module GNOME {
raises (NotFound);
/*
+ * get_objects:
+ *
+ * Returns a vCalendar with all the objects
+ */
+ string get_objects ();
+
+ /*
* get_updated_objects:
*
* Returns a vCalendar with all the objects that have been
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index 5d2aba31b3..c7794b7e85 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -8,6 +8,11 @@ gnorba_DATA = gnomecal.gnorba
help_base = $(datadir)/gnome/help/cal
+if HAVE_GNOME_PILOT
+EXTRA_PROGRAMS = todo-conduit-control-applet calendar-conduit-control-applet
+endif
+bin_PROGRAMS = gnomecal
+
INCLUDES = \
-I$(includedir) \
$(GNOME_INCLUDEDIR) \
@@ -15,9 +20,6 @@ INCLUDES = \
$(PISOCK_INCLUDEDIR) \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\"
-bin_PROGRAMS = gnomecal @CALSYNC@
-EXTRA_PROGRAMS = calendar-pilot-sync
-
GNOMECAL_CORBA_GENERATED = \
GnomeCal.h \
GnomeCal.c \
@@ -101,8 +103,6 @@ calendar_pilot_sync_SOURCES = \
timeutil.c \
timeutil.h
-
-
LINK_FLAGS = \
$(GNOME_LIBDIR) \
$(GNOMEGNORBA_LIBS) \
@@ -113,38 +113,84 @@ calendar_pilot_sync_LDADD = \
$(LINK_FLAGS)
+if HAVE_GNOME_PILOT
#calendar_conduit
calendar_conduitsdir=$(libdir)/gnome-pilot/conduits
-calendar_conduits_LTLIBRARIES = @CALCONDUITLIB@
+calendar_conduits_LTLIBRARIES = libcalendar_conduit.la
-EXTRA_LTLIBRARIES = libcalendar_conduit.la
+libcalendar_conduit_la_SOURCES = \
+ calendar-conduit.c
libcalendar_conduit_la_LDFLAGS = \
-rpath $(libdir)
libcalendar_conduit_la_LIBADD = \
- $(GNOME_CONDUIT_LIBS) \
+ $(PISOCK_LIBS) \
$(GNOME_LIBDIR) \
$(GNOME_LIBS)
-libcalendar_conduit_la_SOURCES = \
- calendar-conduit.c
+calendar_conduit_control_applet_SOURCES = \
+ calendar-conduit-control-applet.c
+
+calendar_conduit_control_applet_LDADD = \
+ $(CAPPLET_LIBS) \
+ $(GNOME_LIBDIR) \
+ $(GNOME_CAPPLET_LIBS) \
+ $(PISOCK_LIBS) \
+ $(GNOMEUI_LIBS) \
+ $(PISOCK_LIBS) \
+ $(GNOME_PILOT_LIBS) \
+ $(INTLLIBS)
+
+#todo_conduit
+todo_conduitsdir=$(libdir)/gnome-pilot/conduits
-#libcalendar_conduit_la_OBJECTS = \
-# calendar-conduit.o
+todo_conduits_LTLIBRARIES = libtodo_conduit.la
-#gncal_LDADD = $(LINK_FLAGS)
+libtodo_conduit_la_LDFLAGS = \
+ -rpath $(libdir)
+
+libtodo_conduit_la_LIBADD = \
+ $(GNOME_LIBDIR) \
+ $(GNOME_LIBS)
+
+libtodo_conduit_la_SOURCES = \
+ todo-conduit.c
+
+todo_conduit_control_applet_SOURCES = \
+ todo-conduit-control-applet.c
+
+todo_conduit_control_applet_LDADD = \
+ $(CAPPLET_LIBS) \
+ $(GNOME_LIBDIR) \
+ $(GNOME_CAPPLET_LIBS) \
+ $(PISOCK_LIBS) \
+ $(GNOMEUI_LIBS) \
+ $(PISOCK_LIBS) \
+ $(GNOME_PILOT_LIBS) \
+ $(INTLLIBS)
+endif # HAVE_GNOME_PILOT
gnomecal_LDADD = $(LINK_FLAGS)
+if HAVE_GNOME_PILOT
+ccenterdir = $(datadir)/control-center
+Rootdir = $(ccenterdir)
+PalmPilotdir = $(ccenterdir)/Peripherals/PalmPilot
+Conduitsdir = $(PalmPilotdir)/Conduits
+
+Conduits_DATA = \
+ calendar-conduit-control-applet.desktop \
+ todo-conduit-control-applet.desktop
+endif
+
EXTRA_DIST = \
gncal.desktop \
bell.xpm \
recur.xpm \
$(idl_DATA) \
- $(gnorba_DATA)
-
+ $(gnorba_DATA) \
Productivitydir = $(datadir)/gnome/apps/Applications
@@ -152,3 +198,4 @@ Productivity_DATA = gncal.desktop
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(help_base)/C
+ $(mkinstalldirs) $(Conduitsdir)
diff --git a/calendar/gui/calendar-conduit-control-applet.c b/calendar/gui/calendar-conduit-control-applet.c
new file mode 100644
index 0000000000..f8e234ac13
--- /dev/null
+++ b/calendar/gui/calendar-conduit-control-applet.c
@@ -0,0 +1,279 @@
+/* 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 "calendar-conduit.h"
+
+/* tell changes callbacks to ignore changes or not */
+static gboolean ignore_changes=FALSE;
+
+/* capplet widget */
+static GtkWidget *capplet=NULL;
+
+/* host/device/pilot configuration windows */
+GtkWidget *cfgOptionsWindow=NULL;
+GtkWidget *cfgStateWindow=NULL;
+GtkWidget *dialogWindow=NULL;
+
+gboolean activated,org_activation_state;
+GnomePilotConduitMgmt *conduit;
+
+static void doTrySettings(GtkWidget *widget, ConduitCfg *conduitCfg);
+static void doRevertSettings(GtkWidget *widget, ConduitCfg *conduitCfg);
+static void doSaveSettings(GtkWidget *widget, ConduitCfg *conduitCfg);
+
+static void readStateCfg(GtkWidget *w);
+static void setStateCfg(GtkWidget *w);
+
+gchar *pilotId;
+CORBA_Environment ev;
+
+static void
+doTrySettings(GtkWidget *widget, ConduitCfg *conduitCfg)
+{
+ readStateCfg(cfgStateWindow);
+ if(activated)
+ gpilotd_conduit_mgmt_enable(conduit,pilotId);
+ else
+ gpilotd_conduit_mgmt_disable(conduit,pilotId);
+}
+
+static void
+doSaveSettings(GtkWidget *widget, ConduitCfg *conduitCfg)
+{
+ doTrySettings(widget, conduitCfg);
+ save_configuration(NULL);
+}
+
+
+static void
+doRevertSettings(GtkWidget *widget, ConduitCfg *conduitCfg)
+{
+ activated = org_activation_state;
+ setStateCfg(cfgStateWindow);
+}
+
+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)
+{
+ if (!ignore_changes)
+ capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
+}
+
+static void
+clist_changed(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};
+
+ 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;
+}
+
+static void toggled_cb(GtkWidget *widget, gpointer data) {
+ gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(widget)->active);
+ capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
+}
+
+static GtkWidget
+*createStateCfgWindow(void)
+{
+ GtkWidget *vbox, *table;
+ GtkWidget *entry, *label;
+ GtkWidget *button;
+
+ vbox = gtk_vbox_new(FALSE, GNOME_PAD);
+
+ table = gtk_table_new(2, 2, FALSE);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 4);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 10);
+ gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD);
+
+ label = gtk_label_new(_("Enabled"));
+ gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1,2);
+
+ button = gtk_check_button_new();
+ gtk_object_set_data(GTK_OBJECT(vbox), "conduit_on_off", button);
+ gtk_signal_connect(GTK_OBJECT(button), "toggled",
+ GTK_SIGNAL_FUNC(toggled_cb),
+ NULL);
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 1,2);
+
+ return vbox;
+}
+
+static void
+setStateCfg(GtkWidget *cfg)
+{
+ GtkWidget *button;
+ gchar num[40];
+
+ button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off");
+
+ g_assert(button!=NULL);
+
+ ignore_changes = TRUE;
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),activated);
+ gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(button)->active);
+ ignore_changes = FALSE;
+}
+
+
+static void
+readStateCfg(GtkWidget *cfg)
+{
+ GtkWidget *button;
+
+ button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off");
+
+ g_assert(button!=NULL);
+
+ activated = GTK_TOGGLE_BUTTON(button)->active;
+}
+
+static void
+pilot_capplet_setup(void)
+{
+ GtkWidget *frame, *table;
+
+ capplet = capplet_widget_new();
+
+ table = gtk_table_new(1, 2, FALSE);
+ gtk_container_border_width(GTK_CONTAINER(table), GNOME_PAD);
+ gtk_container_add(GTK_CONTAINER(capplet), table);
+
+ frame = gtk_frame_new(_("Conduit state"));
+ gtk_container_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL);
+ gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1);
+ cfgStateWindow = createStateCfgWindow();
+ gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow);
+
+ gtk_signal_connect(GTK_OBJECT(capplet), "try",
+ GTK_SIGNAL_FUNC(doTrySettings), NULL);
+ gtk_signal_connect(GTK_OBJECT(capplet), "revert",
+ GTK_SIGNAL_FUNC(doRevertSettings), NULL);
+ gtk_signal_connect(GTK_OBJECT(capplet), "ok",
+ GTK_SIGNAL_FUNC(doSaveSettings), NULL);
+ gtk_signal_connect(GTK_OBJECT(capplet), "help",
+ GTK_SIGNAL_FUNC(about_cb), NULL);
+
+
+ setStateCfg(cfgStateWindow);
+
+ gtk_widget_show_all(capplet);
+}
+
+void 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);
+ gnome_dialog_run_and_close(GNOME_DIALOG(dialogWindow));
+ va_end(ap);
+}
+
+gchar *get_pilot_id_from_gpilotd() {
+ gchar **pilots;
+ int i;
+
+ i=0;
+ gpilotd_get_pilots(&pilots);
+ if(pilots) {
+ while(pilots[i]) { g_message("pilot %d = \"%s\"",i,pilots[i]); i++; }
+ if(i==0) {
+ run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
+ return NULL;
+ } 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."));
+ return NULL;
+ }
+}
+
+int
+main( int argc, char *argv[] )
+{
+ /* we're a capplet */
+ gnome_capplet_init ("calendar conduit control applet", NULL, argc, argv,
+ NULL,
+ 0, NULL);
+
+ /* put all code to set things up in here */
+ conduit = gpilotd_conduit_mgmt_new("calendar_conduit");
+
+ /* get pilot name from gpilotd */
+ /* 1. initialize the gpilotd connection */
+ gpilotd_init(&argc,argv);
+ /* 2 connect to gpilotd */
+ if(!gpilotd_connect()) g_error("Cannot connect to gpilotd");
+
+ pilotId = get_pilot_id_from_gpilotd();
+ if(!pilotId) return -1;
+ org_activation_state = activated = gpilotd_conduit_mgmt_is_enabled(conduit,pilotId);
+
+ pilot_capplet_setup();
+
+
+ /* done setting up, now run main loop */
+ capplet_gtk_main();
+ g_free(pilotId);
+ return 0;
+}
diff --git a/calendar/gui/calendar-conduit.c b/calendar/gui/calendar-conduit.c
index d9658f08a3..f7d1ebdd71 100644
--- a/calendar/gui/calendar-conduit.c
+++ b/calendar/gui/calendar-conduit.c
@@ -16,9 +16,93 @@
#include <pwd.h>
#include <signal.h>
#include <errno.h>
+
+#include <libgnorba/gnorba.h>
+#include <libgnorba/gnome-factory.h>
+
#include <gpilotd/gnome-pilot-conduit.h>
#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
+#include "GnomeCal.h"
+#include "calobj.h"
+#include "calendar.h"
+
+#include "calendar-conduit.h"
+
+typedef struct _ConduitData ConduitData;
+
+struct _ConduitData {
+ struct AppointmentAppInfo ai;
+ Calendar *cal;
+};
+
+#define GET_DATA(c) ((ConduitData*)gtk_object_get_data(GTK_OBJECT(c),"conduit_data"))
+
+GNOME_Calendar_Repository calendar;
+CORBA_Environment ev;
+
+static GNOME_Calendar_Repository
+calendar_server (void)
+{
+ if(calendar!=CORBA_OBJECT_NIL) return calendar;
+
+ calendar = goad_server_activate_with_id (NULL, "IDL:GNOME:Calendar:Repository:1.0",
+ 0, NULL);
+
+ if (calendar == CORBA_OBJECT_NIL)
+ g_error ("Can not communicate with GnomeCalendar server");
+
+ if (ev._major != CORBA_NO_EXCEPTION){
+ printf ("Exception: %s\n", CORBA_exception_id (&ev));
+ abort ();
+ }
+
+ return calendar;
+}
+
+static gint
+load_records(GnomePilotConduit *c)
+{
+ char *vcalendar_string;
+ char *error;
+ ConduitData *cd;
+
+ vcalendar_string =
+ GNOME_Calendar_Repository_get_updated_objects (calendar_server(), &ev);
+
+ cd = GET_DATA(c);
+ cd->cal = calendar_new("Temporary");
+
+ error = calendar_load_from_memory(cd->cal,vcalendar_string);
+
+ return 0;
+}
+
+static gint
+pre_sync(GnomePilotConduit *c, GnomePilotDBInfo *dbi)
+{
+ int l;
+ unsigned char *buf;
+
+ gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi);
+
+ load_records(c);
+
+ buf = (unsigned char*)g_malloc(0xffff);
+ if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff))<0) {
+ return -1;
+ }
+ unpack_AppointmentAppInfo(&(GET_DATA(c)->ai),buf,l);
+ g_free(buf);
+
+ return 0;
+}
+
+static gint
+post_sync(GnomePilotConduit *c)
+{
+ return 0;
+}
static gint
match_record (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
@@ -169,15 +253,31 @@ transmit (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
return NULL;
}
-GnomePilotConduit *
+static GnomePilotConduit *
conduit_get_gpilot_conduit (guint32 pilotId)
{
GtkObject *retval;
+ ConduitCfg *cfg;
+ ConduitData *cdata;
+
+ CORBA_exception_init (&ev);
g_print ("creating our new conduit\n");
retval = gnome_pilot_conduit_standard_abs_new ("DatebookDB", 0x64617465);
-
g_assert (retval != NULL);
+ gnome_pilot_conduit_construct(GNOME_PILOT_CONDUIT(retval),"calendar");
+
+ cfg = g_new0(ConduitCfg,1);
+ g_assert(cfg != NULL);
+ gtk_object_set_data(retval,"conduit_cfg",cfg);
+
+ cdata = g_new0(ConduitData,1);
+ g_assert(cdata != NULL);
+ cdata = NULL;
+ gtk_object_set_data(retval,"conduit_data",cdata);
+
+ calendar = CORBA_OBJECT_NIL;
+
gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, NULL);
gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, NULL);
gtk_signal_connect (retval, "archive_local", (GtkSignalFunc) archive_local, NULL);
@@ -195,14 +295,30 @@ conduit_get_gpilot_conduit (guint32 pilotId)
gtk_signal_connect (retval, "free_transmit", (GtkSignalFunc) free_transmit, NULL);
gtk_signal_connect (retval, "delete_all", (GtkSignalFunc) delete_all, NULL);
gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, NULL);
- g_print ("*\n*\n Done connecting signals\n\n");
+ gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, NULL);
+ gtk_signal_connect (retval, "post_sync", (GtkSignalFunc) post_sync, NULL);
+
+ load_configuration(&cfg,pilotId);
return GNOME_PILOT_CONDUIT (retval);
}
-void
+
+static void
conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
-{
+{
+ ConduitCfg *cc;
+ ConduitData *cd;
+
+ cc = GET_CONFIG(conduit);
+ destroy_configuration(&cc);
+
+ cd = GET_DATA(conduit);
+ if(cd->cal!=NULL) calendar_destroy(cd->cal);
+
gtk_object_destroy (GTK_OBJECT (conduit));
+
+ GNOME_Calendar_Repository_done (calendar_server(), &ev);
+
}
diff --git a/calendar/gui/calendar-conduit.h b/calendar/gui/calendar-conduit.h
new file mode 100644
index 0000000000..5b7be2367d
--- /dev/null
+++ b/calendar/gui/calendar-conduit.h
@@ -0,0 +1,52 @@
+/* $Id$ */
+
+#ifndef __CALENDAR_CONDUIT_H__
+#define __CALENDAR_CONDUIT_H__
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pi-datebook.h>
+#include <gnome.h>
+
+
+typedef struct _ConduitCfg ConduitCfg;
+
+struct _ConduitCfg {
+ gboolean open_secret;
+ guint32 pilotId;
+};
+
+#define GET_CONFIG(c) ((ConduitCfg*)gtk_object_get_data(GTK_OBJECT(c),"conduit_cfg"))
+
+static void load_configuration(ConduitCfg **c,guint32 pilotId) {
+ gchar prefix[256];
+ g_snprintf(prefix,255,"/gnome-pilot.d/calendard-conduit/Pilot_%u/",pilotId);
+
+ *c = g_new0(ConduitCfg,1);
+ gnome_config_push_prefix(prefix);
+ (*c)->open_secret = gnome_config_get_bool("open secret=FALSE");
+ gnome_config_pop_prefix();
+
+ (*c)->pilotId = pilotId;
+}
+
+static void save_configuration(ConduitCfg *c) {
+ gchar prefix[256];
+
+ 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_pop_prefix();
+
+ gnome_config_sync();
+ gnome_config_drop_all();
+}
+
+static void destroy_configuration(ConduitCfg **c) {
+ g_free(*c);
+ *c = NULL;
+}
+
+#endif __CALENDAR_CONDUIT_H__
diff --git a/calendar/gui/corba-cal.c b/calendar/gui/corba-cal.c
index f322b41db8..3e95571f6c 100644
--- a/calendar/gui/corba-cal.c
+++ b/calendar/gui/corba-cal.c
@@ -179,6 +179,33 @@ cal_repo_update_pilot_id (PortableServer_Servant servant,
}
static CORBA_char *
+cal_repo_get_objects (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal = gnomecal_from_servant (servant);
+ Calendar *dirty_cal;
+ GList *l;
+ char *str;
+ CORBA_char *res;
+
+ dirty_cal = calendar_new ("Temporal");
+
+ for (l = gcal->cal->events; l; l = l->next){
+ iCalObject *obj = l->data;
+
+ obj = ical_object_duplicate (l->data);
+
+ calendar_add_object (dirty_cal, obj);
+ }
+ str = calendar_get_as_vcal_string (dirty_cal);
+ res = CORBA_string_dup (str);
+ g_free (str);
+ calendar_destroy (dirty_cal);
+
+ return res;
+}
+
+static CORBA_char *
cal_repo_get_updated_objects (PortableServer_Servant servant,
CORBA_Environment *ev)
{
@@ -225,6 +252,7 @@ init_calendar_repo_class (void)
calendar_repository_epv.get_id_from_pilot_id = cal_repo_get_id_from_pilot_id;
calendar_repository_epv.delete_object = cal_repo_delete_object;
calendar_repository_epv.update_object = cal_repo_update_object;
+ calendar_repository_epv.get_objects = cal_repo_get_objects;
calendar_repository_epv.get_updated_objects = cal_repo_get_updated_objects;
calendar_repository_epv.update_pilot_id = cal_repo_update_pilot_id;
@@ -263,4 +291,3 @@ gnome_calendar_create_corba_server (GnomeCalendar *calendar)
poa, calendar_servant, &ev);
CORBA_exception_free (&ev);
}
-
diff --git a/calendar/gui/todo-conduit-control-applet.c b/calendar/gui/todo-conduit-control-applet.c
new file mode 100644
index 0000000000..def35ca376
--- /dev/null
+++ b/calendar/gui/todo-conduit-control-applet.c
@@ -0,0 +1,278 @@
+/* Control applet ("capplet") for the gnome-pilot todo 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 <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 "todo-conduit.h"
+
+/* tell changes callbacks to ignore changes or not */
+static gboolean ignore_changes=FALSE;
+
+/* capplet widget */
+static GtkWidget *capplet=NULL;
+
+/* host/device/pilot configuration windows */
+GtkWidget *cfgOptionsWindow=NULL;
+GtkWidget *cfgStateWindow=NULL;
+GtkWidget *dialogWindow=NULL;
+
+gboolean activated,org_activation_state;
+GnomePilotConduitMgmt *conduit;
+
+static void doTrySettings(GtkWidget *widget, ConduitCfg *conduitCfg);
+static void doRevertSettings(GtkWidget *widget, ConduitCfg *conduitCfg);
+static void doSaveSettings(GtkWidget *widget, ConduitCfg *conduitCfg);
+
+static void readStateCfg(GtkWidget *w);
+static void setStateCfg(GtkWidget *w);
+
+gchar *pilotId;
+CORBA_Environment ev;
+
+static void
+doTrySettings(GtkWidget *widget, ConduitCfg *conduitCfg)
+{
+ readStateCfg(cfgStateWindow);
+ if(activated)
+ gpilotd_conduit_mgmt_enable(conduit,pilotId);
+ else
+ gpilotd_conduit_mgmt_disable(conduit,pilotId);
+}
+
+static void
+doSaveSettings(GtkWidget *widget, ConduitCfg *conduitCfg)
+{
+ doTrySettings(widget, conduitCfg);
+ save_configuration(NULL);
+}
+
+
+static void
+doRevertSettings(GtkWidget *widget, ConduitCfg *conduitCfg)
+{
+ activated = org_activation_state;
+ setStateCfg(cfgStateWindow);
+}
+
+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)
+{
+ if (!ignore_changes)
+ capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
+}
+
+static void
+clist_changed(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};
+
+ about = gnome_about_new(_("Gpilotd todo conduit"), VERSION,
+ _("(C) 1998 the Free Software Foundation"),
+ authors,
+ _("Configuration utility for the todo conduit.\n"),
+ _("gnome-unknown.xpm"));
+ gtk_widget_show (about);
+
+ return;
+}
+
+static void toggled_cb(GtkWidget *widget, gpointer data) {
+ gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(widget)->active);
+ capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
+}
+
+static GtkWidget
+*createStateCfgWindow(void)
+{
+ GtkWidget *vbox, *table;
+ GtkWidget *entry, *label;
+ GtkWidget *button;
+
+ vbox = gtk_vbox_new(FALSE, GNOME_PAD);
+
+ table = gtk_table_new(2, 2, FALSE);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 4);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 10);
+ gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD);
+
+ label = gtk_label_new(_("Enabled"));
+ gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1,2);
+
+ button = gtk_check_button_new();
+ gtk_object_set_data(GTK_OBJECT(vbox), "conduit_on_off", button);
+ gtk_signal_connect(GTK_OBJECT(button), "toggled",
+ GTK_SIGNAL_FUNC(toggled_cb),
+ NULL);
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 1,2);
+
+ return vbox;
+}
+
+static void
+setStateCfg(GtkWidget *cfg)
+{
+ GtkWidget *button;
+ gchar num[40];
+
+ button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off");
+
+ g_assert(button!=NULL);
+
+ ignore_changes = TRUE;
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),activated);
+ gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(button)->active);
+ ignore_changes = FALSE;
+}
+
+
+static void
+readStateCfg(GtkWidget *cfg)
+{
+ GtkWidget *button;
+
+ button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off");
+
+ g_assert(button!=NULL);
+
+ activated = GTK_TOGGLE_BUTTON(button)->active;
+}
+
+static void
+pilot_capplet_setup(void)
+{
+ GtkWidget *frame, *table;
+
+ capplet = capplet_widget_new();
+
+ table = gtk_table_new(1, 2, FALSE);
+ gtk_container_border_width(GTK_CONTAINER(table), GNOME_PAD);
+ gtk_container_add(GTK_CONTAINER(capplet), table);
+
+ frame = gtk_frame_new(_("Conduit state"));
+ gtk_container_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL);
+ gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1);
+ cfgStateWindow = createStateCfgWindow();
+ gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow);
+
+ gtk_signal_connect(GTK_OBJECT(capplet), "try",
+ GTK_SIGNAL_FUNC(doTrySettings), NULL);
+ gtk_signal_connect(GTK_OBJECT(capplet), "revert",
+ GTK_SIGNAL_FUNC(doRevertSettings), NULL);
+ gtk_signal_connect(GTK_OBJECT(capplet), "ok",
+ GTK_SIGNAL_FUNC(doSaveSettings), NULL);
+ gtk_signal_connect(GTK_OBJECT(capplet), "help",
+ GTK_SIGNAL_FUNC(about_cb), NULL);
+
+
+ setStateCfg(cfgStateWindow);
+
+ gtk_widget_show_all(capplet);
+}
+
+void 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);
+ gnome_dialog_run_and_close(GNOME_DIALOG(dialogWindow));
+ va_end(ap);
+}
+
+gchar *get_pilot_id_from_gpilotd() {
+ gchar **pilots;
+ int i;
+
+ i=0;
+ gpilotd_get_pilots(&pilots);
+ if(pilots) {
+ while(pilots[i]) { g_message("pilot %d = \"%s\"",i,pilots[i]); i++; }
+ if(i==0) {
+ run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
+ return NULL;
+ } 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."));
+ return NULL;
+ }
+}
+
+int
+main( int argc, char *argv[] )
+{
+ /* we're a capplet */
+ gnome_capplet_init ("todo conduit control applet", NULL, argc, argv,
+ NULL,
+ 0, NULL);
+
+ /* put all code to set things up in here */
+ conduit = gpilotd_conduit_mgmt_new("todo_conduit");
+
+ /* get pilot name from gpilotd */
+ /* 1. initialize the gpilotd connection */
+ gpilotd_init(&argc,argv);
+ /* 2 connect to gpilotd */
+ if(!gpilotd_connect()) g_error("Cannot connect to gpilotd");
+
+ pilotId = get_pilot_id_from_gpilotd();
+ if(!pilotId) return -1;
+ org_activation_state = activated = gpilotd_conduit_mgmt_is_enabled(conduit,pilotId);
+
+ pilot_capplet_setup();
+
+
+ /* done setting up, now run main loop */
+ capplet_gtk_main();
+ g_free(pilotId);
+ return 0;
+}
diff --git a/calendar/gui/todo-conduit.c b/calendar/gui/todo-conduit.c
new file mode 100644
index 0000000000..3a543816af
--- /dev/null
+++ b/calendar/gui/todo-conduit.c
@@ -0,0 +1,256 @@
+/* $Id$ */
+
+#include <glib.h>
+#include <gnome.h>
+
+#include <pi-source.h>
+#include <pi-socket.h>
+#include <pi-file.h>
+#include <pi-dlp.h>
+#include <pi-version.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <utime.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <signal.h>
+#include <errno.h>
+#include <gpilotd/gnome-pilot-conduit.h>
+#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
+
+#include "todo-conduit.h"
+
+static gint
+load_records(GnomePilotConduit *c)
+{
+ return 0;
+}
+
+static gint
+pre_sync(GnomePilotConduit *c, GnomePilotDBInfo *dbi) {
+ int l;
+ unsigned char *buf;
+
+ gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi);
+
+ load_records(c);
+
+ buf = (unsigned char*)g_malloc(0xffff);
+ if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff))<0) {
+ return -1;
+ }
+ unpack_ToDoAppInfo(&(GET_DATA(c)->ai),buf,l);
+ g_free(buf);
+
+ return 0;
+}
+
+static gint
+post_sync(GnomePilotConduit *c) {
+ return 0;
+}
+
+static gint
+match_record (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ LocalRecord **local,
+ PilotRecord *remote,
+ gpointer data)
+{
+ g_print ("in match_record\n");
+ return 0;
+}
+static gint
+free_match (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ LocalRecord **local,
+ gpointer data)
+{
+ g_print ("entering free_match\n");
+ *local = NULL;
+
+ return 0;
+}
+static gint
+archive_local (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ LocalRecord *local,
+ gpointer data)
+{
+ g_print ("entering archive_local\n");
+ return 1;
+
+}
+static gint
+archive_remote (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ LocalRecord *local,
+ PilotRecord *remote,
+ gpointer data)
+{
+ g_print ("entering archive_remote\n");
+ return 1;
+}
+static gint
+store_remote (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ PilotRecord *remote,
+ gpointer data)
+{
+ g_print ("entering store_remote\n");
+ g_print ("Rec:%s:\nLength:%d\n", remote->record, remote->length);
+ return 1;
+}
+static gint
+clear_status_archive_local (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ LocalRecord *local,
+ gpointer data)
+{
+ g_print ("entering clear_status_archive_local\n");
+ return 1;
+}
+static gint
+iterate (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ LocalRecord **local,
+ gpointer data)
+{
+ g_print ("entering iterate\n");
+ return 1;
+}
+static gint
+iterate_specific (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ LocalRecord **local,
+ gint flag,
+ gint archived,
+ gpointer data)
+{
+ g_print ("entering iterate_specific\n");
+ return 1;
+}
+static gint
+purge (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ gpointer data)
+{
+ g_print ("entering purge\n");
+ return 1;
+}
+static gint
+set_status (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ LocalRecord *local,
+ gint status,
+ gpointer data)
+{
+ g_print ("entering set_status\n");
+ return 1;
+}
+static gint
+set_archived (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ LocalRecord *local,
+ gint archived,
+ gpointer data)
+{
+ g_print ("entering set_archived\n");
+ return 1;
+}
+static gint
+set_pilot_id (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ LocalRecord *local,
+ guint32 ID,
+ gpointer data)
+{
+ g_print ("entering set_pilot_id\n");
+ return 1;
+}
+static gint
+compare (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ LocalRecord *local,
+ PilotRecord *remote,
+ gpointer data)
+{
+ g_print ("entering compare\n");
+ return 1;
+}
+static gint
+compare_backup (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ LocalRecord *local,
+ PilotRecord *remote,
+ gpointer data)
+{
+ g_print ("entering compare_backup\n");
+ return 1;
+}
+static gint
+free_transmit (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ LocalRecord *local,
+ PilotRecord *remote,
+ gpointer data)
+{
+ g_print ("entering free_transmit\n");
+ return 1;
+}
+static gint
+delete_all (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ gpointer data)
+{
+ g_print ("entering delete_all\n");
+ return 1;
+}
+static PilotRecord *
+transmit (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
+ LocalRecord *local,
+ gpointer data)
+{
+ g_print ("entering transmit\n");
+ return NULL;
+}
+
+static GnomePilotConduit *
+conduit_get_gpilot_conduit (guint32 pilotId)
+{
+ GtkObject *retval;
+ ConduitCfg *cfg;
+ ConduitData *cdata;
+
+ g_print ("creating our new conduit\n");
+ retval = gnome_pilot_conduit_standard_abs_new ("TodoDB", 0x0);
+ g_assert (retval != NULL);
+ gnome_pilot_conduit_construct(GNOME_PILOT_CONDUIT(retval),"todo");
+
+ cfg = g_new0(ConduitCfg,1);
+ g_assert(cfg != NULL);
+ gtk_object_set_data(retval,"conduit_cfg",cfg);
+
+ cdata = g_new0(ConduitData,1);
+ g_assert(cdata != NULL);
+ gtk_object_set_data(retval,"conduit_data",cdata);
+
+ gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, NULL);
+ gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, NULL);
+ gtk_signal_connect (retval, "archive_local", (GtkSignalFunc) archive_local, NULL);
+ gtk_signal_connect (retval, "archive_remote", (GtkSignalFunc) archive_remote, NULL);
+ gtk_signal_connect (retval, "store_remote", (GtkSignalFunc) store_remote, NULL);
+ gtk_signal_connect (retval, "clear_status_archive_local", (GtkSignalFunc) clear_status_archive_local, NULL);
+ gtk_signal_connect (retval, "iterate", (GtkSignalFunc) iterate, NULL);
+ gtk_signal_connect (retval, "iterate_specific", (GtkSignalFunc) iterate_specific, NULL);
+ gtk_signal_connect (retval, "purge", (GtkSignalFunc) purge, NULL);
+ gtk_signal_connect (retval, "set_status", (GtkSignalFunc) set_status, NULL);
+ gtk_signal_connect (retval, "set_archived", (GtkSignalFunc) set_archived, NULL);
+ gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, NULL);
+ gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, NULL);
+ gtk_signal_connect (retval, "compare_backup", (GtkSignalFunc) compare_backup, NULL);
+ gtk_signal_connect (retval, "free_transmit", (GtkSignalFunc) free_transmit, NULL);
+ gtk_signal_connect (retval, "delete_all", (GtkSignalFunc) delete_all, NULL);
+ gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, NULL);
+ gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, NULL);
+ gtk_signal_connect (retval, "post_sync", (GtkSignalFunc) post_sync, NULL);
+
+ load_configuration(&cfg,pilotId);
+
+ return GNOME_PILOT_CONDUIT (retval);
+}
+static void
+conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
+{
+ ConduitCfg *cc;
+ cc = GET_CONFIG(conduit);
+ destroy_configuration(&cc);
+ gtk_object_destroy (GTK_OBJECT (conduit));
+}
+
+
diff --git a/calendar/gui/todo-conduit.h b/calendar/gui/todo-conduit.h
new file mode 100644
index 0000000000..c224b2b1f3
--- /dev/null
+++ b/calendar/gui/todo-conduit.h
@@ -0,0 +1,59 @@
+/* $Id$ */
+
+#ifndef __TODO_CONDUIT_H__
+#define __TODO_CONDUIT_H__
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pi-todo.h>
+#include <gnome.h>
+
+typedef struct _ConduitCfg ConduitCfg;
+
+struct _ConduitCfg {
+ gboolean open_secret;
+ guint32 pilotId;
+};
+
+#define GET_CONFIG(c) ((ConduitCfg*)gtk_object_get_data(GTK_OBJECT(c),"conduit_cfg"))
+
+typedef struct _ConduitData ConduitData;
+
+struct _ConduitData {
+ struct ToDoAppInfo ai;
+};
+
+#define GET_DATA(c) ((ConduitData*)gtk_object_get_data(GTK_OBJECT(c),"conduit_data"))
+
+static void load_configuration(ConduitCfg **c,guint32 pilotId) {
+ gchar prefix[256];
+ g_snprintf(prefix,255,"/gnome-pilot.d/todod-conduit/Pilot_%u/",pilotId);
+
+ *c = g_new0(ConduitCfg,1);
+ gnome_config_push_prefix(prefix);
+ (*c)->open_secret = gnome_config_get_bool("open secret=FALSE");
+ gnome_config_pop_prefix();
+
+ (*c)->pilotId = pilotId;
+}
+
+static void save_configuration(ConduitCfg *c) {
+ gchar prefix[256];
+
+ g_snprintf(prefix,255,"/gnome-pilot.d/todo-conduit/Pilot_%u/",c->pilotId);
+
+ gnome_config_push_prefix(prefix);
+ gnome_config_set_bool("open secret",c->open_secret);
+ gnome_config_pop_prefix();
+
+ gnome_config_sync();
+ gnome_config_drop_all();
+}
+
+static void destroy_configuration(ConduitCfg **c) {
+ g_free(*c);
+ *c = NULL;
+}
+
+#endif __TODO_CONDUIT_H__