import org.tizen.emulator.manager.resources.FilePathResources;
import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.vms.EmulatorVMList;
+import org.tizen.emulator.manager.vms.SKIN_SHAPE;
import org.tizen.emulator.manager.vms.VMProperty;
import org.tizen.emulator.manager.vms.option.IOption;
import org.tizen.emulator.manager.vms.option.LaunchConfig;
protected String profile;
protected String type;
protected String cpu;
+ protected SKIN_SHAPE skinShape;
protected String binaryVersion;
+ protected boolean isStandard;
+
private String information;
protected String lastCreatedPropertyPath;
public BaseImage(Platform platform, File path) throws IOException {
this.platform = platform;
+ isStandard = true;
+
loadProperty(path);
settingImagePath(path);
initLastCreatedPropertyPath();
lastCreatedPropertyPath = sb.toString();
}
+ private void checkBaseImageName() throws IOException {
+ if (imageName == null) {
+ throw new IOException("Image name is null. This image can not add.");
+ }
+ // check duplicate name
+ for (BaseImage i : platform.getProfileClass().getImageList()) {
+ if (i.getName().equals(imageName)) {
+ throw new IOException(
+ "The same name of the base image already exist."
+ + "(name: " + imageName + ")");
+ }
+ }
+ }
+
private void loadProperty(File path) throws IOException {
File f = new File(path + File.separator + StringResources.IMAGE_INFO_FILENAME);
FileInputStream inputStream = null;
inputStream = new FileInputStream(f);
Properties prop = new Properties();
prop.load(inputStream);
- if (prop.get("[Meta]") != null) {
- loadOldProperty(prop);
- } else {
- imageName = prop.getProperty(StringResources.IMAGE_NAME);
-// imageName = prop.getProperty(StringResources.IMAGE_NAME).toLowerCase();
- if (imageName == null) {
- throw new IOException("Image name is null. This image can not add.");
- }
- version = prop.getProperty(StringResources.IMAGE_VERSION, "2.4");
- profile = prop.getProperty(StringResources.PRODUCT_PROFILE, PlatformStringResources.MobileProfile).toLowerCase();
- type = prop.getProperty(StringResources.IMAGE_TYPE, "default");
- cpu = prop.getProperty(StringResources.TARGET_CPU, "x86");
- cpu = cpu.toLowerCase();
- binaryVersion = prop.getProperty(StringResources.BINARY_VERSION, "1.0.0");
- }
+ imageName = prop.getProperty(StringResources.IMAGE_NAME);
+ checkBaseImageName();
+ version = prop.getProperty(StringResources.IMAGE_VERSION, "2.4");
+ profile = prop.getProperty(StringResources.PRODUCT_PROFILE, PlatformStringResources.MobileProfile).toLowerCase();
+ type = prop.getProperty(StringResources.IMAGE_TYPE, "default");
+ cpu = prop.getProperty(StringResources.TARGET_CPU, "x86");
+ cpu = cpu.toLowerCase();
+ skinShape = SKIN_SHAPE.find(prop.getProperty(StringResources.SKIN_SHAPE, "square"));
+ binaryVersion = prop.getProperty(StringResources.BINARY_VERSION, "1.0.0");
} else {
throw new IOException(StringResources.IMAGE_INFO_FILENAME + " file does not exist.");
}
}
}
- private void loadOldProperty(Properties prop) throws IOException {
-// imageName = prop.getProperty(StringResources.IMAGE_NAME).toLowerCase();
- imageName = prop.getProperty(StringResources.IMAGE_NAME);
- if (imageName == null) {
- throw new IOException("Image name is null. This image can not add.");
- }
- version = platform.getName();
- profile = prop.getProperty(StringResources.PRODUCT_OLD_DOMAIN, PlatformStringResources.MobileProfile).toLowerCase();
- if (profile.equals(PlatformStringResources.OldMobileProfile)) {
- profile = PlatformStringResources.MobileProfile;
- }
- type = prop.getProperty(StringResources.IMAGE_TYPE, "default");
- cpu = prop.getProperty(StringResources.TARGET_CPU, "x86");
- cpu = cpu.toLowerCase();
- }
-
private void settingImagePath(File path) throws IOException {
for (File f : path.listFiles()) {
if (f.isFile() && f.getName().endsWith(cpu.toLowerCase())) {
defaultProperty = vmList.parseXML(propertyFile);
}
}
+
+ public boolean isStandard() {
+ return isStandard;
+ }
+
+ public void setStandard(boolean isStandard) {
+ this.isStandard = isStandard;
+ }
}
import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.ui.detail.item.OptionType;
import org.tizen.emulator.manager.vms.EmulatorVMList;
+import org.tizen.emulator.manager.vms.SKIN_SHAPE;
import org.tizen.emulator.manager.vms.xml.template.DeviceList;
import org.tizen.emulator.manager.vms.xml.template.Item;
import org.tizen.emulator.manager.vms.xml.template.ItemList;
public static ObjectFactory factory = new ObjectFactory();
- public CustomBaseImage(Platform platform, String name, String cpu, String profile) throws IOException {
+ public CustomBaseImage(Platform platform, String path) throws IOException {
+ if (platform == null) {
+ throw new IOException("Failed to create custom base image "
+ + StringResources.NEW_LINE + "because platform is null.");
+ }
this.platform = platform;
+ isStandard = false;
+
+ this.path = path;
+ if (path != null && !path.isEmpty()) {
+ imageName = pathName = path.substring(path.lastIndexOf(File.separator));
+ }
+
+ settingProperty(platform);
- this.imageName = name;
- this.cpu = cpu;
- // TODO
- this.profile = profile;
- this.version = "0";
- this.binaryVersion = "";
initLastCreatedPropertyPath();
loadProperty();
createTemplate();
}
+ private void settingProperty(Platform platform) {
+ version = platform.getVersion();
+ profile = platform.getProfile();
+ type = "custom"; // TODO
+ cpu = "x86";
+ skinShape = SKIN_SHAPE.NONE; // TODO
+ binaryVersion = "";
+ }
+
protected void initLastCreatedPropertyPath() {
StringBuilder sb = new StringBuilder();
sb.append(FilePathResources.getTizenVmsPath()).append(File.separator)
this.platformPath = "";
//this.version = name;
try {
- imageList.add(new CustomBaseImage(this, "x86", "x86", profile));
+ imageList.add(new CustomBaseImage(this, ""));
// TODO
this.profile = imageList.get(0).getProfile();
this.profileClass = profile;
this.profile = profile.getName();
this.version = version;
- this.platformName = profile + "-" + version;
+ this.platformName = this.profile + "-" + version;
this.platformPath = path;
loadSkins();
if(defaultImages.exists() && defaultImages.isDirectory()) {
for (File f : defaultImages.listFiles()) {
if (!f.getName().equals("default")) { // skip default directory
- makeBaseImage(f);
+ //makeBaseImage(f);
}
}
}
if (oldImages.exists() && oldImages.isDirectory()) {
for (File f : oldImages.listFiles()) {
- makeBaseImage(f);
+ //makeBaseImage(f);
}
}
public void setPlugin(EMPlugin plugin) {
this.plugin = plugin;
}
+
+ public Profile getProfileClass() {
+ return profileClass;
+ }
+
+ public void setProfileClass(Profile profileClass) {
+ this.profileClass = profileClass;
+ }
}
package org.tizen.emulator.manager.platform;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import org.tizen.emulator.manager.logging.EMLogger;
import org.tizen.emulator.manager.vms.VMProperty;
import org.tizen.emulator.manager.vms.VMProperty.FSImageType;
}
public void addEmulator(VMProperty vm) {
- vmList.add(vm);
//setting BaseImage
if (vm.getPropertyValue().baseImage == null) {
if (vm.getImageType().equals(FSImageType.standard)) {
}
} else {
// TODO: create custom base image
- vm.getPropertyValue().baseImage = new BaseImage();
+ for (Platform p : platformList) {
+ if (vm.getImagePlatform().equals(p.getName())) {
+ try {
+ vm.getPropertyValue().baseImage
+ = new CustomBaseImage(p,
+ vm.getBaseImagePath());
+ } catch (IOException e) {
+ EMLogger.getLogger().warning(e.getMessage());
+ }
+ }
+ }
}
}
+
+ if (vm.getPropertyValue().baseImage != null) {
+ vmList.add(vm);
+ }
}
public void removeEmulator(VMProperty vm) {
for (File profile : platform.listFiles()) {
if (profile.isDirectory() && isProfileDir(profile)) {
Profile p = ProfileList.makeProfile(profile.getName());
+ String version = platform.getName();
+ // delete 'tizen' string from platform directory name
+ if (version.contains("tizen-")) {
+ version = version.substring(version.lastIndexOf("-") + 1);
+ }
Platform pl = ProfileList.makePlatform (p, // profile
- platform.getName(), // version
+ version, // version
profile.getAbsolutePath()); // platform path
ProfileList.makeBaesImageList(p, pl, profile.getAbsolutePath());
}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms;
+
+public enum SKIN_SHAPE {
+ NONE(""), SQUARE("square"), CIRCLE("circle");
+ String shape;
+
+ SKIN_SHAPE(String shape) {
+ this.shape = shape;
+ }
+
+ @Override
+ public String toString() {
+ return shape;
+ }
+
+ public static SKIN_SHAPE find(String shape) {
+ for (SKIN_SHAPE s : SKIN_SHAPE.values()) {
+ if (shape.equals(s.toString())) {
+ return s;
+ }
+ }
+ // TODO: return null or default value
+ return SQUARE;
+ }
+}
return configuration.getBaseInformation().getDiskImage().getBase();
}
+ public String getBaseImagePath() {
+ if (configuration == null
+ || configuration.getBaseInformation() == null
+ || configuration.getBaseInformation().getDiskImage() == null) {
+ return "";
+ }
+
+ return configuration.getBaseInformation().getDiskImage().getBaseDiskImage().getValue();
+ }
public String getChildImagePath() {
if(configuration == null
|| configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
}
public String getImagePlatform() {
- if (getImageType() == FSImageType.custom) {
- return FSImageType.custom.toString();
- } else {
- String version = getImageVersion();
- String profile = getImageProfile();
- if (version == null) {
- return null;
- }
-
- if (version.contains("tizen")) {
- return version;
- } else {
- if (profile == null) {
- return version;
- }
-
- return profile + "-" + version;
- }
+ String version = getImageVersion();
+ String profile = getImageProfile();
+ if (version == null || profile == null) {
+ return null;
}
+
+ return profile + "-" + version;
}
public EmulatorConfiguration getConfiguration() {