Ejemplo n.º 1
0
void ServerMsgSender::UpdateProfileMsg()
{
	ServerList *sList = ServerList::Instance();

	Handle<ServerInfo> server;
	if(sList->GetServer(serverid, server))
	{
		server->AskUserInfo(serveruid);
	}
}
Ejemplo n.º 2
0
void ServerMsgSender::AddUserAskMsg()
{
	ServerList *sList = ServerList::Instance();

	Handle<ServerInfo> server;
	if(sList->GetServer(serverid, server))
	{
		server->AddUser(serveruid);
	}
}
Ejemplo n.º 3
0
void ServerMsgSender::ReplyAddUserMsg(bool agree)
{
	if(agree)
	{
		ServerList *sList = ServerList::Instance();

		Handle<ServerInfo> server;
		if(sList->GetServer(serverid, server))
		{
			server->AddUser(serveruid);
		}
	}
}
Ejemplo n.º 4
0
int LuaV6Chat3App::GetSearchFriendResult(lua_State *luaState)
{
	V6Chat3App *App = GetV6Chat3App(luaState);
	if (App)
	{
		int id = lua_tointeger(luaState, 2);

		ServerList *list = ServerList::Instance();
		Handle<ServerInfo> server;

		if(list->GetServer(id, server))
		{
			std::list<VCardInfo> vCardList;
			server->GetSearchUsersResult(vCardList);

			lua_newtable(luaState);       // 创建一个表格,放在栈顶
			int i=1;
			for(std::list<VCardInfo>::const_iterator iter=vCardList.begin(); iter!=vCardList.end(); ++iter, ++i)
			{
				lua_pushnumber(luaState, i);
				lua_newtable(luaState);      // 压入value,也是一个table(subtable)
				lua_pushstring(luaState, "id");
				lua_pushnumber(luaState, iter->uid);
				lua_settable(luaState,-3);   // 弹出key,value,并设置到subtable里面去
				lua_pushstring(luaState, "account");
				lua_pushstring(luaState, iter->account.c_str());
				lua_settable(luaState,-3);   // 弹出key,value,并设置到subtable里面去
				lua_pushstring(luaState, "formatted_name");
				lua_pushstring(luaState, iter->formattedName.c_str());
				lua_settable(luaState,-3);   // 弹出key,value,并设置到subtable里面去
				wstring headImagePath(USERHEAD_RELATIVE_PATH);
				headImagePath = headImagePath + L"\\" + iter->photoRelativePath;
				XL_BITMAP_HANDLE bmp = V6Util::GetUserDataImageHandle(headImagePath.c_str());
				if(bmp)
				{
					lua_pushstring(luaState, "head");
					if(!XLUE_PushBitmap(luaState, bmp))
						lua_pushnil(luaState);
					lua_settable(luaState,-3);   //弹出key,value,并设置到subtable里面去
				}
				lua_settable(luaState,-3); // 这时候父table的位置还是-3,弹出key,value(subtable),并设置到table里去
			}

			return 1;
		}
	}
    lua_pushnil(luaState);
	return 1;
}
Ejemplo n.º 5
0
bool ServerUserInfo::Delete()
{
	std::stringstream sid;
	sid << uid;

	ServerList *sList = ServerList::Instance();

	Handle<ServerInfo> server;
	if(sList->GetServer(serverid, server))
	{
		server->DeleteUser(serveruid);
		return delete_peerProfile(sid.str().c_str());
	}

	return false;
}
Ejemplo n.º 6
0
int LuaV6Chat3App::ChangeServerInfo(lua_State *luaState)
{
	V6Chat3App *App = GetV6Chat3App(luaState);
	if (App)
	{
		int id = lua_tointeger(luaState, 2);
		ServerList *list = ServerList::Instance();
		Handle<ServerInfo> server;

		if(list->GetServer(id, server))
		{
			size_t name_len=lua_objlen(luaState, 3);
			const char *name = lua_tolstring(luaState, 3, &name_len);
			size_t admain_len=lua_objlen(luaState, 4);
			const char *admain = lua_tolstring(luaState, 4, &admain_len);
			size_t account_len=lua_objlen(luaState, 5);
			const char *account = lua_tolstring(luaState, 5, &account_len);
			size_t password_len=lua_objlen(luaState, 6);
			const char *password = lua_tolstring(luaState, 6, &password_len);
			size_t introduction_len=lua_objlen(luaState, 7);
			const char *introduction = lua_tolstring(luaState, 7, &introduction_len);

			if(name)
				server->SetName(V6Util::Utf8ToUnicode(name));
			if(admain)
				server->SetIp(admain);
			if(account)
				server->SetUid(account);
			if(password)
				server->SetUpassword(password);
			if(introduction)
				server->SetDescription(V6Util::Utf8ToUnicode(introduction));

			if(server->HasChange())
			{
				server->DisConnect();
				server->Connect();
			}
		}
	}
	return 0;
}
Ejemplo n.º 7
0
void ServerUserInfo::GetLocation(std::wstring &location)
{
	if(user_offline == state)
	{
		location = L"ÀëÏß";
		return;
	}
	else
	{
		ServerList *sList = ServerList::Instance();

		Handle<ServerInfo> server;
		if(sList->GetServer(serverid, server))
		{
			location = server->GetName();
		}
		else
			location = L"δ֪À´Ô´";
	}
}
Ejemplo n.º 8
0
void ServerMsgSender::ChatWithTextMsg(const std::wstring &text, const std::string &sendTime)
{
	ServerList *sList = ServerList::Instance();

	Handle<ServerInfo> server;
	if(sList->GetServer(serverid, server))
	{
		string mtext = V6Util::UnicodeToAnsi(text.c_str());

		map<int, string> nis;

		tr1::regex rxFloat("<\\d+>");  
		tr1::sregex_token_iterator ite(mtext.begin(), mtext.end(), rxFloat), end; 

		SendFileList *list = SendFileList::Instance();
		// 检查内容中是否含有文件
		for ( ; ite != end; ++ite)  
		{  
			string w = ite->str();
			string wi = w.substr(1, w.length()-2);
			int ni = atoi(wi.c_str());
			nis.insert(make_pair(ni, wi));
		}

		for(map<int, string>::iterator it = nis.begin(); it != nis.end(); ++it)
		{
			wstring filepath;
			string rsid;
			if(list->GetFilePath(it->first, filepath))
			{
				if(server->SendFile(serveruid, filepath, rsid))
				{
					tr1::regex rxFloat(it->second);
					mtext = tr1::regex_replace(mtext, rxFloat, rsid);
				}
			}
		}

		server->SendText(serveruid, V6Util::AnsiToUtf8(mtext.c_str()));
	}
}
Ejemplo n.º 9
0
int LuaV6Chat3App::SearchFriendOnServer(lua_State *luaState)
{
	V6Chat3App *App = GetV6Chat3App(luaState);
	if (App)
	{
		int id = lua_tointeger(luaState, 2);

		ServerList *list = ServerList::Instance();
		Handle<ServerInfo> server;

		if(list->GetServer(id, server))
		{
			server->ClearSearchUsersResult();

			size_t search_content_len=lua_objlen(luaState, 3);
			const char *search_content = lua_tolstring(luaState, 3, &search_content_len);
			server->AskUserInfo(search_content);
		}
	}

	return 0;
}
Ejemplo n.º 10
0
int LuaV6Chat3App::GetServerInfoByID(lua_State *luaState)
{
	V6Chat3App *App = GetV6Chat3App(luaState);
	if (App)
	{
		int id = lua_tointeger(luaState, 2);
		ServerList *list = ServerList::Instance();
		Handle<ServerInfo> server;

		if(list->GetServer(id, server))
		{
			lua_newtable(luaState);
			lua_pushstring(luaState, "id");
			lua_pushnumber(luaState, server->GetId());
			lua_settable(luaState,-3);   // 弹出key,value,并设置到subtable里面去
			lua_pushstring(luaState, "server_name");
			lua_pushstring(luaState, V6Util::UnicodeToUtf8(server->GetName().c_str()).c_str());
			lua_settable(luaState,-3);   // 弹出key,value,并设置到subtable里面去
			lua_pushstring(luaState, "account");
			lua_pushstring(luaState, server->GetUid().c_str());
			lua_settable(luaState,-3);   // 弹出key,value,并设置到subtable里面去
			lua_pushstring(luaState, "password");
			lua_pushstring(luaState, server->GetUpassword().c_str());
			lua_settable(luaState,-3);   // 弹出key,value,并设置到subtable里面去
			lua_pushstring(luaState, "introduction");
			lua_pushstring(luaState, V6Util::UnicodeToUtf8(server->GetDescription().c_str()).c_str());
			lua_settable(luaState,-3);   // 弹出key,value,并设置到subtable里面去
			lua_pushstring(luaState, "domain");
			lua_pushstring(luaState, server->GetIp().c_str());
			lua_settable(luaState,-3);   // 弹出key,value,并设置到subtable里面去
			lua_pushstring(luaState, "state");
			lua_pushnumber(luaState, server->GetState());
			lua_settable(luaState,-3);   // 弹出key,value,并设置到subtable里面去
			return 1;
		}
	}
	lua_pushnil(luaState);
	return 1;
}