#include "../../netwaker_member/NetWakerClientInc.h"
#include "FriendListFrame.h"

CFriendListFrame*			g_pFriendListFrame = NULL;

int LuaFunc_BefriendRequest(lua_State* L);
int LuaFunc_AddToIgnoreList(lua_State* L);
int LuaFunc_RemoveFromFriendList(lua_State* L);
int LuaFunc_RemoveFromIgnoreList(lua_State* L);

// ----------------------------------------------------------------------------
CFriendListFrame::CFriendListFrame(CInterface* object)
	: CInterfaceBase(object)
{
	g_pFriendListFrame = this;
}

// ----------------------------------------------------------------------------
CFriendListFrame::~CFriendListFrame()
{
	g_pFriendListFrame = NULL;
}

// ----------------------------------------------------------------------------
void CFriendListFrame::RegisterFunc()
{
	lua_State* L = GetLuaStateWorld();
	if (L)
	{
		lua_register( L, "BefriendRequest",				LuaFunc_BefriendRequest );		
		lua_register( L, "AddToIgnoreList",				LuaFunc_AddToIgnoreList );
		lua_register( L, "RemoveFromFriendList",		LuaFunc_RemoveFromFriendList );
		lua_register( L, "RemoveFromIgnoreList",		LuaFunc_RemoveFromIgnoreList );
	}
}

// ----------------------------------------------------------------------------
int LuaFunc_BefriendRequest(lua_State* L)
{
	char name[256];
	strcpy( name, luaL_checkstring(L, 1) );
	NetCli_FriendList::SChat_BefriendRequest( name );
	return 0;
}

// ----------------------------------------------------------------------------
int LuaFunc_AddToIgnoreList(lua_State* L)
{
	char name[256];
	strcpy( name, luaL_checkstring(L, 1) );
	NetCli_FriendList::SL_AddBadFriend( name );
	return 0;
}

// ----------------------------------------------------------------------------
int LuaFunc_RemoveFromFriendList(lua_State* L)
{
	char name[256];
	strcpy( name, luaL_checkstring(L, 1) );
	NetCli_FriendList::SL_DelFriend( name );
	return 0;
}

// ----------------------------------------------------------------------------
int LuaFunc_RemoveFromIgnoreList(lua_State* L)
{
	char name[256];
	strcpy( name, luaL_checkstring(L, 1) );
	NetCli_FriendList::SL_DelBadFriend( name );
	return 0;
}