// Path: Cloud-Deploy/sysu.cloudgaming/src/main/java/com/sysu/cloudgaming/config/Config.java
// public class Config {
// 	public static final String PROPERTYFILE="agentd.conf";
// 	public static String BASEPATH="d:/cloudgaming/";
// 	public static String VERSION="1.08 Alpha";
// 	public static String LOCALPROGRAMPATH="Games/";
// 	public static String DEAMONPATH="Server.exe";
// 	public static String LOCALPROGRAMXMLNAME="info.xml";
// 	public static String HUBSERVERADDR="222.200.182.75";
// 	public static int SOTIMEOUT=3000;
// 	public static int HUBSERVERPORT=10060;
// 	public static int STUNPORT=3478;
// 	public static int CONNECT_TIMEOUT=3000;
// 	public static String HOSTNAME="GameHost-X-NONAME";
// 	public static int REFRESHINTEVAL=10;
// 	private static Logger logger = LoggerFactory.getLogger(Config.class);
// 	public static boolean loadConfig()
// 	{
// 		logger.info("Build Version:{}",VERSION);
// 		try
// 		{
// 			Properties p = new Properties();
// 		    p.load(new FileInputStream(BASEPATH+PROPERTYFILE));
// 		    logger.info("Server address {}",p.getProperty("ServerActive"));
// 		    HUBSERVERADDR=p.getProperty("ServerActive");
// 		    BASEPATH=p.getProperty("BasePath");
// 		  
// 		    HOSTNAME=p.getProperty("Hostname");
// 		    logger.info("HostName {}",HOSTNAME);
// 		    if(HOSTNAME==null)
// 		    {
// 		    	HOSTNAME=UUID.randomUUID().toString();
// 		    	p.setProperty("Hostname", HOSTNAME);
// 		    	p.store(new FileOutputStream(BASEPATH+PROPERTYFILE), "");
// 		    	logger.info("Generate A host name {}",HOSTNAME);
// 		    }
// 		    
// 		    return true;
// 		}
// 		catch(Exception e)
// 		{
// 			logger.warn("Failed to read config file");
// 			return false;
// 		}
// 	}
// }


import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.input.SAXBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.sysu.cloudgaming.config.Config;
package com.sysu.cloudgaming.node;




public class ProgramManager {
	private static Logger logger = LoggerFactory.getLogger(ProgramManager.class);
	List<ProgramBean> list=new ArrayList<ProgramBean>();
	public  List<ProgramBean> searchLocalProgram()
	{
		list.clear();
		try
		{
			File programPath=new File(Config.LOCALPROGRAMPATH);
			if(!programPath.isDirectory())
			{
				logger.warn("Program Path Not Found!");
				return list;
			}
			File insideProgramPath[]=programPath.listFiles();
			for(int i=0;i<insideProgramPath.length;i++)
			{
				if(insideProgramPath[i].isDirectory())
				{
					File gamePath=insideProgramPath[i];
// Path: Cloud-Deploy/sysu.cloudgaming/src/main/java/com/sysu/cloudgaming/config/Config.java
// public class Config {
// 	public static final String PROPERTYFILE="agentd.conf";
// 	public static String BASEPATH="d:/cloudgaming/";
// 	public static String VERSION="1.08 Alpha";
// 	public static String LOCALPROGRAMPATH="Games/";
// 	public static String DEAMONPATH="Server.exe";
// 	public static String LOCALPROGRAMXMLNAME="info.xml";
// 	public static String HUBSERVERADDR="222.200.182.75";
// 	public static int SOTIMEOUT=3000;
// 	public static int HUBSERVERPORT=10060;
// 	public static int STUNPORT=3478;
// 	public static int CONNECT_TIMEOUT=3000;
// 	public static String HOSTNAME="GameHost-X-NONAME";
// 	public static int REFRESHINTEVAL=10;
// 	private static Logger logger = LoggerFactory.getLogger(Config.class);
// 	public static boolean loadConfig()
// 	{
// 		logger.info("Build Version:{}",VERSION);
// 		try
// 		{
// 			Properties p = new Properties();
// 		    p.load(new FileInputStream(BASEPATH+PROPERTYFILE));
// 		    logger.info("Server address {}",p.getProperty("ServerActive"));
// 		    HUBSERVERADDR=p.getProperty("ServerActive");
// 		    BASEPATH=p.getProperty("BasePath");
// 		  
// 		    HOSTNAME=p.getProperty("Hostname");
// 		    logger.info("HostName {}",HOSTNAME);
// 		    if(HOSTNAME==null)
// 		    {
// 		    	HOSTNAME=UUID.randomUUID().toString();
// 		    	p.setProperty("Hostname", HOSTNAME);
// 		    	p.store(new FileOutputStream(BASEPATH+PROPERTYFILE), "");
// 		    	logger.info("Generate A host name {}",HOSTNAME);
// 		    }
// 		    
// 		    return true;
// 		}
// 		catch(Exception e)
// 		{
// 			logger.warn("Failed to read config file");
// 			return false;
// 		}
// 	}
// }


// Path: Cloud-Deploy/sysu.cloudgaming/src/main/java/com/sysu/cloudgaming/node/ProgramManager.java
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.input.SAXBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.sysu.cloudgaming.config.Config;

package com.sysu.cloudgaming.node;




public class ProgramManager {
	private static Logger logger = LoggerFactory.getLogger(ProgramManager.class);
	List<ProgramBean> list=new ArrayList<ProgramBean>();
	public  List<ProgramBean> searchLocalProgram()
	{
		list.clear();
		try
		{
			File programPath=new File(Config.LOCALPROGRAMPATH);
			if(!programPath.isDirectory())
			{
				logger.warn("Program Path Not Found!");
				return list;
			}
			File insideProgramPath[]=programPath.listFiles();
			for(int i=0;i<insideProgramPath.length;i++)
			{
				if(insideProgramPath[i].isDirectory())
				{
					File gamePath=insideProgramPath[i];
					File infoFile=new File(gamePath.getAbsolutePath()+"/"+Config.LOCALPROGRAMXMLNAME);