/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface calIGoogleSession;
interface calIGoogleCalendar;
interface calIEvent;
interface calIDateTime;
interface calIGenericOperationListener;
interface calIOperationListener;
interface calIGoogleRequest;
interface calIOperation;

interface nsIVariant;

[scriptable, uuid(6a7ba1f0-f271-49b0-8e93-5ca33651b4af)]
interface calIGoogleSessionManager : nsISupports {
    /**
     * getSessionByUsername
     * Get a Session object for the specified username. If aCreate is false,
     * null will be returned if the session doesn't exist. Otherwise, the
     * session will be created.
     *
     * @param aUsername The username to get the session for
     * @param aCreate   If true, the session will be created prior to returning
     */
     calIGoogleSession getSessionByUsername(in AUTF8String aUsername, in boolean aCreate);

};

[scriptable, uuid(652f6233-e03f-438a-bd3b-39877f68c0f4)]
interface calIGoogleSession : nsISupports {
    /**
     * The Authentication Token from Google
     */
    readonly attribute AUTF8String authToken;

    /**
     * The username for this session. To get a session with a different
     * username, use calIGoogleSessionManager.
     */
    readonly attribute AUTF8String userName;

    /**
     * If set, the password will persist across restarts.
     */
    attribute boolean persist;

    /**
     * The user's full name, usually retrieved from the XML <author> fields. If
     * unset, this will return the userName attribute.
     */
    attribute AUTF8String fullName;

    /**
     * The password used to authenticate. It is only important to implement the
     * setter here, since the password is only used internally.
     */
    attribute AUTF8String password;

    /**
     * Resets the Auth token and sets the persist attribute to false.
     */
    void invalidate();

    /**
     * getCalendars
     * Get the list of calendars for this session. The operaion listener will be
     * called with an array of calIGoogleCalendars.
     *
     * @param aListener The listener to call when the calendars were retrieved
     */
    calIOperation getCalendars(in calIGenericOperationListener aListener);

    /**
     * asyncItemRequest
     * Send a request to Google, logging in to the session if required.
     *
     * @param aRequest      The calIGoogleRequest to send
     */
    void asyncItemRequest(in calIGoogleRequest aRequest);
};
