aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/conduits
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/conduits')
-rw-r--r--calendar/conduits/calendar/calendar-conduit-control-applet.c279
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c126
-rw-r--r--calendar/conduits/calendar/calendar-conduit.h52
-rw-r--r--calendar/conduits/todo/todo-conduit-control-applet.c278
-rw-r--r--calendar/conduits/todo/todo-conduit.c256
-rw-r--r--calendar/conduits/todo/todo-conduit.h59
6 files changed, 1045 insertions, 5 deletions
diff --git a/calendar/conduits/calendar/calendar-conduit-control-applet.c b/calendar/conduits/calendar/calendar-conduit-control-applet.c
new file mode 100644
index 0000000000..f8e234ac13
--- /dev/null
+++ b/calendar/conduits/calendar/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/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index d9658f08a3..f7d1ebdd71 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/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/conduits/calendar/calendar-conduit.h b/calendar/conduits/calendar/calendar-conduit.h
new file mode 100644
index 0000000000..5b7be2367d
--- /dev/null
+++ b/calendar/conduits/calendar/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/conduits/todo/todo-conduit-control-applet.c b/calendar/conduits/todo/todo-conduit-control-applet.c
new file mode 100644
index 0000000000..def35ca376
--- /dev/null
+++ b/calendar/conduits/todo/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/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c
new file mode 100644
index 0000000000..3a543816af
--- /dev/null
+++ b/calendar/conduits/todo/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/conduits/todo/todo-conduit.h b/calendar/conduits/todo/todo-conduit.h
new file mode 100644
index 0000000000..c224b2b1f3
--- /dev/null
+++ b/calendar/conduits/todo/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__