package org.richfaces.realworld.util;

/**
 * License Agreement.
 *
 *  JBoss RichFaces - Ajax4jsf Component Library
 *
 * Copyright (C) 2007  Exadel, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

import java.io.Serializable;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.security.Identity;
import org.richfaces.realworld.service.Constants;

@Name("renderLogic")
@Scope(ScopeType.CONVERSATION)
public class RenderLogic implements Serializable{

	@In Identity identity;
	@In ConversationState conversationState;
	
	private static final long serialVersionUID = 5656562187249324512L;
	
	/*public boolean shouldRenderFriendFolders(){
		return conversationState.getSelectedUser() == null;
	}
	
	public boolean shouldRenderFolders(){
		return conversationState.getSelectedUser()!=null && conversationState.getSelectedImage() == null;
	}*/
	
	public boolean shouldRenderImage(){
		return conversationState.getSelectedAlbum()!=null && conversationState.getSelectedImage() != null;
	}
	
	public boolean shouldRenderImageList(){
		return conversationState.getSelectedAlbum()!=null && conversationState.getSelectedImage() == null;
	}
	
	/*public boolean isCurrentUserProfileSelected(){
		return user.equals(conversationState.getSelectedUser());
	}
	
	public boolean isSecondUserProfileSelected(){
		return conversationState.getSecondSelectedUser() != null;
	}*/
	
/*	public boolean isUserAlbumSelected(){
		return conversationState.getSelectedAlbum() != null && conversationState.getSelectedAlbum().getOwner().equals(user);
	}*/
	
	public boolean isUserGuest(){
		return !identity.hasRole(Constants.ADMIN_ROLE);
	}
	
/*	public boolean isOwner(User u){
		return user.equals(u);
	}*/
	
/*	public boolean isProfileSelected(){
		return conversationState.getMainArea() == NavigationEnum.USER_PREFS;
	}*/
	
/*	public boolean shouldRenderFileUpload(){
		return conversationState.getSelectedAlbum()!=null && conversationState.getSelectedAlbum().getOwner().equals(user);
	}*/
	
	/*public boolean isUserSelected(){
		return user.equals(conversationState.getSelectedUser());
	}
	
	public boolean isFriendSelected(){
		return conversationState.getSelectedUser() == null || isUserFriend();
	}*/
	
	/*public boolean isNotFriendSelected(){
		return !isUserSelected() && !isUserFriend();
	}
	
	public boolean isUserFriend(){
		return user.getFriends() != null && user.getFriends().contains(conversationState.getSelectedUser());
	}
	
	public boolean isUserFriend(User u){
		return user.getFriends() != null && user.getFriends().contains(u);
	}*/
	
	public boolean isAlbumSelected(){
		return conversationState.getSelectedAlbum() != null;
	}
	
	public boolean isImageSelected(){
		return conversationState.getSelectedImage() != null;
	}
	
	/*public boolean isAccessToAlbumGranted(Album album){
		return album.getOwner().equals(user) || album.isShared() || isUserFriend(album.getOwner());
	}*/
	
/*	public boolean isUserAlbum(Album album){
		if(album == null){
			return false;
		}
		return album.getOwner().equals(user);
	}
	
	public boolean isFavoriteAlbum(Album album){
		return user.getFavoriteAlbums().contains(album);
	}
	
	public boolean isFavoriteImage(Image image){
		return user.getFavoriteImages().contains(image);
	}*/
	
}
