internal static extern int SetNotificationAppControl(int requestId, int appControlType, SafeAppControlHandle handle);
[DllImport(Libraries.Download, EntryPoint = "download_get_notification_app_control")]
internal static extern int GetNotificationAppControl(int requestId, int appControlType, out SafeAppControlHandle handle);
+ [DllImport(Libraries.Download, EntryPoint = "download_set_cache")]
+ internal static extern int SetDownloadCache(int downloadId, bool enable);
+ [DllImport(Libraries.Download, EntryPoint = "download_get_cache")]
+ internal static extern int GetDownloadCache(int downloadId, out bool enable);
+ [DllImport(Libraries.Download, EntryPoint = "download_reset_cache")]
+ internal static extern int ResetDownloadCache();
+ [DllImport(Libraries.Download, EntryPoint = "download_set_cache_max_size")]
+ internal static extern int SetDownloadCacheMaxSize(uint maxSize);
+ [DllImport(Libraries.Download, EntryPoint = "download_get_cache_max_size")]
+ internal static extern int GetDownloadCacheMaxSize(out uint maxSize);
+ [DllImport(Libraries.Download, EntryPoint = "download_reset_all_cache")]
+ internal static extern int ResetAllDownloadCache();
+ [DllImport(Libraries.Download, EntryPoint = "download_set_cache_path")]
+ internal static extern int SetDownloadCachePath(string cachePath);
+ [DllImport(Libraries.Download, EntryPoint = "download_get_cache_path")]
+ internal static extern int GetDownloadCachePath(out string cachePath);
+ [DllImport(Libraries.Download, EntryPoint = "download_set_cache_lifecycle")]
+ internal static extern int SetDownloadCacheLifeCycle(uint time);
+ [DllImport(Libraries.Download, EntryPoint = "download_get_cache_lifecycle")]
+ internal static extern int GetDownloadCacheLifeCycle(out uint time);
}
}
--- /dev/null
+/*
+* Copyright (c) 2023 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.
+*/
+
+using System;
+using System.ComponentModel;
+
+namespace Tizen.Content.Download
+{
+ /// <summary>
+ /// The CacheManager class provides the functions to manage cache properties.
+ /// </summary>
+ /// <since_tizen> 11 </since_tizen>
+ static class CacheManager
+ {
+
+ /// <summary>
+ /// Clears per app download cache.
+ /// </summary>
+ /// <since_tizen> 11 </since_tizen>
+ /// <privilege>http://tizen.org/privilege/download</privilege>
+ /// <feature>http://tizen.org/feature/download</feature>
+ /// <exception cref="InvalidOperationException">Thrown when it is failed due to an invalid operation.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when a permission is denied.</exception>
+ /// <exception cref="NotSupportedException">Thrown when not supported.</exception>
+ static public void ResetCache()
+ {
+ int ret = Interop.Download.ResetDownloadCache();
+ if (ret != (int)DownloadError.None)
+ {
+ DownloadErrorFactory.ThrowException(ret, "Failed to reset cache");
+ }
+ }
+
+ /// <summary>
+ /// Total maximum cache size considering all apps.
+ /// </summary>
+ /// <since_tizen> 11 </since_tizen>
+ /// <privilege>http://tizen.org/privilege/download</privilege>
+ /// <feature>http://tizen.org/feature/download</feature>
+ /// <exception cref="ArgumentException">Thrown when it is failed due to setting an invalid value.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when it is failed due to an invalid operation.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when a permission is denied.</exception>
+ /// <exception cref="NotSupportedException">Thrown when not supported.</exception>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ static public uint MaxCacheSize
+ {
+ get
+ {
+ uint maxCacheSize;
+ int ret = Interop.Download.GetDownloadCacheMaxSize(out maxCacheSize);
+ if (ret != (int)DownloadError.None)
+ {
+ DownloadErrorFactory.ThrowException(ret, "Failed to get max size of cache");
+ }
+ return maxCacheSize;
+ }
+ set
+ {
+ int ret = Interop.Download.SetDownloadCacheMaxSize(value);
+ if (ret != (int)DownloadError.None)
+ {
+ DownloadErrorFactory.ThrowException(ret, "Failed to set cache max size");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Clears all system download cache.
+ /// </summary>
+ /// <since_tizen> 11 </since_tizen>
+ /// <privilege>http://tizen.org/privilege/download</privilege>
+ /// <feature>http://tizen.org/feature/download</feature>
+ /// <exception cref="InvalidOperationException">Thrown when it is failed due to an invalid operation.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when a permission is denied.</exception>
+ /// <exception cref="NotSupportedException">Thrown when not supported.</exception>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ static public void ResetAllCache()
+ {
+ int ret = Interop.Download.ResetAllDownloadCache();
+ if (ret != (int)DownloadError.None)
+ {
+ DownloadErrorFactory.ThrowException(ret, "Failed to reset all cache");
+ }
+ }
+
+ /// <summary>
+ /// Path of the cache stored.
+ /// </summary>
+ /// <since_tizen> 11 </since_tizen>
+ /// <privilege>http://tizen.org/privilege/download</privilege>
+ /// <feature>http://tizen.org/feature/download</feature>
+ /// <exception cref="ArgumentException">Thrown when it is failed due to setting an invalid value.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when it is failed due to an invalid operation.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when a permission is denied.</exception>
+ /// <exception cref="NotSupportedException">Thrown when not supported.</exception>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ static public string CachePath
+ {
+ get
+ {
+ string cachePath;
+ int ret = Interop.Download.GetDownloadCachePath(out cachePath);
+ if (ret != (int)DownloadError.None)
+ {
+ DownloadErrorFactory.ThrowException(ret, "Failed to get cache path");
+ }
+ return cachePath;
+ }
+ set
+ {
+ int ret = Interop.Download.SetDownloadCachePath(value);
+ if (ret != (int)DownloadError.None)
+ {
+ DownloadErrorFactory.ThrowException(ret, "Failed to set cache path");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Life cycle of the cache in seconds.
+ /// </summary>
+ /// <since_tizen> 11 </since_tizen>
+ /// <privilege>http://tizen.org/privilege/download</privilege>
+ /// <feature>http://tizen.org/feature/download</feature>
+ /// <remarks> The time after which the stored cache will be invalid/stale.</remarks>
+ /// <exception cref="ArgumentException">Thrown when it is failed due to setting an invalid value.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when it is failed due to an invalid operation.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when a permission is denied.</exception>
+ /// <exception cref="NotSupportedException">Thrown when not supported.</exception>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ static public uint CacheLifeCycle
+ {
+ get
+ {
+ uint lifeCycle;
+ int ret = Interop.Download.GetDownloadCacheLifeCycle(out lifeCycle);
+ if (ret != (int)DownloadError.None)
+ {
+ DownloadErrorFactory.ThrowException(ret, "Failed to get cache life cycle.");
+ }
+ return lifeCycle;
+ }
+ set
+ {
+ int ret = Interop.Download.SetDownloadCacheLifeCycle(value);
+ if (ret != (int)DownloadError.None)
+ {
+ DownloadErrorFactory.ThrowException(ret, "Failed to set cache life cycle.");
+ }
+ }
+ }
+ }
+}
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
+using System.ComponentModel;
namespace Tizen.Content.Download
{
DownloadErrorFactory.ThrowException(ret, "Unsetting ProgressChanged callback failed");
}
}
+
+ /// <summary>
+ /// Enabled state of the cache feature.
+ /// </summary>
+ /// <since_tizen> 11 </since_tizen>
+ /// <privilege>http://tizen.org/privilege/download</privilege>
+ /// <feature>http://tizen.org/feature/download</feature>
+ /// <exception cref="ArgumentException">Thrown when it is failed due to setting an invalid value.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when it is failed due to an invalid operation.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when a permission is denied.</exception>
+ /// <exception cref="NotSupportedException">Thrown when not supported.</exception>
+ public bool UsesCache
+ {
+ get
+ {
+ bool enable;
+ int ret = Interop.Download.GetDownloadCache(_downloadId, out enable);
+ if (ret != (int)DownloadError.None)
+ {
+ DownloadErrorFactory.ThrowException(ret, "Failed to get enabled state of cache");
+ }
+ return enable;
+ }
+ set
+ {
+ int ret = Interop.Download.SetDownloadCache(_downloadId, value);
+ if (ret != (int)DownloadError.None)
+ {
+ DownloadErrorFactory.ThrowException(ret, "Failed to set enabled state of download cache");
+ }
+ }
+ }
}
}