Archive‎ > ‎Fall 2009‎ > ‎Course Project‎ > ‎Buddy Suite‎ > ‎Milestone 1: FriendFinder‎ > ‎

FriendFinderTestInterface

package epfl.sweng.friendfinder;

import java.util.Map;
import android.graphics.Point;
import com.google.android.maps.GeoPoint;

/**
 * Test Interface for the Friend Finder.
 *
 * @author Silviu
 * @author Laurent
 */
public interface FriendFinderTestInterface {

    /**
     * Factory class for the FriendFinder().
     */
    public static final class FriendFinderFactory {
        public FriendFinderTestInterface newFriendFinder() {
            return new FriendFinder();
        }
    }

    /**
     * : Class used to hijack the messages that would otherwise be sent to the
     * server, i.e. dslabpc28.epfl.ch
     *
     */
    public interface Destination {
        /**
         * : Receive a message
         *
         * @param message
         *            the message to be received
         */
        public void receive(String message);
    }

    /**
     * Method used to log in.
     *
     * @param username
     *            - the username that will be used to log in
     * @param password
     *            - the associated password
     * @return true if log in succeeded, false in the contrary case
     */
    boolean logIn(String username, String password);

    /**
     * : Method used to log out
     *
     * @return true if log out was successful
     */
    boolean logOut();

    /**
     * : Method used to quit
     */
    void quit();

    /**
     * : Get the current position of the phone
     *
     * @return a GeoPoint representing the current location
     */
    GeoPoint getCurrentLocation();

    /**
     * : Get the location of a friend as the program knows about it
     *
     * @param username
     *            the friend whose location is to be retrieved
     * @return the location of the friend
     */
    GeoPoint getFriendsPosition(String username);

    /**
     * : Sets the phone's position as specified by the parameters
     *
     * @param latitude
     *            the latitude of the phone's position
     * @param longitude
     *            the longitude of the phone's position
     */
    void setCurrentLocation(int latitude, int longitude);

    /**
     * : Retrieves the status of a friend
     *
     * @param username
     *            the friend whose status has to be returned
     * @return true if the friend is logged in, false otherwise
     */
    boolean getFriendsStatus(String username);

    /**
     * : Returns the screen coordinates of where the user is displayed
     *
     * @return a Point representing the screen coordinates
     */
    Point getUserScreenCoordinates();

    /**
     * : Returns the screen coordinations where the friend is displayed.
     *
     * @param username
     *            the friend whose screen coordinates have to be returned
     * @return a Point representing the position on the screen.
     */
    Point getFriendsScreenCoordinates(String username);

    /**
     * : After calling this method, the program will ignore all messages
     * received from the server
     */
    void ignoreIncomingMessagesFromServer();

    /**
     * : After calling this method, the program will react to messages received
     * from the server
     */
    void stopIgnoringMessageFromServer();

    /**
     * : Makes the program react to the passed parameter as if it was coming
     * from the server
     *
     * @param message
     *            the message to act upon
     */
    void receiveFromServer(String message);

    /**
     * : After calling this method, all messages have to be sent to Destination
     * specified as parameter
     *
     * @param destination
     *            the new destination of messages to be sent to the server
     */
    void redirectSendTo(Destination destination);

    /**
     * : After calling this method, all messages must be sent to the server,
     * i.e. dslabpc28.epfl.ch
     */
    void resumeSendingToOriginalServer();

    /**
     * : After calling this method, the friend data should be read from the map.
     *
     * @param mapFromFriendsNameToEmailAddress
     *            the mapping from friends to email addresses
     */
    void setFriends(Map<String, String> mapFromFriendsNameToEmailAddress);
}