/***************************************************************************
 *   Copyright (C) 2004 by yunfan                                          *
 *   yunfan_zg@163.com                                                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program 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 General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef EVAUSER_H
#define EVAUSER_H 

#include "evauserinfo.h"
#include "evafriendlist.h"
#include <string>
#include <list>

class EvaUserSetting;
class EvaUser{
public:
	EvaUser(const int id, const std::string &password);
	EvaUser(const int id, const char *md5Password);
	~EvaUser();
	
	enum UserStatus {Eva_Online, Eva_Offline, Eva_Invisible, Eva_Leave};
	const int getQQ() const { return qqNum; }
	const char *getMd5Password() const { return md5Password; }
	
	void setStatus(const UserStatus status) { this->status = status; }
	const UserStatus getStatus() const { return status; }
	static char getStatusCode(const UserStatus status) ;
	
	void setDetails(const ContactInfo &details) { this->details = details; }
	const ContactInfo &getDetails() const { return details; }
	
	FriendList &getFriendList() { return myFriends; }
	
	const bool newGroup(const std::string &name);
	void clearGroupNames();
	void removeGroupName(const int index);
	const int getGroupIndexOf(const std::string &name);
	void updateGroupName(const std::string &newName, const int index);
	void setAnonymousGroupName(const std::string &name) { anonymousName = name; }
	const std::string getAnonymousGroupName() const { return anonymousName; }
	void setBlackGroupName(const std::string &name) { blackName = name; }	
	const std::string getBlackGroupName() const { return blackName; }	
	static int getAnonymousIndex() { return anonymousIndex; }
	static int getBlackIndex() { return blackIndex; }
	std::list<std::string> &getGroupNames() { return groupNames; }
	void setGroupNames(std::list<std::string> &list) { groupNames = list; }
	const std::string groupNameAtIndex(const int index);
	
	EvaUserSetting *getSetting() { return setting; }
	
	const bool loadGroupedBuddyList();
	const bool saveGroupedBuddyList();
	void setBuddyLoadedEnabled( const bool v) { isBuddyListLoaded = v; }
	const bool isBuddiesLoaded() { return isBuddyListLoaded; }

private:
	int qqNum;
	char *md5Password;
	UserStatus status;
	ContactInfo details;
	FriendList myFriends;
	std::list<std::string> groupNames;
	EvaUserSetting *setting;
	bool isBuddyListLoaded;
	
	static std::string anonymousName;
	static std::string blackName;
	static const int anonymousIndex = 0xfffe;
	static const int blackIndex = 0xffff;
};

#endif


