/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is Sun Microsystems code.
 *
 * The Initial Developer of the Original Code is
 * Sun Microsystems, Inc.
 * Portions created by the Initial Developer are Copyright (C) 2007
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Daniel Boelzle <daniel.boelzle@sun.com>
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

#include "nsISupports.idl"

interface calIOperation;
interface calIGenericOperationListener;

[scriptable, uuid(306DA1C9-DB54-4ef3-B27E-FEA709F638FF)]
interface calICalendarSearchProvider : nsISupports
{
    /**
     * Specifies whether the search string should exactly match.
     */
    const unsigned long HINT_EXACT_MATCH = 1;

    /* ...possibly more to come... */

    /**
     * Searches for calendars matching the specified search string.
     * It's up to the search provider what properties of a calendar
     * it takes into account for the search. The passed hints serve
     * for optimization purposes. Callers need to keep in mind that
     * providers may not be able to implement all of the stated hints
     * passed, thus are required to filter further if necessary.
     * Results are notified to the passed listener interface.
     *
     * @param aString     search string to match
     * @param aHints      search hints
     * @param aMaxResults maximum number of results
     *                    (0 denotes provider specific maximum)
     * @param aListener   called with an array of calICalendar objects
     * @return            optional operation handle to track the operation
     */
    calIOperation searchForCalendars(in AUTF8String aString,
                                     in unsigned long aHints,
                                     in unsigned long aMaxResults,
                                     in calIGenericOperationListener aListener);
};

/**
 * This service acts as a central access point for calendar lookup.
 * A search request will be multiplexed to all added search providers.
 * Adding a search provider is transient.
 */
[scriptable, uuid(2F2055CA-F558-4dc8-A1D4-11384A00E85C)]
interface calICalendarSearchService : calICalendarSearchProvider
{
    /**
     * Gets the currently registered set of search providers.
     */
    void getProviders(out PRUint32 aCount,
                      [array, size_is(aCount), retval] out calICalendarSearchProvider aProviders);

    /**
     * Adds a new search provider.
     */
    void addProvider(in calICalendarSearchProvider aProvider);

    /**
     * Removes a search provider.
     */
    void removeProvider(in calICalendarSearchProvider aProvider);
};
