Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.Mtp / Tizen.Network.Mtp / MtpManager.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using System.Collections.Generic;
19 using System.Threading.Tasks;
20
21 namespace Tizen.Network.Mtp
22 {
23     /// <summary>
24     /// A class for MTP management. It allows applications to use MTP service.
25     /// </summary>
26     /// <remarks>
27     /// http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.
28     /// http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
29     /// </remarks>
30     /// <since_tizen> 5 </since_tizen>
31     static public class MtpManager
32     {
33         /// <summary>
34         /// Gets the list of MTP devices.
35         /// </summary>
36         /// <returns>List of MtpDevice objects.</returns>
37         /// <feature>http://tizen.org/feature/network.mtp</feature>
38         /// <exception cref="NotSupportedException">Thrown when Mtp is not supported.</exception>
39         /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
40         /// <since_tizen> 5 </since_tizen>
41         static public IEnumerable<MtpDevice> GetDevices()
42         {
43             try
44             {
45                 return MtpManagerImpl.Instance.GetDevices();
46             }
47             catch (TypeInitializationException e)
48             {
49                 throw e.InnerException;
50             }
51         }
52
53         /// <summary>
54         /// MtpStateChanged is raised when the Mtp device state is changed.
55         /// </summary>
56         /// <since_tizen> 5 </since_tizen>
57         static public event EventHandler<MtpStateChangedEventArgs> MtpStateChanged
58         {
59             add
60             {
61                 try
62                 {
63                     MtpManagerImpl.Instance.MtpStateChanged += value;
64                 }
65                 catch (TypeInitializationException e)
66                 {
67                     throw e.InnerException;
68                 }
69             }
70             remove
71             {
72                 try
73                 {
74                     MtpManagerImpl.Instance.MtpStateChanged -= value;
75                 }
76                 catch (TypeInitializationException e)
77                 {
78                     throw e.InnerException;
79                 }
80             }
81         }
82     }
83 }