aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-client
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@src.gnome.org>2003-08-08 00:38:20 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2003-08-08 00:38:20 +0800
commitdc84df9871b3171a21d62feec988160f3c608103 (patch)
tree29f8dfbfa57dc43ae07fe645a1664fc5b1222086 /calendar/cal-client
parent64222beb23056f789551b79e78fa721d32408e9e (diff)
downloadgsoc2013-evolution-dc84df9871b3171a21d62feec988160f3c608103.tar
gsoc2013-evolution-dc84df9871b3171a21d62feec988160f3c608103.tar.gz
gsoc2013-evolution-dc84df9871b3171a21d62feec988160f3c608103.tar.bz2
gsoc2013-evolution-dc84df9871b3171a21d62feec988160f3c608103.tar.lz
gsoc2013-evolution-dc84df9871b3171a21d62feec988160f3c608103.tar.xz
gsoc2013-evolution-dc84df9871b3171a21d62feec988160f3c608103.tar.zst
gsoc2013-evolution-dc84df9871b3171a21d62feec988160f3c608103.zip
Merge new-calendar-branch into HEAD
svn path=/trunk/; revision=22129
Diffstat (limited to 'calendar/cal-client')
-rw-r--r--calendar/cal-client/cal-client.c86
-rw-r--r--calendar/cal-client/cal-client.h5
-rw-r--r--calendar/cal-client/cal-query.c25
-rw-r--r--calendar/cal-client/cal-query.h18
4 files changed, 76 insertions, 58 deletions
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index 0854d75b61..740d8f4062 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -1354,13 +1354,12 @@ struct _CalClientGetTimezonesData {
};
CalClientGetStatus
-cal_client_get_default_object (CalClient *client, CalObjType type, CalComponent **comp)
+cal_client_get_default_object (CalClient *client, CalObjType type, icalcomponent **icalcomp)
{
CalClientPrivate *priv;
CORBA_Environment ev;
GNOME_Evolution_Calendar_CalObj comp_str;
CalClientGetStatus retval;
- icalcomponent *icalcomp;
CalClientGetTimezonesData cb_data;
g_return_val_if_fail (client != NULL, CAL_CLIENT_GET_NOT_FOUND);
@@ -1369,10 +1368,10 @@ cal_client_get_default_object (CalClient *client, CalObjType type, CalComponent
priv = client->priv;
g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, CAL_CLIENT_GET_NOT_FOUND);
- g_return_val_if_fail (comp != NULL, CAL_CLIENT_GET_NOT_FOUND);
+ g_return_val_if_fail (icalcomp != NULL, CAL_CLIENT_GET_NOT_FOUND);
retval = CAL_CLIENT_GET_NOT_FOUND;
- *comp = NULL;
+ *icalcomp = NULL;
CORBA_exception_init (&ev);
comp_str = GNOME_Evolution_Calendar_Cal_getDefaultObject (priv->cal, type, &ev);
@@ -1380,24 +1379,14 @@ cal_client_get_default_object (CalClient *client, CalObjType type, CalComponent
if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
goto out;
else if (BONOBO_EX (&ev)) {
- g_message ("cal_client_get_object(): could not get the object");
+ g_message ("cal_client_get_default_object(): could not get the object");
goto out;
}
- icalcomp = icalparser_parse_string (comp_str);
+ *icalcomp = icalparser_parse_string (comp_str);
CORBA_free (comp_str);
- if (!icalcomp) {
- retval = CAL_CLIENT_GET_SYNTAX_ERROR;
- goto out;
- }
-
- *comp = cal_component_new ();
- if (!cal_component_set_icalcomponent (*comp, icalcomp)) {
- icalcomponent_free (icalcomp);
- g_object_unref (*comp);
- *comp = NULL;
-
+ if (!*icalcomp) {
retval = CAL_CLIENT_GET_SYNTAX_ERROR;
goto out;
}
@@ -1411,7 +1400,7 @@ cal_client_get_default_object (CalClient *client, CalObjType type, CalComponent
resize pending, which leads to an assert failure and an abort. */
cb_data.client = client;
cb_data.status = CAL_CLIENT_GET_SUCCESS;
- icalcomponent_foreach_tzid (icalcomp,
+ icalcomponent_foreach_tzid (*icalcomp,
cal_client_get_object_timezones_cb,
&cb_data);
@@ -1427,7 +1416,7 @@ cal_client_get_default_object (CalClient *client, CalObjType type, CalComponent
* cal_client_get_object:
* @client: A calendar client.
* @uid: Unique identifier for a calendar component.
- * @comp: Return value for the calendar component object.
+ * @icalcomp: Return value for the calendar component object.
*
* Queries a calendar for a calendar component object based on its unique
* identifier.
@@ -1435,13 +1424,12 @@ cal_client_get_default_object (CalClient *client, CalObjType type, CalComponent
* Return value: Result code based on the status of the operation.
**/
CalClientGetStatus
-cal_client_get_object (CalClient *client, const char *uid, CalComponent **comp)
+cal_client_get_object (CalClient *client, const char *uid, icalcomponent **icalcomp)
{
CalClientPrivate *priv;
CORBA_Environment ev;
GNOME_Evolution_Calendar_CalObj comp_str;
CalClientGetStatus retval;
- icalcomponent *icalcomp;
CalClientGetTimezonesData cb_data;
g_return_val_if_fail (client != NULL, CAL_CLIENT_GET_NOT_FOUND);
@@ -1451,10 +1439,10 @@ cal_client_get_object (CalClient *client, const char *uid, CalComponent **comp)
g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, CAL_CLIENT_GET_NOT_FOUND);
g_return_val_if_fail (uid != NULL, CAL_CLIENT_GET_NOT_FOUND);
- g_return_val_if_fail (comp != NULL, CAL_CLIENT_GET_NOT_FOUND);
+ g_return_val_if_fail (icalcomp != NULL, CAL_CLIENT_GET_NOT_FOUND);
retval = CAL_CLIENT_GET_NOT_FOUND;
- *comp = NULL;
+ *icalcomp = NULL;
CORBA_exception_init (&ev);
comp_str = GNOME_Evolution_Calendar_Cal_getObject (priv->cal, (char *) uid, &ev);
@@ -1466,20 +1454,10 @@ cal_client_get_object (CalClient *client, const char *uid, CalComponent **comp)
goto out;
}
- icalcomp = icalparser_parse_string (comp_str);
+ *icalcomp = icalparser_parse_string (comp_str);
CORBA_free (comp_str);
- if (!icalcomp) {
- retval = CAL_CLIENT_GET_SYNTAX_ERROR;
- goto out;
- }
-
- *comp = cal_component_new ();
- if (!cal_component_set_icalcomponent (*comp, icalcomp)) {
- icalcomponent_free (icalcomp);
- g_object_unref (G_OBJECT (*comp));
- *comp = NULL;
-
+ if (!*icalcomp) {
retval = CAL_CLIENT_GET_SYNTAX_ERROR;
goto out;
}
@@ -1493,7 +1471,7 @@ cal_client_get_object (CalClient *client, const char *uid, CalComponent **comp)
resize pending, which leads to an assert failure and an abort. */
cb_data.client = client;
cb_data.status = CAL_CLIENT_GET_SUCCESS;
- icalcomponent_foreach_tzid (icalcomp,
+ icalcomponent_foreach_tzid (*icalcomp,
cal_client_get_object_timezones_cb,
&cb_data);
@@ -1936,6 +1914,7 @@ generate_instances_obj_updated_cb (CalClient *client, const char *uid, gpointer
{
GHashTable *uid_comp_hash;
CalComponent *comp;
+ icalcomponent *icalcomp;
CalClientGetStatus status;
const char *comp_uid;
@@ -1953,13 +1932,19 @@ generate_instances_obj_updated_cb (CalClient *client, const char *uid, gpointer
g_hash_table_remove (uid_comp_hash, uid);
g_object_unref (G_OBJECT (comp));
- status = cal_client_get_object (client, uid, &comp);
+ status = cal_client_get_object (client, uid, &icalcomp);
switch (status) {
case CAL_CLIENT_GET_SUCCESS:
- /* The hash key comes from the component's internal data */
- cal_component_get_uid (comp, &comp_uid);
- g_hash_table_insert (uid_comp_hash, (char *) comp_uid, comp);
+ comp = cal_component_new ();
+ if (cal_component_set_icalcomponent (comp, icalcomp)) {
+ /* The hash key comes from the component's internal data */
+ cal_component_get_uid (comp, &comp_uid);
+ g_hash_table_insert (uid_comp_hash, (char *) comp_uid, comp);
+ } else {
+ g_object_unref (comp);
+ icalcomponent_free (icalcomp);
+ }
break;
case CAL_CLIENT_GET_NOT_FOUND:
@@ -2037,21 +2022,28 @@ get_objects_atomically (CalClient *client, CalObjType type, time_t start, time_t
for (l = uids; l; l = l->next) {
CalComponent *comp;
+ icalcomponent *icalcomp;
CalClientGetStatus status;
char *uid;
const char *comp_uid;
uid = l->data;
- status = cal_client_get_object (client, uid, &comp);
+ status = cal_client_get_object (client, uid, &icalcomp);
switch (status) {
case CAL_CLIENT_GET_SUCCESS:
- /* The hash key comes from the component's internal data
- * instead of the duped UID from the list of UIDS.
- */
- cal_component_get_uid (comp, &comp_uid);
- g_hash_table_insert (uid_comp_hash, (char *) comp_uid, comp);
+ comp = cal_component_new ();
+ if (cal_component_set_icalcomponent (comp, icalcomp)) {
+ /* The hash key comes from the component's internal data
+ * instead of the duped UID from the list of UIDS.
+ */
+ cal_component_get_uid (comp, &comp_uid);
+ g_hash_table_insert (uid_comp_hash, (char *) comp_uid, comp);
+ } else {
+ g_object_unref (comp);
+ icalcomponent_free (icalcomp);
+ }
break;
case CAL_CLIENT_GET_NOT_FOUND:
@@ -2912,7 +2904,7 @@ cal_client_get_query (CalClient *client, const char *sexp)
g_return_val_if_fail (sexp != NULL, NULL);
- return cal_query_new (priv->cal, sexp);
+ return cal_query_new (client, priv->cal, sexp);
}
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
index 556049f831..baf2072868 100644
--- a/calendar/cal-client/cal-client.h
+++ b/calendar/cal-client/cal-client.h
@@ -40,7 +40,6 @@ G_BEGIN_DECLS
#define CAL_CLIENT_SET_MODE_STATUS_ENUM_TYPE (cal_client_set_mode_status_enum_get_type ())
#define CAL_MODE_ENUM_TYPE (cal_mode_enum_get_type ())
-typedef struct _CalClient CalClient;
typedef struct _CalClientClass CalClientClass;
typedef struct _CalClientPrivate CalClientPrivate;
@@ -169,11 +168,11 @@ int cal_client_get_n_objects (CalClient *client, CalObjType type);
CalClientGetStatus cal_client_get_default_object (CalClient *client,
CalObjType type,
- CalComponent **comp);
+ icalcomponent **icalcomp);
CalClientGetStatus cal_client_get_object (CalClient *client,
const char *uid,
- CalComponent **comp);
+ icalcomponent **icalcomp);
CalClientGetStatus cal_client_get_timezone (CalClient *client,
const char *tzid,
diff --git a/calendar/cal-client/cal-query.c b/calendar/cal-client/cal-query.c
index 77b18af1ff..914af5db28 100644
--- a/calendar/cal-client/cal-query.c
+++ b/calendar/cal-client/cal-query.c
@@ -37,6 +37,9 @@ struct _CalQueryPrivate {
/* Handle to the query in the server */
GNOME_Evolution_Calendar_Query corba_query;
+
+ /* The CalClient associated with this query */
+ CalClient *client;
};
@@ -366,6 +369,7 @@ cal_query_construct (CalQuery *query,
/**
* cal_query_new:
+ * @client: Client from which the query is being created.
* @cal: Handle to an open calendar.
* @sexp: S-expression that defines the query.
*
@@ -375,7 +379,8 @@ cal_query_construct (CalQuery *query,
* Return value: A newly-created query object, or NULL if the request failed.
**/
CalQuery *
-cal_query_new (GNOME_Evolution_Calendar_Cal cal,
+cal_query_new (CalClient *client,
+ GNOME_Evolution_Calendar_Cal cal,
const char *sexp)
{
CalQuery *query;
@@ -387,5 +392,23 @@ cal_query_new (GNOME_Evolution_Calendar_Cal cal,
return NULL;
}
+ query->priv->client = client;
+
return query;
}
+
+/**
+ * cal_query_get_client
+ * @query: A #CalQuery object.
+ *
+ * Get the #CalClient associated with this query.
+ *
+ * Returns: the associated client.
+ */
+CalClient *
+cal_query_get_client (CalQuery *query)
+{
+ g_return_val_if_fail (IS_CAL_QUERY (query), NULL);
+
+ return query->priv->client;
+}
diff --git a/calendar/cal-client/cal-query.h b/calendar/cal-client/cal-query.h
index 9464e7ae6e..77429035fa 100644
--- a/calendar/cal-client/cal-query.h
+++ b/calendar/cal-client/cal-query.h
@@ -27,6 +27,8 @@
G_BEGIN_DECLS
+typedef struct _CalClient CalClient;
+
#define CAL_QUERY_TYPE (cal_query_get_type ())
@@ -66,16 +68,18 @@ typedef struct {
void (* eval_error) (CalQuery *query, const char *error_str);
} CalQueryClass;
-GType cal_query_get_type (void);
+GType cal_query_get_type (void);
-GType cal_query_done_status_enum_get_type (void);
+GType cal_query_done_status_enum_get_type (void);
-CalQuery *cal_query_construct (CalQuery *query,
- GNOME_Evolution_Calendar_Cal cal,
- const char *sexp);
+CalQuery *cal_query_construct (CalQuery *query,
+ GNOME_Evolution_Calendar_Cal cal,
+ const char *sexp);
-CalQuery *cal_query_new (GNOME_Evolution_Calendar_Cal cal,
- const char *sexp);
+CalQuery *cal_query_new (CalClient *client,
+ GNOME_Evolution_Calendar_Cal cal,
+ const char *sexp);
+CalClient *cal_query_get_client (CalQuery *query);