Target Classes

TbSync can manage different types of storage targets (calendars, address books, whatever) for each folder / resource found on the server. The provider only has to set a value for the targetType folder property when creating new folders. For each possible value, the provider must implememt a matching class of type TargetData in his provider namespace.

Example:

If one of the possible values of the targetType property is MyCalendar, the provider must implement a TargetData class inside his provider.js with a name of TargetData_MyCalendar.

When interacting with TbSync, for example when syncing a specific folder / resource, you will usually have access to a FolderData() instance, which will return the associated TargetData via FolderData.targetData().

class TargetData(folderData)

TargetData constrcutor.

Arguments:
  • folderData (FolderData) – The FolderData instance of the folder for which this TargetData instance is being created.
TargetData.disconnectTarget()

Disconnects the target in the local storage from this TargetData, but does not delete it, so it becomes a stale “left over”. A call to TargetData.hasTarget() should return false, after this has been executed.

TargetData.getTarget()

Returns the actual target object (for example a nsIAbDirectory). If the target does not exist, it should be created.

Note

The thrown error message will be used as a status and TbSync will use status.<Error.message> from your string bundle (see Base.getStringBundleUrl()) for the actual error/status message.

Throws:Error – Reason, why the target could not be created.
Returns:Object – Whatever you want to use as target object for this TargetData.
TargetData.hasTarget()

Check, if the target object of this TargetData exists in the local storage.

Returns:boolean – True, if target exists.
TargetData.removeTarget()

Removes the target from the local storage. If it does not exist, return silently. A call to TargetData.hasTarget() should return false, after this has been executed.

TargetData.setReadOnly(value)

The readonly property of the associated folder has been changed via the TbSync UI.

Note

This might be changed to a general FolderProperty observer.

Arguments:
  • value (boolean) – The current value of the downloadonly folder property.
TargetData.targetName

Getter/Setter for the target name.