package com.tootsville.tootsbook.client;

import java.io.IOException;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import com.tootsville.tootsbook.client.exception.AlreadyExistsException;
import com.tootsville.tootsbook.client.exception.InsufficientFundsException;
import com.tootsville.tootsbook.client.exception.InvalidCredentialsException;
import com.tootsville.tootsbook.client.exception.NotFoundException;
import com.tootsville.tootsbook.client.exception.PrivilegeRequiredException;
import com.tootsville.tootsbook.client.exception.SessionTimedOutException;
import com.tootsville.tootsbook.client.util.AvailableItems;
import com.tootsville.tootsbook.client.util.Post;
import com.tootsville.tootsbook.client.util.StoreInventory;
import com.tootsville.tootsbook.client.util.UserProfile;
import com.tootsville.tootsbook.server.BookServiceImpl;

/**
 * The client side interface for the RPC service.
 * 
 * @author <a href="mailto:twheys@gmail.com@resinteractive.com">Tim
 *         Heys</a>
 */
@RemoteServiceRelativePath ("service")
public interface BookService extends RemoteService {
	/**
	 * <pre>
	 * twheys@gmail.com Feb 15, 2010
	 * </pre>
	 * 
	 * TO addComment WRITEME...
	 * 
	 * @param post WRITEME
	 * @return WRITEME
	 * @throws InvalidCredentialsException WRITEME
	 * @throws SessionTimedOutException WRITEME
	 * @throws IOException WRITEME
	 * @throws PrivilegeRequiredException WRITEME
	 */
	Post addComment (Post post)
		throws InvalidCredentialsException, SessionTimedOutException,
		IOException, PrivilegeRequiredException;

	/**
	 * <pre>
	 * twheys@gmail.com Feb 15, 2010
	 * </pre>
	 * 
	 * TO addPost WRITEME...
	 * 
	 * @param toUserID WRITEME
	 * @param post WRITEME
	 * @return WRITEME
	 * @throws InvalidCredentialsException WRITEME
	 * @throws SessionTimedOutException WRITEME
	 * @throws IOException WRITEME
	 * @throws PrivilegeRequiredException WRITEME
	 */
	Post addPost (final int toUserID, Post post)
		throws InvalidCredentialsException, SessionTimedOutException,
		IOException, PrivilegeRequiredException;

	/**
	 * <pre>
	 * twheys@gmail.com Dec 31, 2009
	 * </pre>
	 * 
	 * TO applyItems Replace the current active items of each item ID
	 * with the ID passed for each parameter.
	 * 
	 * @param pageBGSlotNum The Slot Number of the new Page BG item
	 * @param boxStylesSlotNum The Slot Number of the new box styles
	 *            item
	 * @param iconSlotNum The Slot Number of the new icon item
	 * @param titleBGSlotNum The Slot Number of the new title BG item
	 * @param avatarBGSlotNum The Slot Number of the new avatar BG item
	 * @throws SessionTimedOutException If the user is timed out.
	 */
	void applyItems (int pageBGSlotNum, int boxStylesSlotNum,
			int iconSlotNum, int titleBGSlotNum, int avatarBGSlotNum)
		throws SessionTimedOutException;

	/**
	 * Check the if the user has a session
	 * 
	 * @return A {@link UserProfile} if a session exists.
	 * @throws SessionTimedOutException If no session exists.
	 */
	UserProfile checkSession () throws SessionTimedOutException;

	/**
	 * <pre>
	 * twheys@gmail.com Dec 31, 2009
	 * </pre>
	 * 
	 * TO deletePost search for the post by id and set it as deleted.
	 * 
	 * @param id WRITEME WRITEME
	 * @param post WRITEME
	 * @return WRITEME
	 * @throws SessionTimedOutException WRITEME
	 */
	Post deletePost (int id, Post post) throws SessionTimedOutException;

	/**
	 * <pre>
	 * twheys@gmail.com Feb 15, 2010
	 * </pre>
	 * 
	 * TO getRecentPosts WRITEME...
	 * 
	 * @param numberOfDisplayedPosts WRITEME
	 * @return WRITEME
	 */
	Post [] getAdminConsolePosts (int numberOfDisplayedPosts);

	/**
	 * <pre>
	 * twheys@gmail.com Dec 31, 2009
	 * </pre>
	 * 
	 * TO getAvailableThemeItems search all items and a users inventory,
	 * adding the active one first.
	 * 
	 * @return WRITEME
	 * @throws SessionTimedOutException WRITEME
	 * @throws PrivilegeRequiredException WRITEME
	 */
	AvailableItems getAvailableThemeItems ()
		throws SessionTimedOutException, PrivilegeRequiredException;

	/**
	 * <pre>
	 * twheys@gmail.com Jan 15, 2010
	 * </pre>
	 * 
	 * TO getBuddyPosts WRITEME...
	 * 
	 * @param userID WRITEME
	 * @return WRITEME
	 */
	Post [] getBuddyPosts (int userID);

	/**
	 * <pre>
	 * twheys@gmail.com Feb 24, 2010
	 * </pre>
	 * 
	 * TO getInventoryForStore WRITEME...
	 * 
	 * @param storeID WRITEME
	 * @return WRITEME
	 */
	StoreInventory getInventoryForStore (int storeID);

	/**
	 * <pre>
	 * twheys@gmail.com Jan 15, 2010
	 * </pre>
	 * 
	 * TO getMoreBuddyPosts WRITEME...
	 * 
	 * @param userID WRITEME
	 * @param start WRITEME
	 * @return WRITEME WRITEME
	 */
	Post [] getMoreBuddyPosts (int userID, int start);

	/**
	 * Retrieve additional posts for a user. The number of posts
	 * retrieved is set as a constant
	 * {@link BookServiceImpl#getMoreBuddyPosts(int, int)}. Use getPosts
	 * to retrieve an initial set of posts then use this to retrieve
	 * additional data.
	 * 
	 * @param userID The user ID who's posts are being searched for.
	 * @param start The ID of which post to start. This should be the
	 *            last post ID from what was received by
	 *            {@link #getPosts(int)}
	 * @return a new array of Posts and their comments.
	 */
	public Post [] getMorePosts (final int userID, final int start);

	/**
	 * <pre>
	 * twheys@gmail.com Feb 15, 2010
	 * </pre>
	 * 
	 * TO getNewHomePosts WRITEME...
	 * 
	 * @param mostRecentPostID WRITEME
	 * @return WRITEME
	 * @throws SessionTimedOutException WRITEME
	 */
	Post [] getNewHomePosts (int mostRecentPostID)
		throws SessionTimedOutException;

	/**
	 * <pre>
	 * twheys@gmail.com Feb 15, 2010
	 * </pre>
	 * 
	 * TO getNewProfilePosts WRITEME...
	 * 
	 * @param profileID WRITEME
	 * @param mostRecentPostID WRITEME
	 * @return WRITEME
	 * @throws SessionTimedOutException WRITEME
	 */
	Post [] getNewProfilePosts (int profileID, int mostRecentPostID)
		throws SessionTimedOutException;

	/**
	 * <pre>
	 * twheys@gmail.com Mar 1, 2010
	 * </pre>
	 * 
	 * TO getPeanutsForUser WRITEME...
	 * 
	 * @param userID WRITEME
	 * @return WRITEME
	 */
	int getPeanutsForUser (int userID);

	/**
	 * <pre>
	 * twheys@gmail.com Feb 15, 2010
	 * </pre>
	 * 
	 * TO getPosts WRITEME...
	 * 
	 * @param userID WRITEME
	 * @return WRITEME
	 */
	Post [] getPosts (int userID);

	/**
	 * <pre>
	 * twheys@gmail.com Feb 15, 2010
	 * </pre>
	 * 
	 * TO getUser WRITEME...
	 * 
	 * @param userID WRITEME
	 * @return WRITEME
	 * @throws NotFoundException WRITEME
	 */
	UserProfile getUser (int userID) throws NotFoundException;

	/**
	 * @param userName WRITEME
	 * @param password WRITEME
	 * @return After validating the user's credentials and status,
	 *         returns a UserInfo object matching.
	 * @throws NotFoundException If the user name does not retrieve any
	 *             account.
	 * @throws PrivilegeRequiredException If the user is not a paid
	 *             member.
	 * @throws InvalidCredentialsException If the password provided is
	 *             invalid.
	 */
	UserProfile login (String userName, String password)
		throws NotFoundException, PrivilegeRequiredException,
		InvalidCredentialsException;

	/**
	 * Clear all sessions on the servlet. <strong>You still need to log
	 * the user out of the client side.</strong>
	 */
	void logout ();

	/**
	 * <pre>
	 * twheys@gmail.com Feb 26, 2010
	 * </pre>
	 * 
	 * TO purchaseItem WRITEME...
	 * 
	 * @param itemID WRITEME
	 * @throws SessionTimedOutException WRITEME
	 * @throws AlreadyExistsException WRITEME
	 * @throws InsufficientFundsException WRITEME
	 */
	void purchaseItem (int itemID)
		throws SessionTimedOutException, AlreadyExistsException,
		InsufficientFundsException;

	/**
	 * Report the author of the post and delete the post.
	 * 
	 * @param post WRITEME
	 * @return WRITEME
	 * @throws SessionTimedOutException WRITEME
	 */
	Post reportPost (Post post) throws SessionTimedOutException;


}
