public UrlServiceSubscription(DeviceService service, string uri, JsonObject payload, bool isWebOs,
     ResponseListener listener)
     : base(service, uri, payload, listener)
 {
     if (isWebOs)
         HttpMethod = "subscribe";
 }
        private void AppStoreCommandExecute(object obj)
        {
            if (appStoreSession != null)
            {
                appStoreSession.Close(null);
                appStoreSession = null;
            }
            var listener = new ResponseListener
                (
                loadEventArg =>
                {
                    var session = LoadEventArgs.GetValue<LaunchSession>(loadEventArg);
                    appStoreSession = session;
                },
                serviceCommandError =>
                {

                }
                );

            String appId = null;

            if (selectedDevice.GetServiceByName("Netcast TV") != null)
                appId = "125071";
            else if (selectedDevice.GetServiceByName("webOS TV") != null)
                appId = "redbox";
            else if (selectedDevice.GetServiceByName("Roku") != null)
                appId = "13535";

            launcher.LaunchAppStore(appId, listener);
        }
 public ServiceCommand(IServiceCommandProcessor service, string targetUrl, Object payload, ResponseListener listener)
 {
     Service = service;
     Target = targetUrl;
     Payload = payload;
     responseListener = listener;
     HttpMethod = TypePost;
 }
 public ServiceCommand(IServiceCommandProcessor service, string uri, IJsonValue payload, ResponseListener listener)
 {
     Service = service;
     Target = uri;
     Payload = payload;
     RequestId = -1;
     HttpMethod = "request";
     responseListener = listener;
 }
        private void SetControlKeys()
        {
            if (selectedDevice != null)
            {
                KeyCommand.Enabled = selectedDevice.HasCapability(KeyControl.KeyCode);
                ChannelCommand.Enabled = selectedDevice.HasCapability(TvControl.ChannelUp);
                PowerCommand.Enabled = selectedDevice.HasCapability(PowerControl.Off);

                if (selectedDevice.HasCapability(TvControl.ChannelList))
                {
                    var listener = new ResponseListener
                        (
                        loadEventArg =>
                        {
                            var channels = LoadEventArgs.GetValue<List<ChannelInfo>>(loadEventArg);
                            App.MainDispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                            {
                                Channels = channels;
                            });
                        },
                        serviceCommandError =>
                        {

                        }
                        );
                    tvControl.GetChannelList(listener);
                }

                if (selectedDevice.HasCapability(TvControl.ChannelSubscribe))
                {
                    var listener = new ResponseListener
                        (
                        loadEventArg =>
                        {
                            var channel = LoadEventArgs.GetValue<ChannelInfo>(loadEventArg);
                            App.MainDispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                            {
                                SelectedChannel = channel;
                            });
                        },
                        serviceCommandError =>
                        {

                        }
                        );
                    tvControl.SubscribeCurrentChannel(listener);
                }
            }
        }
        private void InputCommandExecute(object obj)
        {
            var listener = new ResponseListener
                (
                loadEventArg =>
                {
                    var launchPickerSession = LoadEventArgs.GetValue<LaunchSession>(loadEventArg);
                    inputPickerSession = launchPickerSession;
                },
                serviceCommandError =>
                {

                }
                );
            externalInputControl.LaunchInputPicker(listener);
        }
        private void CloseWebAppCommandExecute(object obj)
        {
            CloseWebAppCommand.Enabled = false;
            SendMessageCommand.Enabled = false;
            SendJsonCommand.Enabled = false;
            LeaveWebAppCommand.Enabled = false;
            isLaunched = false;
            mWebAppSession.WebAppSessionListener = null;

            var listener = new ResponseListener
                (
                loadEventArg =>
                {
                    LaunchWebAppCommand.Enabled = true;
                },
                serviceCommandError =>
                {
                    LaunchWebAppCommand.Enabled = true;
                }
                );
            mWebAppSession.Close(listener);
        }
 public void PlayMedia(string url, string mimeType, string title, string description, string iconSrc,
     bool shouldLoop, ResponseListener listener)
 {
     if (dlnaService != null)
     {
         dlnaService.PlayMedia(url, mimeType, title, description, iconSrc, shouldLoop, listener);
     }
 }
 public void Pause(ResponseListener listener)
 {
     SendVirtualKeyCode((int)NetcastVirtualKeycodes.PAUSE, listener);
 }
 public void Next(ResponseListener listener)
 {
     throw new NotImplementedException();
 }
 public void LaunchYouTube(string contentId, ResponseListener listener)
 {
     const string appName = "YouTube";
     LaunchNamedApplication(appName, listener);
 }
        public void LaunchInputPicker(ResponseListener pListener)
        {
            const string appName = "Input List";
            var encodedStr = HttpMessage.Encode(appName);

            var responseListener = new ResponseListener
            (
                loadEventArg =>
                {

                    var responseLaunchListener = new ResponseListener
                    (
                        loadEventArg2 =>
                        {
                            if (inputPickerSession == null)
                            {
                                inputPickerSession = (LaunchSession)loadEventArg2;
                            }

                            Util.PostSuccess(pListener, loadEventArg2);
                        },
                        serviceCommandError => Util.PostError(pListener, serviceCommandError)
                    );
                    LaunchApplication(appName, ((AppInfo)loadEventArg).Id, null, responseLaunchListener);
                },
                serviceCommandError => Util.PostError(pListener, serviceCommandError)
            );

            GetApplication(encodedStr, responseListener);
        }
 public void LaunchBrowser(string url, ResponseListener listener)
 {
     const string appName = "Internet";
     LaunchNamedApplication(appName, listener);
 }
 public void GetMute(ResponseListener listener)
 {
     var responseListener = new ResponseListener
     (
         loadEventArg => Util.PostSuccess(listener, ((VolumeStatus)loadEventArg).IsMute),
         serviceCommandError => Util.PostError(listener, serviceCommandError)
     );
     GetVolumeStatus(responseListener);
 }
 public void GetExternalInputList(ResponseListener listener)
 {
     throw new NotImplementedException();
 }
 public void LaunchAppWithInfo(AppInfo appInfo, ResponseListener listener)
 {
     LaunchAppWithInfo(appInfo, null, listener);
 }
        public void LaunchAppWithInfo(AppInfo appInfo, Object ps, ResponseListener listener)
        {
            var appName = HttpMessage.Encode(appInfo.Name);
            var appId = appInfo.Id;
            string contentId = null;
            JsonObject mps = null;
            var o = ps as JsonObject;
            if (o != null)
                mps = o;

            if (mps != null)
            {
                contentId = mps.GetNamedString("contentId");
            }

            LaunchApplication(appName, appId, contentId, listener);
        }
 public void GetPlayState(ResponseListener listener)
 {
     Util.PostError(listener, ServiceCommandError.NotSupported());
 }
 public void LaunchHulu(string contentId, ResponseListener listener)
 {
     const string appName = "Hulu";
     LaunchNamedApplication(appName, listener);
 }
 public void GetPosition(ResponseListener listener)
 {
     if (dlnaService != null)
     {
         dlnaService.GetPosition(listener);
     }
 }
        public void LaunchNetflix(string contentId, ResponseListener listener)
        {
            //    string appName = "Netflix";

            //    getApplication(appName, new ResponseListener() {

            //        public void onSuccess( AppInfo appInfo) {
            //            JsonObject jsonObj = new JsonObject();

            //            try {
            //                jsonObj.put("id", appInfo.getId());
            //                jsonObj.put("name", appName);
            //            } catch (Exception e) {
            //                throw e;
            //            }

            //            ResponseListener responseListener = new ResponseListener() {

            //                public void onSuccess(Object response) {
            //                    LaunchSession launchSession = LaunchSession.launchSessionForAppId(appInfo.getId());
            //                    launchSession.setAppName(appName);
            //                    launchSession.setService(NetcastTVService.this);
            //                    launchSession.setSessionType(LaunchSessionType.App);

            //                    Util.PostSuccess(listener, launchSession);
            //                }

            //                public void onError(ServiceCommandError error) {
            //                    if ( listener != null )
            //                        Util.PostError(listener, error);
            //                }
            //            };

            //            string requestURL = getUDAPRequestURL(UDAP_PATH_APPTOAPP_COMMAND);

            //            Dictionary<string,string> ps = new Dictionary<string,string>();
            //            ps.Add("name", "SearchCMDPlaySDPContent");
            //            ps.Add("content_type", "1");
            //            ps.Add("conts_exec_type", "20");
            //            ps.Add("conts_plex_type_flag", "N");
            //            ps.Add("conts_search_id", "2023237");
            //            ps.Add("conts_age", "18");
            //            ps.Add("exec_id", "netflix");
            //            ps.Add("item_id", "-Q m=http%3A%2F%2Fapi.netflix.com%2Fcatalog%2Ftitles%2Fmovies%2F" + contentId + "&amp;source_type=4&amp;trackId=6054700&amp;trackUrl=https%3A%2F%2Fapi.netflix.com%2FAPI_APP_ID_6261%3F%23Search%3F");
            //            ps.Add("app_type", "");

            //            string httpMessage = getUDAPMessageBody(UDAP_API_COMMAND, ps);

            //            ServiceCommand request = new ServiceCommand(NetcastTVService.this, requestURL, httpMessage, responseListener);
            //            request.send();
            //        }

            //        public void onError(ServiceCommandError error) {
            //            if ( listener != null )
            //                Util.PostError(listener, error);
            //        }
            //    });
        }
 public void GetRunningApp(ResponseListener listener)
 {
     // Do nothing - Not Supported
     Util.PostError(listener, ServiceCommandError.NotSupported());
 }
 public void Left(ResponseListener listener)
 {
     SendVirtualKeyCode((int)NetcastVirtualKeycodes.KEY_RIGHT, listener);
 }
        public void GetVolume(ResponseListener listener)
        {
            var responseListener = new ResponseListener
            (
                loadEventArg =>
                {
                    var v = (loadEventArg as LoadEventArgs).Load.GetPayload() as VolumeStatus;
                    if (v != null) Util.PostSuccess(listener, v.Volume);
                },

                serviceCommandError => Util.PostError(listener, serviceCommandError)
            );

            GetVolumeStatus(responseListener);
        }
 public void Ok(ResponseListener listener)
 {
     SendVirtualKeyCode((int)NetcastVirtualKeycodes.OK, listener);
 }
 public void Home(ResponseListener listener)
 {
     SendVirtualKeyCode((int)NetcastVirtualKeycodes.HOME, listener);
 }
 public void Play(ResponseListener listener)
 {
     SendVirtualKeyCode((int)NetcastVirtualKeycodes.PLAY, listener);
 }
        public void LaunchApp(string appId, ResponseListener listener)
        {
            var responseListener = new ResponseListener
            (
                loadEventArg => LaunchAppWithInfo((AppInfo)loadEventArg, listener),
                serviceCommandError => Util.PostError(listener, serviceCommandError)
            );

            GetAppInfoForId(appId, responseListener);
        }
 public void PowerOff(ResponseListener listener)
 {
     SendVirtualKeyCode((int)NetcastVirtualKeycodes.POWER, new ResponseListener());
 }
        public void LaunchAppStore(string appId, ResponseListener listener)
        {
            //    string targetPath = getUDAPRequestURL(ROAP_PATH_APP_STORE);

            //    Map<string, string> ps = new HashMap<string, string>();
            //    ps.Add("name", "SearchCMDPlaySDPContent");
            //    ps.Add("content_type", "4");
            //    ps.Add("conts_exec_type", "");
            //    ps.Add("conts_plex_type_flag", "");
            //    ps.Add("conts_search_id", "");
            //    ps.Add("conts_age", "12");
            //    ps.Add("exec_id", "");
            //    ps.Add("item_id", HttpMessage.encode(appId));
            //    ps.Add("app_type", "S");

            //    string httpMessage = getUDAPMessageBody(UDAP_API_COMMAND, ps);

            //    ResponseListener responseListener = new ResponseListener() {

            //        public void onSuccess(Object response) {
            //            LaunchSession launchSession = LaunchSession.launchSessionForAppId(appId);
            //            launchSession.setAppName("LG Smart World"); // TODO: this will not work in Korea, use Korean name instead
            //            launchSession.setService(NetcastTVService.this);
            //            launchSession.setSessionType(LaunchSessionType.App);

            //            Util.PostSuccess(listener, launchSession);
            //        }

            //        public void onError(ServiceCommandError error) {
            //            Util.PostError(listener, error);
            //        }
            //    };
            //    ServiceCommand command = new ServiceCommand(this, targetPath, httpMessage, responseListener);
            //    command.send();
        }