Modify the signature of insatll API for mount installation
authorjongmyeongko <jongmyeong.ko@samsung.com>
Tue, 11 Jul 2017 06:50:22 +0000 (15:50 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Fri, 21 Jul 2017 02:24:00 +0000 (11:24 +0900)
usage :
PackageManager.Install(packagePath, InstallType.Mount);

Change-Id: I936f93780167ac68b441f6b73aa11eb03c5a26c2
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
src/Tizen.Applications.PackageManager/Interop/Interop.PackageManager.cs [changed mode: 0644->0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/InstallationMode.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index e8fac2d..92ad54e
@@ -186,6 +186,9 @@ internal static partial class Interop
         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_install")]
         internal static extern ErrorCode PackageManagerRequestInstall(SafePackageManagerRequestHandle requestHandle, string path, out int id);
 
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_mount_install")]
+        internal static extern ErrorCode PackageManagerRequestMountInstall(SafePackageManagerRequestHandle requestHandle, string path, out int id);
+
         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_uninstall")]
         internal static extern ErrorCode PackageManagerRequestUninstall(SafePackageManagerRequestHandle requestHandle, string name, out int id);
 
@@ -216,6 +219,9 @@ internal static partial class Interop
         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_install_with_cb")]
         internal static extern ErrorCode PackageManagerRequestInstallWithCB(SafePackageManagerRequestHandle requestHandle, string path, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);
 
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_mount_install_with_cb")]
+        internal static extern ErrorCode PackageManagerRequestMountInstallWithCB(SafePackageManagerRequestHandle requestHandle, string path, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);
+
         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_uninstall_with_cb")]
         internal static extern ErrorCode PackageManagerRequestUninstallWithCB(SafePackageManagerRequestHandle requestHandle, string name, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);
 
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/InstallationMode.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/InstallationMode.cs
new file mode 100755 (executable)
index 0000000..da643db
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017 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.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for installation mode.
+    /// </summary>
+    public enum InstallationMode
+    {
+        /// <summary>
+        /// Normal Mode.
+        /// </summary>
+        Normal,
+        /// <summary>
+        /// Mount Mode.
+        /// </summary>
+        Mount
+    }
+}
old mode 100644 (file)
new mode 100755 (executable)
index 6b49900..1efd51f
@@ -55,6 +55,9 @@ namespace Tizen.Applications
         private static Dictionary<int, RequestEventCallback> RequestCallbacks = new Dictionary<int, RequestEventCallback>();
         private static Dictionary<int, SafePackageManagerRequestHandle> RequestHandles = new Dictionary<int, SafePackageManagerRequestHandle>();
 
+        private delegate Interop.PackageManager.ErrorCode InstallMethodWithCallback(SafePackageManagerRequestHandle requestHandle, string pkgPath, Interop.PackageManager.PackageManagerRequestEventCallback requestCallback, IntPtr userData, out int requestID);
+        private delegate Interop.PackageManager.ErrorCode InstallMethod(SafePackageManagerRequestHandle requestHandle, string pkgPath, out int requestID);
+
         /// <summary>
         /// InstallProgressChanged event. This event is occurred when a package is getting installed and the progress of the request to the package manager changes.
         /// </summary>
@@ -387,124 +390,131 @@ namespace Tizen.Applications
         /// To check the result of installation, the caller should check the progress using InstallProgressChanged event.
         /// </remarks>
         /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
-        public static bool Install(string packagePath)
+        public static bool Install(string packagePath, InstallationMode installMode = InstallationMode.Normal)
         {
-            return Install(packagePath, null, PackageType.UNKNOWN, null);
+            return Install(packagePath, null, PackageType.UNKNOWN, null, installMode);
         }
 
         /// <summary>
         /// Installs package located at the given path
         /// </summary>
         /// <param name="packagePath">Absolute path for the package to be installed</param>
-        /// <param name="eventCallback">Optional - The event callback will be invoked only for the current request</param>
+        /// <param name="eventCallback">The event callback will be invoked only for the current request</param>
+        /// <param name="installMode">Optional parameter to indicate special installation mode</param>
         /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
         /// <remarks>
         /// The 'true' means that just the request of installation is seccessful.
         /// To check the result of installation, the caller should check the progress using InstallProgressChanged event OR eventCallback.
         /// </remarks>
         /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
-        public static bool Install(string packagePath, RequestEventCallback eventCallback)
+        public static bool Install(string packagePath, RequestEventCallback eventCallback, InstallationMode installMode = InstallationMode.Normal)
         {
-            return Install(packagePath, null, PackageType.UNKNOWN, eventCallback);
+            return Install(packagePath, null, PackageType.UNKNOWN, eventCallback, installMode);
         }
 
         /// <summary>
         /// Installs package located at the given path
         /// </summary>
         /// <param name="packagePath">Absolute path for the package to be installed</param>
-        /// <param name="type">Optional - Package type for the package to be installed</param>
+        /// <param name="type">Package type for the package to be installed</param>
+        /// <param name="installMode">Optional parameter to indicate special installation mode</param>
         /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
         /// <remarks>
         /// The 'true' means that just the request of installation is seccessful.
         /// To check the result of installation, the caller should check the progress using InstallProgressChanged event.
         /// </remarks>
         /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
-        public static bool Install(string packagePath, PackageType type)
+        public static bool Install(string packagePath, PackageType type, InstallationMode installMode = InstallationMode.Normal)
         {
-            return Install(packagePath, null, type, null);
+            return Install(packagePath, null, type, null, installMode);
         }
 
         /// <summary>
         /// Installs package located at the given path
         /// </summary>
         /// <param name="packagePath">Absolute path for the package to be installed</param>
-        /// <param name="expansionPackagePath">Optional - Absolute path for the expansion package to be installed</param>
+        /// <param name="expansionPackagePath">Absolute path for the expansion package to be installed</param>
+        /// <param name="installMode">Optional parameter to indicate special installation mode</param>
         /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
         /// <remarks>
         /// The 'true' means that just the request of installation is seccessful.
         /// To check the result of installation, the caller should check the progress using InstallProgressChanged event.
         /// </remarks>
         /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
-        public static bool Install(string packagePath, string expansionPackagePath)
+        public static bool Install(string packagePath, string expansionPackagePath, InstallationMode installMode = InstallationMode.Normal)
         {
-            return Install(packagePath, expansionPackagePath, PackageType.UNKNOWN, null);
+            return Install(packagePath, expansionPackagePath, PackageType.UNKNOWN, null, installMode);
         }
 
         /// <summary>
         /// Installs package located at the given path
         /// </summary>
         /// <param name="packagePath">Absolute path for the package to be installed</param>
-        /// <param name="type">Optional - Package type for the package to be installed</param>
-        /// <param name="eventCallback">Optional - The event callback will be invoked only for the current request</param>
+        /// <param name="type">Package type for the package to be installed</param>
+        /// <param name="eventCallback">The event callback will be invoked only for the current request</param>
+        /// <param name="installMode">Optional parameter to indicate special installation mode</param>
         /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
         /// <remarks>
         /// The 'true' means that just the request of installation is seccessful.
         /// To check the result of installation, the caller should check the progress using InstallProgressChanged event OR eventCallback.
         /// </remarks>
         /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
-        public static bool Install(string packagePath, PackageType type, RequestEventCallback eventCallback)
+        public static bool Install(string packagePath, PackageType type, RequestEventCallback eventCallback, InstallationMode installMode = InstallationMode.Normal)
         {
-            return Install(packagePath, null, type, eventCallback);
+            return Install(packagePath, null, type, eventCallback, installMode);
         }
 
         /// <summary>
         /// Installs package located at the given path
         /// </summary>
         /// <param name="packagePath">Absolute path for the package to be installed</param>
-        /// <param name="expansionPackagePath">Optional - Absolute path for the expansion package to be installed</param>
-        /// <param name="eventCallback">Optional - The event callback will be invoked only for the current request</param>
+        /// <param name="expansionPackagePath">Absolute path for the expansion package to be installed</param>
+        /// <param name="eventCallback">The event callback will be invoked only for the current request</param>
+        /// <param name="installMode">Optional parameter to indicate special installation mode</param>
         /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
         /// <remarks>
         /// The 'true' means that just the request of installation is seccessful.
         /// To check the result of installation, the caller should check the progress using InstallProgressChanged event OR eventCallback.
         /// </remarks>
         /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
-        public static bool Install(string packagePath, string expansionPackagePath, RequestEventCallback eventCallback)
+        public static bool Install(string packagePath, string expansionPackagePath, RequestEventCallback eventCallback, InstallationMode installMode = InstallationMode.Normal)
         {
-            return Install(packagePath, expansionPackagePath, PackageType.UNKNOWN, eventCallback);
+            return Install(packagePath, expansionPackagePath, PackageType.UNKNOWN, eventCallback, installMode);
         }
 
         /// <summary>
         /// Installs package located at the given path
         /// </summary>
         /// <param name="packagePath">Absolute path for the package to be installed</param>
-        /// <param name="expansionPackagePath">Optional - Absolute path for the expansion package to be installed</param>
-        /// <param name="type">Optional - Package type for the package to be installed</param>
+        /// <param name="expansionPackagePath">Absolute path for the expansion package to be installed</param>
+        /// <param name="type">Package type for the package to be installed</param>
+        /// <param name="installMode">Optional parameter to indicate special installation mode</param>
         /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
         /// <remarks>
         /// The 'true' means that just the request of installation is seccessful.
         /// To check the result of installation, the caller should check the progress using InstallProgressChanged event.
         /// </remarks>
         /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
-        public static bool Install(string packagePath, string expansionPackagePath, PackageType type)
+        public static bool Install(string packagePath, string expansionPackagePath, PackageType type, InstallationMode installMode = InstallationMode.Normal)
         {
-            return Install(packagePath, expansionPackagePath, type, null);
+            return Install(packagePath, expansionPackagePath, type, null, installMode);
         }
 
         /// <summary>
         /// Installs package located at the given path
         /// </summary>
         /// <param name="packagePath">Absolute path for the package to be installed</param>
-        /// <param name="expansionPackagePath">Optional - Absolute path for the expansion package to be installed</param>
-        /// <param name="type">Optional - Package type for the package to be installed</param>
-        /// <param name="eventCallback">Optional - The event callback will be invoked only for the current request</param>
+        /// <param name="expansionPackagePath">Absolute path for the expansion package to be installed</param>
+        /// <param name="type">Package type for the package to be installed</param>
+        /// <param name="eventCallback">The event callback will be invoked only for the current request</param>
+        /// <param name="installMode">Optional parameter to indicate special installation mode</param>
         /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
         /// <remarks>
         /// The 'true' means that just the request of installation is seccessful.
         /// To check the result of installation, the caller should check the progress using InstallProgressChanged event OR eventCallback.
         /// </remarks>
         /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
-        public static bool Install(string packagePath, string expansionPackagePath, PackageType type, RequestEventCallback eventCallback)
+        public static bool Install(string packagePath, string expansionPackagePath, PackageType type, RequestEventCallback eventCallback, InstallationMode installMode = InstallationMode.Normal)
         {
             SafePackageManagerRequestHandle RequestHandle;
             var err = Interop.PackageManager.PackageManagerRequestCreate(out RequestHandle);
@@ -541,7 +551,16 @@ namespace Tizen.Applications
                 int requestId;
                 if (eventCallback != null)
                 {
-                    err = Interop.PackageManager.PackageManagerRequestInstallWithCB(RequestHandle, packagePath, internalRequestEventCallback, IntPtr.Zero, out requestId);
+                    InstallMethodWithCallback install;
+                    if (installMode == InstallationMode.Mount)
+                    {
+                        install = Interop.PackageManager.PackageManagerRequestMountInstallWithCB;
+                    }
+                    else
+                    {
+                        install = Interop.PackageManager.PackageManagerRequestInstallWithCB;
+                    }
+                    err = install(RequestHandle, packagePath, internalRequestEventCallback, IntPtr.Zero, out requestId);
                     if (err == Interop.PackageManager.ErrorCode.None)
                     {
                         RequestCallbacks.Add(requestId, eventCallback);
@@ -556,7 +575,16 @@ namespace Tizen.Applications
                 }
                 else
                 {
-                    err = Interop.PackageManager.PackageManagerRequestInstall(RequestHandle, packagePath, out requestId);
+                    InstallMethod install;
+                    if (installMode == InstallationMode.Mount)
+                    {
+                        install = Interop.PackageManager.PackageManagerRequestMountInstall;
+                    }
+                    else
+                    {
+                        install = Interop.PackageManager.PackageManagerRequestInstall;
+                    }
+                    err = install(RequestHandle, packagePath, out requestId);
                     if (err != Interop.PackageManager.ErrorCode.None)
                     {
                         Log.Warn(LogTag, string.Format("Failed to install package {0}. err = {1}", packagePath, err));