aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/conduits
diff options
context:
space:
mode:
authorJP Rosevear <jpr@novell.com>2004-08-03 02:33:39 +0800
committerJP Rosevear <jpr@src.gnome.org>2004-08-03 02:33:39 +0800
commit5bf015c170d771049f19c008ae9297deb725b0f4 (patch)
tree5b50c805a13736b92d3e54f60be1a46f6ce46cb1 /calendar/conduits
parent3014d0ac205f89e275945ceea1392caaa69ff6fc (diff)
downloadgsoc2013-evolution-5bf015c170d771049f19c008ae9297deb725b0f4.tar
gsoc2013-evolution-5bf015c170d771049f19c008ae9297deb725b0f4.tar.gz
gsoc2013-evolution-5bf015c170d771049f19c008ae9297deb725b0f4.tar.bz2
gsoc2013-evolution-5bf015c170d771049f19c008ae9297deb725b0f4.tar.lz
gsoc2013-evolution-5bf015c170d771049f19c008ae9297deb725b0f4.tar.xz
gsoc2013-evolution-5bf015c170d771049f19c008ae9297deb725b0f4.tar.zst
gsoc2013-evolution-5bf015c170d771049f19c008ae9297deb725b0f4.zip
get source list and source (todoconduit_dupe_configuration): copy source
2004-08-01 JP Rosevear <jpr@novell.com> * conduits/todo/todo-conduit.c (todoconduit_load_configuration): get source list and source (todoconduit_dupe_configuration): copy source list and source (todoconduit_destroy_configuration): unref source list and source (start_calendar_server): open the source that was set earlier (fill_widgets): set the source option menu value (create_settings_window): pass source list to pilot settings (save_settings): mark source with pilot-sync property * conduits/calendar/calendar-conduit.c: as above * conduits/todo/Makefile.am: link to and include misc. widgets * conduits/calendar/Makefile.am: ditto svn path=/trunk/; revision=26798
Diffstat (limited to 'calendar/conduits')
-rw-r--r--calendar/conduits/calendar/Makefile.am3
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c54
-rw-r--r--calendar/conduits/todo/Makefile.am3
-rw-r--r--calendar/conduits/todo/todo-conduit.c58
4 files changed, 99 insertions, 19 deletions
diff --git a/calendar/conduits/calendar/Makefile.am b/calendar/conduits/calendar/Makefile.am
index 7bf53a7aed..0b6f78655f 100644
--- a/calendar/conduits/calendar/Makefile.am
+++ b/calendar/conduits/calendar/Makefile.am
@@ -1,6 +1,8 @@
INCLUDES = \
-I$(top_srcdir)/e-util \
-I$(top_builddir)/e-util \
+ -I$(top_srcdir)/widgets/misc \
+ -I$(top_builddir)/widgets/misc \
$(EVOLUTION_CALENDAR_CONDUIT_CFLAGS)
# Calendar Conduit
@@ -13,6 +15,7 @@ libecalendar_conduit_la_LDFLAGS = -module -avoid-version
libecalendar_conduit_la_LIBADD = \
$(top_builddir)/e-util/libeutil.la \
$(top_builddir)/e-util/libeconduit.la \
+ $(top_builddir)/widgets/misc/libemiscwidgets.la \
$(EVOLUTION_CALENDAR_CONDUIT_LIBS)
e-calendar-$(BASE_VERSION).conduit: e-calendar.conduit.in
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index e1ab03f7f8..7885dadb9e 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -94,6 +94,8 @@ struct _ECalConduitCfg {
guint32 pilot_id;
GnomePilotConduitSyncType sync_type;
+ ESourceList *source_list;
+ ESource *source;
gboolean secret;
gboolean multi_day_split;
@@ -130,6 +132,19 @@ calconduit_load_configuration (guint32 pilot_id)
g_snprintf (prefix, 255, "/gnome-pilot.d/e-calendar-conduit/Pilot_%u/", pilot_id);
gnome_config_push_prefix (prefix);
+ if (!e_cal_get_sources (&c->source_list, E_CAL_SOURCE_TYPE_EVENT, NULL))
+ c->source_list = NULL;
+ if (c->source_list) {
+ c->source = e_pilot_get_sync_source (c->source_list);
+ if (!c->source)
+ c->source = e_source_list_peek_source_any (c->source_list);
+ if (c->source) {
+ g_object_ref (c->source);
+ } else {
+ g_object_unref (c->source_list);
+ c->source_list = NULL;
+ }
+ }
c->secret = gnome_config_get_bool ("secret=FALSE");
c->multi_day_split = gnome_config_get_bool ("multi_day_split=TRUE");
if ((c->last_uri = gnome_config_get_string ("last_uri")) && !strncmp (c->last_uri, "file://", 7)) {
@@ -164,6 +179,7 @@ calconduit_save_configuration (ECalConduitCfg *c)
g_snprintf (prefix, 255, "/gnome-pilot.d/e-calendar-conduit/Pilot_%u/", c->pilot_id);
gnome_config_push_prefix (prefix);
+ e_pilot_set_sync_source (c->source_list, c->source);
gnome_config_set_bool ("secret", c->secret);
gnome_config_set_bool ("multi_day_split", c->multi_day_split);
gnome_config_set_string ("last_uri", c->last_uri);
@@ -184,6 +200,11 @@ calconduit_dupe_configuration (ECalConduitCfg *c)
retval = g_new0 (ECalConduitCfg, 1);
retval->pilot_id = c->pilot_id;
retval->sync_type = c->sync_type;
+
+ if (c->source_list)
+ retval->source_list = g_object_ref (c->source_list);
+ if (c->source)
+ retval->source = g_object_ref (c->source);
retval->secret = c->secret;
retval->multi_day_split = c->multi_day_split;
retval->last_uri = g_strdup (c->last_uri);
@@ -196,6 +217,8 @@ calconduit_destroy_configuration (ECalConduitCfg *c)
{
g_return_if_fail (c != NULL);
+ g_object_unref (c->source_list);
+ g_object_unref (c->source);
g_free (c->last_uri);
g_free (c);
}
@@ -407,14 +430,17 @@ static int
start_calendar_server (ECalConduitContext *ctxt)
{
g_return_val_if_fail (ctxt != NULL, -2);
-
- /* FIXME Need a mechanism for the user to select uri's */
- /* FIXME Can we use the cal model? */
-
- if (!e_cal_open_default (&ctxt->client, E_CAL_SOURCE_TYPE_EVENT, NULL, NULL, NULL))
+
+ if (ctxt->cfg->source) {
+ ctxt->client = e_cal_new (ctxt->cfg->source, E_CAL_SOURCE_TYPE_EVENT);
+ if (!e_cal_open (ctxt->client, TRUE, NULL))
+ return -1;
+ } else if (!e_cal_open_default (&ctxt->client, E_CAL_SOURCE_TYPE_EVENT, NULL, NULL, NULL)) {
return -1;
-
- return 0;
+ }
+
+ return 0;
+
}
/* Utility routines */
@@ -1801,6 +1827,9 @@ prepare (GnomePilotConduitSyncAbs *conduit,
static void
fill_widgets (ECalConduitContext *ctxt)
{
+ if (ctxt->cfg->source)
+ e_pilot_settings_set_source (E_PILOT_SETTINGS (ctxt->ps),
+ ctxt->cfg->source);
e_pilot_settings_set_secret (E_PILOT_SETTINGS (ctxt->ps),
ctxt->cfg->secret);
@@ -1813,8 +1842,11 @@ create_settings_window (GnomePilotConduit *conduit,
ECalConduitContext *ctxt)
{
LOG (g_message ( "create_settings_window" ));
+
+ if (!ctxt->cfg->source_list)
+ return -1;
- ctxt->ps = e_pilot_settings_new ();
+ ctxt->ps = e_pilot_settings_new (ctxt->cfg->source_list);
ctxt->gui = e_cal_gui_new (E_PILOT_SETTINGS (ctxt->ps));
gtk_container_add (GTK_CONTAINER (parent), ctxt->ps);
@@ -1835,8 +1867,12 @@ display_settings (GnomePilotConduit *conduit, ECalConduitContext *ctxt)
static void
save_settings (GnomePilotConduit *conduit, ECalConduitContext *ctxt)
{
- LOG (g_message ( "save_settings" ));
+ LOG (g_message ( "save_settings" ));
+ if (ctxt->new_cfg->source)
+ g_object_unref (ctxt->new_cfg->source);
+ ctxt->new_cfg->source = g_object_ref (e_pilot_settings_get_source (E_PILOT_SETTINGS (ctxt->ps)));
+ g_object_ref (ctxt->new_cfg->source);
ctxt->new_cfg->secret =
e_pilot_settings_get_secret (E_PILOT_SETTINGS (ctxt->ps));
e_cal_gui_fill_config (ctxt->gui, ctxt->new_cfg);
diff --git a/calendar/conduits/todo/Makefile.am b/calendar/conduits/todo/Makefile.am
index 15e7a81f84..8753a50395 100644
--- a/calendar/conduits/todo/Makefile.am
+++ b/calendar/conduits/todo/Makefile.am
@@ -1,6 +1,8 @@
INCLUDES = \
-I$(top_srcdir)/e-util \
-I$(top_builddir)/e-util \
+ -I$(top_srcdir)/widgets/misc \
+ -I$(top_builddir)/widgets/misc \
$(EVOLUTION_CALENDAR_CONDUIT_CFLAGS)
# ToDo Conduit
@@ -13,6 +15,7 @@ libetodo_conduit_la_LDFLAGS = -module -avoid-version
libetodo_conduit_la_LIBADD = \
$(top_builddir)/e-util/libeutil.la \
$(top_builddir)/e-util/libeconduit.la \
+ $(top_builddir)/widgets/misc/libemiscwidgets.la \
$(EVOLUTION_CALENDAR_CONDUIT_LIBS)
e-todo-$(BASE_VERSION).conduit: e-todo.conduit.in
diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c
index 8ec67f6d73..5e500b141a 100644
--- a/calendar/conduits/todo/todo-conduit.c
+++ b/calendar/conduits/todo/todo-conduit.c
@@ -48,7 +48,7 @@
GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
-#define CONDUIT_VERSION "0.1.5"
+#define CONDUIT_VERSION "0.1.6"
#define DEBUG_TODOCONDUIT 1
/* #undef DEBUG_TODOCONDUIT */
@@ -96,6 +96,8 @@ struct _EToDoConduitCfg {
guint32 pilot_id;
GnomePilotConduitSyncType sync_type;
+ ESourceList *source_list;
+ ESource *source;
gboolean secret;
gint priority;
@@ -109,6 +111,8 @@ todoconduit_load_configuration (guint32 pilot_id)
GnomePilotConduitManagement *management;
GnomePilotConduitConfig *config;
gchar prefix[256];
+
+
g_snprintf (prefix, 255, "/gnome-pilot.d/e-todo-conduit/Pilot_%u/",
pilot_id);
@@ -130,7 +134,21 @@ todoconduit_load_configuration (guint32 pilot_id)
/* Custom settings */
gnome_config_push_prefix (prefix);
-
+
+ if (!e_cal_get_sources (&c->source_list, E_CAL_SOURCE_TYPE_TODO, NULL))
+ c->source_list = NULL;
+ if (c->source_list) {
+ c->source = e_pilot_get_sync_source (c->source_list);
+ if (!c->source)
+ c->source = e_source_list_peek_source_any (c->source_list);
+ if (c->source) {
+ g_object_ref (c->source);
+ } else {
+ g_object_unref (c->source_list);
+ c->source_list = NULL;
+ }
+ }
+
c->secret = gnome_config_get_bool ("secret=FALSE");
c->priority = gnome_config_get_int ("priority=3");
c->last_uri = gnome_config_get_string ("last_uri");
@@ -149,6 +167,7 @@ todoconduit_save_configuration (EToDoConduitCfg *c)
c->pilot_id);
gnome_config_push_prefix (prefix);
+ e_pilot_set_sync_source (c->source_list, c->source);
gnome_config_set_bool ("secret", c->secret);
gnome_config_set_int ("priority", c->priority);
gnome_config_set_string ("last_uri", c->last_uri);
@@ -169,6 +188,10 @@ todoconduit_dupe_configuration (EToDoConduitCfg *c)
retval->sync_type = c->sync_type;
retval->pilot_id = c->pilot_id;
+ if (c->source_list)
+ retval->source_list = g_object_ref (c->source_list);
+ if (c->source)
+ retval->source = g_object_ref (c->source);
retval->secret = c->secret;
retval->priority = c->priority;
retval->last_uri = g_strdup (c->last_uri);
@@ -181,6 +204,8 @@ todoconduit_destroy_configuration (EToDoConduitCfg *c)
{
g_return_if_fail (c != NULL);
+ g_object_unref (c->source_list);
+ g_object_unref (c->source);
g_free (c->last_uri);
g_free (c);
}
@@ -270,7 +295,7 @@ static EToDoConduitContext *
e_todo_context_new (guint32 pilot_id)
{
EToDoConduitContext *ctxt = g_new0 (EToDoConduitContext, 1);
-
+
ctxt->cfg = todoconduit_load_configuration (pilot_id);
ctxt->new_cfg = todoconduit_dupe_configuration (ctxt->cfg);
ctxt->gui = NULL;
@@ -399,13 +424,15 @@ static int
start_calendar_server (EToDoConduitContext *ctxt)
{
g_return_val_if_fail (ctxt != NULL, -2);
-
- /* FIXME Need a mechanism for the user to select uri's */
- /* FIXME Can we use the cal model? */
-
- if (!e_cal_open_default (&ctxt->client, E_CAL_SOURCE_TYPE_TODO, NULL, NULL, NULL))
+
+ if (ctxt->cfg->source) {
+ ctxt->client = e_cal_new (ctxt->cfg->source, E_CAL_SOURCE_TYPE_TODO);
+ if (!e_cal_open (ctxt->client, TRUE, NULL))
+ return -1;
+ } else if (!e_cal_open_default (&ctxt->client, E_CAL_SOURCE_TYPE_TODO, NULL, NULL, NULL)) {
return -1;
-
+ }
+
return 0;
}
@@ -1292,6 +1319,9 @@ prepare (GnomePilotConduitSyncAbs *conduit,
static void
fill_widgets (EToDoConduitContext *ctxt)
{
+ if (ctxt->cfg->source)
+ e_pilot_settings_set_source (E_PILOT_SETTINGS (ctxt->ps),
+ ctxt->cfg->source);
e_pilot_settings_set_secret (E_PILOT_SETTINGS (ctxt->ps),
ctxt->cfg->secret);
@@ -1304,8 +1334,11 @@ create_settings_window (GnomePilotConduit *conduit,
EToDoConduitContext *ctxt)
{
LOG (g_message ( "create_settings_window" ));
+
+ if (!ctxt->cfg->source_list)
+ return -1;
- ctxt->ps = e_pilot_settings_new ();
+ ctxt->ps = e_pilot_settings_new (ctxt->cfg->source_list);
ctxt->gui = e_todo_gui_new (E_PILOT_SETTINGS (ctxt->ps));
gtk_container_add (GTK_CONTAINER (parent), ctxt->ps);
@@ -1315,6 +1348,7 @@ create_settings_window (GnomePilotConduit *conduit,
return 0;
}
+
static void
display_settings (GnomePilotConduit *conduit, EToDoConduitContext *ctxt)
{
@@ -1328,6 +1362,10 @@ save_settings (GnomePilotConduit *conduit, EToDoConduitContext *ctxt)
{
LOG (g_message ( "save_settings" ));
+ if (ctxt->new_cfg->source)
+ g_object_unref (ctxt->new_cfg->source);
+ ctxt->new_cfg->source = e_pilot_settings_get_source (E_PILOT_SETTINGS (ctxt->ps));
+ g_object_ref (ctxt->new_cfg->source);
ctxt->new_cfg->secret = e_pilot_settings_get_secret (E_PILOT_SETTINGS (ctxt->ps));
e_todo_gui_fill_config (ctxt->gui, ctxt->new_cfg);