aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/publish-calendar/publish-location.c
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 /plugins/publish-calendar/publish-location.c
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.
Diffstat (limited to 'plugins/publish-calendar/publish-location.c')
-rw-r--r--plugins/publish-calendar/publish-location.c34
1 files changed, 33 insertions, 1 deletions
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);