6.3.3 Delete

Delete is used to remove a calendar from the device or, one or more entries from a calendar. Entries are deleted from the specified calendar or, from the default one if no calendar is specified. You can delete a calendar in synchronous mode. You can delete calendar entries both in synchronous and asynchronous mode.

Note:

The following are the examples for using Delete:

Synchronous

event_id = calendar_handle.call('Delete', {'Type': u'CalendarEntry', 'id': del_id_list})

Asynchronous

event_id = calendar_handle.call('Delete', {'Type': u'CalendarEntry', 'id': del_id_list}, callback= del_callback)

where del_callback is a user defined callback function.

The following table summarizes the specification of Delete:

Interface IDataSource
Description Deletes the specified calendar from the Device or, one or more entries / instances from a specific calendar file.
Response Model Synchronous for type Calendar and both synchronous and asynchronous for type CalendarEntry.
Pre-condition IDataSource interface is loaded.
Post-condition Nil

Input Parameters for Calendar

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

Table 6.38: Input parameters for Calendar Delete
Name Type Range Description
Type unicode string Calendar Performs the operation on all available calendars if the type is Calendar.
Data map CalendarName: unicode string Deletes the given calendar. You cannot delete the default calendar.


Output Parameters for Calendar

Output parameter contains ErrorCode and an optional ErrorMessage, which is displayed when the operation fails.

Table 6.39: Output parameters for Calendar Delete
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

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

Table 6.40: Input parameters for Calendar Entry Delete
Name Type Range Description
Type unicode string CalendarEntry Performs the operation on entries of the specified calendar, if the type is CalendarEntry.
Data map [CalendarName]: unicode string
[IdList] or [LocalIdList]: List of unicode string
[StartRange]: datetime
[EndRange]: datetime
[DeleteAll]: bool
Uses the default calendar if the CalendarName is not specified.
You can specify either IdList or LocalIdList with StartRange or EndRange or, both.
Deletes the instances within the specified range if range is specified. Deletes entries that match the IdList or LocalIdList if no range is specified.
Deletes all entries within the specified calendar if the DeleteAll field is set.

One of the fields from the set IdList or LocalIdList, StartRange, EndRange, and DeleteAll must be passed to delete entries. If not, error is returned. Invalid id or LocalIds from list are ignored.


Output Parameters for Calendar Entry

Output parameter contains ErrorCode, and an ErrorMessage, which is displayed when the operation fails.

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


Errors

The following table lists the errors and their values:

Table 6.42: Error codes
Error code value Description
1000 Invalid service argument
1004 Service not supported
1012 Item not found


Error Messages

The following table lists the errors messages and their description:

Table 6.43: Error messages
Error messages Description
Calendar:Delete:Type is invalid Delete called with invalid Type
Calendar:Delete:CalendarName is missing Delete (type Calendar) called without passing CalendarName
Calendar:Delete:CalendarName is invalid Invalid type is passed for CalendarName
Calendar:Delete:StartRange is invalid Invalid type is passed for StartRange parameter
Calendar:Delete:EndRange is invalid Invalid type is passed for EndRange parameter
Calendar:Delete:DeleteAll is invalid Invalid type is passed for DeleteAll parameter
Calendar:Delete:IdList is invalid Invalid type is passed for IdList parameter
Calendar:Delete:LocalIdList is invalid Invalid type is passed for LocalIdList parameter
Calendar:Delete:Data is missing Delete (type CalendarEntry) called with invalid delete Data
Calendar:Delete:Data is invalid Invalid type is passed for Data parameter


Example

The following sample code illustrates how to delete a specified calendar entry in asynchronous mode:

import scriptext
import e32

# Using e32.Ao_lock() so that the main function can wait 
# till the callback is hit.
lock = e32.Ao_lock()

# Callback function will be called when the requested service is complete
def del_callback(trans_id, event_id, input_params):
    if event_id != scriptext.EventCompleted:   
# Check the event status
        print "Error in the operation"
        print "Error code is: " + str(input_params["ReturnValue"]["ErrorCode"])
        if "ErrorMessage" in input_params["ReturnValue"]:
            print "Error message is: " + input_params["ReturnValue"]["ErrorMessage"]
    elif event_id == scriptext.EventCompleted:
        print "Entry deleted successfully."

    lock.signal()

# Returns the list of calendar id's that needs to be deleted.
del_id_list = get_cal_del_id()

# Load Calendar service
calendar_handle = scriptext.load('Service.Calendar', 'IDataSource')
event_id = calendar_handle.call('Delete', {'Type': u'CalendarEntry', 'IdList': del_id_list}, callback=del_callback)

print "Waiting for the request to be processed!"
lock.wait()
print "Request complete!"

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