亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? deviceimpl.java

?? JAVA 訪問USB JAVA 訪問USB JAVA 訪問USB JAVA 訪問USB JAVA 訪問USB JAVA 訪問USB
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * Java USB Library
 * Copyright (C) 2000 by David Brownell
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package usb.linux;

import java.io.File;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Locale;

import usb.core.*;
import usb.util.LangCode;


/**
 * Provides access to a USB device.  To use a device, first make sure that
 * you can use the selected configuration.  (The Linux kernel makes
 * sure a selection is made, although at this writing it doesn't consider
 * power consumption or other limitations when doing so.
 * Don't use the change-configuration functionality yet.)
 *
 * @author David Brownell
 * @version $Id: DeviceImpl.java,v 1.5 2001/01/02 21:06:43 dbrownell Exp $
 */
final class DeviceImpl extends Device implements DeviceSPI
{
    // DEFERRED FUNCTIONALITY:
    // - Anything for iso support, including synchFrame control msg
    // - Configuration changing (broken support exists)
    // - Alternate settings (incomplete support exists)


    /** the bus we're connected to */
    private final USB		usb;

    private String		path;

    // Used for internal synchronization; it should only be known
    // within this class.  Protects string cache and configuration.
    private final Object	lock = new Object ();

    // XXX Our record of the configuration could be out of date
    // since the kernel doesn't yet protect anyone from changes to
    // it, even driver software claiming interfaces exposed by
    // the current configuration.

    private int			selectedConfig = -1;
    private Configuration	currentConfig;

    private DeviceDescriptor	descriptor;

    private boolean		checkedStrings;
    private int			languages [];

    // cache just one language; key = Byte (id)
    private int			cachedLanguage;
    private Hashtable		stringCache;

    /** for hub nodes, lists children; else null */
    private DeviceImpl		children [];

    private DeviceImpl		hub;
    private int			hubPortNum;


    // XXX Need kernel support for some device lock to safeguard
    // devices against unexpected concurrent operations.  Control
    // messages can interfere with other work in some cases.  This
    // is an acknowledged open usbdevfs issue.  We should be able to
    // workaround other user mode code with O_EXCL.  That'd also
    // prevent multiple jUSB or libusb processes from working at
    // the same time as this, though ...


    // package private
    DeviceImpl (USB bus, File f, int a)
    throws IOException, SecurityException
    {
	super (null, bus, a);

	usb = bus;
	path = f.getPath ();

	// should only fail if the device unplugged before
	// we opened it, or permissions were bogus, or ...
	if ((fd = openNative (path)) < 0) {
	    String	message;

	    message = "can't open device file r/w, " + path;
	    if (fd == -USBException.EPERM)
		throw new SecurityException (message);
	    else
		throw new USBException (message, -fd);
	}

	// fd's open; NOW we can get the device descriptor
	try {
	    byte buf [];

	    buf = ControlMessage.getStandardDescriptor (this,
		    Descriptor.TYPE_DEVICE, (byte) 0, 0, 18);
	    descriptor = new DeviceDescriptor (this, buf);
	} catch (IOException e) {
	    if (Linux.debug)
		System.err.println ("get dev descr fail:  "
		    + path
		    + ", "
		    + e.getMessage ());
	    throw e;
	}

	// ... and configuration descriptor
	getConfiguration ();

	if (Linux.trace)
	    System.err.println ("new: " + path);
    }

    public String toString ()
    {
	StringBuffer	buf = new StringBuffer ("{Linux Device: ");
	String		prod = descriptor.getProduct (0);

	buf.append (path);
	if (prod != null) {
	    buf.append (" ");
	    buf.append (prod);
	}
	buf.append ("}");
	return buf.toString ();
    }

    /** Releases any unreleased system resources. */
    protected void finalize ()
    throws USBException
	{ close (); }

    /** 
     * Immediately closes the device; further operations on this object will
     * fail.  This is normally done only when the device is being removed.
     */
    // package private
    void close ()
    throws USBException
    {
	if (fd < 0)
	    return;

	try {
	    // make sure this isn't usable any more
	    int status = closeNative (fd);
	    if (status < 0)
		throw new USBException (
			"error closing device",
			-status);
	} finally {
	    // make sure nobody else sees the device
	    usb.removeDev (this);
	    hub = null;
	    fd = -1;
	}
    }


    /*-------------------------------------------------------------------*/

    // implementations of abstract "Device" methods

    public Device getHub ()
	{ return hub; }

    public int getHubPortNum ()
	{ return hubPortNum; }

    public int getNumPorts ()
	{ return (children == null) ? 0 : children.length; }
    
    public DeviceDescriptor getDeviceDescriptor ()
	{ return descriptor; }

    public Configuration getConfiguration ()
    throws IOException
    {
	if (selectedConfig == -1) {
	    if (descriptor.getNumConfigurations () != 1) {
		ControlMessage	msg = new ControlMessage ();

		msg.setRequestType ((byte)(msg.DIR_TO_HOST
					| msg.TYPE_STANDARD
					| msg.RECIPIENT_DEVICE
					));
		msg.setRequest (msg.GET_CONFIGURATION);
		msg.setValue ((short) 0);
		msg.setIndex ((short) 0);
		msg.setLength (1);
		control (msg);
		selectedConfig = 0xff & msg.getBuffer ()[0];
	    } else
		selectedConfig = 0;
	}
	return getConfiguration (selectedConfig);
    }

    // also a DeviceSPI method
    public Device getChild (int port)
    {
	if (children == null)
	    return null;
	return children [port - 1];
    }

    /*-------------------------------------------------------------------*/

    
    /**
     * Returns the filesystem name for this file.
     */
    public String getPath () { return path; }

	// uses the system locale ...
	// perfect for server/implementation, maybe not for clients.
	// Locale is also not available on all systems; may need
	// to ignore this if no I18N support is available/used.

    private int chooseDefaultLanguage ()
    {
	if (languages.length == 1)
	    return languages [0];
	
	Locale	dflt = Locale.getDefault ();
	int	retval = languages [0];

	for (int i = 0; i < languages.length; i++) {
	    Locale	current = LangCode.getLocale (languages [i]);

	    // return exact matches if possible
	    if (current == dflt)
		return languages [i];

	    // insist on shared language
	    if (current == null)
		continue;
	    if (!current.getLanguage ().equals (dflt.getLanguage ()))
		continue;

	    // could also check country (return now if same)

	    // it's OK, and maybe better than our last guess
	    retval = languages [i];
	}
	return retval;
    }

    /**
     * Returns the string indexed with the specified ID in the
     * default language, or null if there is no such string.
     * Use of cached values is preferred.
     *
     * <p>The default language is the one that is being cached.
     * If this is the first request, then the language of the
     * default locale is used if it is supported, else the first
     * supported language is chosen as a fallback.
     */
    public String getString (int id)
    throws IOException
    {
	if (!checkedStrings)
	    getLanguages ();
	if (languages == null || languages.length == 0)
	    return null;
	if (stringCache == null)
	    return getString (id, chooseDefaultLanguage ());
	else
	    return getString (id, cachedLanguage);
    }

    /**
     * Implementation of {@link usb.core.Device#getString Device.getString}
     * which can cache strings in the device's default language.
     */
    public String getString (int id, int language)
    throws IOException
    {
	if (id == 0)
	    return null;
	if (id < 0 || id > 0xff)
	    throw new IllegalArgumentException ();
	if (!checkedStrings)
	    getLanguages ();
	if (languages == null || languages.length == 0)
	    return null;

	Byte	key = new Byte ((byte) id);
	String	retval = null;

	if (stringCache == null) {
	    synchronized (lock) {
		if (stringCache == null) {
		    cachedLanguage = language;
		    stringCache = new Hashtable (7);
		}
	    }
/**/
	} else if (stringCache.containsKey (key)) {
	    Object	value = stringCache.get (key);

	    if (value instanceof String)
		return (String) value;
	    else
		return null;
/**/
	}
	
	retval = ControlMessage.getString (this, (byte) id, language);

	if (retval == null)	// negative caching
	    stringCache.put (key, Boolean.FALSE);
	else			// positive caching
	    stringCache.put (key, retval);
	return retval;
    }

    public int [] getLanguages ()
    throws IOException
    {
	synchronized (lock) {
	    if (!checkedStrings)
		languages = ControlMessage.getLanguages (this);
	}

	if (languages == null)
	    return null;

	int retval [] = new int [languages.length];
	for (int i = 0; i < languages.length; i++)
	    retval [i] = languages [i];
	return retval;
    }

    /**
     * Returns the specified configuration.
     * This can need to accumulate device-specific smarts.
     */
    public Configuration getConfiguration (int index)
    throws IOException
    {
	Configuration	retval;

	if (index < 0 || index >= descriptor.getNumConfigurations ())
	    throw new IllegalArgumentException ();
	
	synchronized (lock) {
	    if (index == selectedConfig && currentConfig != null)
		return currentConfig;

	    // NOTE:  we _could_ read 'fd' and bypass control messages
	    // for the case of the current configuration

	    retval = new Configuration (this, getConfigBuf (index));
	    if (index == selectedConfig)
		currentConfig = retval;
	}
	return retval;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国模大尺度一区二区三区| 亚洲一级二级在线| 一区二区三区中文字幕| 日本中文字幕不卡| 不卡的av在线播放| 精品国免费一区二区三区| 亚洲激情成人在线| 粗大黑人巨茎大战欧美成人| 欧美日韩综合一区| 亚洲色图欧美激情| 粉嫩欧美一区二区三区高清影视 | 国产成人免费av在线| 色国产精品一区在线观看| 久久久国产精品麻豆| 青青草91视频| 在线播放日韩导航| 一区二区三区日韩欧美| jiyouzz国产精品久久| 精品久久人人做人人爰| 日本欧美加勒比视频| 精品视频免费在线| 亚洲午夜久久久久久久久电影院 | 九九视频精品免费| 日韩午夜精品视频| 日韩影视精彩在线| 欧美福利视频导航| 日韩中文欧美在线| 欧美美女bb生活片| 视频一区在线播放| 欧美一级专区免费大片| 日本不卡视频一二三区| 91精品黄色片免费大全| 午夜精品一区二区三区免费视频| 高清成人在线观看| 国产精品理论片在线观看| 丁香激情综合五月| 中文字幕一区二区视频| 成a人片国产精品| 最新国产精品久久精品| 国产精品传媒在线| 久久久久久久久蜜桃| 久久久久久久综合日本| 91精品国产综合久久精品性色| 91亚洲精品久久久蜜桃网站| 成人午夜看片网址| 久久99精品国产.久久久久久| 亚洲国产精品人人做人人爽| 国产精品午夜在线| 88在线观看91蜜桃国自产| 久久国产乱子精品免费女| 国产一区二区三区久久悠悠色av| 日韩免费观看2025年上映的电影| 国内精品不卡在线| 国产精品伦理一区二区| 在线观看免费成人| 麻豆精品一区二区av白丝在线| 精品久久久久久久久久久久久久久| 经典三级一区二区| 亚洲日穴在线视频| 9191成人精品久久| 国产成人在线视频网站| 亚洲女爱视频在线| 制服丝袜亚洲色图| 国产成人h网站| 午夜久久电影网| 亚洲国产高清在线观看视频| 色哟哟亚洲精品| 激情六月婷婷久久| 亚洲日本va午夜在线影院| 在线成人小视频| fc2成人免费人成在线观看播放| 亚洲视频网在线直播| 日韩一区二区三区电影| 99久久精品国产麻豆演员表| 日韩成人精品在线| 久久久精品国产99久久精品芒果| 欧美在线不卡视频| 国产精品一二三四五| 亚洲风情在线资源站| 久久久www成人免费毛片麻豆 | 亚洲成人免费视频| 精品国产乱码久久久久久久久| 91免费版在线看| 国产一区二区三区免费看| 亚洲不卡一区二区三区| 中文字幕日本不卡| 久久婷婷久久一区二区三区| 欧美亚洲综合色| 93久久精品日日躁夜夜躁欧美| 久久99国产精品久久| 亚洲成人三级小说| 一区二区三区四区国产精品| 国产亚洲一二三区| 亚洲精品在线免费观看视频| 精品视频色一区| 欧美性色欧美a在线播放| 成人爽a毛片一区二区免费| 免费精品视频在线| 日韩中文字幕91| 亚洲大片精品永久免费| 国产成a人亚洲| 亚洲美腿欧美偷拍| 亚洲日本在线a| 久久久国产精品不卡| 不卡的av中国片| 日本伊人色综合网| 中文字幕在线一区| 欧美剧情电影在线观看完整版免费励志电影 | 精品一区二区三区久久| 99精品一区二区三区| 韩国av一区二区三区在线观看| 亚洲私人影院在线观看| 久久免费精品国产久精品久久久久| 555www色欧美视频| 欧美日韩一区二区三区不卡| 色老汉av一区二区三区| 色综合久久88色综合天天 | 欧美精品丝袜中出| 欧美日韩另类一区| 欧美巨大另类极品videosbest| 一本久道久久综合中文字幕| 一本到三区不卡视频| 欧美性感一类影片在线播放| 91官网在线观看| 欧美精品xxxxbbbb| www国产亚洲精品久久麻豆| 日韩免费视频线观看| 久久亚洲春色中文字幕久久久| 久久久久国产成人精品亚洲午夜| 久久精品人人做人人综合| 欧美高清在线精品一区| 亚洲男人的天堂在线观看| 亚洲一级在线观看| 蜜桃精品在线观看| 成人午夜av在线| 日本韩国一区二区三区视频| 欧美午夜免费电影| 精品国产一区二区亚洲人成毛片| 国产亚洲一本大道中文在线| 中文字幕精品一区| 亚洲成人资源网| 国内精品伊人久久久久av影院| 成人免费av资源| 在线精品亚洲一区二区不卡| 日韩一区二区三区视频在线观看 | 国产福利一区二区三区视频在线| 不卡高清视频专区| 51午夜精品国产| 久久九九影视网| 一区二区三区四区不卡视频| 裸体健美xxxx欧美裸体表演| 国产精品香蕉一区二区三区| 色中色一区二区| 精品日韩成人av| 亚洲另类在线视频| 狠狠狠色丁香婷婷综合激情| 91视视频在线观看入口直接观看www | 精品国产99国产精品| 久久精品免视看| 亚洲最大成人综合| 亚洲精品免费一二三区| 一区二区三区久久| 国产成人精品免费在线| 91精品一区二区三区久久久久久| 久久综合九色综合欧美就去吻| 国产精品一区一区三区| 成人精品鲁一区一区二区| 在线观看成人免费视频| 精品国产麻豆免费人成网站| 亚洲一区二区三区激情| 国产成人精品三级麻豆| 欧美一区二区性放荡片| 亚洲免费观看视频| 高清日韩电视剧大全免费| 欧美一区二区成人6969| 亚洲综合色噜噜狠狠| 国产精品一区二区在线播放 | 亚洲电影激情视频网站| 国产九九视频一区二区三区| 在线播放国产精品二区一二区四区| 欧美国产激情二区三区 | www激情久久| 日本成人超碰在线观看| 欧美性受xxxx黑人xyx性爽| 中文字幕在线视频一区| 国产精品12区| www久久精品| 精品一区二区三区香蕉蜜桃| 欧美精品色一区二区三区| 亚洲欧美国产高清| 91麻豆国产福利精品| 国产精品美女久久久久aⅴ国产馆| 国产综合久久久久影院| 日韩欧美一区在线| 秋霞成人午夜伦在线观看| 欧美高清视频不卡网| 日日摸夜夜添夜夜添亚洲女人| 在线观看亚洲a| 亚洲va中文字幕| 欧美久久久一区|