aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-05-04 22:31:12 +0800
committerMilan Crha <mcrha@redhat.com>2009-05-04 22:31:12 +0800
commitb73ed1d9ffd6975d94638364b6a7fcd7f29a6c23 (patch)
tree8d4629a4e1e88fbd807e115667bcad514e81c378
parent62085ae755dcd578448ffb35be6cb911c58a89e7 (diff)
downloadgsoc2013-evolution-b73ed1d9ffd6975d94638364b6a7fcd7f29a6c23.tar
gsoc2013-evolution-b73ed1d9ffd6975d94638364b6a7fcd7f29a6c23.tar.gz
gsoc2013-evolution-b73ed1d9ffd6975d94638364b6a7fcd7f29a6c23.tar.bz2
gsoc2013-evolution-b73ed1d9ffd6975d94638364b6a7fcd7f29a6c23.tar.lz
gsoc2013-evolution-b73ed1d9ffd6975d94638364b6a7fcd7f29a6c23.tar.xz
gsoc2013-evolution-b73ed1d9ffd6975d94638364b6a7fcd7f29a6c23.tar.zst
gsoc2013-evolution-b73ed1d9ffd6975d94638364b6a7fcd7f29a6c23.zip
BUGFIX: 547414 - Publish Free/Busy calendar for configurable time
Allow user define time duration for the Free/Busy calendar information in the publish-calendar plugin.
-rw-r--r--plugins/publish-calendar/publish-calendar.glade102
-rw-r--r--plugins/publish-calendar/publish-format-fb.c18
-rw-r--r--plugins/publish-calendar/publish-location.c34
-rw-r--r--plugins/publish-calendar/publish-location.h8
-rw-r--r--plugins/publish-calendar/url-editor-dialog.c21
-rw-r--r--plugins/publish-calendar/url-editor-dialog.h5
6 files changed, 171 insertions, 17 deletions
diff --git a/plugins/publish-calendar/publish-calendar.glade b/plugins/publish-calendar/publish-calendar.glade
index 6f6ae9dcf2..1f1dca0202 100644
--- a/plugins/publish-calendar/publish-calendar.glade
+++ b/plugins/publish-calendar/publish-calendar.glade
@@ -382,7 +382,7 @@
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
- <property name="n_rows">2</property>
+ <property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
@@ -418,6 +418,24 @@
</child>
<child>
+ <widget class="GtkComboBox" id="type_selector">
+ <property name="visible">True</property>
+ <property name="items" translatable="yes">iCal
+Free/Busy</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
+
+ <child>
<widget class="GtkLabel" id="label29">
<property name="visible">True</property>
<property name="label" translatable="yes">Publishing _Frequency:</property>
@@ -439,8 +457,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@@ -458,25 +476,87 @@ Manual (via Actions menu)</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="fb_duration_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Time _duration:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">fb_duration_spin</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
- <property name="y_options">fill</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkComboBox" id="type_selector">
+ <widget class="GtkHBox" id="hbox20">
<property name="visible">True</property>
- <property name="items" translatable="yes">iCal
-Free/Busy</property>
- <property name="add_tearoffs">False</property>
- <property name="focus_on_click">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkSpinButton" id="fb_duration_spin">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="climb_rate">1</property>
+ <property name="digits">0</property>
+ <property name="numeric">False</property>
+ <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+ <property name="snap_to_ticks">False</property>
+ <property name="wrap">False</property>
+ <property name="adjustment">1 1 100 1 10 0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="fb_duration_combo">
+ <property name="visible">True</property>
+ <property name="items" translatable="yes">days
+weeks
+months</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
diff --git a/plugins/publish-calendar/publish-format-fb.c b/plugins/publish-calendar/publish-format-fb.c
index 5956b0ff8d..a4b3a44544 100644
--- a/plugins/publish-calendar/publish-format-fb.c
+++ b/plugins/publish-calendar/publish-format-fb.c
@@ -33,7 +33,7 @@
#include "publish-format-fb.h"
static gboolean
-write_calendar (gchar *uid, ESourceList *source_list, GOutputStream *stream, GError **error)
+write_calendar (gchar *uid, ESourceList *source_list, GOutputStream *stream, int dur_type, int dur_value, GError **error)
{
ESource *source;
ECal *client = NULL;
@@ -47,7 +47,19 @@ write_calendar (gchar *uid, ESourceList *source_list, GOutputStream *stream, GEr
utc = icaltimezone_get_utc_timezone ();
start = time_day_begin_with_zone (start, utc);
- end = time_add_week_with_zone (start, 6, utc);
+
+ switch (dur_type) {
+ case FB_DURATION_DAYS:
+ end = time_add_day_with_zone (start, dur_value, utc);
+ break;
+ default:
+ case FB_DURATION_WEEKS:
+ end = time_add_week_with_zone (start, dur_value, utc);
+ break;
+ case FB_DURATION_MONTHS:
+ end = time_add_month_with_zone (start, dur_value, utc);
+ break;
+ }
source = e_source_list_peek_source_by_uid (source_list, uid);
if (source)
@@ -109,7 +121,7 @@ publish_calendar_as_fb (GOutputStream *stream, EPublishUri *uri, GError **error)
l = uri->events;
while (l) {
gchar *uid = l->data;
- if (!write_calendar (uid, source_list, stream, error))
+ if (!write_calendar (uid, source_list, stream, uri->fb_duration_type, uri->fb_duration_value, error))
break;
l = g_slist_next (l);
}
diff --git a/plugins/publish-calendar/publish-location.c b/plugins/publish-calendar/publish-location.c
index 2de877b093..1ebe2cfefb 100644
--- a/plugins/publish-calendar/publish-location.c
+++ b/plugins/publish-calendar/publish-location.c
@@ -120,7 +120,7 @@ e_publish_uri_from_xml (const gchar *xml)
{
xmlDocPtr doc;
xmlNodePtr root, p;
- xmlChar *location, *enabled, *frequency;
+ xmlChar *location, *enabled, *frequency, *fb_duration_value, *fb_duration_type;
xmlChar *publish_time, *format, *username = NULL;
GSList *events = NULL;
EPublishUri *uri;
@@ -146,6 +146,8 @@ e_publish_uri_from_xml (const gchar *xml)
frequency = xmlGetProp (root, (const unsigned char *)"frequency");
format = xmlGetProp (root, (const unsigned char *)"format");
publish_time = xmlGetProp (root, (const unsigned char *)"publish_time");
+ fb_duration_value = xmlGetProp (root, (xmlChar *)"fb_duration_value");
+ fb_duration_type = xmlGetProp (root, (xmlChar *)"fb_duration_type");
if (location != NULL)
uri->location = (char *)location;
@@ -158,6 +160,23 @@ e_publish_uri_from_xml (const gchar *xml)
if (publish_time != NULL)
uri->last_pub_time = (char *)publish_time;
+ if (fb_duration_value)
+ uri->fb_duration_value = atoi ((char *)fb_duration_value);
+ else
+ uri->fb_duration_value = -1;
+
+ if (uri->fb_duration_value < 1)
+ uri->fb_duration_value = 6;
+ else if (uri->fb_duration_value > 100)
+ uri->fb_duration_value = 100;
+
+ if (fb_duration_type && g_str_equal ((char *)fb_duration_type, "days"))
+ uri->fb_duration_type = FB_DURATION_DAYS;
+ else if (fb_duration_type && g_str_equal ((char *)fb_duration_type, "months"))
+ uri->fb_duration_type = FB_DURATION_MONTHS;
+ else
+ uri->fb_duration_type = FB_DURATION_WEEKS;
+
uri->password = g_strdup ("");
for (p = root->children; p != NULL; p = p->next) {
@@ -173,6 +192,8 @@ e_publish_uri_from_xml (const gchar *xml)
xmlFree (enabled);
xmlFree (frequency);
xmlFree (format);
+ xmlFree (fb_duration_value);
+ xmlFree (fb_duration_type);
xmlFreeDoc (doc);
return uri;
@@ -204,6 +225,17 @@ e_publish_uri_to_xml (EPublishUri *uri)
xmlSetProp (root, (const unsigned char *)"format", (unsigned char *)format);
xmlSetProp (root, (const unsigned char *)"publish_time", (unsigned char *)uri->last_pub_time);
+ g_free (format);
+ format = g_strdup_printf ("%d", uri->fb_duration_value);
+ xmlSetProp (root, (xmlChar *)"fb_duration_value", (xmlChar *)format);
+
+ if (uri->fb_duration_type == FB_DURATION_DAYS)
+ xmlSetProp (root, (xmlChar *)"fb_duration_type", (xmlChar *)"days");
+ else if (uri->fb_duration_type == FB_DURATION_MONTHS)
+ xmlSetProp (root, (xmlChar *)"fb_duration_type", (xmlChar *)"months");
+ else
+ xmlSetProp (root, (xmlChar *)"fb_duration_type", (xmlChar *)"weeks");
+
for (calendars = uri->events; calendars != NULL; calendars = g_slist_next (calendars)) {
xmlNodePtr node;
node = xmlNewChild (root, NULL, (const unsigned char *)"event", NULL);
diff --git a/plugins/publish-calendar/publish-location.h b/plugins/publish-calendar/publish-location.h
index f3fbf03d49..ec627d18ce 100644
--- a/plugins/publish-calendar/publish-location.h
+++ b/plugins/publish-calendar/publish-location.h
@@ -56,6 +56,12 @@ static const int publish_format_type_mask[] = {
-1,
};
+enum FBDurationType {
+ FB_DURATION_DAYS,
+ FB_DURATION_WEEKS,
+ FB_DURATION_MONTHS
+};
+
typedef struct _EPublishUri EPublishUri;
struct _EPublishUri {
gboolean enabled;
@@ -65,6 +71,8 @@ struct _EPublishUri {
gchar *password;
GSList *events;
gchar *last_pub_time;
+ int fb_duration_value;
+ int fb_duration_type;
gint service_type;
};
diff --git a/plugins/publish-calendar/url-editor-dialog.c b/plugins/publish-calendar/url-editor-dialog.c
index 8e1c735dc3..ea03320ae8 100644
--- a/plugins/publish-calendar/url-editor-dialog.c
+++ b/plugins/publish-calendar/url-editor-dialog.c
@@ -90,6 +90,9 @@ create_uri (UrlEditorDialog *dialog)
g_free (username);
g_free (password);
}
+
+ uri->fb_duration_value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (dialog->fb_duration_spin));
+ uri->fb_duration_type = gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->fb_duration_combo));
}
static void
@@ -101,6 +104,16 @@ check_input (UrlEditorDialog *dialog)
uri = dialog->uri;
+ if (gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->type_selector)) == 1) {
+ gtk_widget_show (dialog->fb_duration_label);
+ gtk_widget_show (dialog->fb_duration_spin);
+ gtk_widget_show (dialog->fb_duration_combo);
+ } else {
+ gtk_widget_hide (dialog->fb_duration_label);
+ gtk_widget_hide (dialog->fb_duration_spin);
+ gtk_widget_hide (dialog->fb_duration_combo);
+ }
+
if (GTK_WIDGET_IS_SENSITIVE (dialog->events_selector)) {
sources = e_source_selector_get_selection (E_SOURCE_SELECTOR (dialog->events_selector));
n += g_slist_length (sources);
@@ -329,8 +342,11 @@ url_editor_dialog_construct (UrlEditorDialog *dialog)
dialog->gui = gui;
#define GW(name) ((dialog->name) = glade_xml_get_widget (dialog->gui, #name))
- GW(publish_frequency);
GW(type_selector);
+ GW(fb_duration_label);
+ GW(fb_duration_spin);
+ GW(fb_duration_combo);
+ GW(publish_frequency);
GW(events_swin);
@@ -429,6 +445,9 @@ url_editor_dialog_construct (UrlEditorDialog *dialog)
}
}
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->fb_duration_spin), uri->fb_duration_value);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->fb_duration_combo), uri->fb_duration_type);
+
g_signal_connect (G_OBJECT (dialog->publish_service), "changed", G_CALLBACK (publish_service_changed), dialog);
g_signal_connect (G_OBJECT (dialog->type_selector), "changed", G_CALLBACK (type_selector_changed), dialog);
g_signal_connect (G_OBJECT (dialog->publish_frequency), "changed", G_CALLBACK (frequency_changed_cb), dialog);
diff --git a/plugins/publish-calendar/url-editor-dialog.h b/plugins/publish-calendar/url-editor-dialog.h
index 2d985e90e5..3a85fc895e 100644
--- a/plugins/publish-calendar/url-editor-dialog.h
+++ b/plugins/publish-calendar/url-editor-dialog.h
@@ -64,8 +64,11 @@ struct _UrlEditorDialog {
GladeXML *gui;
- GtkWidget *publish_frequency;
GtkWidget *type_selector;
+ GtkWidget *fb_duration_label;
+ GtkWidget *fb_duration_spin;
+ GtkWidget *fb_duration_combo;
+ GtkWidget *publish_frequency;
GtkWidget *events_swin;