Exemplo n.º 1
0
        public ProviderLights(Device.DvDevice aDevice, int aMode)
            : base(aDevice)
        {
            EnableActionGetCount();
            EnableActionGetRoom();
            EnableActionGetName();
            EnableActionGetPosition();
            EnableActionSetColor();
            EnableActionGetColor();
            EnableActionGetColorComponents();

            iLights = new List <Light>();

            switch (aMode)
            {
            case 1:
                InitMode1();
                break;

            case 2:
                InitMode2();
                break;

            case 3:
                InitMode3();
                break;

            default:
                Debug.Assert(false);
                break;
            }
        }
Exemplo n.º 2
0
        public ProviderTestBasic(DvDevice aDevice)
            : base(aDevice)
        {
            EnablePropertyVarUint();
            EnablePropertyVarInt();
            EnablePropertyVarBool();
            EnablePropertyVarStr();
            EnablePropertyVarBin();
            SetPropertyVarUint(0);
            SetPropertyVarInt(0);
            SetPropertyVarBool(false);
            string empty = "";
            byte[] emptyBinary = new byte[0];
            SetPropertyVarStr(empty);
            SetPropertyVarBin(emptyBinary);

            EnableActionIncrement();
            EnableActionDecrement();
            EnableActionToggle();
            EnableActionEchoString();
            EnableActionEchoBinary();
            EnableActionSetUint();
            EnableActionGetUint();
            EnableActionSetInt();
            EnableActionGetInt();
            EnableActionSetBool();
            EnableActionGetBool();
            EnableActionSetString();
            EnableActionGetString();
            EnableActionSetBinary();
            EnableActionGetBinary();
            EnableActionSetMultiple();
        }
Exemplo n.º 3
0
        public ProviderRemoteAccess(DvDevice aDevice, string aStoreDir, string aWebServiceHostName, ProxyServer aProxyServer, string aNetworkAdapter)
            : base(aDevice)
        {
            iDeviceUdn = aDevice.Udn();
            iStoreDir = aStoreDir;
            iWebServiceHostName = (aWebServiceHostName ?? kDefaultWebServiceAddress);
            if (!iWebServiceHostName.StartsWith("https://"))
                iWebServiceHostName = "https://" + iWebServiceHostName;
            if (!iWebServiceHostName.EndsWith("/"))
                iWebServiceHostName += "/";
            iProxyServer = aProxyServer;
            iNetworkAdapter = aNetworkAdapter;
            iThread = new Thread(RunThread);
            iCommands = new List<QueuedCommand>();
            iCommandSem = new Semaphore(0, Int32.MaxValue);
            iThread.Start(this);
            iConnectionCheckTimer = new System.Timers.Timer { AutoReset = true, Enabled = false, Interval = kConnectionCheckIntervalMs };
            iConnectionCheckTimer.Elapsed += CheckConnection;
            ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

            EnablePropertyUserName();
            EnablePropertyPublicUri();
            EnablePropertyEnabled();
            EnablePropertyPasswordSet();
            EnableActionSetUserName();
            EnableActionSetPassword();
            EnableActionReset();
            EnableActionEnable();
            EnableActionClearAuthenticatedClients();

            string userDataFileName = FileFullName(kFileUserData);
            if (!File.Exists(userDataFileName))
                WriteUserData(false, "", "", "");
            string xml = File.ReadAllText(userDataFileName, Encoding.UTF8);
            XElement tree = XElement.Parse(xml);
            bool enabled = Convert.ToBoolean(tree.Element(kTagEnabled).Value);
            string userName = tree.Element(kTagUserName).Value;
            iPassword = tree.Element(kTagPassword).Value;
            string publicUrl = tree.Element(kTagPublicUrl).Value;

            SetPropertyUserName(userName);
            SetPropertyPublicUri(publicUrl);
            SetPropertyEnabled(enabled);
            SetPropertyPasswordSet((iPassword.Length > 0));

            if (enabled)
            {
                try
                {
                    Start();
                }
                catch (Exception e)
                {
                    Logger.ErrorFormat("Start failed: {0}", e.Message);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="aDevice">Device the service is being added to and will be offered by</param>
        /// <param name="aDomain">Domain of the vendor who defined the service</param>
        /// <param name="aType">Name of the service</param>
        /// <param name="aVersion">Version number of the service</param>
        protected DvProvider(DvDevice aDevice, String aDomain, String aType, uint aVersion)
        {
            IntPtr domain = InteropUtils.StringToHGlobalUtf8(aDomain);
            IntPtr type   = InteropUtils.StringToHGlobalUtf8(aType);

            iHandle = DvProviderCreate(aDevice.Handle(), domain, type, aVersion);
            Marshal.FreeHGlobal(type);
            Marshal.FreeHGlobal(domain);
            iActions    = new List <OpenHome.Net.Core.Action>();
            iProperties = new List <OpenHome.Net.Core.Property>();
        }
Exemplo n.º 5
0
 public AppListService(DvDevice aDevice, IAppShell aAppShell)
 {
     iDevice = aDevice;
     iProvider = new AppListProvider(iDevice);
     iDevice.SetEnabled();
     iCallbackTracker = new SafeCallbackTracker();
     iHandler = iCallbackTracker.Create<AppStatusChangeEventArgs>(OnAppStatusChanged);
     iAppShell = aAppShell;
     iAppShell.AppStatusChanged += iHandler;
     OnAppStatusChanged(this, new AppStatusChangeEventArgs());
 }
Exemplo n.º 6
0
 public AppController(string aUdn)
 {
     iDevice = new DvDeviceStandard(aUdn);
     // Set initial values for the attributes mandated by UPnP
     iDevice.SetAttribute("Upnp.Domain", "openhome.org");
     iDevice.SetAttribute("Upnp.Type", "AppManager");
     iDevice.SetAttribute("Upnp.Version", "1");
     iDevice.SetAttribute("Upnp.FriendlyName", "OpenHome App AppShell");
     iDevice.SetAttribute("Upnp.Manufacturer", "N/A");
     iDevice.SetAttribute("Upnp.ModelName", "OpenHome App AppShell");
     iProvider = new AppManagerProvider(iDevice);
     iDevice.SetEnabled();
 }
Exemplo n.º 7
0
 public ProviderApp(DvDevice aDevice, string aHostUdn, string aHostResourceUri, string aAppName, string aIconUri, string aDescriptionUri)
     : base(aDevice)
 {
     EnablePropertyName();
     EnablePropertyIconUri();
     EnablePropertyDescriptionUri();
     EnableActionGetName();
     EnableActionGetIconUri();
     EnableActionGetDescriptionUri();
     EnableActionGetHostDevice();
     SetPropertyName(aAppName);
     SetPropertyIconUri(aIconUri);
     SetPropertyDescriptionUri(aDescriptionUri);
     iHostUdn = aHostUdn;
     iHostResourceUri = aHostResourceUri;
 }
Exemplo n.º 8
0
 public ProviderNode(DvDevice aDevice, ISystemClockProvider aSystemClockProvider, ILogControlProvider aLogControlProvider)
     : base(aDevice)
 {
     EnableActionWriteFile();
     EnableActionGetAvailableTimeZones();
     EnableActionGetTime();
     EnableActionSetTimeZone();
     EnableActionSetUtcTime();
     EnableActionGetRecentLog();
     EnableActionGetLogLevelsXml();
     EnableActionSetLogLevelsXml();
     EnablePropertyTimeSequenceNumber();
     EnablePropertyTimeSequenceNumber();
     SetPropertyTimeSequenceNumber(0);
     iSystemClockProvider = aSystemClockProvider;
     iLogControlProvider = aLogControlProvider;
 }
Exemplo n.º 9
0
 public AppContext(
     IAppServices aServices,
     string aStaticPath,
     string aStorePath,
     IConfigFileCollection aConfiguration,
     DvDevice aDevice,
     string aAppName,
     IXappServer aXappServer
     )
 {
     iXappServer = aXappServer;
     Services = aServices;
     StaticPath = aStaticPath;
     StorePath = aStorePath;
     Configuration = aConfiguration;
     Device = aDevice;
     Name = aAppName;
 }
Exemplo n.º 10
0
 public AppManagerProvider(DvDevice aDevice, IAppManagerActionHandler aProvider, string aPresentationUri)
     : base(aDevice)
 {
     EnablePropertyDownloadCount();
     EnablePropertyAppHandleArray();
     EnablePropertyAppSequenceNumberArray();
     EnableActionGetAppStatus();
     EnableActionGetMultipleAppsStatus();
     EnableActionGetAllDownloadsStatus();
     EnableActionInstallAppFromUrl();
     EnableActionRemoveApp();
     EnableActionCancelDownload();
     EnableActionUpdateApp();
     EnableActionGetPresentationUri();
     SetPropertyDownloadCount(0);
     SetPropertyAppHandleArray(Converter.ConvertUintListToNetworkOrderByteArray(new List<uint>()));
     SetPropertyAppSequenceNumberArray(Converter.ConvertUintListToNetworkOrderByteArray(new List<uint>()));
     //BumpDummySequenceNumber();
     iProvider = aProvider;
     iPresentationUri = aPresentationUri;
 }
Exemplo n.º 11
0
 public CpDvDevicePresencePublisher(DvDevice aDvDevice, IDevicePresenceListener aListener)
 {
     iDvDevice = aDvDevice;
     iListener = aListener;
 }
Exemplo n.º 12
0
 public AppListProvider(DvDevice aDevice)
     : base(aDevice)
 {
     EnablePropertyRunningAppList();
     SetPropertyRunningAppList("<runningAppList />");
 }
Exemplo n.º 13
0
        public ProviderSystemUpdate(DvDevice aDevice, IUpdateService aUpdateService, string aDfltConfigFile, string aUserConfigFile)
            : base(aDevice)
        {
            iLogger = LogManager.GetLogger(typeof(ProviderSystemUpdate));

            stateTable = new StringCollection();
            stateTable.AddRange(StateNames);

            EnablePropertyState();
            EnablePropertyProgress();
            EnablePropertyServer();
            EnablePropertyChannel();
            EnablePropertyLastError();
            EnablePropertyAutoUpdate();

            EnableActionCheckForUpdate();
            EnableActionDownloadUpdate();
            EnableActionDoUpdate();
            EnableActionCancelUpdate();
            EnableActionSetSourceInfo();
            EnableActionReboot();
            EnableActionSetAutoUpdate();

            SetPropertyProgress(0);
            SetLastError("Service created OK");

            iUpdateService = aUpdateService;

            /* Set default values */
            CurrentState = kStateIdle;
            SetPropertyServer(aUpdateService.Server);
            SetPropertyChannel(aUpdateService.Channel);
            SetPropertyAutoUpdate(true);

            /* Read the default config file first, if it exists */
            if (aDfltConfigFile != null)
            {
                string file = aDfltConfigFile; // Path.Combine(aDfltConfigDir, kStorageFileName);
                try
                {
                    LoadConfig(file);
                }
                catch (FileNotFoundException)
                {
                    iLogger.Info("Default config file '" + file + "' not found. Using hard-coded values ...");
                }
                catch (DirectoryNotFoundException)
                {
                    iLogger.Info("Default config file '" + file + "' not found. Using hard-coded values ...");
                }
            }

            /* Then try to read the user config file */
            if (aUserConfigFile != null)
            {
                userConfigFile = aUserConfigFile; // Path.Combine(aUserConfigDir, kStorageFileName);
                try
                {
                    LoadConfig(userConfigFile, out userConfigXml);
                }
                catch (FileNotFoundException)
                {
                    iLogger.Info("User config file '" + userConfigFile + "' not found. Using defaults ...");
                }
                catch (DirectoryNotFoundException)
                {
                    iLogger.Info("User config file '" + userConfigFile + "' not found. Using defaults ...");
                }
            }

            if (userConfigXml == null)
            {
                userConfigXml = new XElement("SystemUpdate");
            }

            /* If the state read from the config file was UpdateAvailable then we set it
             * to Idle. The service will notify us if an update is still available.
             * If the state was RebootNeeded then this is our first reboot after a software update
             */
            if ( (CurrentState == kStateUpdateAvailable) || (CurrentState == kStateRebootNeeded))
            {
                CurrentState = kStateIdle;
            }

            UpdateUserConfig("State", PropertyState());

            autoUpdateTimer = new Timer(OnAutoUpdateTimer);

            iUpdateService.Server = PropertyServer();
            iUpdateService.Channel = PropertyChannel();

            iUpdateService.UpdateEventHandler += HandleUpdateEvent;

            /* If we are in Idle state then start the service */
            if (CurrentState == kStateIdle)
            {
                iUpdateService.Start();
            }

            /* If autoupdate is on and an update has been downloaded then
             * kick-off the timer to apply it */
            if (PropertyAutoUpdate() && (CurrentState == kStateUpdateDownloaded))
            {
                autoUpdateTimer.Change(kAutoUpdateDelay, Timeout.Infinite);
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// Instruct a device to publish itself using (only) this server.
 /// </summary>
 /// <param name="aDevice"></param>
 public void AddDevice(DvDevice aDevice)
 {
     DvServerUpnpAddDevice(iHandle, aDevice.Handle());
 }
Exemplo n.º 15
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="aDevice">Device the service is being added to and will be offered by</param>
 /// <param name="aDomain">Domain of the vendor who defined the service</param>
 /// <param name="aType">Name of the service</param>
 /// <param name="aVersion">Version number of the service</param>
 protected unsafe DvProvider(DvDevice aDevice, String aDomain, String aType, uint aVersion)
 {
     IntPtr domain = InteropUtils.StringToHGlobalUtf8(aDomain);
     IntPtr type = InteropUtils.StringToHGlobalUtf8(aType);
     iHandle = DvProviderCreate(aDevice.Handle(), domain, type, aVersion);
     Marshal.FreeHGlobal(type);
     Marshal.FreeHGlobal(domain);
     iActions = new List<OpenHome.Net.Core.Action>();
     iProperties = new List<OpenHome.Net.Core.Property>();
 }
Exemplo n.º 16
0
 /// <summary>
 /// Instruct a device to publish itself using (only) this server.
 /// </summary>
 /// <param name="aDevice"></param>
 public void AddDevice(DvDevice aDevice)
 {
     DvServerUpnpAddDevice(iHandle, aDevice.Handle());
 }
Exemplo n.º 17
0
        public AppManagerProvider(DvDevice aDevice)
            : base(aDevice)
        {
            EnablePropertyAppHandleArray();
            EnablePropertyAppSequenceNumberArray();
            // TODO: Initialize handle array.
            // TODO: Initialize seqno array.

            EnableActionGetAppStatus();
            EnableActionGetMultipleAppsStatus();
            EnableActionGetAllDownloadsStatus();
            EnableActionInstallAppFromUrl();
            EnableActionRemoveApp();
            EnableActionCancelDownload();
            EnableActionUpdateApp();
            SetPropertyAppHandleArray(Platform.Converter.ConvertUintListToNetworkOrderByteArray(new List<uint> { DummyAppId }));
            BumpDummySequenceNumber();
        }