aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2001-09-21 03:52:58 +0800
committerJP Rosevear <jpr@src.gnome.org>2001-09-21 03:52:58 +0800
commit4ffc49d7b98f4693991b2cf48d564219217e5307 (patch)
tree7163e8ff0322c6da940091adce214416215967bf
parent55690284e1557f5c85bc8edae36b3cf3817eff9e (diff)
downloadgsoc2013-evolution-4ffc49d7b98f4693991b2cf48d564219217e5307.tar
gsoc2013-evolution-4ffc49d7b98f4693991b2cf48d564219217e5307.tar.gz
gsoc2013-evolution-4ffc49d7b98f4693991b2cf48d564219217e5307.tar.bz2
gsoc2013-evolution-4ffc49d7b98f4693991b2cf48d564219217e5307.tar.lz
gsoc2013-evolution-4ffc49d7b98f4693991b2cf48d564219217e5307.tar.xz
gsoc2013-evolution-4ffc49d7b98f4693991b2cf48d564219217e5307.tar.zst
gsoc2013-evolution-4ffc49d7b98f4693991b2cf48d564219217e5307.zip
gets a config db (cal_backend_file_destroy): release config db
2001-09-20 JP Rosevear <jpr@ximian.com> * pcs/cal-backend-file.c (load_db): gets a config db (cal_backend_file_destroy): release config db (cal_backend_file_init): use load_db (mail_account_get): gets a mail account by number (mail_account_get_default): gets the default mail account (mail_account_is_valid): looks to see if any accounts have the given address (create_user_free_busy): modularize so we can call multiple times if necessary, set organizer (cal_backend_file_get_free_busy): if the list of users is null, use the default account otherwise get the same info for each address that is an identity in the mailer * gui/itip-utils.c (itip_addresses_get): s/gint/glong/ for bonobo conf returns * gui/calendar-commands.c (publish_freebusy_cmd): fix problems from a merge so that we publish 6 weeks of free/busy information again svn path=/trunk/; revision=13015
-rw-r--r--calendar/ChangeLog22
-rw-r--r--calendar/gui/calendar-commands.c9
-rw-r--r--calendar/gui/itip-utils.c2
-rw-r--r--calendar/pcs/cal-backend-file.c160
4 files changed, 174 insertions, 19 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 71679c818e..f92062dbf9 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,25 @@
+2001-09-20 JP Rosevear <jpr@ximian.com>
+
+ * pcs/cal-backend-file.c (load_db): gets a config db
+ (cal_backend_file_destroy): release config db
+ (cal_backend_file_init): use load_db
+ (mail_account_get): gets a mail account by number
+ (mail_account_get_default): gets the default mail account
+ (mail_account_is_valid): looks to see if any accounts have the
+ given address
+ (create_user_free_busy): modularize so we can call multiple times
+ if necessary, set organizer
+ (cal_backend_file_get_free_busy): if the list of users is null,
+ use the default account otherwise get the same info for each
+ address that is an identity in the mailer
+
+ * gui/itip-utils.c (itip_addresses_get): s/gint/glong/ for bonobo
+ conf returns
+
+ * gui/calendar-commands.c (publish_freebusy_cmd): fix problems
+ from a merge so that we publish 6 weeks of free/busy information
+ again
+
2001-09-20 Larry Ewing <lewing@ximian.com>
* gui/dialogs/recurrence-page.c (recurrence_page_destroy): make
diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c
index 5de5b0091f..366026dc96 100644
--- a/calendar/gui/calendar-commands.c
+++ b/calendar/gui/calendar-commands.c
@@ -333,13 +333,16 @@ publish_freebusy_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
GnomeCalendar *gcal;
CalClient *client;
GList *comp_list;
- time_t start, end;
+ icaltimezone *utc;
+ time_t start = time (NULL), end;
gcal = GNOME_CALENDAR (data);
- gnome_calendar_get_current_time_range (gcal, &start, &end);
+
+ utc = icaltimezone_get_utc_timezone ();
+ start = time_day_begin_with_zone (start, utc);
+ end = time_add_week_with_zone (start, 6, utc);
client = gnome_calendar_get_cal_client (gcal);
- /* FIXME: use the "users" parameter */
comp_list = cal_client_get_free_busy (client, NULL, start, end);
if (comp_list) {
GList *l;
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
index 7a5411d752..8fdbe1648e 100644
--- a/calendar/gui/itip-utils.c
+++ b/calendar/gui/itip-utils.c
@@ -84,7 +84,7 @@ itip_addresses_get (void)
static Bonobo_ConfigDatabase db = NULL;
CORBA_Environment ev;
GList *addresses = NULL;
- gint len, def, i;
+ glong len, def, i;
if (db == NULL) {
CORBA_exception_init (&ev);
diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c
index 5649cc39f5..7407b6b7c0 100644
--- a/calendar/pcs/cal-backend-file.c
+++ b/calendar/pcs/cal-backend-file.c
@@ -22,6 +22,9 @@
#include <config.h>
#include <gtk/gtksignal.h>
+#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-moniker-util.h>
+#include <bonobo-conf/bonobo-config-database.h>
#include "e-util/e-dbhash.h"
#include "cal-util/cal-recur.h"
#include "cal-util/cal-util.h"
@@ -70,6 +73,9 @@ struct _CalBackendFilePrivate {
GHashTable *categories;
GHashTable *removed_categories;
+ /* Config database handle for free/busy organizer information */
+ Bonobo_ConfigDatabase db;
+
/* Idle handler for saving the calendar when it is dirty */
guint idle_id;
};
@@ -179,6 +185,24 @@ cal_backend_file_class_init (CalBackendFileClass *class)
backend_class->get_timezone = cal_backend_file_get_timezone;
}
+static Bonobo_ConfigDatabase
+load_db (void)
+{
+ Bonobo_ConfigDatabase db = CORBA_OBJECT_NIL;
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
+
+ if (BONOBO_EX (&ev))
+ db = CORBA_OBJECT_NIL;
+
+ CORBA_exception_free (&ev);
+
+ return db;
+}
+
static void
cal_added_cb (CalBackend *backend, gpointer user_data)
{
@@ -204,6 +228,8 @@ cal_backend_file_init (CalBackendFile *cbfile)
priv->categories = g_hash_table_new (g_str_hash, g_str_equal);
priv->removed_categories = g_hash_table_new (g_str_hash, g_str_equal);
+ priv->db = load_db ();
+
gtk_signal_connect (GTK_OBJECT (cbfile), "cal_added",
GTK_SIGNAL_FUNC (cal_added_cb), NULL);
}
@@ -342,6 +368,9 @@ cal_backend_file_destroy (GtkObject *object)
priv->icalcomp = NULL;
}
+ bonobo_object_release_unref (priv->db, NULL);
+ priv->db = CORBA_OBJECT_NIL;
+
g_free (priv);
cbfile->priv = NULL;
@@ -1112,27 +1141,89 @@ cal_backend_file_get_objects_in_range (CalBackend *backend, CalObjType type,
return event_list;
}
-/* Get_free_busy handler for the file backend */
-static GList *
-cal_backend_file_get_free_busy (CalBackend *backend, GList *users, time_t start, time_t end)
+static void
+mail_account_get (Bonobo_ConfigDatabase db, gint def, char **address, char **name)
{
- CalBackendFile *cbfile;
+ gchar *path;
+
+ *address = NULL;
+ *name = NULL;
+
+ /* get the identity info */
+ path = g_strdup_printf ("/Mail/Accounts/identity_name_%d", def);
+ *name = bonobo_config_get_string (db, path, NULL);
+ g_free (path);
+
+ path = g_strdup_printf ("/Mail/Accounts/identity_address_%d", def);
+ *address = bonobo_config_get_string (db, path, NULL);
+ g_free (path);
+}
+
+static gboolean
+mail_account_get_default (Bonobo_ConfigDatabase db, char **address, char **name)
+{
+ glong def, len;
+
+ *address = NULL;
+ *name = NULL;
+
+ len = bonobo_config_get_long_with_default (db, "/Mail/Accounts/num", 0, NULL);
+ def = bonobo_config_get_long_with_default (db, "/Mail/Accounts/default_account", 0, NULL);
+
+ if (def < len)
+ mail_account_get (db, def, address, name);
+ else
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+mail_account_is_valid (Bonobo_ConfigDatabase db, char *user, char **name)
+{
+ gchar *address;
+ glong len, i;
+
+ len = bonobo_config_get_long_with_default (db, "/Mail/Accounts/num", 0, NULL);
+
+ for (i = 0; i < len; i++) {
+ mail_account_get (db, i, &address, name);
+ if (address != NULL && !strcmp (address, user)) {
+ g_free (address);
+ return TRUE;
+ }
+ g_free (address);
+ g_free (*name);
+ }
+
+ return FALSE;
+}
+
+static icalcomponent *
+create_user_free_busy (CalBackendFile *cbfile, const char *address, const char *cn,
+ time_t start, time_t end)
+{
CalBackendFilePrivate *priv;
GList *uids;
GList *l;
icalcomponent *vfb;
- char *calobj;
- GList *obj_list = NULL;
- cbfile = CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
- g_return_val_if_fail (priv->icalcomp != NULL, NULL);
- g_return_val_if_fail (start != -1 && end != -1, NULL);
- g_return_val_if_fail (start <= end, NULL);
-
/* create the (unique) VFREEBUSY object that we'll return */
vfb = icalcomponent_new_vfreebusy ();
+ if (address != NULL) {
+ icalproperty *prop;
+ icalparameter *param;
+
+ prop = icalproperty_new_organizer (address);
+ if (prop != NULL && cn != NULL) {
+ param = icalparameter_new_cn (cn);
+ icalproperty_add_parameter (prop, param);
+ }
+ if (prop != NULL)
+ icalcomponent_add_property (vfb, prop);
+ }
icalcomponent_set_dtstart (vfb, icaltime_from_timet (start, 1));
icalcomponent_set_dtend (vfb, icaltime_from_timet (end, 1));
@@ -1179,12 +1270,51 @@ cal_backend_file_get_free_busy (CalBackend *backend, GList *users, time_t start,
icalcomponent_add_property (vfb, prop);
}
+ cal_obj_uid_list_free (uids);
- calobj = icalcomponent_as_ical_string (vfb);
- obj_list = g_list_append (obj_list, g_strdup (calobj));
- icalcomponent_free (vfb);
+ return vfb;
+}
- cal_obj_uid_list_free (uids);
+/* Get_free_busy handler for the file backend */
+static GList *
+cal_backend_file_get_free_busy (CalBackend *backend, GList *users, time_t start, time_t end)
+{
+ CalBackendFile *cbfile;
+ CalBackendFilePrivate *priv;
+ gchar *address, *name;
+ icalcomponent *vfb;
+ char *calobj;
+ GList *obj_list = NULL;
+ GList *l;
+
+ cbfile = CAL_BACKEND_FILE (backend);
+ priv = cbfile->priv;
+
+ g_return_val_if_fail (priv->icalcomp != NULL, NULL);
+ g_return_val_if_fail (start != -1 && end != -1, NULL);
+ g_return_val_if_fail (start <= end, NULL);
+
+ if (users == NULL) {
+ if (mail_account_get_default (priv->db, &address, &name)) {
+ vfb = create_user_free_busy (cbfile, address, name, start, end);
+ calobj = icalcomponent_as_ical_string (vfb);
+ obj_list = g_list_append (obj_list, g_strdup (calobj));
+ icalcomponent_free (vfb);
+ g_free (address);
+ g_free (name);
+ }
+ } else {
+ for (l = users; l != NULL; l = l->next ) {
+ address = l->data;
+ if (mail_account_is_valid (priv->db, address, &name)) {
+ vfb = create_user_free_busy (cbfile, address, name, start, end);
+ calobj = icalcomponent_as_ical_string (vfb);
+ obj_list = g_list_append (obj_list, g_strdup (calobj));
+ icalcomponent_free (vfb);
+ g_free (name);
+ }
+ }
+ }
return obj_list;
}