/***************************************************************************
 *   Copyright (C) 2005 by Doo-Hyun Jang                                   *
 *   ring0320@nate.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 BUDDYLIST_H
#define BUDDYLIST_H

#include <qobject.h>
#include <qptrlist.h>
#include <kdebug.h>

#include "buddy.h"

class Buddy;

/**
   @author Doo-Hyun Jang <ring0320@nate.com>
*/
class BuddyList : public QObject
{
Q_OBJECT
public:

		BuddyList() { m_BuddyList.clear(); };
	~BuddyList() {};

	/// 버디리스트에 추가.
	Buddy* addBuddy(Buddy *pBuddy);
	/// return the buddy with the given handle
	/// CMN번호로 Buddy 객체를 얻음.
	Buddy *getBuddyByHandle(const QString sHandle) const;
	/// Nateon ID(ex, xxx@nate.com)으로 Buddy 객체를 얻음.
	Buddy *getBuddyByID(QString sID) const;
	/// Cyworld CMN 으로 Buddy 객체를 얻음.
	Buddy *getBuddyByCyworldCMN(QString sCMN) const;

	/// Hompy Major CMN 으로 Buddy 객체를 얻음.
	Buddy *getBuddyByHompyMajorCMN(QString sCMN) const;
	/// CMN번로로 nick을 얻음.
	QString getBuddyNickByHandle(const QString sHandle) const;
	/// CMN번호로 Nateon ID를 얻음.
	QString getBuddyIDByHandle(const QString sHandle) const;
	/// 전체 Buddy 리스트를 얻음.
	const QPtrList<Buddy>& getBuddyList() const;
	/// GID로 Buddy 리스트를 얻음.
	const QPtrList<Buddy>& getBuddyListByGID(QString sGID);
	/// 버디리스트 clear
	void clear() { m_BuddyList.clear(); }
	/*! 버디 리스트에서 삭제 */
	void remove( Buddy *pBuddy ) { m_BuddyList.remove( pBuddy ); }
	
private:
	/// the list of buddylist
	QPtrList<Buddy> m_BuddyList;

signals:
	/// signal that a buddy changed it's status
	void buddyChangeStatus(Buddy *pBuddy);
	/// signal that a buddy has moved to a different position in the group list
	void buddyMoved(Buddy *pBuddy);
	/// signal that a buddy is offline
	void buddyOffline(Buddy *pBuddy);
	/// signal that a buddy is online
	void buddyOnline(Buddy *pBuddy);
	/// signal that a buddy has been removed
	void buddyRemoved(const Buddy *pBuddy);
};
#endif
