michael@0: /** michael@0: * Copyright (c) 2012-2013, Gerald Garcia, Timo Berger michael@8: * michael@0: * This file is part of Andoid Caldav Sync Adapter Free. michael@0: * michael@0: * Andoid Caldav Sync Adapter Free is free software: you can redistribute michael@0: * it and/or modify it under the terms of the GNU General Public License michael@0: * as published by the Free Software Foundation, either version 3 of the michael@0: * License, or at your option any later version. michael@0: * michael@0: * Andoid Caldav Sync Adapter Free is distributed in the hope that michael@0: * it will be useful, but WITHOUT ANY WARRANTY; without even the implied michael@0: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the michael@0: * GNU General Public License for more details. michael@0: * michael@0: * You should have received a copy of the GNU General Public License michael@0: * along with Andoid Caldav Sync Adapter Free. michael@0: * If not, see . michael@8: * michael@0: */ michael@0: michael@0: package org.gege.caldavsyncadapter.android.entities; michael@0: michael@8: import android.database.Cursor; michael@8: import android.net.Uri; michael@8: import android.provider.CalendarContract.Attendees; michael@8: import android.provider.CalendarContract.Events; michael@8: import android.provider.CalendarContract.Reminders; michael@8: michael@0: import net.fortuna.ical4j.model.Calendar; michael@0: import net.fortuna.ical4j.model.Component; michael@0: import net.fortuna.ical4j.model.ComponentList; michael@0: import net.fortuna.ical4j.model.Date; michael@0: import net.fortuna.ical4j.model.DateTime; michael@0: import net.fortuna.ical4j.model.Dur; michael@0: import net.fortuna.ical4j.model.ParameterList; michael@0: import net.fortuna.ical4j.model.Property; michael@0: import net.fortuna.ical4j.model.PropertyList; michael@0: import net.fortuna.ical4j.model.TimeZone; michael@0: import net.fortuna.ical4j.model.TimeZoneRegistry; michael@0: import net.fortuna.ical4j.model.TimeZoneRegistryFactory; michael@0: import net.fortuna.ical4j.model.component.VAlarm; michael@0: import net.fortuna.ical4j.model.component.VEvent; michael@0: import net.fortuna.ical4j.model.parameter.Cn; michael@0: import net.fortuna.ical4j.model.parameter.PartStat; michael@0: import net.fortuna.ical4j.model.parameter.Role; michael@0: import net.fortuna.ical4j.model.parameter.Rsvp; michael@0: import net.fortuna.ical4j.model.parameter.Value; michael@0: import net.fortuna.ical4j.model.property.Action; michael@0: import net.fortuna.ical4j.model.property.Attendee; michael@0: import net.fortuna.ical4j.model.property.CalScale; michael@0: import net.fortuna.ical4j.model.property.Clazz; michael@0: import net.fortuna.ical4j.model.property.Description; michael@0: import net.fortuna.ical4j.model.property.DtEnd; michael@0: import net.fortuna.ical4j.model.property.DtStart; michael@0: import net.fortuna.ical4j.model.property.Duration; michael@0: import net.fortuna.ical4j.model.property.ExDate; michael@0: import net.fortuna.ical4j.model.property.ExRule; michael@0: import net.fortuna.ical4j.model.property.Location; michael@0: import net.fortuna.ical4j.model.property.Organizer; michael@0: import net.fortuna.ical4j.model.property.ProdId; michael@0: import net.fortuna.ical4j.model.property.RDate; michael@0: import net.fortuna.ical4j.model.property.RRule; michael@0: import net.fortuna.ical4j.model.property.Status; michael@0: import net.fortuna.ical4j.model.property.Summary; michael@0: import net.fortuna.ical4j.model.property.Trigger; michael@0: import net.fortuna.ical4j.model.property.Uid; michael@0: import net.fortuna.ical4j.model.property.Version; michael@8: michael@8: import org.gege.caldavsyncadapter.caldav.entities.CalendarEvent; michael@8: michael@8: import java.net.URISyntaxException; michael@8: import java.text.ParseException; michael@8: michael@32: import static junit.framework.Assert.*; michael@22: michael@21: import com.europalab.caldavsyn.Appctxpro; michael@21: michael@0: //import android.accounts.Account; michael@0: //import android.content.ContentProviderClient; michael@0: //import android.content.ContentValues; michael@0: //import android.content.SyncStats; michael@0: //import android.os.RemoteException; michael@0: //import android.provider.CalendarContract.Calendars; michael@0: //import org.gege.caldavsyncadapter.Event; michael@0: //import org.gege.caldavsyncadapter.caldav.CaldavFacade; michael@0: //import org.gege.caldavsyncadapter.caldav.entities.DavCalendar; michael@0: //import org.gege.caldavsyncadapter.syncadapter.SyncAdapter; michael@0: michael@0: public class AndroidEvent extends org.gege.caldavsyncadapter.Event { michael@0: michael@8: private Uri muri; michael@0: michael@8: private Uri mAndroidCalendarUri; michael@8: michael@8: /** michael@8: * the list of attendees michael@8: */ michael@8: private PropertyList mAttendees = new PropertyList(); michael@8: michael@8: /** michael@8: * the list of reminders michael@8: */ michael@8: private ComponentList mReminders = new ComponentList(); michael@8: michael@8: private Calendar mCalendar = null; michael@0: michael@0: /* private Account mAccount = null; michael@8: private ContentProviderClient mProvider = null;*/ michael@8: michael@8: //public AndroidEvent(Account account, ContentProviderClient provider, Uri uri, Uri calendarUri) { michael@8: public AndroidEvent(Uri uri, Uri calendarUri) { michael@8: super(); michael@8: this.setUri(uri); michael@0: /* this.mAccount = account; michael@8: this.mProvider = provider;*/ michael@8: //this.setCounterpartUri(calendarUri); michael@8: mAndroidCalendarUri = calendarUri; michael@8: } michael@0: michael@8: public Calendar getIcsEvent() { michael@8: return mCalendar; michael@8: } michael@0: michael@8: public String getETag() { michael@8: String Result = ""; michael@8: if (this.ContentValues.containsKey(ETAG)) michael@8: Result = this.ContentValues.getAsString(ETAG); michael@8: return Result; michael@8: } michael@0: michael@8: public void setETag(String eTag) { michael@8: this.ContentValues.put(ETAG, eTag); michael@8: } michael@0: michael@8: public Uri getUri() { michael@8: return muri; michael@8: } michael@0: michael@8: public void setUri(Uri uri) { michael@8: this.muri = uri; michael@8: } michael@0: michael@8: public Uri getAndroidCalendarUri() { michael@8: return mAndroidCalendarUri; michael@8: } michael@0: michael@8: @Override michael@8: public String toString() { michael@8: return this.getUri().toString(); michael@8: } michael@0: michael@8: /** michael@8: * reads an android event from a given cursor into {@link AndroidEvent#ContentValues} michael@8: * michael@8: * @param cur the cursor with the event michael@8: * @return success of this funtion michael@8: * @see AndroidEvent#ContentValues michael@8: */ michael@8: public boolean readContentValues(Cursor cur) { michael@8: this.setETag(cur.getString(cur.getColumnIndex(ETAG))); michael@0: michael@8: this.ContentValues.put(Events.EVENT_TIMEZONE, cur.getString(cur.getColumnIndex(Events.EVENT_TIMEZONE))); michael@8: this.ContentValues.put(Events.EVENT_END_TIMEZONE, cur.getString(cur.getColumnIndex(Events.EVENT_END_TIMEZONE))); michael@8: this.ContentValues.put(Events.DTSTART, cur.getLong(cur.getColumnIndex(Events.DTSTART))); michael@8: this.ContentValues.put(Events.DTEND, cur.getLong(cur.getColumnIndex(Events.DTEND))); michael@8: this.ContentValues.put(Events.ALL_DAY, cur.getLong(cur.getColumnIndex(Events.ALL_DAY))); michael@8: this.ContentValues.put(Events.TITLE, cur.getString(cur.getColumnIndex(Events.TITLE))); michael@8: this.ContentValues.put(Events.CALENDAR_ID, cur.getString(cur.getColumnIndex(Events.CALENDAR_ID))); michael@8: this.ContentValues.put(Events._SYNC_ID, cur.getString(cur.getColumnIndex(Events._SYNC_ID))); michael@8: //this.ContentValues.put(Events.SYNC_DATA1, cur.getString(cur.getColumnIndex(Events.SYNC_DATA1))); //not needed here, eTag has already been read michael@8: this.ContentValues.put(Events.DESCRIPTION, cur.getString(cur.getColumnIndex(Events.DESCRIPTION))); michael@8: this.ContentValues.put(Events.EVENT_LOCATION, cur.getString(cur.getColumnIndex(Events.EVENT_LOCATION))); michael@8: this.ContentValues.put(Events.ACCESS_LEVEL, cur.getInt(cur.getColumnIndex(Events.ACCESS_LEVEL))); michael@0: michael@8: this.ContentValues.put(Events.STATUS, cur.getInt(cur.getColumnIndex(Events.STATUS))); michael@0: michael@8: this.ContentValues.put(Events.LAST_DATE, cur.getInt(cur.getColumnIndex(Events.LAST_DATE))); michael@8: this.ContentValues.put(Events.DURATION, cur.getString(cur.getColumnIndex(Events.DURATION))); michael@0: michael@8: this.ContentValues.put(Events.RDATE, cur.getString(cur.getColumnIndex(Events.RDATE))); michael@8: this.ContentValues.put(Events.RRULE, cur.getString(cur.getColumnIndex(Events.RRULE))); michael@8: this.ContentValues.put(Events.EXRULE, cur.getString(cur.getColumnIndex(Events.EXRULE))); michael@8: this.ContentValues.put(Events.EXDATE, cur.getString(cur.getColumnIndex(Events.EXDATE))); michael@8: this.ContentValues.put(Events.DIRTY, cur.getInt(cur.getColumnIndex(Events.DIRTY))); michael@8: this.ContentValues.put(UID, cur.getString(cur.getColumnIndex(UID))); michael@8: this.ContentValues.put(RAWDATA, cur.getString(cur.getColumnIndex(RAWDATA))); michael@0: michael@8: return true; michael@8: } michael@0: michael@8: /** michael@8: * reads the attendees from a given cursor michael@8: * michael@8: * @param cur the cursor with the attendees michael@8: * @return success of this function michael@8: * @see AndroidEvent#mAttendees michael@8: */ michael@8: public boolean readAttendees(Cursor cur) { michael@8: Attendee attendee = null; michael@8: Organizer organizer = null; michael@8: ParameterList paraList = null; michael@8: michael@8: String Name = ""; michael@8: Cn cn = null; michael@8: michael@8: String Email = ""; michael@8: michael@8: int Relationship = 0; michael@8: michael@8: michael@8: int Status = 0; michael@8: PartStat partstat = null; michael@8: michael@8: int Type = 0; michael@8: Role role = null; michael@8: michael@8: try { michael@8: while (cur.moveToNext()) { michael@8: Name = cur.getString(cur.getColumnIndex(Attendees.ATTENDEE_NAME)); michael@8: Email = cur.getString(cur.getColumnIndex(Attendees.ATTENDEE_EMAIL)); michael@8: Relationship = cur.getInt(cur.getColumnIndex(Attendees.ATTENDEE_RELATIONSHIP)); michael@8: Type = cur.getInt(cur.getColumnIndex(Attendees.ATTENDEE_TYPE)); michael@8: Status = cur.getInt(cur.getColumnIndex(Attendees.ATTENDEE_STATUS)); michael@8: michael@8: if (Relationship == Attendees.RELATIONSHIP_ORGANIZER) { michael@8: organizer = new Organizer(); michael@8: organizer.setValue("mailto:" + Email); michael@8: paraList = organizer.getParameters(); michael@8: mAttendees.add(organizer); michael@8: } else { michael@8: attendee = new Attendee(); michael@8: attendee.setValue("mailto:" + Email); michael@8: paraList = attendee.getParameters(); michael@8: mAttendees.add(attendee); michael@8: } michael@8: michael@8: Rsvp rsvp = new Rsvp(true); michael@8: paraList.add(rsvp); michael@8: michael@8: cn = new Cn(Name); michael@8: paraList.add(cn); michael@8: michael@8: if (Status == Attendees.ATTENDEE_STATUS_INVITED) michael@8: partstat = new PartStat(PartStat.NEEDS_ACTION.getValue()); michael@8: else if (Status == Attendees.ATTENDEE_STATUS_ACCEPTED) michael@8: partstat = new PartStat(PartStat.ACCEPTED.getValue()); michael@8: else if (Status == Attendees.ATTENDEE_STATUS_DECLINED) michael@8: partstat = new PartStat(PartStat.DECLINED.getValue()); michael@8: else if (Status == Attendees.ATTENDEE_STATUS_NONE) michael@8: partstat = new PartStat(PartStat.COMPLETED.getValue()); michael@8: else if (Status == Attendees.ATTENDEE_STATUS_TENTATIVE) michael@8: partstat = new PartStat(PartStat.TENTATIVE.getValue()); michael@8: else michael@8: partstat = new PartStat(PartStat.NEEDS_ACTION.getValue()); michael@8: paraList.add(partstat); michael@8: michael@8: if (Type == Attendees.TYPE_OPTIONAL) michael@8: role = new Role(Role.OPT_PARTICIPANT.getValue()); michael@8: else if (Type == Attendees.TYPE_NONE) michael@8: role = new Role(Role.NON_PARTICIPANT.getValue()); //regular participants in android are non required? michael@8: else if (Type == Attendees.TYPE_REQUIRED) michael@8: role = new Role(Role.REQ_PARTICIPANT.getValue()); michael@8: else michael@8: role = new Role(Role.NON_PARTICIPANT.getValue()); michael@8: paraList.add(role); michael@8: } michael@8: michael@8: } catch (URISyntaxException e) { michael@8: e.printStackTrace(); michael@8: } michael@8: return true; michael@8: } michael@8: michael@8: /** michael@8: * reads the reminders from a given cursor michael@8: * michael@8: * @param cur the cursor with the reminders michael@8: * @return success of this function michael@8: */ michael@8: public boolean readReminder(Cursor cur) { michael@8: int Method; michael@8: int Minutes; michael@8: VAlarm reminder; michael@8: while (cur.moveToNext()) { michael@8: reminder = new VAlarm(); michael@8: Method = cur.getInt(cur.getColumnIndex(Reminders.METHOD)); michael@8: Minutes = cur.getInt(cur.getColumnIndex(Reminders.MINUTES)) * -1; michael@8: michael@8: michael@8: Dur dur = new Dur(0, 0, Minutes, 0); michael@8: Trigger tri = new Trigger(dur); michael@8: Value val = new Value(Duration.DURATION); michael@8: tri.getParameters().add(val); michael@8: reminder.getProperties().add(tri); michael@8: michael@8: Description desc = new Description(); michael@8: desc.setValue("caldavsyncadapter standard description"); michael@8: reminder.getProperties().add(desc); michael@8: michael@8: michael@8: if (Method == Reminders.METHOD_EMAIL) michael@8: reminder.getProperties().add(Action.EMAIL); michael@8: else michael@8: reminder.getProperties().add(Action.DISPLAY); michael@8: michael@8: this.mReminders.add(reminder); michael@8: } michael@8: return true; michael@8: } michael@8: michael@8: /** michael@8: * generates a new ics-file. michael@8: * uses {@link AndroidEvent#ContentValues} as source. michael@8: * this should only be used when a new event has been generated within android. michael@8: * michael@8: * @param strUid the UID for this event. example: UID:e6be67c6-eff0-44f8-a1a0-6c2cb1029944-caldavsyncadapter michael@8: * @return success of the function michael@8: * @see CalendarEvent#fetchBody() michael@8: */ michael@8: public boolean createIcs(String strUid) { michael@8: boolean Result = false; michael@8: TimeZone timeZone = null; michael@22: // Hack to bootstrap a multithreaded class loader context michael@22: if (Thread.currentThread().getContextClassLoader() == null) michael@22: Thread.currentThread().setContextClassLoader(Appctxpro.getContext().getClassLoader()); michael@27: TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); michael@22: assertNotNull(registry); michael@0: //TODO: do not simply create the ics-file new. take into account the RAWDATA if available michael@0: /* michael@0: * dtstart=1365598800000 michael@0: * dtend=1365602400000 michael@0: * eventTimezone=Europe/Berlin michael@0: * eventEndTimezone=null michael@0: * duration=null michael@0: * allDay=0 michael@0: * rrule=null michael@0: * rdate=null michael@0: * exrule=null michael@0: * exdate=null michael@0: * title=Einurlner Termin michael@0: * description=null michael@0: * eventLocation=null michael@0: * accessLevel=0 michael@0: * eventStatus=0 michael@0: * michael@0: * calendar_id=4 michael@0: * lastDate=-197200128 michael@0: * sync_data1=null michael@0: * _sync_id=null michael@0: * dirty=1 michael@0: */ michael@0: michael@8: try { michael@8: mCalendar = new Calendar(); michael@8: PropertyList propCalendar = mCalendar.getProperties(); michael@8: propCalendar.add(new ProdId("-//Ben Fortuna//iCal4j 1.0//EN")); michael@8: propCalendar.add(Version.VERSION_2_0); michael@8: propCalendar.add(CalScale.GREGORIAN); michael@0: michael@8: VEvent event = new VEvent(); michael@8: mCalendar.getComponents().add(event); michael@8: PropertyList propEvent = event.getProperties(); michael@0: michael@8: // DTSTAMP -> is created by new VEvent() automatical michael@8: //na michael@0: michael@8: // CREATED michael@8: //na michael@0: michael@8: // LAST-MODIFIED michael@8: //na michael@8: michael@8: // SEQUENCE michael@8: //na michael@8: michael@8: // DTSTART michael@8: long lngStart = this.ContentValues.getAsLong(Events.DTSTART); michael@8: String strTZStart = this.ContentValues.getAsString(Events.EVENT_TIMEZONE); michael@8: boolean allDay = this.ContentValues.getAsBoolean(Events.ALL_DAY); michael@8: if (lngStart > 0) { michael@8: DtStart dtStart = new DtStart(); michael@8: if (allDay) { michael@8: Date dateStart = new Date(); michael@8: dateStart.setTime(lngStart); michael@8: dtStart.setDate(dateStart); michael@8: } else { michael@8: DateTime datetimeStart = new DateTime(); michael@8: datetimeStart.setTime(lngStart); michael@8: dtStart.setDate(datetimeStart); michael@8: michael@8: timeZone = registry.getTimeZone(strTZStart); michael@8: if (timeZone == null) { michael@8: java.util.TimeZone systemTimeZone = TimeZone.getTimeZone(strTZStart); michael@8: if (systemTimeZone == null) { michael@8: systemTimeZone = TimeZone.getDefault(); michael@8: } michael@8: timeZone = registry.getTimeZone(systemTimeZone.getID()); michael@8: } michael@8: dtStart.setTimeZone(timeZone); michael@8: michael@8: // no timezone information for allDay events michael@8: mCalendar.getComponents().add(timeZone.getVTimeZone()); michael@8: } michael@8: propEvent.add(dtStart); michael@8: } michael@8: michael@8: // DTEND michael@8: long lngEnd = this.ContentValues.getAsLong(Events.DTEND); michael@8: String strTZEnd = this.ContentValues.getAsString(Events.EVENT_END_TIMEZONE); michael@8: if (strTZEnd == null) michael@8: strTZEnd = strTZStart; michael@8: if (lngEnd > 0) { michael@8: DtEnd dtEnd = new DtEnd(); michael@8: if (allDay) { michael@8: Date dateEnd = new Date(); michael@8: dateEnd.setTime(lngEnd); michael@8: dtEnd.setDate(dateEnd); michael@8: } else { michael@8: DateTime datetimeEnd = new DateTime(); michael@8: datetimeEnd.setTime(lngEnd); michael@8: dtEnd.setDate(datetimeEnd); michael@8: if (strTZEnd != null) michael@8: timeZone = registry.getTimeZone(strTZEnd); michael@8: dtEnd.setTimeZone(timeZone); michael@8: } michael@8: propEvent.add(dtEnd); michael@8: } michael@8: michael@8: // DURATION michael@8: if (this.ContentValues.containsKey(Events.DURATION)) { michael@8: String strDuration = this.ContentValues.getAsString(Events.DURATION); michael@8: if (strDuration != null) { michael@8: Duration duration = new Duration(); michael@8: duration.setValue(strDuration); michael@8: michael@8: propEvent.add(duration); michael@8: } michael@8: } michael@8: michael@8: //RRULE michael@8: if (this.ContentValues.containsKey(Events.RRULE)) { michael@8: String strRrule = this.ContentValues.getAsString(Events.RRULE); michael@8: if (strRrule != null) { michael@8: if (!strRrule.equals("")) { michael@8: RRule rrule = new RRule(); michael@8: rrule.setValue(strRrule); michael@8: propEvent.add(rrule); michael@8: } michael@8: } michael@8: } michael@8: michael@8: //RDATE michael@8: if (this.ContentValues.containsKey(Events.RDATE)) { michael@8: String strRdate = this.ContentValues.getAsString(Events.RDATE); michael@8: if (strRdate != null) { michael@8: if (!strRdate.equals("")) { michael@8: RDate rdate = new RDate(); michael@8: rdate.setValue(strRdate); michael@8: propEvent.add(rdate); michael@8: } michael@8: } michael@8: } michael@8: michael@8: //EXRULE michael@8: if (this.ContentValues.containsKey(Events.EXRULE)) { michael@8: String strExrule = this.ContentValues.getAsString(Events.EXRULE); michael@8: if (strExrule != null) { michael@8: if (!strExrule.equals("")) { michael@8: ExRule exrule = new ExRule(); michael@8: exrule.setValue(strExrule); michael@8: propEvent.add(exrule); michael@8: } michael@8: } michael@8: } michael@8: michael@8: //EXDATE michael@8: if (this.ContentValues.containsKey(Events.EXDATE)) { michael@8: String strExdate = this.ContentValues.getAsString(Events.EXDATE); michael@8: if (strExdate != null) { michael@8: if (!strExdate.equals("")) { michael@8: ExDate exdate = new ExDate(); michael@8: exdate.setValue(strExdate); michael@8: propEvent.add(exdate); michael@8: } michael@8: } michael@8: } michael@8: michael@8: //SUMMARY michael@8: if (this.ContentValues.containsKey(Events.TITLE)) { michael@8: String strTitle = this.ContentValues.getAsString(Events.TITLE); michael@8: if (strTitle != null) { michael@8: Summary summary = new Summary(strTitle); michael@8: propEvent.add(summary); michael@8: } michael@8: } michael@8: michael@8: //DESCIPTION michael@8: if (this.ContentValues.containsKey(Events.DESCRIPTION)) { michael@8: String strDescription = this.ContentValues.getAsString(Events.DESCRIPTION); michael@8: if (strDescription != null) { michael@8: if (!strDescription.equals("")) { michael@8: Description description = new Description(strDescription); michael@8: propEvent.add(description); michael@8: } michael@8: } michael@8: } michael@8: michael@8: //LOCATION michael@8: if (this.ContentValues.containsKey(Events.EVENT_LOCATION)) { michael@8: String strLocation = this.ContentValues.getAsString(Events.EVENT_LOCATION); michael@8: if (strLocation != null) { michael@8: if (!strLocation.equals("")) { michael@8: Location location = new Location(strLocation); michael@8: propEvent.add(location); michael@8: } michael@8: } michael@8: } michael@8: michael@8: //CLASS / ACCESS_LEVEL michael@8: if (this.ContentValues.containsKey(Events.ACCESS_LEVEL)) { michael@8: int accessLevel = this.ContentValues.getAsInteger(Events.ACCESS_LEVEL); michael@8: Clazz clazz = new Clazz(); michael@8: if (accessLevel == Events.ACCESS_PUBLIC) michael@8: clazz.setValue(Clazz.PUBLIC.getValue()); michael@8: else if (accessLevel == Events.ACCESS_PRIVATE) michael@8: clazz.setValue(Clazz.PRIVATE.getValue()); michael@8: else if (accessLevel == Events.ACCESS_CONFIDENTIAL) michael@8: clazz.setValue(Clazz.CONFIDENTIAL.getValue()); michael@8: else michael@8: clazz.setValue(Clazz.PUBLIC.getValue()); michael@8: michael@8: propEvent.add(clazz); michael@8: } michael@8: michael@8: //STATUS michael@8: if (this.ContentValues.containsKey(Events.STATUS)) { michael@8: int intStatus = this.ContentValues.getAsInteger(Events.STATUS); michael@8: if (intStatus > -1) { michael@8: Status status = new Status(); michael@8: if (intStatus == Events.STATUS_CANCELED) michael@8: status.setValue(Status.VEVENT_CANCELLED.getValue()); michael@8: else if (intStatus == Events.STATUS_CONFIRMED) michael@8: status.setValue(Status.VEVENT_CONFIRMED.getValue()); michael@8: else if (intStatus == Events.STATUS_TENTATIVE) michael@8: status.setValue(Status.VEVENT_TENTATIVE.getValue()); michael@8: michael@8: propEvent.add(status); michael@8: } michael@8: } michael@8: michael@8: //UID michael@8: Uid uid = new Uid(strUid); michael@8: propEvent.add(uid); michael@8: michael@8: // Attendees michael@8: if (mAttendees.size() > 0) { michael@8: for (Object objProp : mAttendees) { michael@8: Property prop = (Property) objProp; michael@8: propEvent.add(prop); michael@8: } michael@8: } michael@8: michael@8: // Reminders michael@8: if (mReminders.size() > 0) { michael@8: for (Object objComp : mReminders) { michael@10: VAlarm com = (VAlarm) objComp; michael@8: event.getAlarms().add(com); michael@8: } michael@8: } michael@8: michael@8: } catch (ParseException e) { michael@8: e.printStackTrace(); michael@8: } michael@8: michael@8: return Result; michael@8: } michael@8: michael@8: /** michael@8: * marks the android event as already handled michael@8: * @return michael@8: * @see AndroidEvent#cInternalTag michael@8: * @see SyncAdapter#synchroniseEvents(CaldavFacade, Account, ContentProviderClient, Uri, DavCalendar, SyncStats) michael@8: * @throws RemoteException michael@8: */ michael@0: /* public boolean tagAndroidEvent() throws RemoteException { michael@0: michael@0: ContentValues values = new ContentValues(); michael@0: values.put(Event.INTERNALTAG, 1); michael@0: michael@0: int RowCount = this.mProvider.update(asSyncAdapter(this.getUri(), this.mAccount.name, this.mAccount.type), values, null, null); michael@0: //Log.e(TAG,"Rows updated: " + RowCount.toString()); michael@0: michael@0: return (RowCount == 1); michael@0: }*/ michael@0: michael@0: /* private static Uri asSyncAdapter(Uri uri, String account, String accountType) { michael@0: return uri.buildUpon() michael@0: .appendQueryParameter(android.provider.CalendarContract.CALLER_IS_SYNCADAPTER,"true") michael@0: .appendQueryParameter(Calendars.ACCOUNT_NAME, account) michael@0: .appendQueryParameter(Calendars.ACCOUNT_TYPE, accountType).build(); michael@0: }*/ michael@0: } michael@0: