Fix bug 869405 - Add a few interface methods to the libical wrapper. r=mmecca
authorPhilipp Kewisch <mozilla@kewis.ch>
Tue, 07 May 2013 14:44:45 +0200
changeset 15514 638db6e0f8a7e299666fffd0d127c1c6fd7eb25e
parent 15513 f743582c7050fd12afc8dbc3ffc30ffec44c555c
child 15515 1ad08ece23155aaf0c267b8fe87d2a59e85b5ca3
push id920
push userbugzilla@standard8.plus.com
push dateMon, 24 Jun 2013 19:03:14 +0000
treeherdercomm-beta@936bfe9d120b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmmecca
bugs869405
Fix bug 869405 - Add a few interface methods to the libical wrapper. r=mmecca
calendar/base/backend/libical/calDuration.cpp
calendar/base/backend/libical/calICSService.cpp
calendar/base/backend/libical/calPeriod.cpp
calendar/base/backend/libical/calRecurrenceRule.cpp
calendar/base/backend/libical/calUtils.cpp
calendar/base/public/calIDuration.idl
calendar/base/public/calIICSService.idl
calendar/base/public/calIPeriod.idl
calendar/base/public/calIRecurrenceRule.idl
--- a/calendar/base/backend/libical/calDuration.cpp
+++ b/calendar/base/backend/libical/calDuration.cpp
@@ -42,16 +42,28 @@ calDuration::calDuration(const calDurati
 
 calDuration::calDuration(const struct icaldurationtype * const aDurationPtr)
     : mImmutable(false)
 {
     FromIcalDuration(aDurationPtr);
 }
 
 NS_IMETHODIMP
+calDuration::GetIcalDuration(JS::Value*)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+calDuration::SetIcalDuration(JS::Value const&)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
 calDuration::GetIsMutable(bool *aResult)
 {
     NS_ENSURE_ARG_POINTER(aResult);
 
     *aResult = !mImmutable;
     return NS_OK;
 }
 
--- a/calendar/base/backend/libical/calICSService.cpp
+++ b/calendar/base/backend/libical/calICSService.cpp
@@ -21,25 +21,25 @@ calIcalProperty::~calIcalProperty()
         icalproperty_free(mProperty);
     }
 }
 
 NS_IMPL_CLASSINFO(calIcalProperty, NULL, 0, CAL_ICALPROPERTY_CID)
 NS_IMPL_ISUPPORTS1_CI(calIcalProperty, calIIcalProperty)
 
 NS_IMETHODIMP_(icalproperty *)
-calIcalProperty::GetIcalProperty()
+calIcalProperty::GetLibicalProperty()
 {
     return mProperty;
 }
 
 NS_IMETHODIMP_(icalcomponent *)
-calIcalProperty::GetIcalComponent()
+calIcalProperty::GetLibicalComponent()
 {
-    return mParent->GetIcalComponent();
+    return mParent->GetLibicalComponent();
 }
 
 NS_IMETHODIMP
 calIcalProperty::GetIcalString(nsACString &str)
 {
     char const* icalstr = icalproperty_as_ical_string(mProperty);
     if (icalstr == 0) {
 #ifdef DEBUG
@@ -457,16 +457,46 @@ calIcalComponent::~calIcalComponent()
         // In the latter case icaltimezone_free frees the VTIMEZONE component.
         if (mTimezone) {
             icaltimezone_free(mTimezone, 1 /* free struct */);
         } else {
             icalcomponent_free(mComponent);
         }
     }
 }
+NS_IMETHODIMP
+calIcalComponent::GetIcalComponent(JS::Value*)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+calIcalComponent::SetIcalComponent(JS::Value const&)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+calIcalComponent::GetParent(calIIcalComponent** parent)
+{
+    NS_ADDREF(*parent = mParent);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+calIcalComponent::GetIcalTimezone(JS::Value*)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+calIcalComponent::SetIcalTimezone(JS::Value const&)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
 
 NS_IMETHODIMP
 calIcalComponent::AddTimezoneReference(calITimezone *aTimezone)
 {
     NS_ENSURE_ARG_POINTER(aTimezone);
     nsAutoCString tzid;
     nsresult rv = aTimezone->GetTzid(tzid);
     NS_ENSURE_SUCCESS(rv, rv);
@@ -706,16 +736,35 @@ nsresult calIcalComponent::SetDateTimeAt
     if (NS_SUCCEEDED(rc))
         icalcomponent_add_property(mComponent, prop);
     else
         icalproperty_free(prop);
     return rc;
 }
 
 NS_IMETHODIMP
+calIcalProperty::GetParent(calIIcalComponent** parent)
+{
+    NS_ADDREF(*parent = mParent);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+calIcalProperty::GetIcalProperty(JS::Value*)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+calIcalProperty::SetIcalProperty(JS::Value const&)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
 calIcalProperty::SetValueAsDatetime(calIDateTime *dt)
 {
     NS_ENSURE_ARG_POINTER(dt);
     return setDatetime_(toIcalComponent(mParent), mProperty, dt);
 }
 
 nsresult calIcalProperty::setDatetime_(calIcalComponent * parent,
                                        icalproperty * prop,
@@ -803,33 +852,33 @@ calIcalComponent::Get##Attrname(calIDura
 
 
 NS_IMPL_CLASSINFO(calIcalComponent, NULL, nsIClassInfo::THREADSAFE, CAL_ICALCOMPONENT_CID)
 NS_IMPL_THREADSAFE_ISUPPORTS2(calIcalComponent, calIIcalComponent, nsIClassInfo)
 NS_IMPL_CI_INTERFACE_GETTER1(calIcalComponent, calIIcalComponent)
 NS_IMPL_THREADSAFE_CI(calIcalComponent)
 
 NS_IMETHODIMP_(icalcomponent *)
-calIcalComponent::GetIcalComponent()
+calIcalComponent::GetLibicalComponent()
 {
     return mComponent;
 }
 
 NS_IMETHODIMP_(icaltimezone *)
-calIcalComponent::GetIcalTimezone()
+calIcalComponent::GetLibicalTimezone()
 {
     NS_ASSERTION(icalcomponent_isa(mComponent) == ICAL_VTIMEZONE_COMPONENT, "no VTIMEZONE -- unexpected!");
     if (!mTimezone && (icalcomponent_isa(mComponent) == ICAL_VTIMEZONE_COMPONENT)) {
         // xxx todo: libical needs a parent VCALENDAR to retrieve a icaltimezone
         NS_ASSERTION(mParent, "VTIMEZONE has no parent!");
         if (mParent) {
             icalproperty * const tzidProp = icalcomponent_get_first_property(mComponent, ICAL_TZID_PROPERTY);
             NS_ASSERTION(tzidProp, "no TZID property in VTIMEZONE!?");
             if (tzidProp) {
-                mTimezone = icalcomponent_get_timezone(mParent->GetIcalComponent(),
+                mTimezone = icalcomponent_get_timezone(mParent->GetLibicalComponent(),
                                                        icalvalue_get_string(icalproperty_get_value(tzidProp)));
             }
         }
     }
     return mTimezone;
 }
 
 NS_IMETHODIMP
--- a/calendar/base/backend/libical/calPeriod.cpp
+++ b/calendar/base/backend/libical/calPeriod.cpp
@@ -29,16 +29,28 @@ calPeriod::calPeriod(const calPeriod& cp
 
 calPeriod::calPeriod(struct icalperiodtype const* aPeriodPtr)
     : mImmutable(false)
 {
     FromIcalPeriod(aPeriodPtr);
 }
 
 NS_IMETHODIMP
+calPeriod::GetIcalPeriod(JS::Value*)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+calPeriod::SetIcalPeriod(JS::Value const&)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
 calPeriod::GetIsMutable(bool *aResult)
 {
     NS_ENSURE_ARG_POINTER(aResult);
 
     *aResult = !mImmutable;
     return NS_OK;
 }
 
--- a/calendar/base/backend/libical/calRecurrenceRule.cpp
+++ b/calendar/base/backend/libical/calRecurrenceRule.cpp
@@ -523,17 +523,17 @@ calRecurrenceRule::SetIcalProperty(calII
         mIsNegative = false;
     } else {
         return NS_ERROR_INVALID_ARG;
     }
 
     icalproperty *prop;
     struct icalrecurrencetype icalrecur;
 
-    prop = aProp->GetIcalProperty();
+    prop = aProp->GetLibicalProperty();
 
     icalrecur = icalproperty_get_rrule(prop);
 
     // XXX Note that we ignore the dtstart and use the one from the
     // event, though I realize now that we shouldn't.  Ignoring
     // dtstart makes it impossible to have multiple RRULEs on one
     // event that start at different times (e.g. every day starting on
     // jan 1 for 2 weeks, every other day starting on feb 1 for 2
@@ -583,8 +583,20 @@ calRecurrenceRule::GetIcalString(nsACStr
     rv = this->GetIcalProperty(getter_AddRefs(prop));
 
     if (NS_SUCCEEDED(rv)) {
         rv = prop->GetIcalString(str);
     }
 
     return rv;
 }
+
+NS_IMETHODIMP
+calRecurrenceRule::GetWeekStart(short*)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+calRecurrenceRule::SetWeekStart(short)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
--- a/calendar/base/backend/libical/calUtils.cpp
+++ b/calendar/base/backend/libical/calUtils.cpp
@@ -75,17 +75,17 @@ icaltimezone * getIcalTimezone(calITimez
     bool b;
     tz->GetIsUTC(&b);
     if (b) {
         icaltz = icaltimezone_get_utc_timezone();
     } else {
         nsCOMPtr<calIIcalComponent> tzComp;
         tz->GetIcalComponent(getter_AddRefs(tzComp));
         if (tzComp) {
-            icaltz = tzComp->GetIcalTimezone();
+            icaltz = tzComp->GetLibicalTimezone();
         } // else floating or phantom timezone
     }
     return icaltz;
 }
 
 XpcomBase::~XpcomBase() {
 }
 
--- a/calendar/base/public/calIDuration.idl
+++ b/calendar/base/public/calIDuration.idl
@@ -93,14 +93,15 @@ interface calIDuration : nsISupports
   void normalize();
 
   /**
    * Return a string representation of this instance.
    */
   AUTF8String toString();
 
   [noscript,notxpcom] void toIcalDuration(in icaldurationtypeptr idt);
+  attribute jsval icalDuration;
 
   /**
    * This object as an iCalendar DURATION string
    */
   attribute ACString icalString;
 };
--- a/calendar/base/public/calIICSService.idl
+++ b/calendar/base/public/calIICSService.idl
@@ -29,16 +29,28 @@ interface nsIInputStream;
  * no intervening getNextFoo(otherfootype)s, or removeFoo()s, or addFoo()s. In
  * general, you want to do as little manipulation of your FooContainers as
  * possible while iterating over them.
  */
 [scriptable,uuid(c4637c40-3c4c-4ecd-b802-8b5b46bdf5a4)]
 interface calIIcalComponent : nsISupports
 {
     /**
+     * The parent ical property
+     */
+    readonly attribute calIIcalComponent parent;
+
+    /**
+     * Access to the inner ical.js objects. Only use these if you know what you
+     * are doing.
+     */
+    attribute jsval icalComponent;
+    attribute jsval icalTimezone;
+
+    /**
      * This is the value that an integer-valued getter will provide if
      * there is no such property on the wrapped ical structure.
      */
     const int32_t INVALID_VALUE = -1;
 
     /**
      * @param kind ANY, XROOT, VCALENDAR, VEVENT, etc.
      */
@@ -137,30 +149,41 @@ interface calIIcalComponent : nsISupport
                                 [array,size_is(aCount),retval] out calITimezone aTimezones);
 
     /**
      * Clones the component. The cloned component is decoupled from any parent.
      * @return cloned component
      */
     calIIcalComponent clone();
 
-    [noscript,notxpcom] icalcomponentptr getIcalComponent();
-    [noscript,notxpcom] icaltimezoneptr getIcalTimezone();
+    [noscript,notxpcom] icalcomponentptr getLibicalComponent();
+    [noscript,notxpcom] icaltimezoneptr getLibicalTimezone();
 };
 
 [scriptable,uuid(17349a10-5d80-47fa-9bea-f22957357675)]
 interface calIIcalProperty : nsISupports
 {
     /**
      * The whole property as an ical string.
      * @exception Any libical error will be thrown as an calIError::ICS_ error.
      */
     readonly attribute AUTF8String icalString;
 
     /**
+     * Access to the inner ical.js objects. Only use these if you know what you
+     * are doing.
+     */
+    attribute jsval icalProperty;
+
+    /**
+     * The parent component containing this property
+     */
+    readonly attribute calIIcalComponent parent;
+
+    /**
      * Return a string representation of this instance.
      */
     AUTF8String toString();
 
     /**
      * The value of the property as string.
      * The exception for properties of TEXT or X- type, those will be unescaped
      * when getting, and also expects an unescaped string when setting.
@@ -182,31 +205,22 @@ interface calIIcalProperty : nsISupports
     // XXX attribute AUTF8String stringValueWithParams; ?
     readonly attribute AUTF8String propertyName;
 
     AUTF8String getParameter(in AUTF8String paramname);
     void setParameter(in AUTF8String paramname, in AUTF8String paramval);
 
     AUTF8String getFirstParameterName();
     AUTF8String getNextParameterName();
-    /**
-     * This does not work with X-PARAMETERS, due to limitations in libical.
-     * You have to use clearXParameters() and then rebuild the ones you wanted
-     * to preserve.  Sorry about that.
-     */
+
     void removeParameter(in AUTF8String paramname);
     void clearXParameters();
 
-    [noscript,notxpcom] icalpropertyptr getIcalProperty();
-    /**
-     * Returns the icalcompoment this property belongs to. Please note
-     * that the returned object is a raw pointer to the appropriate
-     * component and is owned by libical.
-     */
-    [noscript,notxpcom] icalcomponentptr getIcalComponent();
+    [noscript,notxpcom] icalpropertyptr getLibicalProperty();
+    [noscript,notxpcom] icalcomponentptr getLibicalComponent();
 };
 
 [scriptable,uuid(41fb4cbd-9977-41c7-b179-ab567e4b9395)]
 interface calIIcsComponentParsingListener : nsISupports
 {
     /**
      * Called when the parsing has completed.
      *
--- a/calendar/base/public/calIPeriod.idl
+++ b/calendar/base/public/calIPeriod.idl
@@ -1,23 +1,24 @@
-/* -*- Mode: idl; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 interface calIDateTime;
 interface calIDuration;
 
 [ptr] native icalperiodtypeptr(struct icalperiodtype);
 
 [scriptable,uuid(03cde9c7-c864-4109-8bea-ebbff01cbab9)]
 interface calIPeriod : nsISupports
 {
+  attribute jsval icalPeriod;
+
   /**
    * isMutable is true if this instance is modifiable.
    * If isMutable is false, any attempts to modify
    * the object will throw NS_ERROR_OBJECT_IS_IMMUTABLE.
    */
   readonly attribute boolean isMutable;
 
   /**
--- a/calendar/base/public/calIRecurrenceRule.idl
+++ b/calendar/base/public/calIRecurrenceRule.idl
@@ -38,16 +38,20 @@ interface calIRecurrenceRule : calIRecur
   // recurrence.
   attribute long count;
   attribute calIDateTime untilDate;
 
   // if this isn't infinite recurrence, this flag indicates whether
   // it was set by count or not
   readonly attribute boolean isByCount;
 
+  // The week start for this rule, used for certain calculations. This is a
+  // value from 0=Sunday to 6=Saturday.
+  attribute short weekStart;
+
   // the components defining the recurrence
   // "BYSECOND", "BYMINUTE", "BYHOUR", "BYDAY",
   // "BYMONTHDAY", "BYYEARDAY", "BYWEEKNO", "BYMONTH",
   // "BYSETPOS"
   void getComponent (in AUTF8String aComponentType,
                      out unsigned long aCount, [array,size_is(aCount),retval] out short aValues);
   void setComponent (in AUTF8String aComponentType,
                      in unsigned long aCount, [array,size_is(aCount)] in short aValues);