783b261419900a836f03bb1e96b942a8e804807e
[platform/core/csapi/mtp.git] / 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="ArgumentException">Thrown when method is failed due to an invalid parameter.</exception>
40         /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
41         /// <since_tizen> 5 </since_tizen>
42         static public IEnumerable<MtpDevice> GetDevices()
43         {
44             try
45             {
46                 return MtpManagerImpl.Instance.GetDevices();
47             }
48             catch (TypeInitializationException e)
49             {
50                 throw e.InnerException;
51             }
52         }
53
54         /// <summary>
55         /// MtpStateChanged is raised when the Mtp device state is changed.
56         /// </summary>
57         /// <since_tizen> 5 </since_tizen>
58         static public event EventHandler<MtpStateChangedEventArgs> MtpStateChanged
59         {
60             add
61             {
62                 try
63                 {
64                     MtpManagerImpl.Instance.MtpStateChanged += value;
65                 }
66                 catch (TypeInitializationException e)
67                 {
68                     throw e.InnerException;
69                 }
70             }
71             remove
72             {
73                 try
74                 {
75                     MtpManagerImpl.Instance.MtpStateChanged -= value;
76                 }
77                 catch (TypeInitializationException e)
78                 {
79                     throw e.InnerException;
80                 }
81             }
82         }
83     }
84 }