private void FinishRunHosts(Udbus.v4v.v4vConnection connection, Udbus.Core.ServiceConnectionParams serviceConnectionParams) { this.connection = connection; this.serviceConnectionParams = serviceConnectionParams; log.Info("Connection helloed with name {0} and signalName {1}", serviceConnectionParams.Name, serviceConnectionParams.SignalName); System.Uri uriBase = new System.Uri(Udbus.WCF.Constants.BaseAddress); new Udbus.WCF.Service.Host.Init.InitHostMakerRegistry(); new global::XenClientGuestService.wcf.Hosts.Init.InitHostMakerRegistry(); Udbus.WCF.Service.Host.RegistryDictionaryHolder registry = Udbus.WCF.Service.Host.HostMakerRegistry.RegistryDictionaryClone; log.Info("Launching hosts..."); // Build all hosts including "special" properties host. ICollection <Udbus.WCF.Service.Host.ServiceHostCreationData> hostdata = Udbus.WCF.Service.Host.HostMakerRegistry.BuildAllHosts( registry.Values , new Udbus.WCF.Host.WCFServiceParams(serviceConnectionParams) , new Uri[] { uriBase } ); System.ServiceModel.NetNamedPipeBinding namedpipeBinding = new System.ServiceModel.NetNamedPipeBinding(); System.ServiceModel.Channels.Binding binding = namedpipeBinding; binding.SendTimeout = TimeSpan.MaxValue; binding.ReceiveTimeout = TimeSpan.MaxValue; foreach (Udbus.WCF.Service.Host.ServiceHostCreationData host in hostdata) { host.Host.AddServiceEndpoint(host.CreationParams.ContractType, binding, host.CreationParams.RelativeName); } this.hosts = hostdata.Select <Udbus.WCF.Service.Host.ServiceHostCreationData, System.ServiceModel.ServiceHost>(Udbus.WCF.Service.Host.ServiceHostCreationData.DataToHost); DbusUtils.RunHosts(hosts); this.threadInfo = RunSignalsAsync(out this.threadSignalLoop, serviceConnectionParams); }
private static void ClickThroughPressed() { foreach (ScreenSaver screenSaver in _screenSavers) { string clickThroughURL = screenSaver.GetClickThroughURL(); _logger.WriteTimestampedMessage("clickthroughURL: " + clickThroughURL); if (clickThroughURL.StartsWith("app://")) { switch (clickThroughURL) { case "app://ContentExchanger": System.Diagnostics.Process.Start(_contentExchangerPath); _logger.WriteTimestampedMessage("successfully started app in " + _contentExchangerPath); break; case "app://ContentExchanger-s": System.Diagnostics.Process.Start(_contentExchangerPath, "/s"); _logger.WriteTimestampedMessage("successfully started app in " + _contentExchangerPath + " in safe mode"); break; // TODO: when installer supports repair mode, add this case statement /* case "app://SoftwareInstaller": * // TODO: execute software installer here * break;*/ } } if (clickThroughURL.StartsWith("http://") || clickThroughURL.StartsWith("https://")) { // click log to memory screenSaver.AddClickLog(); _logger.WriteTimestampedMessage("successfully added click log."); // cross-desktop communication can't be made; communicate to the SSG to open browser ScreensaverGuardianClient client = null; try { System.ServiceModel.NetNamedPipeBinding binding = new System.ServiceModel.NetNamedPipeBinding(); binding.Name = "SSGBinding"; binding.TransferMode = System.ServiceModel.TransferMode.Buffered; binding.ReceiveTimeout = TimeSpan.FromMinutes(1); binding.SendTimeout = TimeSpan.FromMinutes(1); client = new ScreensaverGuardianClient(binding, new System.ServiceModel.EndpointAddress("net.pipe://localhost/OxigenService")); client.OpenBrowser(clickThroughURL); } catch (Exception ex) { _logger.WriteError(ex); } finally { if (client != null) { client.Dispose(); } } _logger.WriteTimestampedMessage("web browser opening attempted."); } } }
/// <summary> /// Retuns the newly constructed and configured WCF bindig derived class instance of the specified type. /// </summary> /// <remarks> /// This function might get more important if other WCF bingis are supported. /// All settings to a specific binding shuld be made here. /// All binding are probably not needed. /// </remarks> /// <param name="endPoint">EndPoint entity containig iformation about, what type of binding to return and how to set it.</param> /// <returns>The new configured binding element.</returns> public static System.ServiceModel.Channels.Binding GetWCFBinding(EndPoint endPoint) { if (endPoint.RemotingMechanism == RemotingMechanism.TcpBinary) { return(null); } System.ServiceModel.Channels.Binding ret = null; WCFBinding bindingEnum = endPoint.Binding; switch (bindingEnum) { #region BasicHttpBinding case WCFBinding.BasicHttpBinding: { //WARNING: untested code System.ServiceModel.BasicHttpBinding bhb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: bhb = new System.ServiceModel.BasicHttpBinding(); bhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; bhb.MaxReceivedMessageSize = Int32.MaxValue; bhb.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: bhb = new System.ServiceModel.BasicHttpBinding(endPoint.BindingConfigurationName); break; } ret = bhb; break; } #endregion #region MsmqIntegrationBinding case WCFBinding.MsmqIntegrationBinding: { //WARNING: untested code System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding mib = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: mib = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding(); mib.Security.Mode = System.ServiceModel.MsmqIntegration.MsmqIntegrationSecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: mib = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding(endPoint.BindingConfigurationName); break; } ret = mib; break; } #endregion #region NetMsmqBinding case WCFBinding.NetMsmqBinding: { //WARNING: untested code System.ServiceModel.NetMsmqBinding nmb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: nmb = new System.ServiceModel.NetMsmqBinding(); nmb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; nmb.Security.Mode = System.ServiceModel.NetMsmqSecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: nmb = new System.ServiceModel.NetMsmqBinding(endPoint.BindingConfigurationName); break; } ret = nmb; break; } #endregion #region NetNamedPipeBinding case WCFBinding.NetNamedPipeBinding: { //WARNING: untested code System.ServiceModel.NetNamedPipeBinding nnpb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: nnpb = new System.ServiceModel.NetNamedPipeBinding(); nnpb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; nnpb.Security.Mode = System.ServiceModel.NetNamedPipeSecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: nnpb = new System.ServiceModel.NetNamedPipeBinding(endPoint.BindingConfigurationName); break; } ret = nnpb; break; } #endregion #region NetPeerTcpBinding case WCFBinding.NetPeerTcpBinding: { //WARNING: untested code System.ServiceModel.NetPeerTcpBinding nptb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: nptb = new System.ServiceModel.NetPeerTcpBinding(); nptb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; nptb.Security.Mode = System.ServiceModel.SecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: nptb = new System.ServiceModel.NetPeerTcpBinding(endPoint.BindingConfigurationName); break; } ret = nptb; break; } #endregion #region NetTcpBinding case WCFBinding.NetTcpBinding: { System.ServiceModel.NetTcpBinding ntb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: ntb = new System.ServiceModel.NetTcpBinding(); ntb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; ntb.MaxReceivedMessageSize = Int32.MaxValue; ntb.Security.Mode = System.ServiceModel.SecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: ntb = new System.ServiceModel.NetTcpBinding(endPoint.BindingConfigurationName); break; } ret = ntb; break; } #endregion #region WSDualHttpBinding case WCFBinding.WSDualHttpBinding: { //WARNING: untested code System.ServiceModel.WSDualHttpBinding wdhb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: wdhb = new System.ServiceModel.WSDualHttpBinding(); wdhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; wdhb.Security.Mode = System.ServiceModel.WSDualHttpSecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: wdhb = new System.ServiceModel.WSDualHttpBinding(endPoint.BindingConfigurationName); break; } ret = wdhb; break; } #endregion #region WSFederationHttpBinding case WCFBinding.WSFederationHttpBinding: { //WARNING: untested code System.ServiceModel.WSFederationHttpBinding wfhb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: wfhb = new System.ServiceModel.WSFederationHttpBinding(); wfhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; break; case WCFBindingSettingType.UseConfigFile: wfhb = new System.ServiceModel.WSFederationHttpBinding(endPoint.BindingConfigurationName); break; } ret = wfhb; break; } #endregion #region WSHttpBinding case WCFBinding.WSHttpBinding: { System.ServiceModel.WSHttpBinding whb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: whb = new System.ServiceModel.WSHttpBinding(); whb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; whb.MaxReceivedMessageSize = Int32.MaxValue; whb.Security.Mode = System.ServiceModel.SecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: whb = new System.ServiceModel.WSHttpBinding(endPoint.BindingConfigurationName); break; } ret = whb; break; } #endregion } return(ret); }
/// <summary> /// Retuns the newly constructed and configured WCF bindig derived class instance of the specified type. /// </summary> /// <remarks> /// This function might get more important if other WCF bingis are supported. /// All settings to a specific binding shuld be made here. /// All binding are probably not needed. /// </remarks> /// <param name="endPoint">EndPoint entity containig iformation about, what type of binding to return and how to set it.</param> /// <returns>The new configured binding element.</returns> public static System.ServiceModel.Channels.Binding GetWCFBinding(EndPoint endPoint) { if (endPoint.RemotingMechanism == RemotingMechanism.TcpBinary) return null; System.ServiceModel.Channels.Binding ret = null; WCFBinding bindingEnum = endPoint.Binding; switch (bindingEnum) { #region BasicHttpBinding case WCFBinding.BasicHttpBinding: { //WARNING: untested code System.ServiceModel.BasicHttpBinding bhb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: bhb = new System.ServiceModel.BasicHttpBinding(); bhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; bhb.MaxReceivedMessageSize = Int32.MaxValue; bhb.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: bhb = new System.ServiceModel.BasicHttpBinding(endPoint.BindingConfigurationName); break; } ret = bhb; break; } #endregion #region MsmqIntegrationBinding case WCFBinding.MsmqIntegrationBinding: { //WARNING: untested code System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding mib = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: mib = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding(); mib.Security.Mode = System.ServiceModel.MsmqIntegration.MsmqIntegrationSecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: mib = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding(endPoint.BindingConfigurationName); break; } ret = mib; break; } #endregion #region NetMsmqBinding case WCFBinding.NetMsmqBinding: { //WARNING: untested code System.ServiceModel.NetMsmqBinding nmb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: nmb = new System.ServiceModel.NetMsmqBinding(); nmb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; nmb.Security.Mode = System.ServiceModel.NetMsmqSecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: nmb = new System.ServiceModel.NetMsmqBinding(endPoint.BindingConfigurationName); break; } ret = nmb; break; } #endregion #region NetNamedPipeBinding case WCFBinding.NetNamedPipeBinding: { //WARNING: untested code System.ServiceModel.NetNamedPipeBinding nnpb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: nnpb = new System.ServiceModel.NetNamedPipeBinding(); nnpb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; nnpb.Security.Mode = System.ServiceModel.NetNamedPipeSecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: nnpb = new System.ServiceModel.NetNamedPipeBinding(endPoint.BindingConfigurationName); break; } ret = nnpb; break; } #endregion #region NetPeerTcpBinding case WCFBinding.NetPeerTcpBinding: { //WARNING: untested code System.ServiceModel.NetPeerTcpBinding nptb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: nptb = new System.ServiceModel.NetPeerTcpBinding(); nptb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; nptb.Security.Mode = System.ServiceModel.SecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: nptb = new System.ServiceModel.NetPeerTcpBinding(endPoint.BindingConfigurationName); break; } ret = nptb; break; } #endregion #region NetTcpBinding case WCFBinding.NetTcpBinding: { System.ServiceModel.NetTcpBinding ntb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: ntb = new System.ServiceModel.NetTcpBinding(); ntb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; ntb.MaxReceivedMessageSize = Int32.MaxValue; ntb.Security.Mode = System.ServiceModel.SecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: ntb = new System.ServiceModel.NetTcpBinding(endPoint.BindingConfigurationName); break; } ret = ntb; break; } #endregion #region WSDualHttpBinding case WCFBinding.WSDualHttpBinding: { //WARNING: untested code System.ServiceModel.WSDualHttpBinding wdhb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: wdhb = new System.ServiceModel.WSDualHttpBinding(); wdhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; wdhb.Security.Mode = System.ServiceModel.WSDualHttpSecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: wdhb = new System.ServiceModel.WSDualHttpBinding(endPoint.BindingConfigurationName); break; } ret = wdhb; break; } #endregion #region WSFederationHttpBinding case WCFBinding.WSFederationHttpBinding: { //WARNING: untested code System.ServiceModel.WSFederationHttpBinding wfhb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: wfhb = new System.ServiceModel.WSFederationHttpBinding(); wfhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; break; case WCFBindingSettingType.UseConfigFile: wfhb = new System.ServiceModel.WSFederationHttpBinding(endPoint.BindingConfigurationName); break; } ret = wfhb; break; } #endregion #region WSHttpBinding case WCFBinding.WSHttpBinding: { System.ServiceModel.WSHttpBinding whb = null; switch (endPoint.BindingSettingType) { case WCFBindingSettingType.Default: whb = new System.ServiceModel.WSHttpBinding(); whb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; whb.MaxReceivedMessageSize = Int32.MaxValue; whb.Security.Mode = System.ServiceModel.SecurityMode.None; break; case WCFBindingSettingType.UseConfigFile: whb = new System.ServiceModel.WSHttpBinding(endPoint.BindingConfigurationName); break; } ret = whb; break; } #endregion } return ret; }
private void FinishRunHosts(Udbus.v4v.v4vConnection connection, Udbus.Core.ServiceConnectionParams serviceConnectionParams) { this.connection = connection; this.serviceConnectionParams = serviceConnectionParams; log.Info("Connection helloed with name {0} and signalName {1}", serviceConnectionParams.Name, serviceConnectionParams.SignalName); System.Uri uriBase = new System.Uri(Udbus.WCF.Constants.BaseAddress); new Udbus.WCF.Service.Host.Init.InitHostMakerRegistry(); new global::XenClientGuestService.wcf.Hosts.Init.InitHostMakerRegistry(); Udbus.WCF.Service.Host.RegistryDictionaryHolder registry = Udbus.WCF.Service.Host.HostMakerRegistry.RegistryDictionaryClone; log.Info("Launching hosts..."); // Build all hosts including "special" properties host. ICollection<Udbus.WCF.Service.Host.ServiceHostCreationData> hostdata = Udbus.WCF.Service.Host.HostMakerRegistry.BuildAllHosts( registry.Values , new Udbus.WCF.Host.WCFServiceParams(serviceConnectionParams) , new Uri[] { uriBase } ); System.ServiceModel.NetNamedPipeBinding namedpipeBinding = new System.ServiceModel.NetNamedPipeBinding(); System.ServiceModel.Channels.Binding binding = namedpipeBinding; binding.SendTimeout = TimeSpan.MaxValue; binding.ReceiveTimeout = TimeSpan.MaxValue; foreach (Udbus.WCF.Service.Host.ServiceHostCreationData host in hostdata) { host.Host.AddServiceEndpoint(host.CreationParams.ContractType, binding, host.CreationParams.RelativeName); } this.hosts = hostdata.Select<Udbus.WCF.Service.Host.ServiceHostCreationData, System.ServiceModel.ServiceHost>(Udbus.WCF.Service.Host.ServiceHostCreationData.DataToHost); DbusUtils.RunHosts(hosts); this.threadInfo = RunSignalsAsync(out this.threadSignalLoop, serviceConnectionParams); }