From 80d7597529a742c2d65f9a084cdd651aed72caaf Mon Sep 17 00:00:00 2001 From: "jihye424.kim" Date: Mon, 24 Aug 2015 17:48:25 +0900 Subject: [PATCH] Property: remove oci device - oci device option move to plugin resources Change-Id: If660ddcb1ab4bae0d8d8f3a18901e80581499702 Signed-off-by: jihye424.kim --- native-src/EnumerationOCI.c | 127 ------------- .../emulator/manager/tool/EnumerationOCI.java | 91 --------- .../ui/detail/item/CommonItemListFactory.java | 4 - .../item/property/OCIDevicesSubViewItem.java | 203 --------------------- .../ui/detail/item/property/OCIViewItem.java | 79 -------- 5 files changed, 504 deletions(-) delete mode 100644 native-src/EnumerationOCI.c delete mode 100644 src/org/tizen/emulator/manager/tool/EnumerationOCI.java delete mode 100644 src/org/tizen/emulator/manager/ui/detail/item/property/OCIDevicesSubViewItem.java delete mode 100644 src/org/tizen/emulator/manager/ui/detail/item/property/OCIViewItem.java diff --git a/native-src/EnumerationOCI.c b/native-src/EnumerationOCI.c deleted file mode 100644 index fde5d52..0000000 --- a/native-src/EnumerationOCI.c +++ /dev/null @@ -1,127 +0,0 @@ -#include "org_tizen_emulator_manager_tool_EnumerationOCI.h" -#include - -/* copy from "libvboxusb.h (qemu/tizen/distrib/libvboxusb/inc/libvboxusb.h)" - struct libvbox_usb should be consistent with "libvboxusb.h". - */ - -#define MAX_ENUM_DEVICES 128 -#define MAX_PORTLEN 16 -#define MAX_PROD_NAME 32 - -typedef struct libvbox_usb{ - int bus_num; - int addr; - char port[MAX_PORTLEN]; - int class_id; - int vendor_id; - int product_id; - char product_name[32]; - int speed; -}libvbox_usb; - - -#ifdef __cplusplus -extern "C" { -#endif - int VBOXUSB_enum_devices(libvbox_usb ** opaque); - void VBOXUSB_free(libvbox_usb* opaque); -#ifdef __cplusplus -} -#endif - - -/*JNI*/ - -#define CLASS_ID_HUB 9 - -JNIEXPORT jobject JNICALL Java_org_tizen_emulator_manager_tool_EnumerationOCI_getEnumerationOCIDevice (JNIEnv *env, jclass class) -{ - libvbox_usb *iter, *intern = NULL; - int rc, i; - - jclass class_arraylist = (*env)->FindClass(env, "java/util/ArrayList"); - if (class_arraylist == NULL) { - printf("FindClass(java/util/ArrayList) error \n"); - goto error; - } - jmethodID ctor = (*env)->GetMethodID(env, class_arraylist, "", "()V"); - if (ctor == NULL){ - printf("GetMethodID() error \n"); - goto error; - } - jmethodID add = (*env)->GetMethodID(env, class_arraylist, "add", "(Ljava/lang/Object;)Z"); - if (add == NULL){ - printf("GetMethodID(add) error \n"); - goto error; - } - jobject device_arraylist = (*env)->NewObject(env, class_arraylist, ctor, ""); - if (device_arraylist == NULL) { - printf("NewObject(device_arraylist) error \n"); - goto error; - } - jclass class_enumeration = (*env)->FindClass(env, "org/tizen/emulator/manager/tool/EnumerationOCI"); - if (class_enumeration ==NULL){ - printf("FindClass(Enumeration) error \n"); - goto error; - } - jmethodID enum_ctor = (*env)->GetMethodID(env, class_enumeration, "", "()V"); - if (enum_ctor == NULL) { - printf("GetMethodID(enumeration init) error \n"); - goto error; - } - rc = VBOXUSB_enum_devices(&intern); - if(!rc) { - printf("VBOXUSB_enum_devices error \n"); - goto error; - } - iter = intern; - for(i = 0; i < rc; i++) { - if (iter->class_id != CLASS_ID_HUB) { - jobject device = (*env)->NewObject(env, class_enumeration, enum_ctor, ""); - if (device == NULL) { - printf("NewObject(device) error \n"); - goto error; - } - jfieldID field_pid = (*env)->GetFieldID(env, class_enumeration, "addr", "I"); - jfieldID field_vid = (*env)->GetFieldID(env, class_enumeration, "bus", "I"); - jfieldID field_name = (*env)->GetFieldID(env, class_enumeration, "deviceName", "Ljava/lang/String;"); - if (field_pid == NULL || field_vid == NULL || field_name == NULL) { - printf("GetFieldID(addr, bus, deviceName) error \n"); - goto error; - } - jstring str = (*env)->NewStringUTF(env, iter->product_name); - if (str == NULL) { - printf("NewStringUTF(product_name) error \n"); - goto error; - } - (*env)->SetIntField(env, device, field_pid, iter->product_id); - (*env)->SetIntField(env, device, field_vid, iter->vendor_id); - //(*env)->SetIntField(env, device, field_pid, iter->product_id); - //(*env)->SetIntField(env, device, field_vid, iter->vendor_id); - (*env)->SetObjectField(env, device, field_name, str); - if (!(*env)->CallBooleanMethod(env, device_arraylist, add, device)) { - printf("CallbooleanMethod error \n"); - goto error; - } - - //(*env)->CallObjectMethod(env, device_arraylist, add, device); - } - iter ++; - } - - (*env)->DeleteLocalRef(env, class_enumeration); - (*env)->DeleteLocalRef(env, class_arraylist); - - if(intern != NULL) - VBOXUSB_free(intern); - return device_arraylist ; -error: - (*env)->DeleteLocalRef(env, class_enumeration); - (*env)->DeleteLocalRef(env, class_arraylist); - - if(intern != NULL) - VBOXUSB_free(intern); - return NULL; - -} diff --git a/src/org/tizen/emulator/manager/tool/EnumerationOCI.java b/src/org/tizen/emulator/manager/tool/EnumerationOCI.java deleted file mode 100644 index d08819d..0000000 --- a/src/org/tizen/emulator/manager/tool/EnumerationOCI.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * MunKyu Im - * JiHye Kim - * Minkee Lee - * SeokYeon Hwang - * Sangho Park - * - * 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.tool; - -import java.util.ArrayList; -import org.tizen.emulator.manager.EmulatorManager; -import org.tizen.emulator.manager.logging.EMLogger; -import org.tizen.emulator.manager.resources.StringResources; - -public class EnumerationOCI { - public int bus; // vender id - public int addr; // product id - public String deviceName; - private static boolean isSuccess = false; - static { - if (!EmulatorManager.isMac()) { - try { - System.loadLibrary("EnumerationOCI"); //$NON-NLS-1$ - isSuccess = true; - } catch (UnsatisfiedLinkError e) { - //System.err.println("Native code library(EnumerationOCI) failed to load"); - EMLogger.getLogger().warning("Native code library(EnumerationOCI) failed to load.." //$NON-NLS-1$ - + StringResources.NEW_LINE + "Error: " + e.getMessage()); //$NON-NLS-1$ - } - } - } - - public static boolean isSuccessToLoadLib() { - return EnumerationOCI.isSuccess; - } - - @ Override - public String toString() { - return deviceName; - } - - public String getName() { - return deviceName; - } - - public void setName(String deviceName) { - this.deviceName = deviceName; - } - - public void setBus(int bus) { - this.bus = bus; - } - - public int getBus() { - return bus; - } - - public void setAddr(int addr) { - this.addr = addr; - } - - public int getAddr() { - return addr; - } - - public static native ArrayList getEnumerationOCIDevice(); -} diff --git a/src/org/tizen/emulator/manager/ui/detail/item/CommonItemListFactory.java b/src/org/tizen/emulator/manager/ui/detail/item/CommonItemListFactory.java index 2eed250..650d54f 100644 --- a/src/org/tizen/emulator/manager/ui/detail/item/CommonItemListFactory.java +++ b/src/org/tizen/emulator/manager/ui/detail/item/CommonItemListFactory.java @@ -53,7 +53,6 @@ import org.tizen.emulator.manager.ui.detail.item.property.NetMacViewItem; import org.tizen.emulator.manager.ui.detail.item.property.NetProxyViewItem; import org.tizen.emulator.manager.ui.detail.item.property.NetTapDeviceViewItem; import org.tizen.emulator.manager.ui.detail.item.property.NetTapDeviceViewItemWin; -import org.tizen.emulator.manager.ui.detail.item.property.OCIViewItem; import org.tizen.emulator.manager.ui.detail.item.property.ProcessorViewItem; import org.tizen.emulator.manager.ui.detail.item.property.RamSizeItem; import org.tizen.emulator.manager.ui.detail.item.property.SuspendSupportViewItem; @@ -205,9 +204,6 @@ public abstract class CommonItemListFactory implements IItemListFactory{ } else if (name.equals(ITEM_TUNER)) { itemList.add(new TunerViewItem(item, currentLineLabel)); - } else if (name.equals(ITEM_OCI_DEVICE)) { - itemList.add(new OCIViewItem(item, currentLineLabel)); - } else if (type.equals(ItemType.TOGGLE.getName())) { itemList.add(new OnOffViewItem(item, currentLineLabel)); diff --git a/src/org/tizen/emulator/manager/ui/detail/item/property/OCIDevicesSubViewItem.java b/src/org/tizen/emulator/manager/ui/detail/item/property/OCIDevicesSubViewItem.java deleted file mode 100644 index dba94e2..0000000 --- a/src/org/tizen/emulator/manager/ui/detail/item/property/OCIDevicesSubViewItem.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * JiHye Kim - * Minkee Lee - * SeokYeon Hwang - * Sangho Park - * - * 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.ui.detail.item.property; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.StringTokenizer; - -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.Composite; -import org.tizen.emulator.manager.EmulatorManager; -import org.tizen.emulator.manager.logging.EMLogger; -import org.tizen.emulator.manager.resources.StringResources; -import org.tizen.emulator.manager.tool.EnumerationOCI; -import org.tizen.emulator.manager.ui.detail.item.template.ComboSubViewItem; -import org.tizen.emulator.manager.ui.detail.item.template.LabelViewItem; -import org.tizen.emulator.manager.vms.OCI; -import org.tizen.emulator.manager.vms.OCIList; -import org.tizen.emulator.manager.vms.VMPropertyValue; -import org.tizen.emulator.manager.vms.xml.template.Item; - -public class OCIDevicesSubViewItem extends ComboSubViewItem{ - private OCI newOCIDevice; - ArrayList enumerationOCIDeviceList = OCIList.getInstance().getOCIList(); - ArrayList selectedOciDevicesList = OCIList.getInstance().getOCISelectList(); - - public static String VALUE_NONE = "(None)"; //$NON-NLS-1$ - - public OCIDevicesSubViewItem(LabelViewItem parentItem, Composite comp, - Item template) { - super(parentItem, comp, template); - } - - @Override - public void addComboBoxListener() { - combo.addSelectionListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - if (combo.getSelectionIndex() != 0) { - selectedOciDevicesList.removeAll(selectedOciDevicesList); - selectedOciDevicesList.add(enumerationOCIDeviceList.get(combo.getSelectionIndex() - 1)); - - newValue = selectedOciDevicesList.get(0).getName(); - } else { - newValue = VALUE_NONE; - } - - if (!parentItem.isCreateMode()) { - parentItem.getListener().ChangeValue(parentItem.getThis()); - } - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - // TODO Auto-generated method stub - } - }); - } - - @Override - public void setValue(VMPropertyValue value) { - value.ociDevice = newOCIDevice; - value.ociOptions = newValue; - } - - @Override - public boolean settingDetailItem(VMPropertyValue value) { - if (!EmulatorManager.isMac()) { - try { - scanOCIDevice(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - EMLogger.getLogger().warning("filed scan OCI Device...." //$NON-NLS-1$ - + StringResources.NEW_LINE + "Error: " + e.getMessage()); //$NON-NLS-1$ - } catch (UnsatisfiedLinkError e) { - e.printStackTrace(); - EMLogger.getLogger().warning("filed scan OCI Device...." //$NON-NLS-1$ - + StringResources.NEW_LINE + "Error: " + e.getMessage()); //$NON-NLS-1$ - } - } - String device = null; - - if (!value.ociOptions.toString().equals(VALUE_NONE) && !value.ociOptions.toString().equals(" ")) { //$NON-NLS-1$ - device = setOLDDevice(value.ociOptions); - } - - if (OCIList.getInstance().findOCIDeviceName(device) != null) { - valueLabel.setText(value.ociOptions); - } else { -// valueLabel.setText(""); - valueLabel.setText(VALUE_NONE); - } - return false; - } - - @Override - public boolean settingModifyItem(VMPropertyValue value) { - if (!EmulatorManager.isMac()) { - try { - scanOCIDevice(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - EMLogger.getLogger().warning("filed scan OCI Device...." //$NON-NLS-1$ - + StringResources.NEW_LINE + "Error: " + e.getMessage()); //$NON-NLS-1$ - } catch (UnsatisfiedLinkError e) { - e.printStackTrace(); - EMLogger.getLogger().warning("filed scan OCI Device...." //$NON-NLS-1$ - + StringResources.NEW_LINE + "Error: " + e.getMessage()); //$NON-NLS-1$ - } - } - newOCIDevice = value.ociDevice; - if (value.ociOptions.toString().equals(VALUE_NONE) || value.ociOptions.toString().equals(" ")) { //$NON-NLS-1$ - oldValue = newValue = value.ociOptions; - } else { - selectedOciDevicesList.removeAll(selectedOciDevicesList); - String device = setOLDDevice(value.ociOptions); - oldValue = newValue = device; - } - - combo.removeAll(); - combo.add(VALUE_NONE); - - for (int i = 0; i < OCIList.getInstance().getOCICount(); i++) { - combo.add(enumerationOCIDeviceList.get(i).getName()); - } - - for (int i = 0; i < combo.getItemCount(); i++) { - if (combo.getItem(i).equals(oldValue)) { - combo.select(i); - break; - } else { - combo.select(0); - } - } - - return true; - } - - public void scanOCIDevice() throws IOException { - enumerationOCIDeviceList.removeAll(enumerationOCIDeviceList); - selectedOciDevicesList.removeAll(selectedOciDevicesList); - - ArrayList deviceList = null; - - if (EnumerationOCI.isSuccessToLoadLib()) { - deviceList = EnumerationOCI.getEnumerationOCIDevice(); - } - - if (deviceList != null) { - for (int i = 0; i < deviceList.size(); i++) { - //System.out.println("name : " + deviceList.get(i).getName() + ", addr : "+deviceList.get(i).getAddr() + ", bus : " + deviceList.get(i).getBus()); - OCIList.getInstance().makeOCIList(deviceList.get(i).getName(), deviceList.get(i).getAddr(), deviceList.get(i).getBus()); - } - } - } - - public String setOLDDevice(String ociOptions) { - String device = null; - - StringTokenizer s = new StringTokenizer(ociOptions, ","); //$NON-NLS-1$ - while (s.hasMoreTokens()) { - device = s.nextToken(); - - if (OCIList.getInstance().findOCIDeviceName(device) != null) { - selectedOciDevicesList.add(OCIList.getInstance().findOCIDeviceName(device)); - } - } - return device; - } - -} diff --git a/src/org/tizen/emulator/manager/ui/detail/item/property/OCIViewItem.java b/src/org/tizen/emulator/manager/ui/detail/item/property/OCIViewItem.java deleted file mode 100644 index bc9b8d4..0000000 --- a/src/org/tizen/emulator/manager/ui/detail/item/property/OCIViewItem.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * MunKyu Im - * JiHye Kim - * Minkee Lee - * SeokYeon Hwang - * Sangho Park - * - * 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.ui.detail.item.property; - -import java.util.ArrayList; -import java.util.List; - -import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem; -import org.tizen.emulator.manager.ui.detail.item.template.DetailSubViewItem; -import org.tizen.emulator.manager.ui.detail.item.template.LabelViewItem; -import org.tizen.emulator.manager.vms.xml.template.Item; - -public class OCIViewItem extends LabelViewItem{ - - public static String ITEM_DEVICES = "devices"; //$NON-NLS-1$ - - public OCIViewItem(Item template, LineLabelViewItem lineLabelViewItem) { - super(template, lineLabelViewItem); - } - - protected List getSubItemList() { - if (subItemList == null) { - subItemList = new ArrayList(); - - List itemList = template.getItem(); - int i=0; - for (Item item : itemList) { - String itemName = item.getName(); - if (itemName.equals(ITEM_DEVICES)) { - subItemList.add(new OCIDevicesSubViewItem(this, compList.get(i++), item)); - } - } - } - return subItemList; - } - - // TODO - protected int getSubItemCount(Item template) { - List itemList = template.getItem(); - int count = 0; - for (Item item : itemList) { - String itemName = item.getName(); - if (itemName.equals(ITEM_DEVICES)) { - count++; - } - } - return count; - } - -} -- 2.7.4