repeatRule.setInt( RepeatRule.DAY_IN_YEAR, dayInYear );
}
}
// Reminder
ReminderObject reminderObj = _that.getReminder();
// Attendees
AttendeeObject[] attendees = _that.getAttendees();
// FreeBusy
int freeBusy = _that.getFreeBusy();
// AllDay
boolean allday = _that.isAllDay();
// Create a new appointment
EventList eventList;
if( _serviceName.length() > 0 ) {
eventList = (EventList) PIM.getInstance().openPIMList( PIM.EVENT_LIST, PIM.READ_WRITE, _serviceName );
} else {
eventList = (EventList) PIM.getInstance().openPIMList( PIM.EVENT_LIST, PIM.READ_WRITE );
}
if( _event == null )
_event = eventList.createEvent();
if( _event.countValues( Event.LOCATION ) > 0 ) {
if( location.length() > 0 ) {
_event.setString( Event.LOCATION, 0, Event.ATTR_NONE, location );
} else {
_event.removeValue( Event.LOCATION, 0 );
}
} else {
if( location.length() > 0 ) {
_event.addString( Event.LOCATION, Event.ATTR_NONE, location );
}
}
if( _event.countValues( Event.SUMMARY ) > 0 ) {
if( summary.length() > 0 ) {
_event.setString( Event.SUMMARY, 0, Event.ATTR_NONE, summary );
} else {
_event.removeValue( Event.SUMMARY, 0 );
}
} else {
if( summary.length() > 0 ) {
_event.addString( Event.SUMMARY, Event.ATTR_NONE, summary );
}
}
if( _event.countValues( Event.NOTE ) > 0 ) {
if( note.length() > 0 ) {
_event.setString( Event.NOTE, 0, Event.ATTR_NONE, note );
} else {
_event.removeValue( Event.NOTE, 0 );
}
} else {
if( note.length() > 0 ) {
_event.addString( Event.NOTE, Event.ATTR_NONE, note );
}
}
// patch for compensating the one day offset in the calendar for all 6.0 simulator bundles, for all-day events and
// WEEKLY and MONTHLY appointments
String softwareVersion = DeviceInfo.getSoftwareVersion();
if( softwareVersion.startsWith( SOFTWARE_VERSION_SIX ) ) {
if( allday ) {
adjustDates( start, end );
} else if( repeatRule != null ) {
int frequency = repeatRule.getInt( RepeatRule.FREQUENCY );
if( frequency == RepeatRule.WEEKLY || frequency == RepeatRule.MONTHLY ) {
adjustDates( start, end );
}
}
} // this temporary patch should be removed when the one-day offset bug gets fixed in the Java APIs
if( _event.countValues( Event.START ) > 0 ) {
if( start != null ) {
_event.setDate( Event.START, 0, Event.ATTR_NONE, start.getTime() );
} else {
_event.removeValue( Event.START, 0 );
}
} else {
if( start != null ) {
_event.addDate( Event.START, Event.ATTR_NONE, start.getTime() );
}
}
if( _event.countValues( Event.END ) > 0 ) {
if( end != null ) {
_event.setDate( Event.END, 0, Event.ATTR_NONE, end.getTime() );
} else {
_event.removeValue( Event.END, 0 );
}
} else {
if( end != null ) {
_event.addDate( Event.END, Event.ATTR_NONE, end.getTime() );
}
}
// recurrence
_event.setRepeat( repeatRule );
// reminder
if( reminderObj != null ) {
int reminderType = reminderObj.getType();
int reminderRelativeTime;
if( reminderType != ReminderConstructor.TYPE_RELATIVE ) {
throw new IllegalArgumentException( "The type of reminder of appointment should be relative!" );
// reminderRelativeTime = (int) (reminderObj.getDate().getTime()-start.getTime());
}
reminderRelativeTime = (int) ( reminderObj.getRelativeHours() * 3600 ); // 1 hr = 3600 sec
if( _event.countValues( Event.ALARM ) > 0 ) {
if( reminderRelativeTime > 0 ) {
_event.setInt( Event.ALARM, 0, Event.ATTR_NONE, reminderRelativeTime );
} else {