From: Dinesh Dwivedi Date: Tue, 11 Jul 2017 15:47:13 +0000 (+0530) Subject: [USB] Add UsbDeviceStrings class X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f3fadfa2d6c16b1aeb9cf9f30b307805ab4322d9;p=platform%2Fcore%2Fcsapi%2Fusb.git [USB] Add UsbDeviceStrings class Change-Id: Iee68a0f705ccba5a26db697a832b63ae55fafc51 Signed-off-by: Dinesh Dwivedi --- diff --git a/Tizen.System.Usb/Usb/UsbDevice.cs b/Tizen.System.Usb/Usb/UsbDevice.cs index c625825..3e18f9c 100644 --- a/Tizen.System.Usb/Usb/UsbDevice.cs +++ b/Tizen.System.Usb/Usb/UsbDevice.cs @@ -130,6 +130,18 @@ namespace Tizen.System.Usb } } + /// + /// String associated with device. + /// + public UsbDeviceStrings Strings + { + get + { + ThrowIfDisposed(); + return new UsbDeviceStrings(this, "us-ascii"); + } + } + /// /// Opens device, which allows performing operations on it. /// diff --git a/Tizen.System.Usb/Usb/UsbDeviceStrings.cs b/Tizen.System.Usb/Usb/UsbDeviceStrings.cs new file mode 100644 index 0000000..347e4fa --- /dev/null +++ b/Tizen.System.Usb/Usb/UsbDeviceStrings.cs @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.System.Usb +{ + /// + /// String information for USB device. + /// + public class UsbDeviceStrings + { + private readonly UsbDevice _device; + private string _language; + + internal UsbDeviceStrings(UsbDevice device, string language) + { + _device = device; + _language = language; + } + + /// + /// Gets string describing device manufacturer. + /// + /// Throws exception if device is disconnected or not opened for operation. + /// Throws exception if user has insufficient permission on device. + public string Manufacturer + { + get + { + _device.ThrowIfDisposed(); + return Interop.DescriptorString(_device._handle.GetManufacturerStr, _language); + } + } + + /// + /// Gets product string of device + /// + /// Throws exception if device is not opened for operation. + /// Throws exception if user has insufficient permission on device. + public string Product + { + get + { + _device.ThrowIfDisposed(); + return Interop.DescriptorString(_device._handle.GetProductStr, _language); + } + } + + /// + /// Gets serial number of a device. + /// + /// Throws exception if device is not opened for operation. + /// Throws exception if user has insufficient permission on device. + public string Serial + { + get + { + _device.ThrowIfDisposed(); + return Interop.DescriptorString(_device._handle.GetSerialNumberStr, _language); + } + } + } +}