예제 #1
0
        /// <summary>
        /// Request the launch of Input Delegator to receive the text input from user.
        /// </summary>
        /// <remarks>
        /// You can get the user input by AppControlData.Text.
        /// For more details, see https://docs.tizen.org/application/native/guides/app-management/common-appcontrols/#extra-output-11.
        /// </remarks>
        /// <param name="inputCallback">The callback function to be called when the input is received.</param>
        /// <param name="guideText">The guide text such as "Input user name". This is optional.</param>
        public static void GetTextInput(AppControlReplyCallback inputCallback, string guideText = null)
        {
            AppControl request = new AppControl
            {
                Operation = InputOperation,
                Mime      = "text/plain"
            };

            // The type of input method
            request.ExtraData.Add(AppControlData.InputType, "input_keyboard");

            // The maximum text length allowed.
            request.ExtraData.Add(TextMaxLengthData, "20");

            // The label of the return key.
            request.ExtraData.Add(ReturnKeyTypeData, "Done");

            if (guideText != null)
            {
                request.ExtraData.Add(AppControlData.InputGuideText, guideText);
            }

            // Set the launch mode for the application to be launched.
            // For more details about launch mode, see https://docs.tizen.org/application/dotnet/guides/app-management/app-controls/#application-group-management.
            request.LaunchMode = AppControlLaunchMode.Group;

            AppControl.SendLaunchRequest(request, inputCallback);
        }
예제 #2
0
        /// <summary>
        /// Sends the launch request.
        /// </summary>
        /// <remarks>
        /// The operation is mandatory information for the launch request.
        /// If the operation is not specified, AppControlOperations.Default is used by default.
        /// If the operation is AppControlOperations.Default, the application ID is mandatory to explicitly launch the application.<br/>
        /// Since Tizen 2.4, the launch request of the service application over out of packages is restricted by the platform.
        /// Also, implicit launch requests are NOT delivered to service applications since 2.4.
        /// To launch a service application, an explicit launch request with the application ID given by property ApplicationId MUST be sent.
        /// </remarks>
        /// <param name="launchRequest">The AppControl.</param>
        /// <param name="replyAfterLaunching">The callback function to be called when the reply is delivered.</param>
        /// <exception cref="ArgumentException">Thrown when failed because of the argument is invalid.</exception>
        /// <exception cref="Exceptions.AppNotFoundException">Thrown when the application to run is not found.</exception>
        /// <exception cref="Exceptions.LaunchFailedException">Thrown when the request failed to launch the application.</exception>
        /// <exception cref="Exceptions.LaunchRejectedException">Thrown when the launch request is rejected.</exception>
        /// <exception cref="Exceptions.OutOfMemoryException">Thrown when the memory is insufficient.</exception>
        /// <exception cref="Exceptions.PermissionDeniedException">Thrown when the permission is denied.</exception>
        /// <exception cref="TimeoutException">Thrown when failed because of timeout.</exception>
        /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
        /// <example>
        /// <code>
        /// AppControl appControl = new AppControl();
        /// appControl.ApplicationId = "org.tizen.calculator";
        /// AppControl.SendLaunchRequest(appControl, (launchRequest, replyRequest, result) => {
        ///     // ...
        /// });
        /// </code>
        /// </example>
        /// <since_tizen> 3 </since_tizen>
        public static void SendLaunchRequest(AppControl launchRequest, AppControlReplyCallback replyAfterLaunching)
        {
            if (launchRequest == null)
            {
                throw new ArgumentNullException("launchRequest");
            }

            Interop.AppControl.ErrorCode err;

            if (replyAfterLaunching != null)
            {
                int id = 0;
                lock (s_replyCallbackMaps)
                {
                    id = s_reaustId++;
                    s_replyCallbackMaps[id] = replyAfterLaunching;
                }
                err = Interop.AppControl.SendLaunchRequest(launchRequest._handle, s_replyNativeCallback, (IntPtr)id);
            }
            else
            {
                err = Interop.AppControl.SendLaunchRequest(launchRequest._handle, null, IntPtr.Zero);
            }

            if (err != Interop.AppControl.ErrorCode.None)
            {
                switch (err)
                {
                case Interop.AppControl.ErrorCode.InvalidParameter:
                    throw new ArgumentException("Invalid Arguments");

                case Interop.AppControl.ErrorCode.TimedOut:
                    throw new TimeoutException("Timed out");

                case Interop.AppControl.ErrorCode.OutOfMemory:
                    throw new Exceptions.OutOfMemoryException("Out-of-memory");

                case Interop.AppControl.ErrorCode.AppNotFound:
                    throw new Exceptions.AppNotFoundException("App not found");

                case Interop.AppControl.ErrorCode.LaunchRejected:
                    throw new Exceptions.LaunchRejectedException("Launch rejected");

                case Interop.AppControl.ErrorCode.LaunchFailed:
                    throw new Exceptions.LaunchFailedException("Launch failed");

                case Interop.AppControl.ErrorCode.PermissionDenied:
                    throw new Exceptions.PermissionDeniedException("Permission denied");

                default:
                    throw new Exceptions.LaunchRejectedException("Launch rejected");
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Sends the launch request asynchronously.
        /// </summary>
        /// <remarks>
        /// To use group mode, you must use this function instead of SendLaunchRequestAsync().
        /// </remarks>
        /// <param name="control">appcontrol object</param>
        /// <param name="replyAfterLaunching">The callback function to be called when the reply is delivered.</param>
        /// <returns>A task with the result of the launch request.</returns>
        /// <exception cref="ArgumentException">Thrown when failed because of the argument is invalid.</exception>
        /// <exception cref="InvalidOperationException">Thrown when fail to set component information to the AppControl.</exception>
        /// <exception cref="Exceptions.AppNotFoundException">Thrown when the application to run is not found.</exception>
        /// <exception cref="Exceptions.LaunchRejectedException">Thrown when the launch request is rejected.</exception>
        /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
        /// <since_tizen> 6 </since_tizen>
        public Task <AppControlResult> SendLaunchRequestAsync(AppControl control, AppControlReplyCallback replyAfterLaunching)
        {
            int ret = Interop.AppControl.SetCallerInstanceId(control.SafeAppControlHandle, Id);

            if (ret != 0)
            {
                throw new InvalidOperationException("Failed to set id");
            }

            return(AppControl.SendLaunchRequestAsync(control, replyAfterLaunching));
        }
예제 #4
0
        /// <summary>
        /// Request the launch of Input Delegator to receive the input from user.
        /// Available input types such as voice, emoji, handwriting, and keyboard will be shown.
        /// Then user can select one of them and input the requested data.
        /// </summary>
        /// <remarks>
        /// You can get the user input by AppControlData.Text or AppControlData.Path.
        /// For more details, see https://docs.tizen.org/application/native/guides/app-management/common-appcontrols/#extra-output-11.
        /// If user selects recording type or drawing type, then input data may be stored in media storage.
        /// If so, your application needs the permission to access that input file.
        /// </remarks>
        /// <param name="inputCallback">The callback function to be called when the input is received.</param>
        public static void GetInput(AppControlReplyCallback inputCallback)
        {
            AppControl request = new AppControl
            {
                Operation = InputOperation,
                Mime      = "*/*"
            };

            // Set the launch mode for the application to be launched.
            // For more details about launch mode, see https://docs.tizen.org/application/dotnet/guides/app-management/app-controls/#application-group-management.
            request.LaunchMode = AppControlLaunchMode.Group;

            AppControl.SendLaunchRequest(request, inputCallback);
        }
예제 #5
0
        /// <summary>
        /// Request the launch of Input Delegator to receive the recording input from user.
        /// </summary>
        /// <remarks>
        /// You can get the user input by AppControlData.Path which contains the list of multiple audio file paths.
        /// For more details, see https://docs.tizen.org/application/native/guides/app-management/common-appcontrols/#extra-output-11.
        /// If input data is stored in media storage, then your application needs the permission to access that input file.
        /// </remarks>
        /// <param name="inputCallback">The callback function to be called when the input is received.</param>
        public static void GetRecordingInput(AppControlReplyCallback inputCallback)
        {
            AppControl request = new AppControl
            {
                Operation = InputOperation,
                Mime      = "audio/*"
            };

            // The type of input method
            request.ExtraData.Add(AppControlData.InputType, "input_recording");

            // Set the launch mode for the application to be launched.
            // For more details about launch mode, see https://docs.tizen.org/application/dotnet/guides/app-management/app-controls/#application-group-management.
            request.LaunchMode = AppControlLaunchMode.Group;

            AppControl.SendLaunchRequest(request, inputCallback);
        }
        public Task <Stream> GetImageStreamAsync()
        {
            string resultPath = "";
            TaskCompletionSource <Stream> tcs = new TaskCompletionSource <Stream>();

            AppControl appControl = new AppControl
            {
                Operation = AppControlOperations.Pick,
                Mime      = "image/*",
            };

            AppControlReplyCallback callback = (launchRequest, replyRequest, result) =>
            {
                if (result == AppControlReplyResult.Succeeded)
                {
                    if (replyRequest.ExtraData.IsCollection(App​Control​Data.Selected))
                    {
                        resultPath = replyRequest.ExtraData.Get <IEnumerable <string> >(App​Control​Data.Selected).FirstOrDefault();
                        if (!string.IsNullOrEmpty(resultPath))
                        {
                            tcs.SetResult(new FileStream(resultPath, FileMode.Open, FileAccess.Read));
                        }
                        else
                        {
                            tcs.SetResult(null);
                        }
                    }
                    else
                    {
                        tcs.SetResult(null);
                    }
                }
            };

            try
            {
                AppControl.SendLaunchRequest(appControl, callback);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                tcs.SetResult(null);
            }
            return(tcs.Task);
        }
예제 #7
0
        /// <summary>
        /// Request the launch of Input Delegator to receive the reply input from user.
        /// </summary>
        /// <remarks>
        /// You can get the user input by AppControlData.Text.
        /// For more details, see https://docs.tizen.org/application/native/guides/app-management/common-appcontrols/#extra-output-11.
        /// </remarks>
        /// <param name="inputCallback">The callback function to be called when the input is received.</param>
        /// <param name="incomingMessage">The message to be used as the hint at reply suggestions. This is optional.</param>
        public static void GetReplyInput(AppControlReplyCallback inputCallback, string incomingMessage = null)
        {
            AppControl request = new AppControl
            {
                Operation = InputOperation,
                Mime      = "text/plain"
            };

            // The type of input method
            request.ExtraData.Add(AppControlData.InputType, "input_reply");

            if (incomingMessage != null)
            {
                request.ExtraData.Add(AppControlData.InputPredictionHint, incomingMessage);
            }

            // Set the launch mode for the application to be launched.
            // For more details about launch mode, see https://docs.tizen.org/application/dotnet/guides/app-management/app-controls/#application-group-management.
            request.LaunchMode = AppControlLaunchMode.Group;

            AppControl.SendLaunchRequest(request, inputCallback);
        }
예제 #8
0
        /// <summary>
        /// Request the launch of Input Delegator to receive the text input from user.
        /// </summary>
        /// <remarks>
        /// You can get the user input by AppControlData.Text.
        /// For more details, see https://docs.tizen.org/application/native/guides/app-management/common-appcontrols/#extra-output-11.
        /// </remarks>
        /// <param name="inputCallback">The callback function to be called when the input is received.</param>
        /// <param name="defaultText">The preformatted text to be used as default input, such as "http://" for Web addresses.</param>
        /// <param name="cursorPosition">The position where the cursor is to be set (start at 0). If cursorPosition < 0, then the length of defaultText is used.</param>
        public static void GetTextInput(AppControlReplyCallback inputCallback, string defaultText, int cursorPosition)
        {
            if (defaultText == null)
            {
                throw new ArgumentNullException(nameof(defaultText));
            }

            AppControl request = new AppControl
            {
                Operation = InputOperation,
                Mime      = "text/plain"
            };

            // The type of input method
            request.ExtraData.Add(AppControlData.InputType, "input_keyboard");

            // The maximum text length allowed.
            request.ExtraData.Add(TextMaxLengthData, "20");

            // The label of the return key.
            request.ExtraData.Add(ReturnKeyTypeData, "Go");

            request.ExtraData.Add(AppControlData.InputDefaultText, defaultText);

            if (cursorPosition < 0)
            {
                cursorPosition = defaultText.Length;
            }
            request.ExtraData.Add(CursorPositionSetData, cursorPosition.ToString());

            // Set the launch mode for the application to be launched.
            // For more details about launch mode, see https://docs.tizen.org/application/dotnet/guides/app-management/app-controls/#application-group-management.
            request.LaunchMode = AppControlLaunchMode.Group;

            AppControl.SendLaunchRequest(request, inputCallback);
        }
예제 #9
0
 internal static extern ErrorCode SendLaunchRequestToProvider(SafeFrameBrokerHandle handle, SafeAppControlHandle safeAppControlHandle, AppControlResultCallback resultCallback, AppControlReplyCallback replyCallback, IntPtr userData);
예제 #10
0
        /// <summary>
        /// Sends the launch request asynchronously.
        /// </summary>
        /// <remarks>
        /// The operation is mandatory information for the launch request.
        /// If the operation is not specified, AppControlOperations.Default is used by default.
        /// If the operation is AppControlOperations.Default, the application ID is mandatory to explicitly launch the application.<br/>
        /// Since Tizen 2.4, the launch request of the service application over out of packages is restricted by the platform.
        /// Also, implicit launch requests are NOT delivered to service applications since 2.4.
        /// To launch a service application, an explicit launch request with the application ID given by property ApplicationId MUST be sent.
        /// </remarks>
        /// <param name="launchRequest">The AppControl.</param>
        /// <param name="replyAfterLaunching">The callback function to be called when the reply is delivered.</param>
        /// <returns>A task with the result of the launch request.</returns>
        /// <exception cref="ArgumentException">Thrown when failed because of the argument is invalid.</exception>
        /// <exception cref="Exceptions.AppNotFoundException">Thrown when the application to run is not found.</exception>
        /// <exception cref="Exceptions.LaunchRejectedException">Thrown when the launch request is rejected.</exception>
        /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
        /// <since_tizen> 6 </since_tizen>
        public static Task <AppControlResult> SendLaunchRequestAsync(AppControl launchRequest, AppControlReplyCallback replyAfterLaunching)
        {
            if (launchRequest == null)
            {
                throw new ArgumentNullException(nameof(launchRequest));
            }

            var task = new TaskCompletionSource <AppControlResult>();

            Interop.AppControl.ErrorCode err;
            int requestId = 0;

            lock (s_resultNativeCallbackMaps)
            {
                requestId = s_reaustId++;
                s_resultNativeCallbackMaps[requestId] = (handle, result, userData) =>
                {
                    task.SetResult((AppControlResult)result);
                    lock (s_resultNativeCallbackMaps)
                    {
                        s_resultNativeCallbackMaps.Remove((int)userData);
                    }
                };
            }

            if (replyAfterLaunching != null)
            {
                lock (s_replyCallbackMaps)
                {
                    s_replyCallbackMaps[requestId] = replyAfterLaunching;
                }
                err = Interop.AppControl.SendLaunchRequestAsync(launchRequest.SafeAppControlHandle, s_resultNativeCallbackMaps[requestId], s_replyNativeCallback, (IntPtr)requestId);
            }
            else
            {
                err = Interop.AppControl.SendLaunchRequestAsync(launchRequest.SafeAppControlHandle, s_resultNativeCallbackMaps[requestId], null, (IntPtr)requestId);
            }

            if (err != Interop.AppControl.ErrorCode.None)
            {
                switch (err)
                {
                case Interop.AppControl.ErrorCode.InvalidParameter:
                    throw new ArgumentException("Invalid Arguments");

                case Interop.AppControl.ErrorCode.AppNotFound:
                    throw new Exceptions.AppNotFoundException("App not found");

                case Interop.AppControl.ErrorCode.LaunchRejected:
                    throw new Exceptions.LaunchRejectedException("Launch rejected");

                case Interop.AppControl.ErrorCode.PermissionDenied:
                    throw new Exceptions.PermissionDeniedException("Permission denied");

                default:
                    throw new Exceptions.LaunchRejectedException("Launch rejected");
                }
            }

            return(task.Task);
        }
예제 #11
0
        /// <summary>
        /// Sends the launch request.
        /// </summary>
        /// <remarks>
        /// The operation is mandatory information for the launch request.
        /// If the operation is not specified, AppControlOperations.Default is used by default.
        /// If the operation is AppControlOperations.Default, the application ID is mandatory to explicitly launch the application.<br/>
        /// Since Tizen 2.4, the launch request of the service application over out of packages is restricted by the platform.
        /// Also, implicit launch requests are NOT delivered to service applications since 2.4.
        /// To launch a service application, an explicit launch request with the application ID given by property ApplicationId MUST be sent.
        /// </remarks>
        /// <param name="launchRequest">The AppControl.</param>
        /// <param name="replyAfterLaunching">The callback function to be called when the reply is delivered.</param>
        /// <exception cref="ArgumentException">Thrown when failed because of the argument is invalid.</exception>
        /// <exception cref="Exceptions.AppNotFoundException">Thrown when the application to run is not found.</exception>
        /// <exception cref="Exceptions.LaunchFailedException">Thrown when the request failed to launch the application.</exception>
        /// <exception cref="Exceptions.LaunchRejectedException">Thrown when the launch request is rejected.</exception>
        /// <exception cref="Exceptions.OutOfMemoryException">Thrown when the memory is insufficient.</exception>
        /// <exception cref="Exceptions.PermissionDeniedException">Thrown when the permission is denied.</exception>
        /// <exception cref="TimeoutException">Thrown when failed because of timeout.</exception>
        /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
        /// <example>
        /// <code>
        /// AppControl appControl = new AppControl();
        /// appControl.ApplicationId = "org.tizen.calculator";
        /// AppControl.SendLaunchRequest(appControl, (launchRequest, replyRequest, result) => {
        ///     // ...
        /// });
        /// </code>
        /// </example>
        /// <since_tizen> 3 </since_tizen>
        public static void SendLaunchRequest(AppControl launchRequest, AppControlReplyCallback replyAfterLaunching)
        {
            if (launchRequest == null)
            {
                throw new ArgumentNullException("launchRequest");
            }

            Interop.AppControl.ErrorCode err;

            if (replyAfterLaunching != null)
            {
                int id = 0;
                lock (s_replyNativeCallbackMaps)
                {
                    id = s_replyNativeCallbackId++;
                    s_replyNativeCallbackMaps[id] = (launchRequestHandle, replyRequestHandle, result, userData) =>
                    {
                        if (replyAfterLaunching != null)
                        {
                            Log.Debug(LogTag, "Reply Callback is launched");
                            replyAfterLaunching(new AppControl(launchRequestHandle), new AppControl(replyRequestHandle), (AppControlReplyResult)result);
                            if (result != Interop.AppControl.AppStartedStatus)
                            {
                                lock (s_replyNativeCallbackMaps)
                                {
                                    s_replyNativeCallbackMaps.Remove(id);
                                }
                            }
                        }
                    };
                }
                err = Interop.AppControl.SendLaunchRequest(launchRequest._handle, s_replyNativeCallbackMaps[id], IntPtr.Zero);
            }
            else
            {
                err = Interop.AppControl.SendLaunchRequest(launchRequest._handle, null, IntPtr.Zero);
            }

            if (err != Interop.AppControl.ErrorCode.None)
            {
                switch (err)
                {
                case Interop.AppControl.ErrorCode.InvalidParameter:
                    throw new ArgumentException("Invalid Arguments");

                case Interop.AppControl.ErrorCode.TimedOut:
                    throw new TimeoutException("Timed out");

                case Interop.AppControl.ErrorCode.OutOfMemory:
                    throw new Exceptions.OutOfMemoryException("Out-of-memory");

                case Interop.AppControl.ErrorCode.AppNotFound:
                    throw new Exceptions.AppNotFoundException("App not found");

                case Interop.AppControl.ErrorCode.LaunchRejected:
                    throw new Exceptions.LaunchRejectedException("Launch rejected");

                case Interop.AppControl.ErrorCode.LaunchFailed:
                    throw new Exceptions.LaunchFailedException("Launch failed");

                case Interop.AppControl.ErrorCode.PermissionDenied:
                    throw new Exceptions.PermissionDeniedException("Permission denied");

                default:
                    throw new Exceptions.LaunchRejectedException("Launch rejected");
                }
            }
        }