This commit is contained in:
shaver%mozilla.org 2004-11-23 23:24:36 +00:00
Родитель f21ade5f0b
Коммит 2ac8cdf48d
2 изменённых файлов: 68 добавлений и 8 удалений

Просмотреть файл

@ -109,6 +109,11 @@ interface calIIcalComponent : nsISupports
attribute calIDateTime createdTime;
attribute calIDateTime completedTime;
attribute calIDateTime lastModified;
void getAttendees(out PRUint32 count,
[array,size_is(count),retval] out string attendees);
void setAttendees(in PRUint32 count,
[array,size_is(count)] in string attendees);
};
[scriptable,uuid(c788a1dc-0929-4029-9a14-e1bc654eafad)]

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsComponentManagerUtils.h"
#include "nsCRT.h"
#include "calIEvent.h"
#include "calBaseCID.h"
@ -106,7 +107,7 @@ protected:
return SetProperty(kind, val);
}
void ClearAllProperties(icalproperty_kind kind);
icalcomponent *mComponent;
nsCOMPtr<calIcalComponent> mParent;
@ -115,13 +116,8 @@ protected:
nsresult
calIcalComponent::SetProperty(icalproperty_kind kind, icalvalue *val)
{
icalproperty *prop =
icalcomponent_get_first_property(mComponent, kind);
if (prop) {
icalcomponent_remove_property(mComponent, prop);
icalproperty_free(prop);
}
prop = icalproperty_new(kind);
ClearAllProperties(kind);
icalproperty *prop = icalproperty_new(kind);
if (!prop) {
icalvalue_free(val);
return NS_ERROR_OUT_OF_MEMORY;
@ -255,6 +251,65 @@ DATE_ATTRIBUTE(LastModified, LASTMODIFIED)
DATE_ATTRIBUTE(CreatedTime, CREATED)
DATE_ATTRIBUTE(CompletedTime, COMPLETED)
NS_IMETHODIMP
calIcalComponent::GetAttendees(PRUint32 *count, char ***attendees)
{
char **attlist = nsnull;
PRUint32 attcount = 0;
for (icalproperty *prop =
icalcomponent_get_first_property(mComponent, ICAL_ATTENDEE_PROPERTY);
prop;
prop = icalcomponent_get_next_property(mComponent, ICAL_ATTENDEE_PROPERTY)) {
attcount++;
char **newlist =
NS_STATIC_CAST(char **,
NS_Realloc(attlist, attcount * sizeof(char *)));
if (!newlist)
goto oom;
attlist = newlist;
attlist[attcount - 1] = nsCRT::strdup(icalproperty_get_attendee(prop));
if (!attlist[attcount - 1])
goto oom;
}
*attendees = attlist;
*count = attcount;
return NS_OK;
oom:
for (PRUint32 i = 0; i < attcount - 1; i++)
NS_Free(attlist[i]);
NS_Free(attlist);
return NS_ERROR_OUT_OF_MEMORY;
}
void
calIcalComponent::ClearAllProperties(icalproperty_kind kind)
{
for (icalproperty *prop =
icalcomponent_get_first_property(mComponent, kind),
*next;
prop;
prop = next) {
next = icalcomponent_get_next_property(mComponent, kind);
icalcomponent_remove_property(mComponent, prop);
}
}
NS_IMETHODIMP
calIcalComponent::SetAttendees(PRUint32 count, const char **attendees)
{
ClearAllProperties(ICAL_ATTENDEE_PROPERTY);
for (PRUint32 i = 0; i < count; i++) {
icalproperty *prop = icalproperty_new_attendee(attendees[i]);
if (!prop)
return NS_ERROR_OUT_OF_MEMORY;
icalcomponent_add_property(mComponent, prop);
}
return NS_OK;
}
NS_IMPL_ISUPPORTS1(calICSService, calIICSService)
NS_IMETHODIMP