public ServiceConfig(ServiceConfig config)
        {
            ServiceUuid = config.ServiceUuid;
            connected = config.connected;
            wasConnected = config.wasConnected;
            LastDetected = config.LastDetected;

            listener = config.listener;
        }
        public NetcastTvService(ServiceDescription serviceDescription, ServiceConfig serviceConfig)
            : base(serviceDescription, serviceConfig)
        {
            dlnaService = new DlnaService(serviceDescription, serviceConfig);

            if (serviceDescription != null && serviceDescription.Port != 8080)
                serviceDescription.Port = 8080;

            applications = new List<AppInfo>();
            subscriptions = new List<IServiceSubscription>();

            keyboardstring = new StringBuilder();

            httpClient = new HttpClient();
            inputPickerSession = null;
        }
 public void OnServiceConfigUpdate(ServiceConfig serviceConfig)
 {
     if (connectableDeviceStore == null)
     {
         return;
     }
     foreach (ConnectableDevice device in allDevices.Values)
     {
         if (null != device.GetServiceWithUuid(serviceConfig.ServiceUuid))
         {
             connectableDeviceStore.UpdateDevice(device);
         }
     }
 }
        public void AddServiceDescriptionToDevice(ServiceDescription desc, ConnectableDevice device)
        {
            Logger.Current.AddMessage(string.Format("Adding service: {0} to device with address {1} and id {2}", desc.ServiceId, device.IpAddress, device.Id));
            var deviceServiceClass = deviceClasses[desc.ServiceId];

            if (deviceServiceClass == null)
                return;

            if (deviceServiceClass == typeof (DlnaService))
            {
                if (desc.LocationXml == null)
                    return;
            }
            else if (deviceServiceClass == typeof (NetcastTvService))
            {
                if (!IsNetcast(desc))
                    return;
            }

            ServiceConfig serviceConfig = null;

            if (connectableDeviceStore != null)
                serviceConfig = connectableDeviceStore.GetServiceConfig(desc);

            if (serviceConfig == null)
                serviceConfig = new ServiceConfig(desc);

            serviceConfig.Listener = this;

            var hasType = false;
            var hasService = false;

            foreach (DeviceService service in device.Services)
            {
                if (!service.ServiceDescription.ServiceId.Equals(desc.ServiceId)) continue;
                hasType = true;
                if (service.ServiceDescription.Uuid.Equals(desc.Uuid))
                {
                    hasService = true;
                }
                break;
            }

            if (hasType)
            {
                if (hasService)
                {
                    device.ServiceDescription = desc;

                    var alreadyAddedService = device.GetServiceByName(desc.ServiceId);

                    if (alreadyAddedService != null)
                        alreadyAddedService.SetServiceDescription(desc);

                    return;
                }

                device.RemoveServiceByName(desc.ServiceId);
            }

            var deviceService = DeviceService.GetService(deviceServiceClass, desc, serviceConfig);

            if (deviceService == null) return;

            deviceService.SetServiceDescription(desc);
            device.AddService(deviceService);

            //    Type deviceServiceClass;

            //    if (IsNetcast(desc))
            //    {
            //        deviceServiceClass = typeof(NetcastTvService);
            //        var m = deviceServiceClass.GetRuntimeMethod("discoveryParameters", new Type[] { });
            //        var result = m.Invoke(null, new object[0]);

            //        if (result == null)
            //            return;

            //        var discoveryParameters = (JsonObject)result;
            //        var serviceId = discoveryParameters.GetNamedString("serviceId");

            //        if (serviceId.Length == 0)
            //            return;

            //        desc.ServiceId = serviceId;
            //    }
            //    else
            //    {
            //        deviceServiceClass = deviceClasses[desc.ServiceId];
            //    }

            //    if (deviceServiceClass == null)
            //        return;

            //    if (typeof(DlnaService) == deviceServiceClass)
            //    {
            //        const string netcast = "netcast";
            //        const string webos = "webos";

            //        var locNet = desc.LocationXml.IndexOf(netcast, StringComparison.Ordinal);
            //        var locWeb = desc.LocationXml.IndexOf(webos, StringComparison.Ordinal);

            //        if (locNet == -1 && locWeb == -1)
            //            return;
            //    }

            //    var serviceConfig = new ServiceConfig(desc) {Listener = this};

            //    var hasType = false;
            //    var hasService = false;

            //    foreach (var service in device.GetServices().Where(service => service.ServiceDescription.ServiceId.Equals(desc.ServiceId)))
            //    {
            //        hasType = true;
            //        if (service.ServiceDescription.Uuid.Equals(desc.Uuid))
            //        {
            //            hasService = true;
            //        }
            //        break;
            //    }

            //    if (hasType)
            //    {
            //        if (hasService)
            //        {
            //            device.SetServiceDescription(desc);

            //            var alreadyAddedService = device.GetServiceByName(desc.ServiceId);

            //            if (alreadyAddedService != null)
            //                alreadyAddedService.ServiceDescription = desc;

            //            return;
            //        }

            //        device.RemoveServiceByName(desc.ServiceId);
            //    }

            //    var deviceService = DeviceService.GetService(deviceServiceClass, desc, serviceConfig);
            //    deviceService.ServiceDescription = desc;
            //    device.AddService(deviceService);
            //}
        }
 public WebOstvService(ServiceDescription serviceDescription, ServiceConfig serviceConfig)
     : base(serviceDescription, serviceConfig)
 {
     AppToAppIdMappings = new Dictionary<String, String>();
     WebAppSessions = new Dictionary<String, WebOsWebAppSession>();
 }
 public WebOstvService(ServiceConfig serviceConfig)
     : base(serviceConfig)
 {
 }
 public DlnaService(ServiceDescription serviceDescription, ServiceConfig serviceConfig, string controlUrl)
     : base(serviceDescription, serviceConfig)
 {
     this.controlUrl = controlUrl;
 }
 public DlnaService(ServiceDescription serviceDescription, ServiceConfig serviceConfig)
     : base(serviceDescription, serviceConfig)
 {
     UpdateControlUrl(serviceDescription);
     httpServer = new DlnaHttpServer();
 }