+++ /dev/null
-#include "org_tizen_emulator_manager_tool_EnumerationOCI.h"
-#include <stdio.h>
-
-/* 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, "<init>", "()V");
- if (ctor == NULL){
- printf("GetMethodID(<init>) 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, "<init>", "()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;
-
-}
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * MunKyu Im <munkyu.im@samsung.com>
- * 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.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<EnumerationOCI> getEnumerationOCIDevice();
-}
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;
} 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));
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2012 - 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.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<OCI> enumerationOCIDeviceList = OCIList.getInstance().getOCIList();
- ArrayList<OCI> 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<EnumerationOCI> 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;
- }
-
-}
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * MunKyu Im <munkyu.im@samsung.com>
- * 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.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<DetailSubViewItem> getSubItemList() {
- if (subItemList == null) {
- subItemList = new ArrayList<DetailSubViewItem>();
-
- List<Item> 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<Item> itemList = template.getItem();
- int count = 0;
- for (Item item : itemList) {
- String itemName = item.getName();
- if (itemName.equals(ITEM_DEVICES)) {
- count++;
- }
- }
- return count;
- }
-
-}