Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.PackageManager / Tizen.Applications / PackageSizeInformation.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
19 namespace Tizen.Applications
20 {
21     /// <summary>
22     /// This class has the read only properties to get package size information.
23     /// </summary>
24     public class PackageSizeInformation
25     {
26         private long _dataSize;
27         private long _cacheSize;
28         private long _appSize;
29         private long _externalDataSize;
30         private long _externalCacheSize;
31         private long _externalAppSize;
32
33         private PackageSizeInformation() { }
34
35         /// <summary>
36         /// Data size for package.
37         /// </summary>
38         public long DataSize { get { return _dataSize; } }
39
40         /// <summary>
41         /// Cache size for package.
42         /// </summary>
43         public long CacheSize { get { return _cacheSize; } }
44
45         /// <summary>
46         /// Application size for package.
47         /// </summary>
48         public long AppSize { get { return _appSize; } }
49
50         /// <summary>
51         /// External data size for package.
52         /// </summary>
53         public long ExternalDataSize { get { return _externalDataSize; } }
54
55         /// <summary>
56         /// External cache size for package.
57         /// </summary>
58         public long ExternalCacheSize { get { return _externalCacheSize; } }
59
60         /// <summary>
61         /// External application size for package.
62         /// </summary>
63         public long ExternalAppSize { get { return _externalAppSize; } }
64
65         // This method assumes that pass handle is already validated
66         internal static PackageSizeInformation GetPackageSizeInformation(IntPtr handle)
67         {
68             var pkgSizeInfo = new PackageSizeInformation();
69             Interop.PackageManager.PackageSizeInfoGetDataSize(handle, out pkgSizeInfo._dataSize);
70             Interop.PackageManager.PackageSizeInfoGetCacheSize(handle, out pkgSizeInfo._cacheSize);
71             Interop.PackageManager.PackageSizeInfoGetAppSize(handle, out pkgSizeInfo._appSize);
72             Interop.PackageManager.PackageSizeInfoGetExtDataSize(handle, out pkgSizeInfo._externalDataSize);
73             Interop.PackageManager.PackageSizeInfoGetExtCacheSize(handle, out pkgSizeInfo._externalCacheSize);
74             Interop.PackageManager.PackageSizeInfoGetExtAppSize(handle, out pkgSizeInfo._externalAppSize);
75             return pkgSizeInfo;
76         }
77     }
78 }