Beispiel #1
0
void LLPanelFriends::onClickExport(void* user_data)
{
	LLPanelFriends* panelp = (LLPanelFriends*)user_data;
	std::string agn;
	gAgent.getName(agn);
	std::string filename = agn+".friendlist";
	LLFilePicker& picker = LLFilePicker::instance();
	if(!picker.getSaveFile( LLFilePicker::FFSAVE_ALL, filename ) )
	{
		// User canceled save.
		return;
	}
	filename = picker.getFirstFile();
	std::vector<LLScrollListItem*> selected = panelp->mFriendsList->getAllData();//->getAllSelected();

	LLSD llsd;
	//U32 count = 0;
	//std::string friendlist;
	for(std::vector<LLScrollListItem*>::iterator itr = selected.begin(); itr != selected.end(); ++itr)
	{
		LLSD fraind;
		std::string friend_name = (*itr)->getColumn(LIST_FRIEND_NAME)->getValue().asString();
		std::string friend_uuid = (*itr)->getUUID().asString();
		bool show_online_status = (*itr)->getColumn(LIST_VISIBLE_ONLINE)->getValue().asBoolean();
		bool show_map_location = (*itr)->getColumn(LIST_VISIBLE_MAP)->getValue().asBoolean();
		bool allow_modify_objects = (*itr)->getColumn(LIST_EDIT_MINE)->getValue().asBoolean();
		fraind["name"] = friend_name;
		fraind["see_online"] = show_online_status;
		fraind["can_map"] = show_map_location;
		fraind["can_mod"] = allow_modify_objects;
		//friendlist += friend_name+"|"+friend_uuid+"|"+show_online_status+"|"+show_map_location+"|"+allow_modify_objects+"\n";
		llsd[friend_uuid] = fraind;
		//count += 1;
	}

	LLViewerLogin* vl = LLViewerLogin::getInstance();
	std::string grid_uri = vl->getCurrentGridURI();
	//LLStringUtil::toLower(uris[0]);
	llsd["GRID"] = grid_uri;


	llofstream export_file;
	export_file.open(filename);
	LLSDSerialize::toPrettyXML(llsd, export_file);
	export_file.close();
}
Beispiel #2
0
void LLPanelFriends::onClickImport(void* user_data)
//THIS CODE IS DESIGNED SO THAT EXP/IMP BETWEEN GRIDS WILL FAIL
//because assuming someone having the same name on another grid is the same person is generally a bad idea
//i might add the option to query the user as to intelligently detecting matching names on a alternative grid
// jcool410
{
	//LLPanelFriends* panelp = (LLPanelFriends*)user_data;
	//is_agent_friend(

	const std::string filename = upload_pick((void*)LLFilePicker::FFLOAD_ALL);
		
	if (filename.empty())
		return;

	llifstream importer(filename);
	LLSD data;
	LLSDSerialize::fromXMLDocument(data, importer);
	if(data.has("GRID"))
	{
		LLViewerLogin* vl = LLViewerLogin::getInstance();
		std::string grid_uri = vl->getCurrentGridURI();
		std::string grid = grid_uri;
		if(grid != data["GRID"])return;
		data.erase("GRID");
	}

#if LL_WINDOWS
	std::string file = filename.substr(filename.find_last_of("\\")+1);
#else
	std::string file = filename.substr(filename.find_last_of("/")+1);
#endif

	std::string importstate = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "friendimportstate.dat");
	
	llifstream stateload(importstate);
	LLSD importstatellsd;
	LLSDSerialize::fromXMLDocument(importstatellsd, stateload);


	//LLMessageSystem* msg = gMessageSystem;
	LLSD newdata;

	LLSD::map_const_iterator iter;
	for(iter = data.beginMap(); iter != data.endMap(); ++iter)
	{//first= var second = val
		LLSD content = iter->second;
		if(!content.has("name"))continue;
		if(!content.has("see_online"))continue;
		if(!content.has("can_map"))continue;
		if(!content.has("can_mod"))continue;

		LLUUID agent_id = LLUUID(iter->first);
		if(merging && importstatellsd.has(agent_id.asString()))continue;//dont need to request what weve already requested from another list import and have not got a reply yet

		std::string agent_name = content["name"];
		if(!is_agent_friend(agent_id))//dont need to request what we have
		{
			if(merging)importstatellsd[agent_id.asString()] = content;//MERGEEEE
			requestFriendship(agent_id, agent_name, "Imported from "+file);
			newdata[iter->first] = iter->second;
		}else 
		{
			//data.erase(iter->first);
			//--iter;//god help us all
		}
	}
	data = newdata;
	newdata = LLSD();

	if(!merging)
	{
		merging = true;//this hack is to support importing multiple account lists without spamming users but considering LLs fail in forcing silent declines
		importstatellsd = data;
	}

	llofstream export_file;
	export_file.open(importstate);
	LLSDSerialize::toPrettyXML(importstatellsd, export_file);
	export_file.close();
}