2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Runtime.InteropServices;
19 using System.Collections.Generic;
21 namespace Tizen.Network.Mtp
24 /// A class for Mtp Object informations. It allows applications to handle object informations.
26 public class MtpObject : IDisposable
28 private int _deviceHandle = -1;
29 private int _objectHandle = -1;
30 private bool disposed = false;
35 public string FileName
40 int ret = Interop.Mtp.ObjectInformation.GetFileName(_deviceHandle, _objectHandle, out strPtr);
41 if (ret != (int)MtpError.None)
43 Log.Error(Globals.LogTag, "Failed to get file name, Error - " + (MtpError)ret);
46 return Marshal.PtrToStringAnsi(strPtr);
53 public string Keywords
58 int ret = Interop.Mtp.ObjectInformation.GetKeywords(_deviceHandle, _objectHandle, out strPtr);
59 if (ret != (int)MtpError.None)
61 Log.Error(Globals.LogTag, "Failed to get keywords, Error - " + (MtpError)ret);
64 return Marshal.PtrToStringAnsi(strPtr);
69 /// The association description.
71 public int AssociationDescription
76 int ret = Interop.Mtp.ObjectInformation.GetAssociationDescription(_deviceHandle, _objectHandle, out value);
77 if (ret != (int)MtpError.None)
79 Log.Error(Globals.LogTag, "Failed to get association decription, Error - " + (MtpError)ret);
86 /// The association type.
88 public int AssociationType
93 int ret = Interop.Mtp.ObjectInformation.GetAssociationType(_deviceHandle, _objectHandle, out value);
94 if (ret != (int)MtpError.None)
96 Log.Error(Globals.LogTag, "Failed to get association type, Error - " + (MtpError)ret);
110 int ret = Interop.Mtp.ObjectInformation.GetSize(_deviceHandle, _objectHandle, out value);
111 if (ret != (int)MtpError.None)
113 Log.Error(Globals.LogTag, "Failed to get size, Error - " + (MtpError)ret);
120 //TODO /// The parent object handle.
122 public int ParentObjectHandle
127 int ret = Interop.Mtp.ObjectInformation.GetParentObjectHandle(_deviceHandle, _objectHandle, out value);
128 if (ret != (int)MtpError.None)
130 Log.Error(Globals.LogTag, "Failed to get parent object handle, Error - " + (MtpError)ret);
137 //TODO /// The storage.
144 int ret = Interop.Mtp.ObjectInformation.GetStorage(_deviceHandle, _objectHandle, out value);
145 if (ret != (int)MtpError.None)
147 Log.Error(Globals.LogTag, "Failed to get storage, Error - " + (MtpError)ret);
156 public int DateCreated
161 int ret = Interop.Mtp.ObjectInformation.GetDateCreated(_deviceHandle, _objectHandle, out value);
162 if (ret != (int)MtpError.None)
164 Log.Error(Globals.LogTag, "Failed to get date created, Error - " + (MtpError)ret);
171 /// The date modified.
173 public int DateModified
178 int ret = Interop.Mtp.ObjectInformation.GetDateModified(_deviceHandle, _objectHandle, out value);
179 if (ret != (int)MtpError.None)
181 Log.Error(Globals.LogTag, "Failed to get date modified, Error - " + (MtpError)ret);
190 public MtpFileType FileType
195 int ret = Interop.Mtp.ObjectInformation.GetStorage(_deviceHandle, _objectHandle, out value);
196 if (ret != (int)MtpError.None)
198 Log.Error(Globals.LogTag, "Failed to get file type, Error - " + (MtpError)ret);
200 return (MtpFileType)value;
205 /// The image bit depth.
207 public int ImageBitDepth
212 int ret = Interop.Mtp.ObjectInformation.GetImageBitDepth(_deviceHandle, _objectHandle, out value);
213 if (ret != (int)MtpError.None)
215 Log.Error(Globals.LogTag, "Failed to get image bit depth, Error - " + (MtpError)ret);
222 /// The image pixel width.
224 public int ImagePixelWidth
229 int ret = Interop.Mtp.ObjectInformation.GetImagePixWidth(_deviceHandle, _objectHandle, out value);
230 if (ret != (int)MtpError.None)
232 Log.Error(Globals.LogTag, "Failed to get image pixel width, Error - " + (MtpError)ret);
239 /// The image pixel height.
241 public int ImagePixelHeight
246 int ret = Interop.Mtp.ObjectInformation.GetImagePixHeight(_deviceHandle, _objectHandle, out value);
247 if (ret != (int)MtpError.None)
249 Log.Error(Globals.LogTag, "Failed to get image pixel height, Error - " + (MtpError)ret);
256 /// The thumbnail size.
258 public int ThumbnailSize
263 int ret = Interop.Mtp.ObjectInformation.GetThumbnailSize(_deviceHandle, _objectHandle, out value);
264 if (ret != (int)MtpError.None)
266 Log.Error(Globals.LogTag, "Failed to get thumbnail size, Error - " + (MtpError)ret);
273 /// The thumbnail file type.
275 public int ThumbnailFileType
280 int ret = Interop.Mtp.ObjectInformation.GetThumbnailFileType(_deviceHandle, _objectHandle, out value);
281 if (ret != (int)MtpError.None)
283 Log.Error(Globals.LogTag, "Failed to get thumbnail file type, Error - " + (MtpError)ret);
290 /// The thumbnail pixel width.
292 public int ThumbnailPixelWidth
297 int ret = Interop.Mtp.ObjectInformation.GetThumbnailPixWidth(_deviceHandle, _objectHandle, out value);
298 if (ret != (int)MtpError.None)
300 Log.Error(Globals.LogTag, "Failed to get thumbnail pixel width, Error - " + (MtpError)ret);
307 /// The thumbnail pixel height.
309 public int ThumbnailPixelHeight
314 int ret = Interop.Mtp.ObjectInformation.GetThumbnailPixHeight(_deviceHandle, _objectHandle, out value);
315 if (ret != (int)MtpError.None)
317 Log.Error(Globals.LogTag, "Failed to get thumbnail pixel height, Error - " + (MtpError)ret);
323 internal MtpObject(int deviceHandle, int objectHandle)
325 _deviceHandle = deviceHandle;
326 _objectHandle = objectHandle;
334 public void Dispose()
337 GC.SuppressFinalize(this);
340 private void Dispose(bool disposing)
347 // Free managed objects.
349 //Free unmanaged objects