aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/caldav
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/caldav')
-rw-r--r--plugins/caldav/ChangeLog26
-rw-r--r--plugins/caldav/caldav-source.c171
-rw-r--r--plugins/caldav/org-gnome-evolution-caldav.eplug.xml2
3 files changed, 183 insertions, 16 deletions
diff --git a/plugins/caldav/ChangeLog b/plugins/caldav/ChangeLog
index 5463c6124e..8236b8f2e2 100644
--- a/plugins/caldav/ChangeLog
+++ b/plugins/caldav/ChangeLog
@@ -1,3 +1,29 @@
+2008-12-08 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #562990
+
+ * caldav-source.c: (user_changed), (oge_caldav): Use 'username'
+ property of the ESource to read/write user name, not the uri.
+
+2008-11-28 Milan Crha <mcrha@redhat.com>
+
+ ** Part of fix for bug #503662
+
+ * caldav-source.c: (user_changed):
+ Set NULL properly to protect against using already freed memory.
+
+2008-11-28 Milan Crha <mcrha@redhat.com>
+
+ ** Part of fix for bug #359745
+
+ * caldav-source.c: (ensure_caldav_source_group),
+ (e_plugin_lib_enable): Ensure source group for VTODO and VJOURNAL too.
+ * caldav-source.c: (set_refresh_time), (get_refresh_minutes),
+ (spin_changed), (option_changed), (oge_caldav):
+ Be able to change refresh time for the CalDAV sources.
+ * org-gnome-evolution-caldav.eplug.xml:
+ Show CalDAV options under all the other standard options.
+
2008-09-02 Sankar P <psankar@novell.com>
License Changes
diff --git a/plugins/caldav/caldav-source.c b/plugins/caldav/caldav-source.c
index 24bf2040f3..6fb7ea3841 100644
--- a/plugins/caldav/caldav-source.c
+++ b/plugins/caldav/caldav-source.c
@@ -52,21 +52,31 @@ GtkWidget * oge_caldav (EPlugin *epl,
/* plugin intialization */
static void
-ensure_caldav_source_group (void)
+ensure_caldav_source_group (ECalSourceType source_type)
{
ESourceList *slist;
- ESourceGroup *group;
-
+ GSList *groups, *g;
+ ESourceGroup *group = NULL;
- if (!e_cal_get_sources (&slist, E_CAL_SOURCE_TYPE_EVENT, NULL)) {
+ if (!e_cal_get_sources (&slist, source_type, NULL)) {
g_warning ("Could not get calendar source list from GConf!");
return;
}
- group = e_source_list_peek_group_by_name (slist, _("CalDAV"));
+ groups = e_source_list_peek_groups (slist);
+ for (g = groups; g; g = g->next) {
+ group = E_SOURCE_GROUP (g->data);
+
+ if (group && e_source_group_peek_base_uri (group) && strncmp ("caldav://", e_source_group_peek_base_uri (group), 9) == 0)
+ break;
+
+ group = NULL;
+ }
if (group == NULL) {
+ /* no such group has been found, create it */
gboolean res;
+
group = e_source_group_new (_("CalDAV"), "caldav://");
res = e_source_list_add_group (slist, group, -1);
@@ -77,8 +87,12 @@ ensure_caldav_source_group (void)
}
g_object_unref (group);
- g_object_unref (slist);
+ } else {
+ /* we found the group, change the name based on the actual language */
+ e_source_group_set_name (group, _("CalDAV"));
}
+
+ g_object_unref (slist);
}
int
@@ -87,7 +101,9 @@ e_plugin_lib_enable (EPluginLib *ep, int enable)
if (enable) {
d(g_print ("CalDAV Eplugin starting up ...\n"));
- ensure_caldav_source_group ();
+ ensure_caldav_source_group (E_CAL_SOURCE_TYPE_EVENT);
+ ensure_caldav_source_group (E_CAL_SOURCE_TYPE_TODO);
+ ensure_caldav_source_group (E_CAL_SOURCE_TYPE_JOURNAL);
}
return 0;
@@ -174,21 +190,100 @@ user_changed (GtkEntry *editable, ESource *source)
euri = e_uri_new (uri);
g_free (euri->user);
+ euri->user = NULL;
- if (user != NULL) {
- euri->user = g_strdup (user);
+ if (user != NULL && *user) {
e_source_set_property (source, "auth", "1");
} else {
e_source_set_property (source, "auth", NULL);
}
- e_source_set_property (source, "username", euri->user);
+ e_source_set_property (source, "username", user);
ruri = print_uri_noproto (euri);
e_source_set_relative_uri (source, ruri);
g_free (ruri);
e_uri_free (euri);
}
+static void
+set_refresh_time (ESource *source, GtkWidget *spin, GtkWidget *option)
+{
+ int time;
+ int item_num = 0;
+ const char *refresh_str = e_source_get_property (source, "refresh");
+ time = refresh_str ? atoi (refresh_str) : 30;
+
+ if (time && !(time % 10080)) {
+ /* weeks */
+ item_num = 3;
+ time /= 10080;
+ } else if (time && !(time % 1440)) {
+ /* days */
+ item_num = 2;
+ time /= 1440;
+ } else if (time && !(time % 60)) {
+ /* hours */
+ item_num = 1;
+ time /= 60;
+ }
+ gtk_option_menu_set_history (GTK_OPTION_MENU (option), item_num);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time);
+}
+
+static char *
+get_refresh_minutes (GtkWidget *spin, GtkWidget *option)
+{
+ int setting = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
+ switch (gtk_option_menu_get_history (GTK_OPTION_MENU (option))) {
+ case 0:
+ /* minutes */
+ break;
+ case 1:
+ /* hours */
+ setting *= 60;
+ break;
+ case 2:
+ /* days */
+ setting *= 1440;
+ break;
+ case 3:
+ /* weeks - is this *really* necessary? */
+ setting *= 10080;
+ break;
+ default:
+ g_warning ("Time unit out of range");
+ break;
+ }
+
+ return g_strdup_printf ("%d", setting);
+}
+
+static void
+spin_changed (GtkSpinButton *spin, ESource *source)
+{
+ char *refresh_str;
+ GtkWidget *option;
+
+ option = g_object_get_data (G_OBJECT (spin), "option");
+
+ refresh_str = get_refresh_minutes ((GtkWidget *) spin, option);
+ e_source_set_property (source, "refresh", refresh_str);
+ g_free (refresh_str);
+}
+
+static void
+option_changed (GtkOptionMenu *option, ESource *source)
+{
+ char *refresh_str;
+ GtkWidget *spin;
+
+ spin = g_object_get_data (G_OBJECT (option), "spin");
+
+ refresh_str = get_refresh_minutes (spin, (GtkWidget *) option);
+ e_source_set_property (source, "refresh", refresh_str);
+ g_free (refresh_str);
+}
+
GtkWidget *
oge_caldav (EPlugin *epl,
EConfigHookItemFactoryData *data)
@@ -204,11 +299,13 @@ oge_caldav (EPlugin *epl,
GtkWidget *widget;
GtkWidget *luser;
GtkWidget *user;
+ GtkWidget *label, *hbox, *spin, *option, *menu;
+ GtkWidget *times[4];
char *uri;
char *username;
const char *ssl_prop;
gboolean ssl_enabled;
- int row;
+ int row, i;
source = t->source;
group = e_source_peek_group (source);
@@ -230,10 +327,12 @@ oge_caldav (EPlugin *epl,
return NULL;
}
- username = euri->user;
+ g_free (euri->user);
euri->user = NULL;
uri = e_uri_to_string (euri, FALSE);
+ username = e_source_get_duped_property (source, "username");
+
ssl_prop = e_source_get_property (source, "ssl");
if (ssl_prop && ssl_prop[0] == '1') {
ssl_enabled = TRUE;
@@ -268,12 +367,14 @@ oge_caldav (EPlugin *epl,
G_CALLBACK (location_changed),
source);
+ row++;
+
cssl = gtk_check_button_new_with_mnemonic (_("Use _SSL"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cssl), ssl_enabled);
gtk_widget_show (cssl);
gtk_table_attach (GTK_TABLE (parent),
cssl, 1, 2,
- row + 1, row + 2,
+ row , row + 1,
GTK_FILL, 0, 0, 0);
g_signal_connect (G_OBJECT (cssl),
@@ -281,19 +382,21 @@ oge_caldav (EPlugin *epl,
G_CALLBACK (ssl_changed),
source);
+ row++;
+
luser = gtk_label_new_with_mnemonic (_("User_name:"));
gtk_widget_show (luser);
gtk_misc_set_alignment (GTK_MISC (luser), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (parent),
luser, 0, 1,
- row + 2, row + 3,
+ row, row + 1,
GTK_FILL, 0, 0, 0);
user = gtk_entry_new ();
gtk_widget_show (user);
gtk_entry_set_text (GTK_ENTRY (user), username ? username : "");
gtk_table_attach (GTK_TABLE (parent), user,
- 1, 2, row + 2, row + 3,
+ 1, 2, row, row + 1,
GTK_EXPAND | GTK_FILL, 0, 0, 0);
gtk_label_set_mnemonic_widget (GTK_LABEL (luser), user);
@@ -303,10 +406,48 @@ oge_caldav (EPlugin *epl,
G_CALLBACK (user_changed),
source);
+ row++;
g_free (uri);
g_free (username);
+ /* add refresh option */
+ label = gtk_label_new_with_mnemonic (_("Re_fresh:"));
+ gtk_widget_show (label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row+1, GTK_FILL, 0, 0, 0);
+
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_widget_show (hbox);
+
+ spin = gtk_spin_button_new_with_range (0, 100, 1);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin);
+ gtk_widget_show (spin);
+ gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, TRUE, 0);
+
+ option = gtk_option_menu_new ();
+ gtk_widget_show (option);
+ times[0] = gtk_menu_item_new_with_label (_("minutes"));
+ times[1] = gtk_menu_item_new_with_label (_("hours"));
+ times[2] = gtk_menu_item_new_with_label (_("days"));
+ times[3] = gtk_menu_item_new_with_label (_("weeks"));
+ menu = gtk_menu_new ();
+ gtk_widget_show (menu);
+ for (i = 0; i < 4; i++) {
+ gtk_widget_show (times[i]);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), times[i]);
+ }
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (option), menu);
+ set_refresh_time (source, spin, option);
+ gtk_box_pack_start (GTK_BOX (hbox), option, FALSE, TRUE, 0);
+
+ g_object_set_data (G_OBJECT (option), "spin", spin);
+ g_signal_connect (G_OBJECT (option), "changed", G_CALLBACK (option_changed), source);
+ g_object_set_data (G_OBJECT (spin), "option", option);
+ g_signal_connect (G_OBJECT (spin), "value-changed", G_CALLBACK (spin_changed), source);
+
+ gtk_table_attach (GTK_TABLE (parent), hbox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+
return widget;
}
diff --git a/plugins/caldav/org-gnome-evolution-caldav.eplug.xml b/plugins/caldav/org-gnome-evolution-caldav.eplug.xml
index dc728f1e7f..368570d49b 100644
--- a/plugins/caldav/org-gnome-evolution-caldav.eplug.xml
+++ b/plugins/caldav/org-gnome-evolution-caldav.eplug.xml
@@ -17,7 +17,7 @@
id="org.gnome.evolution.calendar.calendarProperties">
<item type="item_table"
- path="00.general/00.source/15.caldav"
+ path="00.general/00.source/99.caldav"
factory="oge_caldav"/>
</group>