aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog23
-rw-r--r--calendar/cal-client/cal-client.c43
-rw-r--r--calendar/cal-client/cal-client.h2
-rw-r--r--calendar/cal-util/calobj.h26
-rw-r--r--calendar/gui/Makefile.am2
-rw-r--r--calendar/gui/event-editor.c3
-rw-r--r--calendar/idl/evolution-calendar.idl3
-rw-r--r--calendar/pcs/cal-backend-imc.c55
-rw-r--r--calendar/pcs/cal-backend.c19
-rw-r--r--calendar/pcs/cal-backend.h4
-rw-r--r--calendar/pcs/cal.c29
11 files changed, 206 insertions, 3 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 58da7e9a31..ee24dbf58a 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,26 @@
+2000-06-09 Federico Mena Quintero <federico@helixcode.com>
+
+ * idl/evolution-calendar.idl (Cal): Added a get_n_objects()
+ method.
+
+ * pcs/cal-backend.c (cal_backend_get_n_objects): New function.
+
+ * pcs/cal-backend-imc.c (cal_backend_imc_get_n_objects):
+ Implemented.
+
+ * pcs/cal.c (Cal_get_n_objects): Implemented.
+
+ * cal-client/cal-client.c (cal_client_get_uids): Free the ev.
+ (cal_client_get_n_objects): Implemented.
+
+ * cal-util/calobj.h (iCalObjectField): New enumeration to identify
+ the fields in an iCalObject.
+
+2000-06-08 Federico Mena Quintero <federico@helixcode.com>
+
+ * gui/event-editor.c (event_editor_destroy): Free the private
+ structure.
+
2000-06-08 Federico Mena Quintero <federico@helixcode.com>
* cal-util/calobj.c (ical_object_to_vobject): Allow for NULL
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index 23ab9bc003..921e2dac59 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -551,6 +551,42 @@ cal_client_create_calendar (CalClient *client, const char *str_uri)
return load_or_create (client, str_uri, FALSE);
}
+int
+cal_client_get_n_objects (CalClient *client, CalObjType type)
+{
+ CalClientPrivate *priv;
+ CORBA_Environment ev;
+ int n;
+ int t;
+
+ g_return_val_if_fail (client != NULL, -1);
+ g_return_val_if_fail (IS_CAL_CLIENT (client), -1);
+
+ priv = client->priv;
+ g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, -1);
+
+ t = (((type & CALOBJ_TYPE_EVENT) ? Evolution_Calendar_TYPE_EVENT : 0)
+ | ((type & CALOBJ_TYPE_TODO) ? Evolution_Calendar_TYPE_TODO : 0)
+ | ((type & CALOBJ_TYPE_JOURNAL) ? Evolution_Calendar_TYPE_JOURNAL : 0)
+ | ((type & CALOBJ_TYPE_OTHER) ? Evolution_Calendar_TYPE_OTHER : 0)
+ /*
+ | ((type & CALOBJ_TYPE_ANY) ? Evolution_Calendar_TYPE_ANY : 0)
+ */
+ );
+
+ CORBA_exception_init (&ev);
+ n = Evolution_Calendar_Cal_get_n_objects (priv->cal, t, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_message ("cal_client_get_n_objects(): could not get the number of objects");
+ CORBA_exception_free (&ev);
+ return -1;
+ }
+
+ CORBA_exception_free (&ev);
+ return n;
+}
+
/**
* cal_client_get_object:
* @client: A calendar client.
@@ -562,9 +598,8 @@ cal_client_create_calendar (CalClient *client, const char *str_uri)
* sought object, or NULL if no object had the specified UID. A complete
* calendar is returned because you also need the timezone data.
**/
-CalClientGetStatus cal_client_get_object (CalClient *client,
- const char *uid,
- iCalObject **ico)
+CalClientGetStatus
+cal_client_get_object (CalClient *client, const char *uid, iCalObject **ico)
{
CalClientPrivate *priv;
CORBA_Environment ev;
@@ -677,6 +712,8 @@ cal_client_get_uids (CalClient *client, CalObjType type)
return NULL;
}
+ CORBA_exception_free (&ev);
+
/* Create the list */
uids = NULL;
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
index 755b005f74..947c9dd5dc 100644
--- a/calendar/cal-client/cal-client.h
+++ b/calendar/cal-client/cal-client.h
@@ -81,6 +81,8 @@ CalClient *cal_client_new (void);
gboolean cal_client_load_calendar (CalClient *client, const char *str_uri);
gboolean cal_client_create_calendar (CalClient *client, const char *str_uri);
+int cal_client_get_n_objects (CalClient *client, CalObjType type);
+
CalClientGetStatus cal_client_get_object (CalClient *client,
const char *uid,
iCalObject **ico);
diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h
index 57514250e5..c93c79f906 100644
--- a/calendar/cal-util/calobj.h
+++ b/calendar/cal-util/calobj.h
@@ -13,6 +13,7 @@
BEGIN_GNOME_DECLS
+/* Alarm types */
enum AlarmType {
ALARM_MAIL,
ALARM_PROGRAM,
@@ -20,12 +21,37 @@ enum AlarmType {
ALARM_AUDIO
};
+/* Whether the alarm should trigger N mins/hours/days before its due time */
enum AlarmUnit {
ALARM_MINUTES,
ALARM_HOURS,
ALARM_DAYS
};
+/* Field identifiers for the iCalObject structure */
+typedef enum {
+ ICAL_OBJECT_FIELD_COMMENT,
+ ICAL_OBJECT_FIELD_COMPLETED,
+ ICAL_OBJECT_FIELD_CREATED,
+ ICAL_OBJECT_FIELD_DESCRIPTION,
+ ICAL_OBJECT_FIELD_DTSTAMP,
+ ICAL_OBJECT_FIELD_DTSTART,
+ ICAL_OBJECT_FIELD_DTEND,
+ ICAL_OBJECT_FIELD_GEO,
+ ICAL_OBJECT_FIELD_LAST_MOD,
+ ICAL_OBJECT_FIELD_LOCATION,
+ ICAL_OBJECT_FIELD_ORGANIZER,
+ ICAL_OBJECT_FIELD_PERCENT,
+ ICAL_OBJECT_FIELD_PRIORITY,
+ ICAL_OBJECT_FIELD_SUMMARY,
+ ICAL_OBJECT_FIELD_URL,
+ ICAL_OBJECT_FIELD_DALARM,
+ ICAL_OBJECT_FIELD_AALARM,
+ ICAL_OBJECT_FIELD_PALARM,
+ ICAL_OBJECT_FIELD_MALARM,
+ ICAL_OBJECT_FIELD_NUM_FIELDS
+} iCalObjectField;
+
typedef struct {
enum AlarmType type;
int enabled;
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index ed50ac64a1..7a126b79ef 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -12,6 +12,7 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/calendar \
-I$(top_srcdir)/libical/src/libical \
+ -I$(top_srcdir)/widgets \
-I$(includedir) \
$(BONOBO_VFS_GNOME_CFLAGS) \
$(GNOME_CONDUIT_INCLUDEDIR) \
@@ -28,6 +29,7 @@ LINK_FLAGS = \
$(top_builddir)/e-util/libeutil.la \
$(top_builddir)/widgets/e-paned/libepaned.a \
$(top_builddir)/widgets/e-text/libetext.a \
+ $(top_builddir)/widgets/e-table/libetable.a \
$(top_builddir)/libversit/libversit.la \
$(top_builddir)/libical/src/libical/libical.a
diff --git a/calendar/gui/event-editor.c b/calendar/gui/event-editor.c
index e3ae2e5307..89e7eb5033 100644
--- a/calendar/gui/event-editor.c
+++ b/calendar/gui/event-editor.c
@@ -272,6 +272,9 @@ event_editor_destroy (GtkObject *object)
priv->xml = NULL;
}
+ g_free (priv);
+ ee->priv = NULL;
+
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl
index 29d0a79780..b7340bf51a 100644
--- a/calendar/idl/evolution-calendar.idl
+++ b/calendar/idl/evolution-calendar.idl
@@ -80,6 +80,9 @@ module Calendar {
/* A calendar is identified by its URI */
readonly attribute string uri;
+ /* Gets the number of objects of the specified types */
+ long get_n_objects (in CalObjType type);
+
/* Gets an object based on its URI */
CalObj get_object (in CalObjUID uid)
raises (NotFound);
diff --git a/calendar/pcs/cal-backend-imc.c b/calendar/pcs/cal-backend-imc.c
index a85c8ce535..713cddd7fe 100644
--- a/calendar/pcs/cal-backend-imc.c
+++ b/calendar/pcs/cal-backend-imc.c
@@ -74,6 +74,8 @@ static GnomeVFSURI *cal_backend_imc_get_uri (CalBackend *backend);
static void cal_backend_imc_add_cal (CalBackend *backend, Cal *cal);
static CalBackendLoadStatus cal_backend_imc_load (CalBackend *backend, GnomeVFSURI *uri);
static void cal_backend_imc_create (CalBackend *backend, GnomeVFSURI *uri);
+
+static int cal_backend_imc_get_n_objects (CalBackend *backend, CalObjType type);
static char *cal_backend_imc_get_object (CalBackend *backend, const char *uid);
static GList *cal_backend_imc_get_uids (CalBackend *backend, CalObjType type);
static GList *cal_backend_imc_get_events_in_range (CalBackend *backend, time_t start, time_t end);
@@ -137,6 +139,7 @@ cal_backend_imc_class_init (CalBackendIMCClass *class)
backend_class->add_cal = cal_backend_imc_add_cal;
backend_class->load = cal_backend_imc_load;
backend_class->create = cal_backend_imc_create;
+ backend_class->get_n_objects = cal_backend_imc_get_n_objects;
backend_class->get_object = cal_backend_imc_get_object;
backend_class->get_uids = cal_backend_imc_get_uids;
backend_class->get_events_in_range = cal_backend_imc_get_events_in_range;
@@ -829,6 +832,58 @@ cal_backend_imc_create (CalBackend *backend, GnomeVFSURI *uri)
save (cbimc);
}
+struct get_n_objects_closure {
+ CalObjType type;
+ int n;
+};
+
+/* Counts the number of objects of the specified type. Called from
+ * g_hash_table_foreach().
+ */
+static void
+count_objects (gpointer key, gpointer value, gpointer data)
+{
+ iCalObject *ico;
+ struct get_n_objects_closure *c;
+ gboolean store;
+
+ ico = value;
+ c = data;
+
+ store = FALSE;
+
+ if (ico->type == ICAL_EVENT)
+ store = (c->type & CALOBJ_TYPE_EVENT) != 0;
+ else if (ico->type == ICAL_TODO)
+ store = (c->type & CALOBJ_TYPE_TODO) != 0;
+ else if (ico->type == ICAL_JOURNAL)
+ store = (c->type & CALOBJ_TYPE_JOURNAL) != 0;
+ else
+ store = (c->type & CALOBJ_TYPE_OTHER) != 0;
+
+ if (store)
+ c->n++;
+}
+
+/* Get_n_objects handler for the IMC backend */
+static int
+cal_backend_imc_get_n_objects (CalBackend *backend, CalObjType type)
+{
+ CalBackendIMC *cbimc;
+ IMCPrivate *priv;
+ struct get_n_objects_closure c;
+
+ cbimc = CAL_BACKEND_IMC (backend);
+ priv = cbimc->priv;
+
+ g_return_val_if_fail (priv->loaded, -1);
+
+ c.type = type;
+ c.n = 0;
+
+ g_hash_table_foreach (priv->object_hash, count_objects, &c);
+}
+
/* Get_object handler for the IMC backend */
static char *
cal_backend_imc_get_object (CalBackend *backend, const char *uid)
diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c
index 15cfb1e7bc..7956f77473 100644
--- a/calendar/pcs/cal-backend.c
+++ b/calendar/pcs/cal-backend.c
@@ -177,6 +177,25 @@ cal_backend_create (CalBackend *backend, GnomeVFSURI *uri)
}
/**
+ * cal_backend_get_n_objects:
+ * @backend: A calendar backend.
+ * @type: Types of objects that will be included in the count.
+ *
+ * Queries the number of calendar objects of a particular type.
+ *
+ * Return value: Number of objects of the specified @type.
+ **/
+int
+cal_backend_get_n_objects (CalBackend *backend, CalObjType type)
+{
+ g_return_val_if_fail (backend != NULL, -1);
+ g_return_val_if_fail (IS_CAL_BACKEND (backend), -1);
+
+ g_assert (CLASS (backend)->get_n_objects != NULL);
+ return (* CLASS (backend)->get_n_objects) (backend, type);
+}
+
+/**
* cal_backend_get_object:
* @backend: A calendar backend.
* @uid: Unique identifier for a calendar object.
diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h
index 2bbac4b3d4..57f3acf18e 100644
--- a/calendar/pcs/cal-backend.h
+++ b/calendar/pcs/cal-backend.h
@@ -64,6 +64,8 @@ struct _CalBackendClass {
void (* add_cal) (CalBackend *backend, Cal *cal);
CalBackendLoadStatus (* load) (CalBackend *backend, GnomeVFSURI *uri);
void (* create) (CalBackend *backend, GnomeVFSURI *uri);
+
+ int (* get_n_objects) (CalBackend *backend, CalObjType type);
char *(* get_object) (CalBackend *backend, const char *uid);
GList *(* get_uids) (CalBackend *backend, CalObjType type);
GList *(* get_events_in_range) (CalBackend *backend, time_t start, time_t end);
@@ -85,6 +87,8 @@ CalBackendLoadStatus cal_backend_load (CalBackend *backend, GnomeVFSURI *uri);
void cal_backend_create (CalBackend *backend, GnomeVFSURI *uri);
+int cal_backend_get_n_objects (CalBackend *backend, CalObjType type);
+
char *cal_backend_get_object (CalBackend *backend, const char *uid);
GList *cal_backend_get_uids (CalBackend *backend, CalObjType type);
diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c
index 13fab067f8..a01c0ce8dc 100644
--- a/calendar/pcs/cal.c
+++ b/calendar/pcs/cal.c
@@ -166,7 +166,35 @@ Cal_get_uri (PortableServer_Servant servant,
g_free (str_uri);
return str_uri_copy;
+}
+
+/* Cal::get_n_objects method */
+static CORBA_long
+Cal_get_n_objects (PortableServer_Servant servant,
+ Evolution_Calendar_CalObjType type,
+ CORBA_Environment *ev)
+{
+ Cal *cal;
+ CalPrivate *priv;
+ int t;
+ int n;
+
+ cal = CAL (bonobo_object_from_servant (servant));
+ priv = cal->priv;
+
+ /* Translate the CORBA flags to our own flags */
+
+ t = (((type & Evolution_Calendar_TYPE_EVENT) ? CALOBJ_TYPE_EVENT : 0)
+ | ((type & Evolution_Calendar_TYPE_TODO) ? CALOBJ_TYPE_TODO : 0)
+ | ((type & Evolution_Calendar_TYPE_JOURNAL) ? CALOBJ_TYPE_JOURNAL : 0)
+ | ((type & Evolution_Calendar_TYPE_OTHER) ? CALOBJ_TYPE_OTHER : 0)
+ /*
+ | ((type & Evolution_Calendar_TYPE_ANY) ? CALOBJ_TYPE_ANY : 0)
+ */
+ );
+ n = cal_backend_get_n_objects (priv->backend, t);
+ return n;
}
/* Cal::get_object method */
@@ -504,6 +532,7 @@ cal_get_epv (void)
epv = g_new0 (POA_Evolution_Calendar_Cal__epv, 1);
epv->_get_uri = Cal_get_uri;
+ epv->get_n_objects = Cal_get_n_objects;
epv->get_object = Cal_get_object;
epv->get_uids = Cal_get_uids;
epv->get_events_in_range = Cal_get_events_in_range;