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 public class ReceivedAppControl : AppControl
48 private const string LogTag = "Tizen.Applications";
51 /// Initializes a ReceivedAppControl class.
53 public ReceivedAppControl(SafeAppControlHandle handle) : base(handle)
58 /// Gets the application ID of the caller from the launch request.
61 /// The application ID of the caller
65 /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
67 /// ReceivedAppControl control = e.ReceivedAppControl;
68 /// string caller = control.CallerApplicationId;
72 public string CallerApplicationId
76 string value = String.Empty;
77 Interop.AppControl.ErrorCode err = Interop.AppControl.GetCaller(SafeAppControlHandle, out value);
78 if (err != Interop.AppControl.ErrorCode.None)
80 Log.Warn(LogTag, "Failed to get the caller application id from the AppControl. Err = " + err);
87 /// Checks whether the caller is requesting a reply from the launch request.
90 /// If true this ReceivedAppControl is requested by the caller, otherwise false
94 /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
96 /// ReceivedAppControl control = e.ReceivedAppControl;
97 /// bool isReply = control.IsReplyRequest;
101 public bool IsReplyRequest
106 Interop.AppControl.ErrorCode err = Interop.AppControl.IsReplyRequested(SafeAppControlHandle, out value);
107 if (err != Interop.AppControl.ErrorCode.None)
109 Log.Warn(LogTag, "Failed to check the reply of the AppControl is requested. Err = " + err);
116 /// Replies to the launch request sent by the caller.
117 /// If the caller application sent the launch request to receive the result, the callee application can return the result back to the caller.
119 /// <param name="replyRequest">The AppControl in which the results of the callee are contained</param>
120 /// <param name="result">The result code of the launch request</param>
123 /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
125 /// ReceivedAppControl control = e.ReceivedAppControl;
126 /// if (control.IsReplyRequest)
128 /// AppControl replyRequest = new AppControl();
129 /// replyRequest.ExtraData.Add("myKey", "I'm replying");
130 /// control.ReplyToLaunchRequest(replyRequest, AppControlReplyResult.Succeeded);
135 public void ReplyToLaunchRequest(AppControl replyRequest, AppControlReplyResult result)
137 if (replyRequest == null)
139 throw new ArgumentNullException("replyRequest");
141 Interop.AppControl.ErrorCode err = Interop.AppControl.ReplyToLaunchRequest(replyRequest.SafeAppControlHandle, this.SafeAppControlHandle, (int)result);
142 if (err != Interop.AppControl.ErrorCode.None)
143 throw new InvalidOperationException("Failed to reply. Err = " + err);