diff --git a/calendar/base/src/calEvent.js b/calendar/base/src/calEvent.js index 5b90168c271..0cde7080aa7 100644 --- a/calendar/base/src/calEvent.js +++ b/calendar/base/src/calEvent.js @@ -154,8 +154,7 @@ calEvent.prototype = { classes["@mozilla.org/calendar/ics-service;1"]. getService(Components.interfaces.calIICSService); var calcomp = icssvc.createIcalComponent("VCALENDAR"); - calcomp.prodid = "-//Mozilla Calendar//NONSGML Sunbird//EN"; - calcomp.version = "2.0"; + calSetProdidVersion(calcomp); if (this.hasProperty("METHOD")) { calcomp.method = this.getProperty("METHOD"); } diff --git a/calendar/base/src/calIcsSerializer.js b/calendar/base/src/calIcsSerializer.js index dd9495f1290..4086c565c7d 100644 --- a/calendar/base/src/calIcsSerializer.js +++ b/calendar/base/src/calIcsSerializer.js @@ -102,8 +102,7 @@ function is_getIcalComponent() { icsSvc = Components.classes["@mozilla.org/calendar/ics-service;1"] .getService(Components.interfaces.calIICSService); var calComp = icsSvc.createIcalComponent("VCALENDAR"); - calComp.version = "2.0"; - calComp.prodid = "-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN"; + calSetProdidVersion(calComp); for each (var prop in this.mProperties) { calComp.addProperty(prop); diff --git a/calendar/base/src/calTodo.js b/calendar/base/src/calTodo.js index 2927e3e4a4e..d157efd86ad 100644 --- a/calendar/base/src/calTodo.js +++ b/calendar/base/src/calTodo.js @@ -182,8 +182,7 @@ calTodo.prototype = { classes["@mozilla.org/calendar/ics-service;1"]. getService(Components.interfaces.calIICSService); var calcomp = icssvc.createIcalComponent("VCALENDAR"); - calcomp.prodid = "-//Mozilla Calendar//NONSGML Sunbird//EN"; - calcomp.version = "2.0"; + calSetProdidVersion(calcomp); calcomp.addSubcomponent(this.icalComponent); return calcomp.serializeToICS(); }, diff --git a/calendar/base/src/calUtils.js b/calendar/base/src/calUtils.js index 4b830590735..c1dc4925e63 100644 --- a/calendar/base/src/calUtils.js +++ b/calendar/base/src/calUtils.js @@ -1334,3 +1334,21 @@ function sameDay(date1, date2) { return false; } +/** + * This is a centralized function for setting the prodid and version on an + * ical components. This should be used whenever you need to set the prodid + * and version on a calIcalComponent object. + * + * @param + * aIcalComponent The ical component to set the prodid and version on. + */ +function calSetProdidVersion(aIcalComponent) { + + // Throw for an invalid parameter + if (!aIcalComponent instanceof Components.interfaces.calIIcalComponent) + throw Components.results.NS_ERROR_INVALID_ARG; + + // Set the prodid and version + aIcalComponent.prodid = "-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN"; + aIcalComponent.version = "2.0"; +} diff --git a/calendar/providers/caldav/calDavCalendar.js b/calendar/providers/caldav/calDavCalendar.js index 22950542e60..36e5257e7f0 100644 --- a/calendar/providers/caldav/calDavCalendar.js +++ b/calendar/providers/caldav/calDavCalendar.js @@ -605,8 +605,7 @@ calDavCalendar.prototype = { const icssvc = Components.classes["@mozilla.org/calendar/ics-service;1"]. getService(Components.interfaces.calIICSService); var modifiedItem = icssvc.createIcalComponent("VCALENDAR"); - modifiedItem.prodid = "-//Mozilla Calendar//NONSGML Sunbird//EN"; - modifiedItem.version = "2.0"; + calSetProdidVersion(modifiedItem); modifiedItem.addSubcomponent(aNewItem.icalComponent); if (aNewItem.recurrenceInfo) { var exceptions = aNewItem.recurrenceInfo.getExceptionIds({}); diff --git a/calendar/resources/content/clipboard.js b/calendar/resources/content/clipboard.js index 10e581f1009..ab96facaf51 100644 --- a/calendar/resources/content/clipboard.js +++ b/calendar/resources/content/clipboard.js @@ -122,8 +122,7 @@ function copyToClipboard( calendarItemArray ) var icssrv = Components.classes["@mozilla.org/calendar/ics-service;1"] .getService(Components.interfaces.calIICSService); var calComp = icssrv.createIcalComponent("VCALENDAR"); - calComp.version = "2.0"; - calComp.prodid = "-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN"; + calSetProdidVersion(calComp); for each (item in calendarItemArray) { // If we copy an item and paste it again, it will have the same ID as