renamed updateObject to updateObjects and removed the UID argument, since

2001-07-11  Damon Chaplin  <damon@ximian.com>

	* idl/evolution-calendar.idl: renamed updateObject to updateObjects
	and removed the UID argument, since it can add/update multiple objects
	at once. (It can't yet, but it will!)

	* pcs/cal.c:
	* pcs/cal-backend.[hc]:
	* pcs/cal-backend-file.c: renamed update_object to update_objects and
	got rid of the UID arg.

	* cal-client/cal-client.c (cal_client_update_objects): new function to
	add/update multiple objects in one go, i.e for iTIP and for importing
	calendars.

	* gui/print.c (print_date_label): fixed type bug.

	* gui/e-week-view.[hc]:
	* gui/e-week-view-event-item.c: draw the timezone icons if the event's
	DTSTART or DTEND is in a different timezone to the current one.
	Note that we may want to change this so it compares the UTC offsets
	rather than the TZIDs, since currently it will draw the icons for all
	events coming from iTIP requests from other clients.

svn path=/trunk/; revision=11027
This commit is contained in:
Damon Chaplin
2001-07-12 02:38:25 +00:00
committed by Damon Chaplin
parent 0a9ff51460
commit 421aa80ae6
11 changed files with 138 additions and 39 deletions

View File

@ -1,3 +1,27 @@
2001-07-11 Damon Chaplin <damon@ximian.com>
* idl/evolution-calendar.idl: renamed updateObject to updateObjects
and removed the UID argument, since it can add/update multiple objects
at once. (It can't yet, but it will!)
* pcs/cal.c:
* pcs/cal-backend.[hc]:
* pcs/cal-backend-file.c: renamed update_object to update_objects and
got rid of the UID arg.
* cal-client/cal-client.c (cal_client_update_objects): new function to
add/update multiple objects in one go, i.e for iTIP and for importing
calendars.
* gui/print.c (print_date_label): fixed type bug.
* gui/e-week-view.[hc]:
* gui/e-week-view-event-item.c: draw the timezone icons if the event's
DTSTART or DTEND is in a different timezone to the current one.
Note that we may want to change this so it compares the UTC offsets
rather than the TZIDs, since currently it will draw the icons for all
events coming from iTIP requests from other clients.
2001-07-11 Federico Mena Quintero <federico@ximian.com>
Fixes bug #4380 as well as some leftovers from the days of struct

View File

@ -301,7 +301,7 @@ free_timezone (gpointer key, gpointer value, gpointer data)
{
/* Note that the key comes from within the icaltimezone value, so we
don't free that. */
icaltimezone_free (value);
icaltimezone_free (value, TRUE);
}
/* Destroy handler for the calendar client */
@ -1773,10 +1773,10 @@ append_timezone_string (gpointer key, gpointer value, gpointer data)
To do that we check every TZID in the component to see if it is a builtin
timezone. If it is, we see if it it in our cache. If it is in our cache,
then we know the server already has it and we don't need to send it.
If it isn't in our cache, then we need to send it to the server, and we
can add it to the cache as well. If we need to send any timezones to the
server, then we have to create a complete VCALENDAR object, otherwise
we can just send a single VEVENT/VTODO as before. */
If it isn't in our cache, then we need to send it to the server.
If we need to send any timezones to the server, then we have to create a
complete VCALENDAR object, otherwise we can just send a single VEVENT/VTODO
as before. */
static char*
cal_client_get_component_as_string (CalClient *client,
CalComponent *comp)
@ -1831,8 +1831,6 @@ cal_client_get_component_as_string (CalClient *client,
g_hash_table_destroy (timezone_hash);
fprintf (stderr, "Object String:\n=======\n%s======\n", obj_string);
return obj_string;
}
@ -1855,7 +1853,6 @@ cal_client_update_object (CalClient *client, CalComponent *comp)
CORBA_Environment ev;
gboolean retval;
char *obj_string;
const char *uid;
g_return_val_if_fail (client != NULL, FALSE);
g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
@ -1869,12 +1866,10 @@ cal_client_update_object (CalClient *client, CalComponent *comp)
cal_component_commit_sequence (comp);
cal_component_get_uid (comp, &uid);
obj_string = cal_client_get_component_as_string (client, comp);
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_Cal_updateObject (priv->cal, (char *) uid, obj_string, &ev);
GNOME_Evolution_Calendar_Cal_updateObjects (priv->cal, obj_string, &ev);
g_free (obj_string);
if (ev._major == CORBA_USER_EXCEPTION &&
@ -1892,6 +1887,66 @@ cal_client_update_object (CalClient *client, CalComponent *comp)
return retval;
}
/**
* cal_client_update_objects:
* @client: A calendar client.
* @icalcomp: A toplevel VCALENDAR libical component.
*
* Asks a calendar to add or update one or more components, possibly including
* VTIMEZONE data. Any existing components with the same UIDs will be
* replaced. The VTIMEZONE data will be compared to existing VTIMEZONEs in
* the calendar, and the VTIMEZONEs may possibly be renamed, as well as all
* references to them throughout the VCALENDAR.
*
* The client program should not assume that the objects are actually in the
* server's storage until it has received the "obj_updated" notification
* signal.
*
* Return value: TRUE on success, FALSE on specifying an invalid component.
**/
gboolean
cal_client_update_objects (CalClient *client, icalcomponent *icalcomp)
{
CalClientPrivate *priv;
CORBA_Environment ev;
gboolean retval;
char *obj_string;
g_return_val_if_fail (client != NULL, FALSE);
g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
priv = client->priv;
g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED,
FALSE);
g_return_val_if_fail (icalcomp != NULL, FALSE);
retval = FALSE;
/* Libical owns this memory, using one of its temporary buffers. */
obj_string = icalcomponent_as_ical_string (icalcomp);
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_Cal_updateObjects (priv->cal, obj_string, &ev);
if (ev._major == CORBA_USER_EXCEPTION &&
strcmp (CORBA_exception_id (&ev),
ex_GNOME_Evolution_Calendar_Cal_InvalidObject) == 0)
goto out;
else if (ev._major != CORBA_NO_EXCEPTION) {
g_message ("cal_client_update_objects(): could not update the objects");
goto out;
}
retval = TRUE;
out:
CORBA_exception_free (&ev);
return retval;
}
/**
* cal_client_remove_object:
* @client: A calendar client.

View File

@ -559,6 +559,7 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem,
GdkGC *gc;
gint num_icons = 0, icon_x_inc;
gboolean draw_reminder_icon = FALSE, draw_recurrence_icon = FALSE;
gboolean draw_timezone_icon = FALSE;
GSList *categories_list, *elem;
week_view = E_WEEK_VIEW (GTK_WIDGET (GNOME_CANVAS_ITEM (wveitem)->canvas)->parent);
@ -581,6 +582,11 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem,
num_icons++;
}
if (!cal_component_compare_event_timezone (comp, week_view->zone)) {
draw_timezone_icon = TRUE;
num_icons++;
}
cal_component_get_categories_list (comp, &categories_list);
num_icons += g_slist_length (categories_list);
@ -611,6 +617,17 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem,
icon_x += icon_x_inc;
}
if (draw_timezone_icon && icon_x + E_WEEK_VIEW_ICON_WIDTH <= x2) {
gdk_gc_set_clip_origin (gc, icon_x, icon_y);
gdk_gc_set_clip_mask (gc, week_view->timezone_mask);
gdk_draw_pixmap (drawable, gc,
week_view->timezone_icon,
0, 0, icon_x, icon_y,
E_WEEK_VIEW_ICON_WIDTH,
E_WEEK_VIEW_ICON_HEIGHT);
icon_x += icon_x_inc;
}
/* draw categories icons */
for (elem = categories_list; elem; elem = elem->next) {
char *category;

View File

@ -60,6 +60,7 @@
/* Images */
#include "art/bell.xpm"
#include "art/recur.xpm"
#include "art/timezone-16.xpm"
#include "art/jump.xpm"
#define E_WEEK_VIEW_SMALL_FONT \
@ -541,6 +542,7 @@ e_week_view_realize (GtkWidget *widget)
/* Create the pixmaps. */
week_view->reminder_icon = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &week_view->reminder_mask, NULL, bell_xpm);
week_view->recurrence_icon = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &week_view->recurrence_mask, NULL, recur_xpm);
week_view->timezone_icon = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &week_view->timezone_mask, NULL, timezone_16_xpm);
}
@ -2457,6 +2459,10 @@ e_week_view_reshape_event_span (EWeekView *week_view,
if (cal_component_has_recurrences (comp))
num_icons++;
if (!cal_component_compare_event_timezone (comp,
week_view->zone))
num_icons++;
cal_component_get_categories_list (comp, &categories_list);
num_icons += g_slist_length (categories_list);

View File

@ -303,6 +303,8 @@ struct _EWeekView
GdkBitmap *reminder_mask;
GdkPixmap *recurrence_icon;
GdkBitmap *recurrence_mask;
GdkPixmap *timezone_icon;
GdkBitmap *timezone_mask;
/* Colors for drawing. */
GdkColor colors[E_WEEK_VIEW_COLOR_LAST];

View File

@ -2104,7 +2104,7 @@ print_date_label (GnomePrintContext *pc, CalComponent *comp,
cal_component_get_completed (comp, &datetime.value);
if (datetime.value)
complete = icaltime_as_timet_with_zone (*datetime.value, zone);
cal_component_free_icaltimetype (&datetime.value);
cal_component_free_icaltimetype (datetime.value);
buffer[0] = '\0';

View File

@ -175,7 +175,7 @@ module Calendar {
* object after this call, and call getObject to get the
* updated version.
*/
void updateObject (in CalObjUID uid, in CalObj calobj)
void updateObjects (in CalObj calobj)
raises (InvalidObject);
/* Removes a component */

View File

@ -89,8 +89,7 @@ static GNOME_Evolution_Calendar_CalComponentAlarms *cal_backend_file_get_alarms_
CalBackend *backend, const char *uid,
time_t start, time_t end, gboolean *object_found);
static gboolean cal_backend_file_update_object (CalBackend *backend, const char *uid,
const char *calobj);
static gboolean cal_backend_file_update_objects (CalBackend *backend, const char *calobj);
static gboolean cal_backend_file_remove_object (CalBackend *backend, const char *uid);
static icaltimezone* cal_backend_file_get_timezone (CalBackend *backend, const char *tzid);
@ -159,7 +158,7 @@ cal_backend_file_class_init (CalBackendFileClass *class)
backend_class->get_changes = cal_backend_file_get_changes;
backend_class->get_alarms_in_range = cal_backend_file_get_alarms_in_range;
backend_class->get_alarms_for_object = cal_backend_file_get_alarms_for_object;
backend_class->update_object = cal_backend_file_update_object;
backend_class->update_objects = cal_backend_file_update_objects;
backend_class->remove_object = cal_backend_file_remove_object;
backend_class->get_timezone = cal_backend_file_get_timezone;
@ -1635,9 +1634,9 @@ notify_remove (CalBackendFile *cbfile, const char *uid)
}
}
/* Update_object handler for the file backend */
/* Update_objects handler for the file backend. */
static gboolean
cal_backend_file_update_object (CalBackend *backend, const char *uid, const char *calobj)
cal_backend_file_update_objects (CalBackend *backend, const char *calobj)
{
CalBackendFile *cbfile;
CalBackendFilePrivate *priv;
@ -1652,7 +1651,6 @@ cal_backend_file_update_object (CalBackend *backend, const char *uid, const char
g_return_val_if_fail (priv->icalcomp != NULL, FALSE);
g_return_val_if_fail (uid != NULL, FALSE);
g_return_val_if_fail (calobj != NULL, FALSE);
/* Pull the component from the string and ensure that it is sane */
@ -1714,18 +1712,18 @@ cal_backend_file_update_object (CalBackend *backend, const char *uid, const char
return FALSE;
}
/* Check the UID for sanity's sake */
/* Get the UID, and check it isn't empty. */
cal_component_get_uid (comp, &comp_uid);
if (strcmp (uid, comp_uid) != 0) {
if (!comp_uid || !comp_uid[0]) {
gtk_object_unref (GTK_OBJECT (comp));
return FALSE;
}
/* Update the component */
old_comp = lookup_component (cbfile, uid);
old_comp = lookup_component (cbfile, comp_uid);
if (old_comp)
remove_component (cbfile, old_comp);

View File

@ -146,7 +146,7 @@ cal_backend_class_init (CalBackendClass *class)
class->get_changes = NULL;
class->get_alarms_in_range = NULL;
class->get_alarms_for_object = NULL;
class->update_object = NULL;
class->update_objects = NULL;
class->remove_object = NULL;
}
@ -471,10 +471,9 @@ cal_backend_get_alarms_for_object (CalBackend *backend, const char *uid,
}
/**
* cal_backend_update_object:
* cal_backend_update_objects:
* @backend: A calendar backend.
* @uid: Unique identifier of the object to update.
* @calobj: String representation of the new calendar object.
* @calobj: String representation of the new calendar object(s).
*
* Updates an object in a calendar backend. It will replace any existing
* object that has the same UID as the specified one. The backend will in
@ -484,15 +483,14 @@ cal_backend_get_alarms_for_object (CalBackend *backend, const char *uid,
* with an unsupported type.
**/
gboolean
cal_backend_update_object (CalBackend *backend, const char *uid, const char *calobj)
cal_backend_update_objects (CalBackend *backend, const char *calobj)
{
g_return_val_if_fail (backend != NULL, FALSE);
g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE);
g_return_val_if_fail (uid != NULL, FALSE);
g_return_val_if_fail (calobj != NULL, FALSE);
g_assert (CLASS (backend)->update_object != NULL);
return (* CLASS (backend)->update_object) (backend, uid, calobj);
g_assert (CLASS (backend)->update_objects != NULL);
return (* CLASS (backend)->update_objects) (backend, calobj);
}
/**

View File

@ -104,7 +104,7 @@ struct _CalBackendClass {
time_t start, time_t end, gboolean *object_found);
/* Object manipulation virtual methods */
gboolean (* update_object) (CalBackend *backend, const char *uid, const char *calobj);
gboolean (* update_objects) (CalBackend *backend, const char *calobj);
gboolean (* remove_object) (CalBackend *backend, const char *uid);
/* Timezone related virtual methods */
@ -147,7 +147,7 @@ GNOME_Evolution_Calendar_CalComponentAlarms *cal_backend_get_alarms_for_object (
CalBackendGetAlarmsForObjectResult *result);
gboolean cal_backend_update_object (CalBackend *backend, const char *uid, const char *calobj);
gboolean cal_backend_update_objects (CalBackend *backend, const char *calobj);
gboolean cal_backend_remove_object (CalBackend *backend, const char *uid);

View File

@ -347,12 +347,11 @@ impl_Cal_get_alarms_for_object (PortableServer_Servant servant,
}
}
/* Cal::update_object method */
/* Cal::update_objects method */
static void
impl_Cal_update_object (PortableServer_Servant servant,
const GNOME_Evolution_Calendar_CalObjUID uid,
const GNOME_Evolution_Calendar_CalObj calobj,
CORBA_Environment *ev)
impl_Cal_update_objects (PortableServer_Servant servant,
const GNOME_Evolution_Calendar_CalObj calobj,
CORBA_Environment *ev)
{
Cal *cal;
CalPrivate *priv;
@ -360,7 +359,7 @@ impl_Cal_update_object (PortableServer_Servant servant,
cal = CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
if (!cal_backend_update_object (priv->backend, uid, calobj))
if (!cal_backend_update_objects (priv->backend, calobj))
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_Calendar_Cal_InvalidObject,
NULL);
@ -592,7 +591,7 @@ cal_class_init (CalClass *klass)
epv->getFreeBusy = impl_Cal_get_free_busy;
epv->getAlarmsInRange = impl_Cal_get_alarms_in_range;
epv->getAlarmsForObject = impl_Cal_get_alarms_for_object;
epv->updateObject = impl_Cal_update_object;
epv->updateObjects = impl_Cal_update_objects;
epv->removeObject = impl_Cal_remove_object;
epv->getQuery = impl_Cal_get_query;
}