aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-02-04 12:42:34 +0800
committerArturo Espinosa <unammx@src.gnome.org>2000-02-04 12:42:34 +0800
commit5d56cdb0b37b4b8919df92ff35daf06934666061 (patch)
tree1721fac57d85fd8247b966d8ab7de312ca04aebe /calendar
parentd5c007ca4f4f12e354e3aae8b13706fb9e358599 (diff)
downloadgsoc2013-evolution-5d56cdb0b37b4b8919df92ff35daf06934666061.tar
gsoc2013-evolution-5d56cdb0b37b4b8919df92ff35daf06934666061.tar.gz
gsoc2013-evolution-5d56cdb0b37b4b8919df92ff35daf06934666061.tar.bz2
gsoc2013-evolution-5d56cdb0b37b4b8919df92ff35daf06934666061.tar.lz
gsoc2013-evolution-5d56cdb0b37b4b8919df92ff35daf06934666061.tar.xz
gsoc2013-evolution-5d56cdb0b37b4b8919df92ff35daf06934666061.tar.zst
gsoc2013-evolution-5d56cdb0b37b4b8919df92ff35daf06934666061.zip
New function to create the base VObject for a calendar.
2000-02-04 Federico Mena Quintero <federico@helixcode.com> * cal-backend.c (get_calendar_base_vobject): New function to create the base VObject for a calendar. (cal_backend_get_object): Create the base calendar and add the sought object to it, then stringify it. * evolution-calendar.idl (Listener::obj_added Listener::obj_changed): Now these pass in just the UIDs, not the complete objects. * cal-listener.c (Listener_obj_added): Changed to pass in the uid, not the object. (Listener_obj_changed): Likewise. * cal-client.h (CalClientClass): Made the obj_added and obj_changed signals take in the UIDs, not the full objects. * cal-client.c (obj_added_cb): Likewise. (obj_changed_cb): Likewise. svn path=/trunk/; revision=1666
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog21
-rw-r--r--calendar/cal-backend.c46
-rw-r--r--calendar/cal-client.c15
-rw-r--r--calendar/cal-client.h4
-rw-r--r--calendar/cal-client/cal-client.c15
-rw-r--r--calendar/cal-client/cal-client.h4
-rw-r--r--calendar/cal-client/cal-listener.c8
-rw-r--r--calendar/cal-client/cal-listener.h6
-rw-r--r--calendar/cal-listener.c8
-rw-r--r--calendar/cal-listener.h6
-rw-r--r--calendar/evolution-calendar.idl4
-rw-r--r--calendar/idl/evolution-calendar.idl4
-rw-r--r--calendar/pcs/cal-backend.c46
13 files changed, 149 insertions, 38 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index fdf45f6f6b..489b0f319c 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,26 @@
2000-02-04 Federico Mena Quintero <federico@helixcode.com>
+ * cal-backend.c (get_calendar_base_vobject): New function to
+ create the base VObject for a calendar.
+ (cal_backend_get_object): Create the base calendar and add the
+ sought object to it, then stringify it.
+
+ * evolution-calendar.idl (Listener::obj_added
+ Listener::obj_changed): Now these pass in just the UIDs, not the
+ complete objects.
+
+ * cal-listener.c (Listener_obj_added): Changed to pass in the uid,
+ not the object.
+ (Listener_obj_changed): Likewise.
+
+ * cal-client.h (CalClientClass): Made the obj_added and
+ obj_changed signals take in the UIDs, not the full objects.
+
+ * cal-client.c (obj_added_cb): Likewise.
+ (obj_changed_cb): Likewise.
+
+2000-02-04 Federico Mena Quintero <federico@helixcode.com>
+
* cal-backend.c (CalBackendPrivate): Renamed the event_hash field
to object_hash. Now we hash all the calendar's objects here based
on their UIDs.
diff --git a/calendar/cal-backend.c b/calendar/cal-backend.c
index ffbbdab472..72315e3882 100644
--- a/calendar/cal-backend.c
+++ b/calendar/cal-backend.c
@@ -26,6 +26,11 @@
+/* VCalendar product ID */
+#define PRODID "-//Helix Code//NONSGML Tlacuache//EN"
+
+
+
/* Private part of the CalBackend structure */
typedef struct {
/* URI where the calendar data is stored */
@@ -265,6 +270,35 @@ load_from_vobject (CalBackend *backend, VObject *vobject)
}
}
+/* Creates a VObject with the base information of a calendar */
+static VObject *
+get_calendar_base_vobject (CalBackend *backend)
+{
+ VObject *vobj;
+ time_t now;
+ struct tm tm;
+
+ /* We call localtime for the side effect of setting tzname */
+
+ now = time (NULL);
+ tm = *localtime (&now);
+
+ vobj = newVObject (VCCalProp);
+
+ addPropValue (vobj, VCProdIdProp, PRODID);
+
+#if defined (HAVE_TM_ZONE)
+ addPropValue (vobj, VCTimeZoneProp, tm.tm_zone);
+#elif defined (HAVE_TZNAME)
+ addPropValue (vobj, VCTimeZoneProp, tzname[0]);
+#endif
+
+ /* Per the vCalendar spec, this must be "1.0" */
+ addPropValue (vobj, VCVersionProp, "1.0");
+
+ return vobj;
+}
+
/**
@@ -433,6 +467,7 @@ cal_backend_get_object (CalBackend *backend, const char *uid)
{
CalBackendPrivate *priv;
iCalObject *ico;
+ VObject *vcalobj, *vobj;
char *buf;
g_return_val_if_fail (backend != NULL, NULL);
@@ -450,5 +485,14 @@ cal_backend_get_object (CalBackend *backend, const char *uid)
if (!ico)
return NULL;
- /* FIXME */
+ vcalobj = get_calendar_base_vobject (backend);
+ vobj = ical_object_to_vobject (ico);
+ addVObjectProp (vcalobj, vobj);
+
+ buf = writeMemVObject (NULL, NULL, vcalobj);
+
+ cleanVObject (vcalobj);
+ cleanStrTbl ();
+
+ return buf;
}
diff --git a/calendar/cal-client.c b/calendar/cal-client.c
index 2125760eb0..63d33610f6 100644
--- a/calendar/cal-client.c
+++ b/calendar/cal-client.c
@@ -245,17 +245,17 @@ cal_loaded_cb (CalListener *listener,
/* Handle the obj_added signal from the listener */
static void
-obj_added_cb (CalListener *listener, Evolution_Calendar_CalObj calobj, gpointer data)
+obj_added_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data)
{
CalClient *client;
client = CAL_CLIENT (data);
- gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_ADDED], calobj);
+ gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_ADDED], uid);
}
/* Handle the obj_removed signal from the listener */
static void
-obj_removed_cb (CalListener *listener, Evolution_Calendar_CalObjUID uid, gpointer data)
+obj_removed_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data)
{
CalClient *client;
@@ -265,12 +265,12 @@ obj_removed_cb (CalListener *listener, Evolution_Calendar_CalObjUID uid, gpointe
/* Handle the obj_changed signal from the listener */
static void
-obj_changed_cb (CalListener *listener, Evolution_Calendar_CalObj calobj, gpointer data)
+obj_changed_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data)
{
CalClient *client;
client = CAL_CLIENT (data);
- gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_CHANGED], calobj);
+ gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_CHANGED], uid);
}
@@ -432,8 +432,9 @@ cal_client_load_calendar (CalClient *client, const char *str_uri)
*
* Queries a calendar for a calendar object based on its unique identifier.
*
- * Return value: The string representation of the calendar object corresponding
- * to the specified @uid, or NULL if no such object was found.
+ * Return value: The string representation of a complete calendar wrapping the
+ * sought object, or NULL if no object had the specified UID. A complete
+ * calendar is returned because you also need the timezone data.
**/
char *
cal_client_get_object (CalClient *client, const char *uid)
diff --git a/calendar/cal-client.h b/calendar/cal-client.h
index b20a3c378c..2f9ae5e1f8 100644
--- a/calendar/cal-client.h
+++ b/calendar/cal-client.h
@@ -58,9 +58,9 @@ struct _CalClientClass {
void (* cal_loaded) (CalClient *client, CalClientLoadStatus status);
- void (* obj_added) (CalClient *client, const char *str_obj);
+ void (* obj_added) (CalClient *client, const char *uid);
void (* obj_removed) (CalClient *client, const char *uid);
- void (* obj_changed) (CalClient *client, const char *str_obj);
+ void (* obj_changed) (CalClient *client, const char *uid);
};
GtkType cal_client_get_type (void);
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index 2125760eb0..63d33610f6 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -245,17 +245,17 @@ cal_loaded_cb (CalListener *listener,
/* Handle the obj_added signal from the listener */
static void
-obj_added_cb (CalListener *listener, Evolution_Calendar_CalObj calobj, gpointer data)
+obj_added_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data)
{
CalClient *client;
client = CAL_CLIENT (data);
- gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_ADDED], calobj);
+ gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_ADDED], uid);
}
/* Handle the obj_removed signal from the listener */
static void
-obj_removed_cb (CalListener *listener, Evolution_Calendar_CalObjUID uid, gpointer data)
+obj_removed_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data)
{
CalClient *client;
@@ -265,12 +265,12 @@ obj_removed_cb (CalListener *listener, Evolution_Calendar_CalObjUID uid, gpointe
/* Handle the obj_changed signal from the listener */
static void
-obj_changed_cb (CalListener *listener, Evolution_Calendar_CalObj calobj, gpointer data)
+obj_changed_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data)
{
CalClient *client;
client = CAL_CLIENT (data);
- gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_CHANGED], calobj);
+ gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_CHANGED], uid);
}
@@ -432,8 +432,9 @@ cal_client_load_calendar (CalClient *client, const char *str_uri)
*
* Queries a calendar for a calendar object based on its unique identifier.
*
- * Return value: The string representation of the calendar object corresponding
- * to the specified @uid, or NULL if no such object was found.
+ * Return value: The string representation of a complete calendar wrapping the
+ * sought object, or NULL if no object had the specified UID. A complete
+ * calendar is returned because you also need the timezone data.
**/
char *
cal_client_get_object (CalClient *client, const char *uid)
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
index b20a3c378c..2f9ae5e1f8 100644
--- a/calendar/cal-client/cal-client.h
+++ b/calendar/cal-client/cal-client.h
@@ -58,9 +58,9 @@ struct _CalClientClass {
void (* cal_loaded) (CalClient *client, CalClientLoadStatus status);
- void (* obj_added) (CalClient *client, const char *str_obj);
+ void (* obj_added) (CalClient *client, const char *uid);
void (* obj_removed) (CalClient *client, const char *uid);
- void (* obj_changed) (CalClient *client, const char *str_obj);
+ void (* obj_changed) (CalClient *client, const char *uid);
};
GtkType cal_client_get_type (void);
diff --git a/calendar/cal-client/cal-listener.c b/calendar/cal-client/cal-listener.c
index 62db9c287d..fee7e96024 100644
--- a/calendar/cal-client/cal-listener.c
+++ b/calendar/cal-client/cal-listener.c
@@ -269,14 +269,14 @@ Listener_cal_loaded (PortableServer_Servant servant,
/* Listener::obj_added method */
static void
Listener_obj_added (PortableServer_Servant servant,
- Evolution_Calendar_CalObj calobj,
+ Evolution_Calendar_CalObjUID uid,
CORBA_Environment *ev)
{
CalListener *listener;
listener = CAL_LISTENER (bonobo_object_from_servant (servant));
gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_ADDED],
- calobj);
+ uid);
}
/* Listener::obj_removed method */
@@ -295,14 +295,14 @@ Listener_obj_removed (PortableServer_Servant servant,
/* Listener::obj_changed method */
static void
Listener_obj_changed (PortableServer_Servant servant,
- Evolution_Calendar_CalObj calobj,
+ Evolution_Calendar_CalObjUID uid,
CORBA_Environment *ev)
{
CalListener *listener;
listener = CAL_LISTENER (bonobo_object_from_servant (servant));
gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_CHANGED],
- calobj);
+ uid);
}
/**
diff --git a/calendar/cal-client/cal-listener.h b/calendar/cal-client/cal-listener.h
index bc112091f9..8988148f34 100644
--- a/calendar/cal-client/cal-listener.h
+++ b/calendar/cal-client/cal-listener.h
@@ -61,9 +61,9 @@ struct _CalListenerClass {
void (* cal_loaded) (CalListener *listener,
CalListenerLoadStatus status,
Evolution_Calendar_Cal cal);
- void (* obj_added) (CalListener *listener, Evolution_Calendar_CalObj calobj);
- void (* obj_removed) (CalListener *listener, Evolution_Calendar_CalObjUID uid);
- void (* obj_changed) (CalListener *listener, Evolution_Calendar_CalObj calobj);
+ void (* obj_added) (CalListener *listener, const Evolution_Calendar_CalObjUID uid);
+ void (* obj_removed) (CalListener *listener, const Evolution_Calendar_CalObjUID uid);
+ void (* obj_changed) (CalListener *listener, const Evolution_Calendar_CalObjUID uid);
};
GtkType cal_listener_get_type (void);
diff --git a/calendar/cal-listener.c b/calendar/cal-listener.c
index 62db9c287d..fee7e96024 100644
--- a/calendar/cal-listener.c
+++ b/calendar/cal-listener.c
@@ -269,14 +269,14 @@ Listener_cal_loaded (PortableServer_Servant servant,
/* Listener::obj_added method */
static void
Listener_obj_added (PortableServer_Servant servant,
- Evolution_Calendar_CalObj calobj,
+ Evolution_Calendar_CalObjUID uid,
CORBA_Environment *ev)
{
CalListener *listener;
listener = CAL_LISTENER (bonobo_object_from_servant (servant));
gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_ADDED],
- calobj);
+ uid);
}
/* Listener::obj_removed method */
@@ -295,14 +295,14 @@ Listener_obj_removed (PortableServer_Servant servant,
/* Listener::obj_changed method */
static void
Listener_obj_changed (PortableServer_Servant servant,
- Evolution_Calendar_CalObj calobj,
+ Evolution_Calendar_CalObjUID uid,
CORBA_Environment *ev)
{
CalListener *listener;
listener = CAL_LISTENER (bonobo_object_from_servant (servant));
gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_CHANGED],
- calobj);
+ uid);
}
/**
diff --git a/calendar/cal-listener.h b/calendar/cal-listener.h
index bc112091f9..8988148f34 100644
--- a/calendar/cal-listener.h
+++ b/calendar/cal-listener.h
@@ -61,9 +61,9 @@ struct _CalListenerClass {
void (* cal_loaded) (CalListener *listener,
CalListenerLoadStatus status,
Evolution_Calendar_Cal cal);
- void (* obj_added) (CalListener *listener, Evolution_Calendar_CalObj calobj);
- void (* obj_removed) (CalListener *listener, Evolution_Calendar_CalObjUID uid);
- void (* obj_changed) (CalListener *listener, Evolution_Calendar_CalObj calobj);
+ void (* obj_added) (CalListener *listener, const Evolution_Calendar_CalObjUID uid);
+ void (* obj_removed) (CalListener *listener, const Evolution_Calendar_CalObjUID uid);
+ void (* obj_changed) (CalListener *listener, const Evolution_Calendar_CalObjUID uid);
};
GtkType cal_listener_get_type (void);
diff --git a/calendar/evolution-calendar.idl b/calendar/evolution-calendar.idl
index 2ccfc0ec80..6746eb66a1 100644
--- a/calendar/evolution-calendar.idl
+++ b/calendar/evolution-calendar.idl
@@ -51,13 +51,13 @@ module Calendar {
void cal_loaded (in LoadStatus status, in Cal cal);
/* Called from a Calendar when an object is added */
- void obj_added (in CalObj calobj);
+ void obj_added (in CalObjUID uid);
/* Called from a Calendar when an object is removed */
void obj_removed (in CalObjUID uid);
/* Called from a Calendar when an object is changed */
- void obj_changed (in CalObj calobj);
+ void obj_changed (in CalObjUID uid);
};
/* A calendar factory, can load and create calendars */
diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl
index 2ccfc0ec80..6746eb66a1 100644
--- a/calendar/idl/evolution-calendar.idl
+++ b/calendar/idl/evolution-calendar.idl
@@ -51,13 +51,13 @@ module Calendar {
void cal_loaded (in LoadStatus status, in Cal cal);
/* Called from a Calendar when an object is added */
- void obj_added (in CalObj calobj);
+ void obj_added (in CalObjUID uid);
/* Called from a Calendar when an object is removed */
void obj_removed (in CalObjUID uid);
/* Called from a Calendar when an object is changed */
- void obj_changed (in CalObj calobj);
+ void obj_changed (in CalObjUID uid);
};
/* A calendar factory, can load and create calendars */
diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c
index ffbbdab472..72315e3882 100644
--- a/calendar/pcs/cal-backend.c
+++ b/calendar/pcs/cal-backend.c
@@ -26,6 +26,11 @@
+/* VCalendar product ID */
+#define PRODID "-//Helix Code//NONSGML Tlacuache//EN"
+
+
+
/* Private part of the CalBackend structure */
typedef struct {
/* URI where the calendar data is stored */
@@ -265,6 +270,35 @@ load_from_vobject (CalBackend *backend, VObject *vobject)
}
}
+/* Creates a VObject with the base information of a calendar */
+static VObject *
+get_calendar_base_vobject (CalBackend *backend)
+{
+ VObject *vobj;
+ time_t now;
+ struct tm tm;
+
+ /* We call localtime for the side effect of setting tzname */
+
+ now = time (NULL);
+ tm = *localtime (&now);
+
+ vobj = newVObject (VCCalProp);
+
+ addPropValue (vobj, VCProdIdProp, PRODID);
+
+#if defined (HAVE_TM_ZONE)
+ addPropValue (vobj, VCTimeZoneProp, tm.tm_zone);
+#elif defined (HAVE_TZNAME)
+ addPropValue (vobj, VCTimeZoneProp, tzname[0]);
+#endif
+
+ /* Per the vCalendar spec, this must be "1.0" */
+ addPropValue (vobj, VCVersionProp, "1.0");
+
+ return vobj;
+}
+
/**
@@ -433,6 +467,7 @@ cal_backend_get_object (CalBackend *backend, const char *uid)
{
CalBackendPrivate *priv;
iCalObject *ico;
+ VObject *vcalobj, *vobj;
char *buf;
g_return_val_if_fail (backend != NULL, NULL);
@@ -450,5 +485,14 @@ cal_backend_get_object (CalBackend *backend, const char *uid)
if (!ico)
return NULL;
- /* FIXME */
+ vcalobj = get_calendar_base_vobject (backend);
+ vobj = ical_object_to_vobject (ico);
+ addVObjectProp (vcalobj, vobj);
+
+ buf = writeMemVObject (NULL, NULL, vcalobj);
+
+ cleanVObject (vcalobj);
+ cleanStrTbl ();
+
+ return buf;
}