[evolution-data-server] Add e_cal_component_id_new().



commit a8a19aa2d89f713edb7c6757cdad032a31e38c6f
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Mar 18 07:56:26 2013 -0400

    Add e_cal_component_id_new().

 calendar/libecal/e-cal-component.c                 |   39 ++++++++++++++++----
 calendar/libecal/e-cal-component.h                 |    3 ++
 .../calendar/libecal/libecal-sections.txt          |    1 +
 3 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/calendar/libecal/e-cal-component.c b/calendar/libecal/e-cal-component.c
index 1cc00a9..538488c 100644
--- a/calendar/libecal/e-cal-component.c
+++ b/calendar/libecal/e-cal-component.c
@@ -5196,6 +5196,37 @@ e_cal_component_free_id (ECalComponentId *id)
 }
 
 /**
+ * e_cal_component_id_new:
+ * @uid: a unique ID string
+ * @rid: (allow-none): an optional recurrence ID string
+ *
+ * Creates a new #ECalComponentId from @uid and @rid, which should be
+ * freed with e_cal_component_free_id().
+ *
+ * Returns: an #ECalComponentId
+ *
+ * Since: 3.10
+ **/
+ECalComponentId *
+e_cal_component_id_new (const gchar *uid,
+                        const gchar *rid)
+{
+       ECalComponentId *id;
+
+       g_return_val_if_fail (uid != NULL, NULL);
+
+       /* Normalize an empty recurrence ID to NULL. */
+       if (rid != NULL && *rid == '\0')
+               rid = NULL;
+
+       id = g_new0 (ECalComponentId, 1);
+       id->uid = g_strdup (uid);
+       id->rid = g_strdup (rid);
+
+       return id;
+}
+
+/**
  * e_cal_component_id_copy:
  * @id: an #ECalComponentId
  *
@@ -5209,15 +5240,9 @@ e_cal_component_free_id (ECalComponentId *id)
 ECalComponentId *
 e_cal_component_id_copy (const ECalComponentId *id)
 {
-       ECalComponentId *copy;
-
        g_return_val_if_fail (id != NULL, NULL);
 
-       copy = g_new0 (ECalComponentId, 1);
-       copy->uid = g_strdup (id->uid);
-       copy->rid = g_strdup (id->rid);
-
-       return copy;
+       return e_cal_component_id_new (id->uid, id->rid);
 }
 
 /**
diff --git a/calendar/libecal/e-cal-component.h b/calendar/libecal/e-cal-component.h
index 705e68c..149f8ac 100644
--- a/calendar/libecal/e-cal-component.h
+++ b/calendar/libecal/e-cal-component.h
@@ -247,6 +247,9 @@ ECalComponentId *
                e_cal_component_get_id          (ECalComponent *comp);
 void           e_cal_component_free_id         (ECalComponentId *id);
 ECalComponentId *
+               e_cal_component_id_new          (const gchar *uid,
+                                                const gchar *rid);
+ECalComponentId *
                e_cal_component_id_copy         (const ECalComponentId *id);
 guint          e_cal_component_id_hash         (const ECalComponentId *id);
 gboolean       e_cal_component_id_equal        (const ECalComponentId *id1,
diff --git a/docs/reference/calendar/libecal/libecal-sections.txt 
b/docs/reference/calendar/libecal/libecal-sections.txt
index 3bc5889..39ebb3c 100644
--- a/docs/reference/calendar/libecal/libecal-sections.txt
+++ b/docs/reference/calendar/libecal/libecal-sections.txt
@@ -258,6 +258,7 @@ e_cal_component_get_uid
 e_cal_component_set_uid
 e_cal_component_get_id
 e_cal_component_free_id
+e_cal_component_id_new
 e_cal_component_id_copy
 e_cal_component_id_hash
 e_cal_component_id_equal


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]