[gnome-calendar] recurrence: add a function to check equality of recurrences
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] recurrence: add a function to check equality of recurrences
- Date: Thu, 13 Jul 2017 16:34:30 +0000 (UTC)
commit 59fcd01192ac87e429cefce826d3e73827c34ad2
Author: Yash Singh <yashdev10p gmail com>
Date: Wed Jul 12 01:56:44 2017 +0530
recurrence: add a function to check equality of recurrences
The gcal_recurrence_is_equal function checks if two recurrences are
equal or not. When a user is trying to modify the recurrence-rules
of an already recurring event, this function tells us if the
recurrence-dialog should pop up or not.
This patch also removes some unused code.
https://bugzilla.gnome.org/show_bug.cgi?id=782755
src/gcal-recurrence.c | 45 +++++++++++++++++++++++++++++++++++++++------
src/gcal-recurrence.h | 3 +++
2 files changed, 42 insertions(+), 6 deletions(-)
---
diff --git a/src/gcal-recurrence.c b/src/gcal-recurrence.c
index ee85e45..1291ae4 100644
--- a/src/gcal-recurrence.c
+++ b/src/gcal-recurrence.c
@@ -90,6 +90,45 @@ gcal_recurrence_free (GcalRecurrence *recur)
}
/**
+ * gcal_recurrence_is_equal:
+ * @recur1: (nullable): a #GcalRecurrence
+ * @recur2: (nullable): a #GcalRecurrence
+ *
+ * Checks if @recur1 and @recur2 are equal or not
+ *
+ * Returns: %TRUE if both are equal, %FALSE otherwise
+ */
+
+gboolean
+gcal_recurrence_is_equal (GcalRecurrence *recur1,
+ GcalRecurrence *recur2)
+{
+ if (recur1 == recur2)
+ return TRUE;
+ else if (!recur1 || !recur2)
+ return FALSE;
+
+ if (recur1->frequency != recur2->frequency)
+ return FALSE;
+
+ if (recur1->limit_type != recur2->limit_type)
+ return FALSE;
+
+ if (recur1->limit_type == GCAL_RECURRENCE_UNTIL)
+ {
+ if (!g_date_time_equal (recur1->limit.until, recur2->limit.until))
+ return FALSE;
+ }
+ else if (recur1->limit_type == GCAL_RECURRENCE_COUNT)
+ {
+ if (recur1->limit.count != recur2->limit.count)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
* gcal_recurrence_parse_recurrence_rules:
* @comp: an #ECalComponent
*
@@ -192,12 +231,6 @@ gcal_recurrence_to_rrule (GcalRecurrence *recur)
rrule = g_new0 (struct icalrecurrencetype, 1);
icalrecurrencetype_clear (rrule);
- rrule->until.second = 0;
- rrule->until.minute = 0;
- rrule->until.hour = 0;
- rrule->until.is_date = TRUE;
- rrule->until.is_utc = FALSE;
-
switch (recur->frequency)
{
case GCAL_RECURRENCE_DAILY:
diff --git a/src/gcal-recurrence.h b/src/gcal-recurrence.h
index 737b27b..6a313dd 100644
--- a/src/gcal-recurrence.h
+++ b/src/gcal-recurrence.h
@@ -67,6 +67,9 @@ GcalRecurrence* gcal_recurrence_copy (GcalRecurrence
void gcal_recurrence_free (GcalRecurrence *recur);
+gboolean gcal_recurrence_is_equal (GcalRecurrence *recur1,
+ GcalRecurrence *recur2);
+
GcalRecurrence* gcal_recurrence_parse_recurrence_rules (ECalComponent *comp);
struct icalrecurrencetype* gcal_recurrence_to_rrule (GcalRecurrence *recur);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]