Calendaring API
---------------

Copyright (c) 1999-2006 IceWarp Ltd. All rights reserved.


OverView
--------

IceWarp Calendaring is a server based application which has a set of API functions for the complete calendaring usage.
You have to be familiar with the Calendaring DB structures which can be seen in the Calendar.xml file including
all field type values, comments and more.

Currently in order to access the API you have to use the WebMailCOM.dll COM object to all the functions.
The object name is IceWarpWebMailCOM.Calendar and you can see the complete usage in the PHP source code of webmail.
The important part is the COM object has only one function which wraps all functions below.

VARIANT CalendarFunctionCall(VARIANT funcname, VARIANT param1, VARIANT param2, VARIANT param3, VARIANT param4)

funcname - function name below 
param1..param4 - the proper values for the functions

Result - string result of the function result. Either it contains the ID from the function, list of results from the DB or an error code.
List of results - URLEncoded list of headers on one line and URLEncoded values of headers on multiple following lines (Eg. "EvnClass&EvnNote&" CRLF "E&Note&" CRLF "T&Task%20Note&" CRLF)
Parameters - URLEncoded list of headers and values. (Eg. EvnClass=E&EvnNote=Note)


Functions
---------

// ----------------
// Access Functions
// ----------------

Function LoginUser(EmailAddress, Password: String; IP: String = ''; Options: String = ''; P: Pointer = Nil): String;
// Logs in the user with the email address password and IP connected to. If successul the function
// returns the Session ID which has to be used for other function processing.

Function LogoutUser(SessionID: String): Boolean;
// Logs out the user and terminates all group session IDs. This function has to be called everytime a user
// logs in and does not log out his session too.

Function AuthenticateChallenge(P: Pointer = Nil): String;
// Returns the challenge string for authentication. The P parameter is not specified and will be ignored.

Function Authenticate(EmailAddress, Hash: String; IP: String = ''; Options: String = ''; P: Pointer = Nil): String;
// Authenticates the user using the Method. P is not specified. Hash is the calcualted digest using the challenge string and the password.
// By default CRAM-MD5 authentication scheme is used.
// The result is the same as for LoginUser.

Function UserLoggedOn(SessionID: String): Boolean;
// Returns true if session ID exists

Function GetGroupAccess(SessionID, GroupID: String): String;
// Once you know the GroupIDs (GetGroupList) you want to view/edit you need to get a group session ID by this function.
// If successful it will return the group session ID.

Function GetGroupAccessRights(GroupSessionID: String): String;
// Returns the rights for the group session.
// Bit 0 - Is Owner
// Bit 1 - Can Edit
// Bit 2 - Full Control

// --------------
// List Functions
// --------------

Function GetGroupList(SessionID: String; EmailAddress: String = ''): String;
// Returns the list of all groups (IDs & Titles) for the session or other user email address (if trusted user)

Function GetEventList(GroupSessionID: String; Where: String = ''; OtherSelect: String = ''): String;
Function GetRecurrenceEventList(GroupSessionID: String; Where: String = ''; OtherSelect: String = ''): String;
Function GetReminderEventList(GroupSessionID: String; Where: String = ''; OtherSelect: String = ''): String;
Function GetAllIntervalEvents(GroupSessionID: String; Interval: String; Where: String = ''; OtherSelect: String = ''): String;
// Returns a list of all Events for the GroupSessionID.
// Where specifies other SQL conditions. Eg. EvnClass = 'E'
// OtherSelect specifies what fields you want to return besides EVN_ID. Eg: EvnClass,EnvNote
// GetAllIntervalEvents Interval - JulianDateStart "-" JulianDateEnd

Function GetEventDetailList(GroupSessionID: String; Where: String = ''; OtherSelect: String = ''): String;
// Returns the same output as GetEventList plus some other detailed information about
// reminders, recurrences (outer join with the tables EventReminder and EventRecurrence)

Function GetEventInfo(GroupSessionID: String; EventID: String): String;
// Returns a complete Event info

Function GetvCalendar(GroupSessionID: String; EventID: String; Format:: String = ''): String;
// Returns the vCalendar of the calendar object (vEvent, vToDo, vJournal, vNote)

Function GetEventCategories(GroupSessionID: String; EventID: String): String;
Function GetEventReminders(GroupSessionID: String; EventID: String): String;
Function GetEventRecurrence(GroupSessionID: String; EventID: String): String;
Function GetEventContacts(GroupSessionID: String; EventID: String): String;
// Returns all items for the Event

Function GetEventNoteText(GroupSessionID: String; EventID: String): String;
// Returns unlimited text for a Note object

Function GetVFreeBusy(GroupSessionID: String; Interval: String; Where: String = ''): String;
// Returns the VFreeBusy versit object for the given inteval

Function GetGroupUsers(GroupSessionID: String): String;
// Returns a complete list of all EventUsers for the GroupSessionID. Only owner of the group can
// call this function.

Function GetOwnerInfo(SessionID: String): String;
// Returns owner details

Function GetHolidays(SessionID: String): String;
// Returns all system holidays and also the ones set for the user with the Selected flag

Function GetIntervalHolidays(SessionID: String; Interval: String): String;
// Returns holiday values and attributes for the given interval

Function GetContactList(GroupSessionID: String; Where: String = ''; OtherSelect: String = ''): String;
// Returns a list of all contacts in the group

Function GetContactInfo(GroupSessionID: String; ContactID: String): String;
// Returns the details of the contact

Function GetContactDetailList(GroupSessionID: String; Where: String = ''; OtherSelect: String = ''): String;
// Returns the same output as GetContactList plus some other detailed information about
// locations

Function GetvCard(GroupSessionID: String; ContactID: String; Format:: String = ''): String;
// Returns the vCard of the contact object

Function GetContactLocations(GroupSessionID: String; ContactID: String): String;
// Returns a list of all contact locations

Function GetContactLocationPhones(GroupSessionID: String; LocationID: String): String;
// Returns a list of all contact location phones

Function GetContactCertificate(GroupSessionID: String; ContactID: String): String;
// Returns the certificate of the contact

// ------------------
// Add/Edit Functions
// ------------------
// Parameters contain an URL encoded field value string. Eg: EvnNote=Note%20Here&EvnClass=T
// Non-mandatory parameters specify an edit/update function of an existing record.
// All functions return the item ID of the inserted or updated record if successful.

Function AddGroup(SessionID: String; Parameters: String; GroupID: String = ''): String;
// Only owner can call this function to create a new Group. Group is a store for all
// events and can each can have different share modes etc. By default every user has
// a default group.

Function AddHoliday(SessionID: String; Parameters: String): Boolean;
// Adds a new holiday

Function AddGroupUser(GroupSessionID: String; Parameters: String): String;
// Only Owner can call this function to add trusted users who can view the group's
// events.

Function AddEventInfo(GroupSessionID: String; Parameters: String; EventID: String = ''): String;
// Adds or edits an event.

Function AddvCalendar(GroupSessionID: String; Item: String; EventID: String = ''; Format:: String = ''): String;
// Adds or edits a vCalendar object

Function AddEventCategory(GroupSessionID: String; EventID: String; Parameters: String): String;
Function AddEventReminder(GroupSessionID: String; EventID: String; Parameters: String): String;
Function AddEventContact(GroupSessionID: String; EventID: String; Parameters: String): String;
Function AddEventRecurrence(GroupSessionID: String; EventID: String; Parameters: String): String;
// Adds new records for an event.

Function SetEventNoteText(GroupSessionID: String; EventID: String; Text: String): Boolean;
// Sets unlimited text for a Note object

Function UpdateOwnerInfo(SessionID: String; Parameters: String): Boolean;
// Owner can set his own info. For example the DailyReminder etc.

Function AddContactInfo(GroupSessionID: String; Parameters: String; ContactID: String = ''): String;
// Adds a new contact

Function AddvCard(GroupSessionID: String; Item: String; ContactID: String = ''; Format:: String = ''): String;
// Adds or edits a vCard object

Function AddContactLocation(GroupSessionID: String; ContactID: String; Parameters: String): String;
// Adds a new contact location

Function AddContactLocationPhone(GroupSessionID: String; LocationID: String; Parameters: String): Boolean;
// Adds a new contact location phone

Function SetContactCertificate(GroupSessionID: String; ContactID: String; Cert: String): Boolean;
// Sets the certificate of the contact

// ----------------
// Delete Functions
// ----------------
// Non-mandatory parameters specify a particular ID to be deleted. If empty all records for the event will be deleted.

Function DeleteGroup(SessionID: String; GroupID: String): Boolean;
// Only owner can call this fuction to delete an existing group.

Function DeleteHolidays(SessionID: String): Boolean;
// Deletes all holidays

Function DeleteGroupUsers(GroupSessionID: String; ID: String = ''): Boolean;
// Only owner can deletes users from a group

Function DeleteEvent(GroupSessionID: String; EventID: String): Boolean;
// Delete an existing event. Automatically deletes all event items too.

Function DeleteEventCategories(GroupSessionID: String; EventID: String; ID: String = ''): Boolean;
Function DeleteEventReminders(GroupSessionID: String; EventID: String; ID: String = ''): Boolean;
Function DeleteEventContacts(GroupSessionID: String; EventID: String; ID: String = ''): Boolean;
Function DeleteEventRecurrence(GroupSessionID: String; EventID: String): Boolean;
// Delete event items.

Function DeleteGroupEvents(GroupSessionID: String): Boolean;
// Deletes all objects from a group.

Function DeleteContact(GroupSessionID: String; ContactID: String): Boolean;
// Delete an existing contact. Automatically deletes all contact table items too.

Function DeleteContactLocations(GroupSessionID: String; ContactID: String; LocationID: String = ''): Boolean;
// Delete all contact locations or one location with its phones numbers.

Function DeleteContactLocationPhones(GroupSessionID: String; LocationID: String): Boolean;
// Delete all contact location phones

// ---------------
// Other Functions
// ---------------
Function ExportGroup(GroupSessionID: String): String;
// Exports all group data for the owner to XML

Function ImportGroup(GroupSessionID: String; Data: String): Boolean;
// Imports all group data for the owner from XML

Function IsAddressBookEmail(OwnerEmail: String; Email: String; Separate: Boolean): Boolean;
// Returns True if there is the Email in the address book of the Owner

Function GetServerVersion: String;
// Returns the server version

Function MigrateData(SourceDSN, DestinationDSN: String; LocalSession: Boolean): Boolean;
// Migrates all data from the Source DSN to the Destination DSN

Function GetLastError(SessionID: String): String;
// Returns the last error
