2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 namespace Tizen.Applications
22 /// Represents the received AppControl.
26 /// public class ReceivedAppControlExample : UIApplication
29 /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
31 /// ReceivedAppControl control = e.ReceivedAppControl;
32 /// if (control.Operation == AppControlOperations.Pick)
34 /// Log.Debug(LogTag, "Received AppControl is Pick");
36 /// if (control.IsReplyRequest)
38 /// AppControl replyRequest = new AppControl();
39 /// replyRequest.ExtraData.Add("myKey", "I'm replying");
40 /// control.ReplyToLaunchRequest(replyRequest, AppControlReplyResult.Succeeded);
46 /// <since_tizen> 3 </since_tizen>
47 public class ReceivedAppControl : AppControl
49 private const string LogTag = "Tizen.Applications";
52 /// Initializes a ReceivedAppControl class.
54 /// <param name="handle">App control handle</param>
55 /// <since_tizen> 3 </since_tizen>
56 public ReceivedAppControl(SafeAppControlHandle handle) : base(handle)
61 /// Gets the application ID of the caller from the launch request.
64 /// The application ID of the caller.
68 /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
70 /// ReceivedAppControl control = e.ReceivedAppControl;
71 /// string caller = control.CallerApplicationId;
75 /// <since_tizen> 3 </since_tizen>
76 public string CallerApplicationId
80 string value = String.Empty;
81 Interop.AppControl.ErrorCode err = Interop.AppControl.GetCaller(SafeAppControlHandle, out value);
82 if (err != Interop.AppControl.ErrorCode.None)
84 Log.Warn(LogTag, "Failed to get the caller application id from the AppControl. Err = " + err);
91 /// Checks whether the caller is requesting a reply from the launch request.
94 /// If true, this ReceivedAppControl is requested by the caller, otherwise false
98 /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
100 /// ReceivedAppControl control = e.ReceivedAppControl;
101 /// bool isReply = control.IsReplyRequest;
105 /// <since_tizen> 3 </since_tizen>
106 public bool IsReplyRequest
111 Interop.AppControl.ErrorCode err = Interop.AppControl.IsReplyRequested(SafeAppControlHandle, out value);
112 if (err != Interop.AppControl.ErrorCode.None)
114 Log.Warn(LogTag, "Failed to check the reply of the AppControl is requested. Err = " + err);
121 /// Replies to the launch request sent by the caller.
122 /// If the caller application sends the launch request to receive the result, the callee application can return the result back to the caller.
124 /// <param name="replyRequest">The AppControl in which the results of the callee are contained.</param>
125 /// <param name="result">The result code of the launch request.</param>
128 /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
130 /// ReceivedAppControl control = e.ReceivedAppControl;
131 /// if (control.IsReplyRequest)
133 /// AppControl replyRequest = new AppControl();
134 /// replyRequest.ExtraData.Add("myKey", "I'm replying");
135 /// control.ReplyToLaunchRequest(replyRequest, AppControlReplyResult.Succeeded);
140 /// <since_tizen> 3 </since_tizen>
141 public void ReplyToLaunchRequest(AppControl replyRequest, AppControlReplyResult result)
143 if (replyRequest == null)
145 throw new ArgumentNullException("replyRequest");
147 Interop.AppControl.ErrorCode err = Interop.AppControl.ReplyToLaunchRequest(replyRequest.SafeAppControlHandle, this.SafeAppControlHandle, (int)result);
148 if (err != Interop.AppControl.ErrorCode.None)
149 throw new InvalidOperationException("Failed to reply. Err = " + err);