[USB] Add UsbDeviceStrings class 54/133854/4
authorDinesh Dwivedi <dinesh.d@samsung.com>
Tue, 11 Jul 2017 15:47:13 +0000 (21:17 +0530)
committerDinesh Dwivedi <dinesh.d@samsung.com>
Tue, 11 Jul 2017 15:47:13 +0000 (21:17 +0530)
Change-Id: Iee68a0f705ccba5a26db697a832b63ae55fafc51
Signed-off-by: Dinesh Dwivedi <dinesh.d@samsung.com>
Tizen.System.Usb/Usb/UsbDevice.cs
Tizen.System.Usb/Usb/UsbDeviceStrings.cs [new file with mode: 0644]

index c62582547253988f1ad6bbc294119b925ff9d464..3e18f9cb771742964319cbebb0a29fb04c97b359 100644 (file)
@@ -130,6 +130,18 @@ namespace Tizen.System.Usb
             }
         }
 
+        /// <summary>
+        /// String associated with device.
+        /// </summary>
+        public UsbDeviceStrings Strings
+        {
+            get
+            {
+                ThrowIfDisposed();
+                return new UsbDeviceStrings(this, "us-ascii");
+            }
+        }
+
         /// <summary>
         /// Opens device, which allows performing operations on it.
         /// </summary>
diff --git a/Tizen.System.Usb/Usb/UsbDeviceStrings.cs b/Tizen.System.Usb/Usb/UsbDeviceStrings.cs
new file mode 100644 (file)
index 0000000..347e4fa
--- /dev/null
@@ -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
+{
+    /// <summary>
+    /// String information for USB device.
+    /// </summary>
+    public class UsbDeviceStrings
+    {
+        private readonly UsbDevice _device;
+        private string _language;
+
+        internal UsbDeviceStrings(UsbDevice device, string language)
+        {
+            _device = device;
+            _language = language;
+        }
+
+        /// <summary>
+        /// Gets string describing device manufacturer.
+        /// </summary>
+        /// <exception cref="InvalidOperationException">Throws exception if device is disconnected or not opened for operation.</exception>
+        /// <exception cref="UnauthorizedAccessException">Throws exception if user has insufficient permission on device.</exception>
+        public string Manufacturer
+        {
+            get
+            {
+                _device.ThrowIfDisposed();
+                return Interop.DescriptorString(_device._handle.GetManufacturerStr, _language);
+            }
+        }
+
+        /// <summary>
+        /// Gets product string of device
+        /// </summary>
+        /// <exception cref="InvalidOperationException">Throws exception if device is not opened for operation.</exception>
+        /// <exception cref="UnauthorizedAccessException">Throws exception if user has insufficient permission on device.</exception>
+        public string Product
+        {
+            get
+            {
+                _device.ThrowIfDisposed();
+                return Interop.DescriptorString(_device._handle.GetProductStr, _language);
+            }
+        }
+
+        /// <summary>
+        /// Gets serial number of a device.
+        /// </summary>
+        /// <exception cref="InvalidOperationException">Throws exception if device is not opened for operation.</exception>
+        /// <exception cref="UnauthorizedAccessException">Throws exception if user has insufficient permission on device.</exception>
+        public string Serial
+        {
+            get
+            {
+                _device.ThrowIfDisposed();
+                return Interop.DescriptorString(_device._handle.GetSerialNumberStr, _language);
+            }
+        }
+    }
+}