6.3.2 Add

Add is used to create a new calendar on the device, add an entry to a calendar, or modify the entry if an entry with the same LocalId already exists in the calendar. The entry is added to the specified calendar or, if no calendar is specified, to the default one. In case the default calendar does not exist, it is created. It is available only in synchronous mode.

The following is an example for using Add:

calendar_handle.call('Add', {'Type': u'CalendarEntry', 'Item': {'Description': u'This is the meeting description', 'StartTime', start_time, 'EndTime', end_time}})
where start_time and end_time are datetime objects.

The following table summarizes the specification of Add:

Interface IDataSource
Description Adds a new calendar in the device or a new entry in a specific calendar file.
Response Model Synchronous
Pre-condition IDataSource interface is loaded. For updating a specific entry, the Id must exist and can be retrieved by a call to Add or GetList.
Post-condition Nil

Input Parameters for Calendar

Input parameter specifies the details of a new calendar. Input parameter has two properties: Type, and Item.

Table 6.25: Input parameters for Calendar Add
Name Type Range Description
Type unicode string Calendar Adds a new calendar
Item map CalendarName: unicode string Specifies the name of the calendar to be added in the format Drivexxx: FileNamexxx.


Output Parameters for Calendar

Output parameter contains an error code and an optional error message if the operation fails.

Table 6.26: Output parameters for Calendar Add
Name Type Range Description
ErrorCode int NA Service specific error code on failure of the operation.
ErrorMessage string NA Error description in Engineering English.


Input Parameters for Calendar Entry

Add performs add or update operations depending on the input parameters of Calendar Entry. Input parameters differ based on the Entry Type (Meeting, To-Do, Reminder, DayEvent, Anniversary).

Table 6.27: Input parameters for Calendar Entry Add
Name Type Range Description
Type unicode string CalendarEntry Adds a new entry or modifies an existing entry depending on the input of Calendar Entry.
Item map [CalendarName]: unicode string
For specific information on Type, refer to the following tables:
Meeting: 6.28
To-Do: 6.29
Anniversary: 6.30
DayEvent: 6.31
Reminder: 6.32
For different entry types, the corresponding input maps are given.

For more information about keys, refer the section Key Values 6.3.7.
The keys mentioned in the tables for each 'Type' are only applicable for that Type, rest are ignored.

The attendee field has a value of type 'map'.
The phoneowner must match the 'Address' field of one of the attendees, which means that a phoneowner is an attendee.



Table 6.28: Entry type: Meeting
Type unicode string Meeting
[Summary] unicode string NA
[SeqNum] 32-bit int NA
StartTime datetime NA
EndTime datetime NA
[Replication] unicode string NA
[Description] unicode string NA
[Priority] 32-bit int NA
[AlarmTime] datetime NA
[Location] unicode string NA
[Status] unicode string Tentative
Confirmed
Cancelled
NullStatus
[RepeatDates] List of dates NA
[ExDates] List of dates NA
[Method] None
Publish
Request
Reply
Add
Cancel
Refresh
Counter
DeclineCounter
NA
[PhoneOwner] unicode string NA
[Organizer] [CommonName]: string
Address: string
NA
[Attendees] List of maps NA
[RepeatRule] map NA



Table 6.29: Entry type: ToDo
Type unicode string ToDo
[Summary] unicode string NA
[EndTime] datetime NA
[Replication] unicode string Open
Private
Restricted
[Description] unicode string NA
[Priority] 32-bit int NA
[AlarmTime] datetime NA
[Status] unicode string TodoNeedsAction
TodoCompleted
TodoInProcess
Cancelled
NullStatus



Table 6.30: Entry type: Anniversary
Type unicode string Anniversary
[Summary] unicode string NA
StartTime datetime NA
[Replication] unicode string Open
Private
Restricted
[Description] unicode string NA
[Priority] 32-bit int NA
[AlarmTime] datetime NA



Table 6.31: Entry type: DayEvent
Type unicode string DayEvent
[Summary] unicode string NA
StartTime datetime NA
[EndTime] datetime (If not specified, the value will be same as StartTime) NA
[Replication] unicode string Open
Private
Restricted
[Description] unicode string NA
[Priority] 32-bit int NA
[AlarmTime] datetime NA



Table 6.32: Entry type: Reminder
Type string Reminder
[Summary] unicode string NA
StartTime datetime NA
[Replication] unicode string Open
Private
Restricted
[Description] unicode string NA
[Priority] 32-bit int NA
[AlarmTime] datetime NA


Output Parameters for Calendar Entry

Output parameter contains the requested information, an ErrorCode, and an ErorrMessage if the operation fails.

Table 6.33: Output parameters for Calendar Entry Add
Name Type Range Description
ErrorCode int NA Service specific error code on failure of the operation.
ErrorMessage string NA Error description in Engineering English.
ReturnValue string NA Returns Id string of the new entry added. The LocalId is obtained by a call to GetList, with Id as filter parameter.


Input Parameters for Update

Input parameter specifies the type on which an operation is performed and the details of the particular Type.

Table 6.34: Input parameters for Update
Name Type Range Description
Type unicode string CalendarEntry Adds a new entry or modifies an existing entry depending on the input of Calendar Entry.
Item map [CalendarName]: unicode string
[LocalId]: unicode string
[InstanceStartTime]: int
CalendarName must be specified in Drivexxx:Filenamexxx. If CalendarName is not specified then update operation is performed on default calendar.

Identifies the Entry by the LocalId. In case of repeating entry, InstanceStartTime (applicable only for Meeting type) is used to identify the instance to be modified. If InstanceStartTime is not specified then it modifies the whole entry. The modifiable fields(except type) is taken from CalendarEntry. RepeatRule can be modified or added for Parent entry only.

The keys mentioned in the tables for each 'Type' are only applicable for that Type, rest are ignored.


Output Parameters for Update

Output parameter contains the Id of the new entry added, ErrorCode, and an ErrorMessage, if the operation fails.

Table 6.35: Output parameters for Update
Name Type Range Description
ErrorCode int NA Service specific error code on failure of the operation.
ErrorMessage string NA Error description in Engineering English.
ReturnValue string NA Returns Id string of the new entry added. The LocalId is obtained by a call to GetList, with Id as filter parameter.


Errors

The following table lists the errors and their values:

Table 6.36: Error codes
Error code value Description
1000 Invalid service argument
1002 Bad argument type
1004 Service not supported
1010 Entry exists
1012 Item not found


Error Messages

The following table lists the error messages and their description:


Table 6.37: Error messages
Error messages Description
Calendar:Add:Entry Type is invalid Invalid type is passed for Type parameter
Calendar:Add:InstanceStartTime is invalid Invalid type is passed for InstanceStartTime parameter
Calendar:Add:LocalId is invalid Invalid type is passed for LocalId parameter
Calendar:Add:Summary is invalid Invalid type is passed for Summary parameter
Calendar:Add:Description is invalid Invalid type is passed for Description parameter
Calendar:Add:Location is invalid Invalid type is passed for Location parameter
Calendar:Add:Replication is invalid Invalid type is passed for Replication parameter
Calendar:Add:Status is invalid Invalid type is passed for Status parameter
Calendar:Add:Method is invalid Invalid type is passed for Method parameter
Calendar:Add:SeqNum is invalid Invalid type is passed for SeqNum parameter
Calendar:Add:Priority is invalid Invalid type is passed for Priority parameter
Calendar:Add:StartTime is invalid Invalid type is passed for StartTime parameter
Calendar:Add:EndTime is invalid Invalid type is passed for EndTime parameter
Calendar:Add:AlarmTime is invalid Invalid type is passed for AlarmTime parameter
Calendar:Add:PhoneOwner is invalid Invalid type is passed for PhoneOwner parameter
Calendar:Add:Organizer is invalid Invalid type is passed for Organizer parameter
Calendar:Add:Attendees is invalid Invalid type is passed for Attendees parameter
Calendar:Add:CommonName is invalid Invalid type is passed for CommonName parameter
Calendar:Add:Address is invalid Invalid type is passed for Address parameter
Calendar:Add:Role is invalid Invalid type is passed for Role parameter
Calendar:Add:Status is invalid Invalid type is passed for Status parameter
Calendar:Add:Rsvp is invalid Invalid type is passed for Rsvp parameter
Calendar:Add:RepeatDates is invalid Invalid type is passed for RepeatDates parameter
Calendar:Add:ExDates is invalid Invalid type is passed for ExDates parameter
Calendar:Add:RepeatRule is invalid Invalid type is passed for RepeatRule parameter
Calendar:Add:Type is invalid Invalid type is passed for RepeatRule:Type parameter
Calendar:Add:Type is missing RepeatRule:Type parameter is missing
Calendar:Add:DaysInWeek is invalid Invalid type passed for RepeatRule:DaysInWeek or list contains invalid data
Calendar:Add:UntilDate is invalid Invalid type passed for RepeatRule:UntilDate
Calendar:Add:RepeatRule:StartDate is invalid Invalid type passed for RepeatRule:StartDate
Calendar:Add:Interval is invalid Invalid type is passed for RepeatRule:Interval parameter
Calendar:Add:MonthDays is invalid Invalid type passed for RepeatRule:MonthDays or list contains invalid data
Calendar:Add:DaysInWeek is invalid Invalid type passed for RepeatRule:DaysInWeek or list contains invalid data
Calendar:Add:DaysOfMonth is invalid Invalid type passed for RepeatRule:DaysOfMonth or list contains invalid data
Calendar:Add:RepeatRule:DaysOfMonth:Day Invalid type passed for RepeatRule:DaysOfMonth:Day
Calendar:Add:RepeatRule:DaysOfMonth:WeekNumber Invalid type passed for RepeatRule:DaysOfMonth:WeekNumber
Calendar:Add:Month Invalid type passed for RepeatRule:Month
Calendar:Add:Item is invalid Invalid type is passed for Item
Calendar:Add:CalendarName is invalid Invalid type is passed for CalendarName
Calendar:Add: is invalid Invalid type is passed for parameter


Example

The following sample code illustrates how to add a calendar entry:

import scriptext
import datetime

# Load Calendar service
calendar_handle = scriptext.load('Service.Calendar', 'IDataSource')

start_time = datetime.datetime(2009,03,12,17,0,0)
end_time = datetime.datetime(2009,03,12,18,0,0)

try:
    calendar_handle.call('Add', {'Type': u'CalendarEntry', 'Item': {'Type': u'Meeting', 'Description': u'This is the meeting description', 'StartTime': start_time, 'EndTime': end_time}})
except scriptext.ScriptextError:
    print 'Error in servicing the request'
else:
    print "Add request successfully complete!"

See About this document... for information on suggesting changes.