/**
 * BEGIN FLOCK GPL
 *
 * Copyright Flock Inc. 2005-2009
 * http://flock.com
 *
 * This file may be used under the terms of the
 * GNU General Public License Version 2 or later (the "GPL"),
 * http://www.gnu.org/licenses/gpl.html
 *
 * 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.
 *
 * END FLOCK GPL
 */

#include "nsISupports.idl"
#include "nsISimpleEnumerator.idl"
#include "flockIError.idl"
#include "flockIListener.idl"
#include "flockIMediaItem.idl"
#include "flockIPhotoUpload.idl"
#include "flockISocialWebService.idl"
#include "flockIMediaUploadWebService.idl"
#include "flockIBlogWebService.idl"

/**
 * A generic JavaScript wrapper for Facebook's api.
 *
 * Reference: http://developers.facebook.com/index.php
 *
 * All api calls except auth.createToken() and auth.getSession() are exposed.
 * These calls are wrapped in the authenticate() method.
 */
// this should actually derive from flockIAuthenticatedAPI
[scriptable, uuid(567877f0-1235-1eab-b0de-0804729c9a66)]
interface flockIFacebookAPI: nsISupports
{
  attribute AString uid;

  /**
   * Authenticate with Facebook using the desktop method
   *
   * @li 1) call auth.createToken() to create a shared token
   * @li 2) open a window with Facebook's API authorization page
   * @li 3) call auth.getSession() to get session/secret for subsequent calls.
   *
   * Notes:
   *   Ability to directly call auth.createToken() is not exposed.
   *   Ability to directly call auth.getSession() is not exposed.
   *
   * @param aFlockListener (in) a flockIListener which responds whether the
   *                       user was successful authenticated / session setup
   */ 
  void authenticate(in flockIListener aFlockListener);

  void deauthenticate();

  /**
   * Get a list of identifiers for friends of the authenticated user
   *
   * @param aFlockListener (in) a flockIListener which responds onSuccess with
   *                       the list of identifers for the user's friends.
   *                       (example identifier: @c iPF_ahrjO4z3fpYh8-ySIMA.. )
   */
  void friendsGet(in flockIListener aFlockListener);

  /**
   * Get a list containing all notifications of the currently logged in user
   *
   * @param aFlockListener (in) a flockIListener which responds onSuccess with
   *                       the notifications list
   */
  void notificationsGet(in flockIListener aFlockListener);

  /**
   * Check if the session is still valid
   *
   * @param aFlockListener (in) a flockIListener which responds onSuccess if
   *                       session is still valid, or onError if the session
   *                       is not or there were other problems.
   */
  void sessionPing(in flockIListener aFlockListener);

  /**
   * Get information for a list of users (specified by identifiers)
   *
   * @param aFlockListener (in) a flockIListener which responds onSuccess with
   *                       a wrappedJS object. The object correspond to the
   *                       JSON response from Facebook.
   *                       see: http://developer.facebook.com/documentation.php
   * 
   * @param users (in) a comma separated list of users for which to retrieve
   *                   info.
   *
   * @param fields (in) an optional comma separated list of fields requested
   *                    from the service (ex: @c 'clubs,books,birthday' ).
   *                    If not specified the query will be for a (flock)
   *                    default set of fields.
   */
  void usersGetInfo(in flockIListener aFlockListener,
                    in AString users,
                    in AString fields);

  /**
   * Get the list of users, friends of the current authenticated user,
   * who uploaded at least one photo since aLastSeen
   *
   * @param aFlockListener (in) a flockIListener which responds onSuccess with
   *                       a nsISimpleEnumerator of property bags. Each property
   *                       bag contains:
   *                       AString uid: the user id on Facebook
   *                       Int32 count: the number of photos uploaded
   *                       since aLastSeen
   *
   *
   * @param aLastSeen (in) the date from which we want to observe updates,
   *                       as a string containing the number of seconds
   *                       since Epoch.
   *
   */
  void getUpdatedMediaFriends(in flockIListener aFlockListener,
                              in string aLastSeen);

  void eventsGetInWindow();
  void friendsGetAppUsers();
  void friendsGetTyped();
  void friendsAreFriends();
  void messagesGetCount();
  void photosGetAlbums();
  void photosGetCommentCount();
  void photosGetFromAlbum();
  void photosGetOfUser();
  void pokesGetCount();

  string getFacebookURL(in string aUrlType, in string aFriendId);

  /**
   * Get a list of albums for a desired user
   *
   * @param aFlockListener (in) A flockIListener which responds
   *                       flickIListener#onSuccess() with an enumerator of
   *                       flockIPhotoAlbum.
   * @param aUserId (in) A user id to get albums for.
   */
  void getAlbums(in flockIListener aFlockListener, in AString aUserId);

  /**
   * Create an album for this user
   *
   * @param aFlockListener (in) A flockIListener which responds
   *                       flockIListener#onSuccess() with with the album that
   *                       was created.
   * @param aAlbumTitle (in) The title of the new album to create.
   */
  void createAlbum(in flockIListener aFlockListener, in AString aAlbumTitle);

  /**
   * Get a list of photos, optionally from a particular album
   *
   * @param aFlockListener (in) A flockIListener which responds
   *                       flockIListener#onSuccess() with an enumerator of
   *                       flockIPhotoAlbum.
   * @param aSubj (in) [optional] Return only photos tagged with this user's
   *                              user id.
   * @param aAlbumID (in) [optional] Return photos only from this album.
   * @param aPidList (in) [optional] Only return photos form this comma
   *                                 separated list.
   *
   * Note: if aSubj is set then only photos tagged with the user id will
   *       be returned as a subset of the other to params.
   */
  void getPhotos(in flockIListener aFlockListener,
                 in AString aSubj,
                 in AString aAlbumID,
                 in AString aPidList);

  /**
   * Upload photos to Facebook from the Flock Photo Uploader.
   *
   * @param aUploadListener (in) A flockIPhotoUploadAPIListener.
   * @param aPhoto (in) An AString containing the full filename of the photo
   *                    to upload.
   * @param aParams (in) An nsIPropertyBag2 containing paramaters to pass to
   *                     flockIPhotoAPI#upload2.
   * @param aUpload (in) A flockIPhotoUpload.
   */
  void uploadPhotosViaUploader(in flockIPhotoUploadAPIListener aUploadListener,
                               in AString aPhoto,
                               in nsIPropertyBag2 aParams,
                               in flockIPhotoUpload aUpload);

  /**
   * Tag photos in Facebook
   * @param aFlockListener (in) A flockIListener which responds...
   * @param aPid (in) An AString containing the id of the photo to be tagged.
   * @param aTagUid (in) An AString containing the user id of the user being
   *                     tagged. Either aTagUid or aTagText must be
   *                     specified.
   * @param aTagText (in) An AString containing some text identifying the
   *                      person being tagged. Either aTagUid or aTagText
   *                      must be specified. This parameter is ignored if
   *                      aTagUid is specified.
   * @param aX (in) An AString containing the horizontal position of the tag,
   *                as a percentage from 0 to 100 from the left of the photo.
   * @param aY (in) An AString containing the vertical position of the tag,
   *                as a percentage from 0 to 100 from the top of the photo.
   * @param aTags (in) An AString containing a JSON-serialized array
   *                   representing a list of tags to be added to the photo.
   *                   If the aTags parameter is specified, the aX, aY,
   *                   aTagUid, and aTagText parameters are ignored. Each
   *                   tag in the list must specify: "x", "y", and either
   *                   the user id "uid" or free-form "text"
   *                   identifying the person being tagged. An example of
   *                   this is the string:
   *                     [ {"x":"30.0","y":"30.0","uid":1234567890},
   *                       {"x":"70.0","y":"70.0","text":"some person"} ]
   */
  void addTag(in flockIListener aFlockListener,
              in AString aPid,
              in AString aTagUid,
              in AString aTagText,
              in AString aX,
              in AString aY,
              in AString aTags);

  /**
   * Set the status of the current user.
   *
   * @param aFlockListener (in) A flockIListener which responds...(may be null)
   * @param aFQLQuery (in) An AString containing the new status text.
   *                       Leave blank to clear the status.
   */
  void setStatus(in flockIListener aFlockListener,
                 in AString aNewStatus);

  /**
   * Add Flock's box to the user profile, and authorize Flock to publish
   * full stories.
   *
   * see: http://www.new.facebook.com/editapps.php?v=all
   */
  void addProfileBox(in flockIListener aFlockListener);

  /**
   * Report a status change to the FB profile page.
   * Status updates for Facebook are ignored.
   *
   * @param aFlockListener (in) A flockIListener which responds...(may be null)
   * @param aAccount (in) The account where the user changed his status
   * @param aStatus (in) The text of the new status
   */
  void reportStatus(in flockIListener aFlockListener,
                    in flockISocialAccount aAccount,
                    in AString aStatus);

  /**
   * Report a blog post publication to the FB profile page
   *
   * @param aFlockListener (in) A flockIListener which responds...(may be null)
   * @param aService (in) The service where the post was published
   * @param aPostTitle (in) The title of the new blog post
   * @param aPostPermalink (in) The permalink of the new blog post
   */
  void reportBlog(in flockIListener aFlockListener,
                  in flockIBlogAccount aAccount,
                  in AString aTitle,
                  in AString aBody,
                  in AString aPermalink);

  /**
   * Report upload of a batch of public photos to a given service.
   * Uploads to Facebook are ignored. Do NOT include any private
   * photo in aPhotoList.
   *
   * @param aFlockListener (in) A flockIListener which responds...(may be null)
   * @param aAccount (in) The account to which photos were uploaded
   * @param aPhotoList (in) enumerator of flockIMediaItem representing the
   *    public photos uploaded
   */
  void reportUpload(in flockIListener aFlockListener,
                    in flockIMediaUploadAccount aAccount,
                    in nsISimpleEnumerator aPhotoList);

  /**
   * Perform a FQL query.
   *
   * @param aFlockListener (in) A flockIListener which responds
   *                       flockIListener#onSuccess() with the XML response.
   * @param aFQLQuery (in) An AString containing the FQL query to perform.
   */
  void doFQLQuery(in flockIListener aFlockListener, in AString aFQLQuery);

  /**
   * Create a facebookPhoto ojbect
   */
  flockIMediaItem createPhoto();
};
