2 * Copyright (c) 2017 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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 using LibTVRefCommonPortable.Utils;
20 using Tizen.Applications;
21 using System.Collections.Generic;
23 namespace LibTVRefCommonTizen.Ports
26 /// Handles the Appcontrol APIs
28 public class AppControlPort : IAppControl
31 /// The app ID of TV reference home application
33 // TODO : change application later
34 public static string TVHomeAppID = "org.tizen.xahome";
37 /// The app ID of TV reference apps-tray application
39 public static string TVAppsAppID = "org.tizen.xaapps";
42 /// Represents the operation to be performed between TVHome and TVApps
43 /// This operation is sended from TVHomes to TVApps
45 public static string AddAppOperation = "http://xahome.tizen.org/appcontrol/operation/add_app";
48 /// Represents the operation to be performed between TVHome and TVApps
49 /// This operation is sended from TVApps to TVHome
51 public static string AppAddedNotifyOperation = "http://xahome.tizen.org/appcontrol/operation/app_added";
53 public static string KeyAddedAppID = "AddedAppID";
56 /// Sends the launch request
58 /// <param name="AppId"> The app ID to explicitly launch</param>
59 public void SendLaunchRequest(string AppId)
63 AppControl appControl = new AppControl();
65 if (AppId == null || AppId.Length <= 0)
67 DebuggingUtils.Err("The AppID is null or blank");
71 appControl.ApplicationId = AppId;
73 AppControl.SendLaunchRequest(appControl);
75 catch (InvalidOperationException)
77 DebuggingUtils.Err("Failed to create AppControl");
82 /// Sends the launch request
84 /// <param name="AppId"> The app ID to explicitly launch</param>
85 /// <param name="extraData">The extra data for the app control</param>
86 public void SendLaunchRequest(string AppId, IDictionary<string, string> extraData)
90 AppControl appControl = new AppControl();
92 if (AppId == null || AppId.Length <= 0)
94 DebuggingUtils.Err("The AppID is null or blank");
100 appControl.ApplicationId = AppId;
101 foreach (var key in extraData.Keys)
103 if (extraData.TryGetValue(key, out value))
105 appControl.ExtraData.Add(key, value);
109 AppControl.SendLaunchRequest(appControl);
111 catch (InvalidOperationException)
113 DebuggingUtils.Err("Failed to create AppControl");
118 /// Sends the 'Add PIN apps' operation to TV Apps
120 public void SendAddAppRequestToApps()
122 AppControl appControl = new AppControl()
124 ApplicationId = TVAppsAppID,
125 Operation = AddAppOperation,
127 AppControl.SendLaunchRequest(appControl);
131 /// Sends the pinned app ID to TV Home
133 /// <param name="addedAddID">The app ID to add PIN list int the TV Home</param>
134 public void SendAppAddedNotificationToHome(string addedAddID)
136 AppControl appControl = new AppControl()
138 ApplicationId = TVHomeAppID,
139 Operation = AppAddedNotifyOperation,
141 appControl.ExtraData.Add(KeyAddedAppID, addedAddID);
142 AppControl.SendLaunchRequest(appControl);