1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/org/gege/caldavsyncadapter/android/entities/AndroidEvent.java Tue Feb 10 18:12:00 2015 +0100 1.3 @@ -0,0 +1,582 @@ 1.4 +/** 1.5 + * Copyright (c) 2012-2013, Gerald Garcia, Timo Berger 1.6 + * 1.7 + * This file is part of Andoid Caldav Sync Adapter Free. 1.8 + * 1.9 + * Andoid Caldav Sync Adapter Free is free software: you can redistribute 1.10 + * it and/or modify it under the terms of the GNU General Public License 1.11 + * as published by the Free Software Foundation, either version 3 of the 1.12 + * License, or at your option any later version. 1.13 + * 1.14 + * Andoid Caldav Sync Adapter Free is distributed in the hope that 1.15 + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied 1.16 + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1.17 + * GNU General Public License for more details. 1.18 + * 1.19 + * You should have received a copy of the GNU General Public License 1.20 + * along with Andoid Caldav Sync Adapter Free. 1.21 + * If not, see <http://www.gnu.org/licenses/>. 1.22 + * 1.23 + */ 1.24 + 1.25 +package org.gege.caldavsyncadapter.android.entities; 1.26 + 1.27 +import java.net.URISyntaxException; 1.28 +import java.text.ParseException; 1.29 +import net.fortuna.ical4j.model.Calendar; 1.30 +import net.fortuna.ical4j.model.Component; 1.31 +import net.fortuna.ical4j.model.ComponentList; 1.32 +import net.fortuna.ical4j.model.Date; 1.33 +import net.fortuna.ical4j.model.DateTime; 1.34 +import net.fortuna.ical4j.model.Dur; 1.35 +import net.fortuna.ical4j.model.ParameterList; 1.36 +import net.fortuna.ical4j.model.Property; 1.37 +import net.fortuna.ical4j.model.PropertyList; 1.38 +import net.fortuna.ical4j.model.TimeZone; 1.39 +import net.fortuna.ical4j.model.TimeZoneRegistry; 1.40 +import net.fortuna.ical4j.model.TimeZoneRegistryFactory; 1.41 +import net.fortuna.ical4j.model.component.VAlarm; 1.42 +import net.fortuna.ical4j.model.component.VEvent; 1.43 +import net.fortuna.ical4j.model.parameter.Cn; 1.44 +import net.fortuna.ical4j.model.parameter.PartStat; 1.45 +import net.fortuna.ical4j.model.parameter.Role; 1.46 +import net.fortuna.ical4j.model.parameter.Rsvp; 1.47 +import net.fortuna.ical4j.model.parameter.Value; 1.48 +import net.fortuna.ical4j.model.property.Action; 1.49 +import net.fortuna.ical4j.model.property.Attendee; 1.50 +import net.fortuna.ical4j.model.property.CalScale; 1.51 +import net.fortuna.ical4j.model.property.Clazz; 1.52 +import net.fortuna.ical4j.model.property.Description; 1.53 +import net.fortuna.ical4j.model.property.DtEnd; 1.54 +import net.fortuna.ical4j.model.property.DtStart; 1.55 +import net.fortuna.ical4j.model.property.Duration; 1.56 +import net.fortuna.ical4j.model.property.ExDate; 1.57 +import net.fortuna.ical4j.model.property.ExRule; 1.58 +import net.fortuna.ical4j.model.property.Location; 1.59 +import net.fortuna.ical4j.model.property.Organizer; 1.60 +import net.fortuna.ical4j.model.property.ProdId; 1.61 +import net.fortuna.ical4j.model.property.RDate; 1.62 +import net.fortuna.ical4j.model.property.RRule; 1.63 +import net.fortuna.ical4j.model.property.Status; 1.64 +import net.fortuna.ical4j.model.property.Summary; 1.65 +import net.fortuna.ical4j.model.property.Trigger; 1.66 +import net.fortuna.ical4j.model.property.Uid; 1.67 +import net.fortuna.ical4j.model.property.Version; 1.68 +//import android.accounts.Account; 1.69 +//import android.content.ContentProviderClient; 1.70 +//import android.content.ContentValues; 1.71 +//import android.content.SyncStats; 1.72 +import android.database.Cursor; 1.73 +import android.net.Uri; 1.74 +//import android.os.RemoteException; 1.75 +import android.provider.CalendarContract.Attendees; 1.76 +//import android.provider.CalendarContract.Calendars; 1.77 +import android.provider.CalendarContract.Events; 1.78 +import android.provider.CalendarContract.Reminders; 1.79 + 1.80 +//import org.gege.caldavsyncadapter.Event; 1.81 +//import org.gege.caldavsyncadapter.caldav.CaldavFacade; 1.82 +import org.gege.caldavsyncadapter.caldav.entities.CalendarEvent; 1.83 +//import org.gege.caldavsyncadapter.caldav.entities.DavCalendar; 1.84 +//import org.gege.caldavsyncadapter.syncadapter.SyncAdapter; 1.85 + 1.86 +public class AndroidEvent extends org.gege.caldavsyncadapter.Event { 1.87 + 1.88 + private Uri muri; 1.89 + 1.90 + private Uri mAndroidCalendarUri; 1.91 + 1.92 + /** 1.93 + * the list of attendees 1.94 + */ 1.95 + private PropertyList mAttendees = new PropertyList(); 1.96 + 1.97 + /** 1.98 + * the list of reminders 1.99 + */ 1.100 + private ComponentList mReminders = new ComponentList(); 1.101 + 1.102 + private Calendar mCalendar = null; 1.103 + 1.104 +/* private Account mAccount = null; 1.105 + private ContentProviderClient mProvider = null;*/ 1.106 + 1.107 + //public AndroidEvent(Account account, ContentProviderClient provider, Uri uri, Uri calendarUri) { 1.108 + public AndroidEvent(Uri uri, Uri calendarUri) { 1.109 + super(); 1.110 + this.setUri(uri); 1.111 +/* this.mAccount = account; 1.112 + this.mProvider = provider;*/ 1.113 + //this.setCounterpartUri(calendarUri); 1.114 + mAndroidCalendarUri = calendarUri; 1.115 + } 1.116 + 1.117 + public Calendar getIcsEvent() { 1.118 + return mCalendar; 1.119 + } 1.120 + 1.121 + public String getETag() { 1.122 + String Result = ""; 1.123 + if (this.ContentValues.containsKey(ETAG)) 1.124 + Result = this.ContentValues.getAsString(ETAG); 1.125 + return Result; 1.126 + } 1.127 + 1.128 + public void setETag(String eTag) { 1.129 + this.ContentValues.put(ETAG, eTag); 1.130 + } 1.131 + 1.132 + public Uri getUri() { 1.133 + return muri; 1.134 + } 1.135 + 1.136 + public void setUri(Uri uri) { 1.137 + this.muri = uri; 1.138 + } 1.139 + 1.140 + public Uri getAndroidCalendarUri() { 1.141 + return mAndroidCalendarUri; 1.142 + } 1.143 + 1.144 + @Override 1.145 + public String toString() { 1.146 + return this.getUri().toString(); 1.147 + } 1.148 + 1.149 + /** 1.150 + * reads an android event from a given cursor into {@link AndroidEvent#ContentValues} 1.151 + * @param cur the cursor with the event 1.152 + * @return success of this funtion 1.153 + * @see AndroidEvent#ContentValues 1.154 + */ 1.155 + public boolean readContentValues(Cursor cur) { 1.156 + this.setETag(cur.getString(cur.getColumnIndex(ETAG))); 1.157 + 1.158 + this.ContentValues.put(Events.EVENT_TIMEZONE, cur.getString(cur.getColumnIndex(Events.EVENT_TIMEZONE))); 1.159 + this.ContentValues.put(Events.EVENT_END_TIMEZONE, cur.getString(cur.getColumnIndex(Events.EVENT_END_TIMEZONE))); 1.160 + this.ContentValues.put(Events.DTSTART, cur.getLong(cur.getColumnIndex(Events.DTSTART))); 1.161 + this.ContentValues.put(Events.DTEND, cur.getLong(cur.getColumnIndex(Events.DTEND))); 1.162 + this.ContentValues.put(Events.ALL_DAY, cur.getLong(cur.getColumnIndex(Events.ALL_DAY))); 1.163 + this.ContentValues.put(Events.TITLE, cur.getString(cur.getColumnIndex(Events.TITLE))); 1.164 + this.ContentValues.put(Events.CALENDAR_ID, cur.getString(cur.getColumnIndex(Events.CALENDAR_ID))); 1.165 + this.ContentValues.put(Events._SYNC_ID, cur.getString(cur.getColumnIndex(Events._SYNC_ID))); 1.166 + //this.ContentValues.put(Events.SYNC_DATA1, cur.getString(cur.getColumnIndex(Events.SYNC_DATA1))); //not needed here, eTag has already been read 1.167 + this.ContentValues.put(Events.DESCRIPTION, cur.getString(cur.getColumnIndex(Events.DESCRIPTION))); 1.168 + this.ContentValues.put(Events.EVENT_LOCATION, cur.getString(cur.getColumnIndex(Events.EVENT_LOCATION))); 1.169 + this.ContentValues.put(Events.ACCESS_LEVEL, cur.getInt(cur.getColumnIndex(Events.ACCESS_LEVEL))); 1.170 + 1.171 + this.ContentValues.put(Events.STATUS, cur.getInt(cur.getColumnIndex(Events.STATUS))); 1.172 + 1.173 + this.ContentValues.put(Events.LAST_DATE, cur.getInt(cur.getColumnIndex(Events.LAST_DATE))); 1.174 + this.ContentValues.put(Events.DURATION, cur.getString(cur.getColumnIndex(Events.DURATION))); 1.175 + 1.176 + this.ContentValues.put(Events.RDATE, cur.getString(cur.getColumnIndex(Events.RDATE))); 1.177 + this.ContentValues.put(Events.RRULE, cur.getString(cur.getColumnIndex(Events.RRULE))); 1.178 + this.ContentValues.put(Events.EXRULE, cur.getString(cur.getColumnIndex(Events.EXRULE))); 1.179 + this.ContentValues.put(Events.EXDATE, cur.getString(cur.getColumnIndex(Events.EXDATE))); 1.180 + this.ContentValues.put(Events.DIRTY, cur.getInt(cur.getColumnIndex(Events.DIRTY))); 1.181 + this.ContentValues.put(UID, cur.getString(cur.getColumnIndex(UID))); 1.182 + this.ContentValues.put(RAWDATA, cur.getString(cur.getColumnIndex(RAWDATA))); 1.183 + 1.184 + return true; 1.185 + } 1.186 + 1.187 + /** 1.188 + * reads the attendees from a given cursor 1.189 + * @param cur the cursor with the attendees 1.190 + * @return success of this function 1.191 + * @see AndroidEvent#mAttendees 1.192 + */ 1.193 + public boolean readAttendees(Cursor cur) { 1.194 + Attendee attendee = null; 1.195 + Organizer organizer = null; 1.196 + ParameterList paraList = null; 1.197 + 1.198 + String Name = ""; 1.199 + Cn cn = null; 1.200 + 1.201 + String Email = ""; 1.202 + 1.203 + int Relationship = 0; 1.204 + 1.205 + 1.206 + int Status = 0; 1.207 + PartStat partstat = null; 1.208 + 1.209 + int Type = 0; 1.210 + Role role = null; 1.211 + 1.212 + try { 1.213 + while (cur.moveToNext()) { 1.214 + Name = cur.getString(cur.getColumnIndex(Attendees.ATTENDEE_NAME)); 1.215 + Email = cur.getString(cur.getColumnIndex(Attendees.ATTENDEE_EMAIL)); 1.216 + Relationship = cur.getInt(cur.getColumnIndex(Attendees.ATTENDEE_RELATIONSHIP)); 1.217 + Type = cur.getInt(cur.getColumnIndex(Attendees.ATTENDEE_TYPE)); 1.218 + Status = cur.getInt(cur.getColumnIndex(Attendees.ATTENDEE_STATUS)); 1.219 + 1.220 + if (Relationship == Attendees.RELATIONSHIP_ORGANIZER) { 1.221 + organizer = new Organizer(); 1.222 + organizer.setValue("mailto:" + Email); 1.223 + paraList = organizer.getParameters(); 1.224 + mAttendees.add(organizer); 1.225 + } else { 1.226 + attendee = new Attendee(); 1.227 + attendee.setValue("mailto:" + Email); 1.228 + paraList = attendee.getParameters(); 1.229 + mAttendees.add(attendee); 1.230 + } 1.231 + 1.232 + Rsvp rsvp = new Rsvp(true); 1.233 + paraList.add(rsvp); 1.234 + 1.235 + cn = new Cn(Name); 1.236 + paraList.add(cn); 1.237 + 1.238 + if (Status == Attendees.ATTENDEE_STATUS_INVITED) 1.239 + partstat = new PartStat(PartStat.NEEDS_ACTION.getValue()); 1.240 + else if (Status == Attendees.ATTENDEE_STATUS_ACCEPTED) 1.241 + partstat = new PartStat(PartStat.ACCEPTED.getValue()); 1.242 + else if (Status == Attendees.ATTENDEE_STATUS_DECLINED) 1.243 + partstat = new PartStat(PartStat.DECLINED.getValue()); 1.244 + else if (Status == Attendees.ATTENDEE_STATUS_NONE) 1.245 + partstat = new PartStat(PartStat.COMPLETED.getValue()); 1.246 + else if (Status == Attendees.ATTENDEE_STATUS_TENTATIVE) 1.247 + partstat = new PartStat(PartStat.TENTATIVE.getValue()); 1.248 + else 1.249 + partstat = new PartStat(PartStat.NEEDS_ACTION.getValue()); 1.250 + paraList.add(partstat); 1.251 + 1.252 + if (Type == Attendees.TYPE_OPTIONAL) 1.253 + role = new Role(Role.OPT_PARTICIPANT.getValue()); 1.254 + else if (Type == Attendees.TYPE_NONE) 1.255 + role = new Role(Role.NON_PARTICIPANT.getValue()); //regular participants in android are non required? 1.256 + else if (Type == Attendees.TYPE_REQUIRED) 1.257 + role = new Role(Role.REQ_PARTICIPANT.getValue()); 1.258 + else 1.259 + role = new Role(Role.NON_PARTICIPANT.getValue()); 1.260 + paraList.add(role); 1.261 + } 1.262 + 1.263 + } catch (URISyntaxException e) { 1.264 + e.printStackTrace(); 1.265 + } 1.266 + return true; 1.267 + } 1.268 + 1.269 + /** 1.270 + * reads the reminders from a given cursor 1.271 + * @param cur the cursor with the reminders 1.272 + * @return success of this function 1.273 + */ 1.274 + public boolean readReminder(Cursor cur) { 1.275 + int Method; 1.276 + int Minutes; 1.277 + VAlarm reminder; 1.278 + while (cur.moveToNext()) { 1.279 + reminder = new VAlarm(); 1.280 + Method = cur.getInt(cur.getColumnIndex(Reminders.METHOD)); 1.281 + Minutes = cur.getInt(cur.getColumnIndex(Reminders.MINUTES)) * -1; 1.282 + 1.283 + 1.284 + Dur dur = new Dur(0, 0, Minutes, 0); 1.285 + Trigger tri = new Trigger(dur); 1.286 + Value val = new Value(Duration.DURATION); 1.287 + tri.getParameters().add(val); 1.288 + reminder.getProperties().add(tri); 1.289 + 1.290 + Description desc = new Description(); 1.291 + desc.setValue("caldavsyncadapter standard description"); 1.292 + reminder.getProperties().add(desc); 1.293 + 1.294 + 1.295 + if (Method == Reminders.METHOD_EMAIL) 1.296 + reminder.getProperties().add(Action.EMAIL); 1.297 + else 1.298 + reminder.getProperties().add(Action.DISPLAY); 1.299 + 1.300 + this.mReminders.add(reminder); 1.301 + } 1.302 + return true; 1.303 + } 1.304 + 1.305 + /** 1.306 + * generates a new ics-file. 1.307 + * uses {@link AndroidEvent#ContentValues} as source. 1.308 + * this should only be used when a new event has been generated within android. 1.309 + * @param strUid the UID for this event. example: UID:e6be67c6-eff0-44f8-a1a0-6c2cb1029944-caldavsyncadapter 1.310 + * @return success of the function 1.311 + * @see CalendarEvent#fetchBody() 1.312 + */ 1.313 + public boolean createIcs(String strUid) { 1.314 + boolean Result = false; 1.315 + TimeZone timezone = null; 1.316 + TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); 1.317 +//TODO: do not simply create the ics-file new. take into account the RAWDATA if available 1.318 + /* 1.319 + * dtstart=1365598800000 1.320 + * dtend=1365602400000 1.321 + * eventTimezone=Europe/Berlin 1.322 + * eventEndTimezone=null 1.323 + * duration=null 1.324 + * allDay=0 1.325 + * rrule=null 1.326 + * rdate=null 1.327 + * exrule=null 1.328 + * exdate=null 1.329 + * title=Einurlner Termin 1.330 + * description=null 1.331 + * eventLocation=null 1.332 + * accessLevel=0 1.333 + * eventStatus=0 1.334 + * 1.335 + * calendar_id=4 1.336 + * lastDate=-197200128 1.337 + * sync_data1=null 1.338 + * _sync_id=null 1.339 + * dirty=1 1.340 + */ 1.341 + 1.342 + try { 1.343 + mCalendar = new Calendar(); 1.344 + PropertyList propCalendar = mCalendar.getProperties(); 1.345 + propCalendar.add(new ProdId("-//Ben Fortuna//iCal4j 1.0//EN")); 1.346 + propCalendar.add(Version.VERSION_2_0); 1.347 + propCalendar.add(CalScale.GREGORIAN); 1.348 + 1.349 + VEvent event = new VEvent(); 1.350 + mCalendar.getComponents().add(event); 1.351 + PropertyList propEvent = event.getProperties(); 1.352 + 1.353 + // DTSTAMP -> is created by new VEvent() automatical 1.354 + //na 1.355 + 1.356 + // CREATED 1.357 + //na 1.358 + 1.359 + // LAST-MODIFIED 1.360 + //na 1.361 + 1.362 + // SEQUENCE 1.363 + //na 1.364 + 1.365 + // DTSTART 1.366 + long lngStart = this.ContentValues.getAsLong(Events.DTSTART); 1.367 + String strTZStart = this.ContentValues.getAsString(Events.EVENT_TIMEZONE); 1.368 + boolean allDay = this.ContentValues.getAsBoolean(Events.ALL_DAY); 1.369 + if (lngStart > 0) { 1.370 + DtStart dtStart = new DtStart(); 1.371 + if (allDay) { 1.372 + Date dateStart = new Date(); 1.373 + dateStart.setTime(lngStart); 1.374 + dtStart.setDate(dateStart); 1.375 + } else { 1.376 + DateTime datetimeStart = new DateTime(); 1.377 + datetimeStart.setTime(lngStart); 1.378 + dtStart.setDate(datetimeStart); 1.379 + 1.380 + timezone = registry.getTimeZone(strTZStart); 1.381 + dtStart.setTimeZone(timezone); 1.382 + 1.383 + // no timezone information for allDay events 1.384 + mCalendar.getComponents().add(timezone.getVTimeZone()); 1.385 + } 1.386 + propEvent.add(dtStart); 1.387 + } 1.388 + 1.389 + // DTEND 1.390 + long lngEnd = this.ContentValues.getAsLong(Events.DTEND); 1.391 + String strTZEnd = this.ContentValues.getAsString(Events.EVENT_END_TIMEZONE); 1.392 + if (strTZEnd == null) 1.393 + strTZEnd = strTZStart; 1.394 + if (lngEnd > 0) { 1.395 + DtEnd dtEnd = new DtEnd(); 1.396 + if (allDay) { 1.397 + Date dateEnd = new Date(); 1.398 + dateEnd.setTime(lngEnd); 1.399 + dtEnd.setDate(dateEnd); 1.400 + } else { 1.401 + DateTime datetimeEnd = new DateTime(); 1.402 + datetimeEnd.setTime(lngEnd); 1.403 + dtEnd.setDate(datetimeEnd); 1.404 + if (strTZEnd != null) 1.405 + timezone = registry.getTimeZone(strTZEnd); 1.406 + dtEnd.setTimeZone(timezone); 1.407 + } 1.408 + propEvent.add(dtEnd); 1.409 + } 1.410 + 1.411 + // DURATION 1.412 + if (this.ContentValues.containsKey(Events.DURATION)) { 1.413 + String strDuration = this.ContentValues.getAsString(Events.DURATION); 1.414 + if (strDuration != null) { 1.415 + Duration duration = new Duration(); 1.416 + duration.setValue(strDuration); 1.417 + 1.418 + propEvent.add(duration); 1.419 + } 1.420 + } 1.421 + 1.422 + //RRULE 1.423 + if (this.ContentValues.containsKey(Events.RRULE)) { 1.424 + String strRrule = this.ContentValues.getAsString(Events.RRULE); 1.425 + if (strRrule != null) { 1.426 + if (!strRrule.equals("")) { 1.427 + RRule rrule = new RRule(); 1.428 + rrule.setValue(strRrule); 1.429 + propEvent.add(rrule); 1.430 + } 1.431 + } 1.432 + } 1.433 + 1.434 + //RDATE 1.435 + if (this.ContentValues.containsKey(Events.RDATE)) { 1.436 + String strRdate = this.ContentValues.getAsString(Events.RDATE); 1.437 + if (strRdate != null) { 1.438 + if (!strRdate.equals("")) { 1.439 + RDate rdate = new RDate(); 1.440 + rdate.setValue(strRdate); 1.441 + propEvent.add(rdate); 1.442 + } 1.443 + } 1.444 + } 1.445 + 1.446 + //EXRULE 1.447 + if (this.ContentValues.containsKey(Events.EXRULE)) { 1.448 + String strExrule = this.ContentValues.getAsString(Events.EXRULE); 1.449 + if (strExrule != null) { 1.450 + if (!strExrule.equals("")) { 1.451 + ExRule exrule = new ExRule(); 1.452 + exrule.setValue(strExrule); 1.453 + propEvent.add(exrule); 1.454 + } 1.455 + } 1.456 + } 1.457 + 1.458 + //EXDATE 1.459 + if (this.ContentValues.containsKey(Events.EXDATE)) { 1.460 + String strExdate = this.ContentValues.getAsString(Events.EXDATE); 1.461 + if (strExdate != null) { 1.462 + if (!strExdate.equals("")) { 1.463 + ExDate exdate = new ExDate(); 1.464 + exdate.setValue(strExdate); 1.465 + propEvent.add(exdate); 1.466 + } 1.467 + } 1.468 + } 1.469 + 1.470 + //SUMMARY 1.471 + if (this.ContentValues.containsKey(Events.TITLE)) { 1.472 + String strTitle = this.ContentValues.getAsString(Events.TITLE); 1.473 + if (strTitle != null) { 1.474 + Summary summary = new Summary(strTitle); 1.475 + propEvent.add(summary); 1.476 + } 1.477 + } 1.478 + 1.479 + //DESCIPTION 1.480 + if (this.ContentValues.containsKey(Events.DESCRIPTION)) { 1.481 + String strDescription = this.ContentValues.getAsString(Events.DESCRIPTION); 1.482 + if (strDescription != null) { 1.483 + if (!strDescription.equals("")) { 1.484 + Description description = new Description(strDescription); 1.485 + propEvent.add(description); 1.486 + } 1.487 + } 1.488 + } 1.489 + 1.490 + //LOCATION 1.491 + if (this.ContentValues.containsKey(Events.EVENT_LOCATION)) { 1.492 + String strLocation = this.ContentValues.getAsString(Events.EVENT_LOCATION); 1.493 + if (strLocation != null) { 1.494 + if (!strLocation.equals("")) { 1.495 + Location location = new Location(strLocation); 1.496 + propEvent.add(location); 1.497 + } 1.498 + } 1.499 + } 1.500 + 1.501 + //CLASS / ACCESS_LEVEL 1.502 + if (this.ContentValues.containsKey(Events.ACCESS_LEVEL)) { 1.503 + int accessLevel = this.ContentValues.getAsInteger(Events.ACCESS_LEVEL); 1.504 + Clazz clazz = new Clazz(); 1.505 + if (accessLevel == Events.ACCESS_PUBLIC) 1.506 + clazz.setValue(Clazz.PUBLIC.getValue()); 1.507 + else if (accessLevel == Events.ACCESS_PRIVATE) 1.508 + clazz.setValue(Clazz.PRIVATE.getValue()); 1.509 + else if (accessLevel == Events.ACCESS_CONFIDENTIAL) 1.510 + clazz.setValue(Clazz.CONFIDENTIAL.getValue()); 1.511 + else 1.512 + clazz.setValue(Clazz.PUBLIC.getValue()); 1.513 + 1.514 + propEvent.add(clazz); 1.515 + } 1.516 + 1.517 + //STATUS 1.518 + if (this.ContentValues.containsKey(Events.STATUS)) { 1.519 + int intStatus = this.ContentValues.getAsInteger(Events.STATUS); 1.520 + if (intStatus > -1) { 1.521 + Status status = new Status(); 1.522 + if (intStatus == Events.STATUS_CANCELED) 1.523 + status.setValue(Status.VEVENT_CANCELLED.getValue()); 1.524 + else if (intStatus == Events.STATUS_CONFIRMED) 1.525 + status.setValue(Status.VEVENT_CONFIRMED.getValue()); 1.526 + else if (intStatus == Events.STATUS_TENTATIVE) 1.527 + status.setValue(Status.VEVENT_TENTATIVE.getValue()); 1.528 + 1.529 + propEvent.add(status); 1.530 + } 1.531 + } 1.532 + 1.533 + //UID 1.534 + Uid uid = new Uid(strUid); 1.535 + propEvent.add(uid); 1.536 + 1.537 + // Attendees 1.538 + if (mAttendees.size() > 0) { 1.539 + for (Object objProp: mAttendees) { 1.540 + Property prop = (Property) objProp; 1.541 + propEvent.add(prop); 1.542 + } 1.543 + } 1.544 + 1.545 + // Reminders 1.546 + if (mReminders.size() > 0) { 1.547 + for (Object objComp: mReminders) { 1.548 + Component com = (Component) objComp; 1.549 + event.getAlarms().add(com); 1.550 + } 1.551 + } 1.552 + 1.553 + } catch (ParseException e) { 1.554 + e.printStackTrace(); 1.555 + } 1.556 + 1.557 + return Result; 1.558 + } 1.559 + 1.560 + /** 1.561 + * marks the android event as already handled 1.562 + * @return 1.563 + * @see AndroidEvent#cInternalTag 1.564 + * @see SyncAdapter#synchroniseEvents(CaldavFacade, Account, ContentProviderClient, Uri, DavCalendar, SyncStats) 1.565 + * @throws RemoteException 1.566 + */ 1.567 +/* public boolean tagAndroidEvent() throws RemoteException { 1.568 + 1.569 + ContentValues values = new ContentValues(); 1.570 + values.put(Event.INTERNALTAG, 1); 1.571 + 1.572 + int RowCount = this.mProvider.update(asSyncAdapter(this.getUri(), this.mAccount.name, this.mAccount.type), values, null, null); 1.573 + //Log.e(TAG,"Rows updated: " + RowCount.toString()); 1.574 + 1.575 + return (RowCount == 1); 1.576 + }*/ 1.577 + 1.578 +/* private static Uri asSyncAdapter(Uri uri, String account, String accountType) { 1.579 + return uri.buildUpon() 1.580 + .appendQueryParameter(android.provider.CalendarContract.CALLER_IS_SYNCADAPTER,"true") 1.581 + .appendQueryParameter(Calendars.ACCOUNT_NAME, account) 1.582 + .appendQueryParameter(Calendars.ACCOUNT_TYPE, accountType).build(); 1.583 + }*/ 1.584 +} 1.585 +