Exemplo n.º 1
0
 public static void ApplicationStop()
 {
     try
     {
         IrssLog.Info("Stopping IR Server (application)");
         IntPtr irssWindow = Win32.FindWindowByTitle(ServerWindowName);
         IntPtr result     = Win32.SendWindowsMessage(irssWindow, 16, 0, 0);
         waitCount = 0;
         while (Win32.FindWindowByTitle(ServerWindowName) != IntPtr.Zero)
         {
             waitCount++;
             if (waitCount > 150)
             {
                 throw new TimeoutException();
             }
             Thread.Sleep(200);
         }
         IrssLog.Info("Stopping IR Server (application) - done");
     }
     catch (TimeoutException ex)
     {
         IrssLog.Error("Stopping IR Server (application) - failed (timeout error)");
         IrssLog.Error(ex);
     }
     catch (Exception ex)
     {
         IrssLog.Error("Stopping IR Server (application) - failed (see following...)");
         IrssLog.Error(ex);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Retreives a list of detected Receiver plugins.
        /// </summary>
        /// <returns>String array of plugin names.</returns>
        public static string[] DetectReceivers()
        {
            IrssLog.Info("Detect Receivers ...");

            PluginBase[] plugins = BasicFunctions.AvailablePlugins();
            if (plugins == null || plugins.Length == 0)
            {
                return(null);
            }

            List <string> receivers = new List <string>();

            foreach (PluginBase plugin in plugins)
            {
                try
                {
                    if ((plugin is IRemoteReceiver || plugin is IKeyboardReceiver || plugin is IMouseReceiver) && plugin.Detect() == PluginBase.DetectionResult.DevicePresent)
                    {
                        receivers.Add(plugin.Name);
                    }
                }
                catch (Exception ex)
                {
                    IrssLog.Error(ex);
                }
            }

            if (receivers.Count > 0)
            {
                return(receivers.ToArray());
            }

            return(null);
        }
Exemplo n.º 3
0
 public static void ApplicationStart()
 {
     try
     {
         IrssLog.Info("Starting IR Server (application)");
         Process IRServer = Process.Start(IRServerFile);
         waitCount = 0;
         while (Win32.FindWindowByTitle(Shared.ServerWindowName) == IntPtr.Zero)
         {
             waitCount++;
             if (waitCount > 150)
             {
                 throw new TimeoutException();
             }
             Thread.Sleep(200);
         }
         IrssLog.Info("Starting IR Server (application) - done");
     }
     catch (TimeoutException ex)
     {
         IrssLog.Error("Starting IR Server (application) - failed (timeout error)");
         IrssLog.Error(ex);
     }
     catch (Exception ex)
     {
         IrssLog.Error("Starting IR Server (application) - failed (see following...)");
         IrssLog.Error(ex);
     }
 }
Exemplo n.º 4
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            string name = textBoxName.Text.Trim();

            if (name.Length == 0)
            {
                MessageBox.Show(this, "You must supply a name for this Macro", "Name missing", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                textBoxName.Focus();
                return;
            }

            if (!Common.IsValidFileName(name))
            {
                MessageBox.Show(this, "You must supply a valid name for this Macro", "Invalid name", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                textBoxName.Focus();
                return;
            }

            try
            {
                string fileName = Path.Combine(Tray.FolderMacros, name + Common.FileExtensionMacro);
                WriteToFile(fileName);
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
                MessageBox.Show(this, ex.Message, "Failed writing macro to file", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            DialogResult = DialogResult.OK;
            Close();
        }
Exemplo n.º 5
0
        private void buttonTest_Click(object sender, EventArgs e)
        {
            string name = textBoxName.Text.Trim();

            if (name.Length == 0)
            {
                MessageBox.Show(this, "You must supply a name for this Macro", "Name missing", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                textBoxName.Focus();
                return;
            }

            if (!Common.IsValidFileName(name))
            {
                MessageBox.Show(this, "You must supply a valid name for this Macro", "Invalid name", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                textBoxName.Focus();
                return;
            }

            try
            {
                string fileName = Path.Combine(Tray.FolderMacros, name + Common.FileExtensionMacro);
                WriteToFile(fileName);

                Tray.ProcessCommand(Common.CmdPrefixMacro + name, false);
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
                MessageBox.Show(this, ex.Message, "Test failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Retreives a list of detected Blaster plugins.
        /// </summary>
        /// <returns>String array of plugin names.</returns>
        public static string[] DetectBlasters()
        {
            IrssLog.Info("Detect Blasters ...");

            PluginBase[] plugins = BasicFunctions.AvailablePlugins();
            if (plugins == null || plugins.Length == 0)
            {
                return(null);
            }

            List <string> blasters = new List <string>();

            foreach (PluginBase plugin in plugins)
            {
                try
                {
                    if (plugin is ITransmitIR && plugin.Detect() == PluginBase.DetectionResult.DevicePresent)
                    {
                        blasters.Add(plugin.Name);
                    }
                }
                catch (Exception ex)
                {
                    IrssLog.Error(ex);
                }
            }

            if (blasters.Count > 0)
            {
                return(blasters.ToArray());
            }

            return(null);
        }
Exemplo n.º 7
0
        private void LoadSettings()
        {
            try
            {
                _autoRun = SystemRegistry.GetAutoRun("Media Center Blaster");
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);

                _autoRun = false;
            }

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(ConfigurationFile);

                _serverHost = doc.DocumentElement.Attributes["ServerHost"].Value;
            }
            catch (FileNotFoundException)
            {
                IrssLog.Warn("Configuration file not found, using defaults");

                CreateDefaultSettings();
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);

                CreateDefaultSettings();
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Detect the presence of this device.
        /// </summary>
        public override DetectionResult Detect()
        {
            try
            {
                new X10Interface();
                return(DetectionResult.DevicePresent);
            }
            catch (COMException ex)
            {
                if (ex.ErrorCode == -2147221164)
                {
                    IrssLog.Warn("{0,15}: needed interface not found", Name);
                }
                else
                {
                    IrssLog.Debug("{0,15}: exception {1}", Name, ex.ErrorCode);
                    return(DetectionResult.DeviceException);
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error("{0,15}: exception {1} type: {2}", Name, ex.Message, ex.GetType());
                return(DetectionResult.DeviceException);
            }

            return(DetectionResult.DeviceNotFound);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Detect the presence of this device.
        /// </summary>
        public override DetectionResult Detect()
        {
            try
            {
                SafeFileHandle deviceHandle = CreateFile(DevicePath,
                                                         CreateFileAccessTypes.GenericRead | CreateFileAccessTypes.GenericWrite,
                                                         CreateFileShares.Read | CreateFileShares.Write, IntPtr.Zero,
                                                         CreateFileDisposition.OpenExisting, CreateFileAttributes.Normal,
                                                         IntPtr.Zero);
                int lastError = Marshal.GetLastWin32Error();

                if (!deviceHandle.IsInvalid)
                {
                    deviceHandle.Dispose();
                    return(DetectionResult.DevicePresent);
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error("{0,15}: exception {1}", Name, ex.Message);
                return(DetectionResult.DeviceException);
            }

            return(DetectionResult.DeviceNotFound);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Config"/> class.
        /// </summary>
        public Config()
        {
            InitializeComponent();
            SetIcons();

            IrssLog.Info("Load plugins from " + Application.StartupPath + "...");

            try
            {
                _transceivers = BasicFunctions.AvailablePlugins();
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);

                _transceivers = null;
            }

            if (_transceivers == null || _transceivers.Length == 0)
            {
                MessageBox.Show(this, "No IR Server Plugins found!", "IR Server Configuration", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            else
            {
                CreateGrid();
            }


            LoadSettings();
        }
Exemplo n.º 11
0
        /// <summary>
        /// Invokes the default window procedure associated with this window.
        /// </summary>
        /// <param name="m">A <see cref="T:System.Windows.Forms.Message"></see> that is associated with the current Windows message.</param>
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == (int)Win32.WindowsMessage.WM_COPYDATA)
            {
                IrssLog.Info("Received WM_COPYDATA message");

                try
                {
                    Win32.COPYDATASTRUCT dataStructure = (Win32.COPYDATASTRUCT)m.GetLParam(typeof(Win32.COPYDATASTRUCT));

                    if (dataStructure.dwData != CopyDataID)
                    {
                        IrssLog.Warn("WM_COPYDATA ID ({0}) does not match expected ID ({1})", dataStructure.dwData, CopyDataID);
                        return;
                    }

                    byte[] dataBytes = new byte[dataStructure.cbData];
                    Marshal.Copy(dataStructure.lpData, dataBytes, 0, dataStructure.cbData);
                    string strData = Encoding.ASCII.GetString(dataBytes);

                    Program.ProcessCommand(strData, false);
                }
                catch (Exception ex)
                {
                    IrssLog.Error("Error processing WM_COPYDATA message: {0}", ex.ToString());
                }
            }

            base.WndProc(ref m);
        }
Exemplo n.º 12
0
        private void RunThread()
        {
            try
            {
                _serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                IPEndPoint ipe = new IPEndPoint(IPAddress.Any, _serverPort);
                _serverSocket.Bind(ipe);

                while (true)
                {
                    AcceptConnection();

                    string command = HttpUtility.UrlDecode(GetCommand());

                    if (command.StartsWith("GET", StringComparison.OrdinalIgnoreCase))
                    {
                        string commandElement = GetCommandElement(command);
                        DoGet(commandElement);
                    }

                    _networkStream.Flush();
                    _networkStream.Close();
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
            }
            finally
            {
                _serverSocket.Close();
            }
        }
Exemplo n.º 13
0
        private static void ClickSetup(object sender, EventArgs e)
        {
            IrssLog.Info("Setup");

            _inConfiguration = true;

            if (_webServer != null)
            {
                _webServer.Stop();
                _webServer = null;
            }

            if (Configure())
            {
                ChangeSkin();
            }

            try
            {
                _webServer = new WebServer(_webPort);
                _webServer.Run();
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
                MessageBox.Show(ex.Message, "Web Remote - Setup Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            _inConfiguration = false;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Write the macro in the RichTextBox to a macro name provided.
        /// </summary>
        /// <param name="fileName">Name of Macro to write (macro name, not file path).</param>
        private void WriteToFile(string fileName)
        {
            _macroFile = fileName;

            try
            {
                using (XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.UTF8))
                {
                    writer.Formatting = Formatting.Indented;
                    writer.WriteStartDocument(true);
                    writer.WriteStartElement("macro");

                    foreach (string item in richTextBoxMacro.Lines)
                    {
                        if (String.IsNullOrEmpty(item))
                        {
                            continue;
                        }

                        writer.WriteStartElement("item");
                        writer.WriteAttributeString("command", item);
                        writer.WriteEndElement();
                    }

                    writer.WriteEndElement();
                    writer.WriteEndDocument();
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Detect the presence of this device.
        /// </summary>
        public override DetectionResult Detect()
        {
            try
            {
                Guid guid = new Guid();
                Win32.HidD_GetHidGuid(ref guid);

                string devicePath = FindDevice(guid);

                if (devicePath != null)
                {
                    return(DetectionResult.DevicePresent);
                }
            }
            catch (Win32Exception ex)
            {
                if (ex.NativeErrorCode != 13)
                {
                    IrssLog.Error("{0,15}: exception {1}", Name, ex.NativeErrorCode);
                    return(DetectionResult.DeviceException);
                }
                IrssLog.Debug("{0,15}: exception {1}", Name, ex.NativeErrorCode);
            }
            catch (Exception ex)
            {
                IrssLog.Error("{0,15}: exception {1} type: {2}", Name, ex.Message, ex.GetType());
                return(DetectionResult.DeviceException);
            }

            return(DetectionResult.DeviceNotFound);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Write the macro in the listBox to a macro name provided.
        /// </summary>
        /// <param name="fileName">Name of Macro to write (macro name, not file path).</param>
        private void WriteToFile(string fileName)
        {
            try
            {
                using (XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.UTF8))
                {
                    writer.Formatting = Formatting.Indented;
                    writer.WriteStartDocument(true);
                    writer.WriteStartElement("macro");

                    foreach (string item in listBoxMacro.Items)
                    {
                        writer.WriteStartElement("item");
                        writer.WriteAttributeString("command", item);
                        writer.WriteEndElement();
                    }

                    writer.WriteEndElement();
                    writer.WriteEndDocument();
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
            }
        }
Exemplo n.º 17
0
        private static void SaveSettings()
        {
            try
            {
                using (XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, Encoding.UTF8))
                {
                    writer.Formatting  = Formatting.Indented;
                    writer.Indentation = 1;
                    writer.IndentChar  = (char)9;
                    writer.WriteStartDocument(true);
                    writer.WriteStartElement("settings"); // <settings>

                    writer.WriteAttributeString("ServerHost", _serverHost);
                    writer.WriteAttributeString("RemoteSkin", _remoteSkin);
                    writer.WriteAttributeString("WebPort", _webPort.ToString());
                    //writer.WriteAttributeString("PasswordHash", _passwordHash);

                    writer.WriteEndElement(); // </settings>
                    writer.WriteEndDocument();
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
            }
        }
Exemplo n.º 18
0
        internal static string PostData(string url, string userName, string password, StbBoxType boxType, int timeout,
                                        string command)
        {
            try
            {
                Uri        uri     = new Uri(url + command);
                WebRequest request = WebRequest.Create(uri);
                request.Credentials = new NetworkCredential(userName, password);
                request.Timeout     = timeout;

                // back to iso encoding sorry , should work anywhere in EU
                // which it doesn't, because dreambox use utf-8 encoding, making all UTF-8 extended characters a multibyte garble if we encode those to iso

                Encoding encode = Encoding.GetEncoding("iso-8859-1");
                if (boxType == StbBoxType.EnigmaV1 || boxType == StbBoxType.EnigmaV2)
                {
                    encode = Encoding.GetEncoding("utf-8");
                }

                using (WebResponse response = request.GetResponse())
                    using (Stream receiveStream = response.GetResponseStream())
                        using (StreamReader reader = new StreamReader(receiveStream, encode))
                            return(reader.ReadToEnd());
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);

                return(String.Empty);
            }
        }
Exemplo n.º 19
0
        private static void SaveSettings()
        {
            try
            {
                using (XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, Encoding.UTF8))
                {
                    writer.Formatting  = Formatting.Indented;
                    writer.Indentation = 1;
                    writer.IndentChar  = (char)9;
                    writer.WriteStartDocument(true);
                    writer.WriteStartElement("settings"); // <settings>

                    writer.WriteAttributeString("Address", _address);
                    writer.WriteAttributeString("UserName", _userName);
                    writer.WriteAttributeString("Password", _password);
                    writer.WriteAttributeString("BoxType", Enum.GetName(typeof(StbBoxType), _boxType));
                    writer.WriteAttributeString("Timeout", _timeout.ToString());

                    writer.WriteEndElement(); // </settings>
                    writer.WriteEndDocument();
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
            }
        }
Exemplo n.º 20
0
        private static void LoadSettings()
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(ConfigurationFile);

                _address  = doc.DocumentElement.Attributes["Address"].Value;
                _userName = doc.DocumentElement.Attributes["UserName"].Value;
                _password = doc.DocumentElement.Attributes["Password"].Value;
                _boxType  = (StbBoxType)Enum.Parse(typeof(StbBoxType), doc.DocumentElement.Attributes["BoxType"].Value, true);
                _timeout  = int.Parse(doc.DocumentElement.Attributes["Timeout"].Value);
            }
            catch (FileNotFoundException)
            {
                IrssLog.Warn("Configuration file not found, using defaults");

                CreateDefaultSettings();
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);

                CreateDefaultSettings();
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Detect the presence of this device.
        /// </summary>
        public override DetectionResult Detect()
        {
            try
            {
                Guid guid = new Guid();
                Win32.HidD_GetHidGuid(ref guid);

                string devicePath = FindDevice(guid);

                if (devicePath != null)
                {
                    return(DetectionResult.DevicePresent);
                }
            }
            catch (FileNotFoundException)
            {
                //No error if driver is not installed. Handled using default return "DeviceNotFound"
            }
            catch (Exception ex)
            {
                IrssLog.Error("{0,15}: exception {1}", Name, ex.Message);
                return(DetectionResult.DeviceException);
            }

            return(DetectionResult.DeviceNotFound);
        }
Exemplo n.º 22
0
        private void EditMacro()
        {
            if (listViewMacro.SelectedItems.Count != 1)
            {
                return;
            }

            try
            {
                string command  = listViewMacro.SelectedItems[0].Text;
                string fileName = Path.Combine(Tray.FolderMacros, command + Common.FileExtensionMacro);

                if (File.Exists(fileName))
                {
                    MacroEditor macroEditor = new MacroEditor(command);
                    macroEditor.ShowDialog(this);
                }
                else
                {
                    RefreshMacroList();

                    throw new FileNotFoundException("Macro file missing", fileName);
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
                MessageBox.Show(this, ex.Message, "Failed to edit macro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 23
0
        // --------------------------------------------------------------------------------------------------
        #region Form callbacks

        private void buttonTest_Click(object sender, EventArgs e)
        {
            string name = textBoxName.Text.Trim();

            try
            {
                string[] commands = new string[listBoxMacro.Items.Count];
                int      index    = 0;
                for (int idx = 0; idx < listBoxMacro.Items.Count; idx++)
                {
                    commands[index++] = GetCommand(idx);
                }

                string fileName = Path.Combine(FolderMacros, Common.FileExtensionMacro);

                IrssMacro.WriteToFile(fileName, commands);
                this.Enabled = false;
                if (_ProcessCommand != null)
                {
                    _ProcessCommand(Common.CmdPrefixMacro, false);
                }
                File.Delete(fileName);
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
                MessageBox.Show(this, ex.Message, "Test failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.Enabled = true;
        }
Exemplo n.º 24
0
        internal bool Start()
        {
            try
            {
                LoadSettings();

                LoadExternalConfig();

                if (String.IsNullOrEmpty(_serverHost))
                {
                    if (!Configure())
                    {
                        return(false);
                    }
                }

                bool clientStarted = false;

                try
                {
                    IPAddress  serverIP = Network.GetIPFromName(_serverHost);
                    IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort);

                    clientStarted = StartClient(endPoint);
                }
                catch (Exception ex)
                {
                    IrssLog.Error(ex);
                    MessageBox.Show("Failed to start IR Server communications, refer to log file for more details.",
                                    "Media Center Blaster - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    clientStarted = false;
                }

                if (clientStarted)
                {
                    _notifyIcon.Visible = true;

                    _mediaState                  = new MediaState();
                    _mediaState.OnMSASEvent     += new MediaState.MSASEventHandler(OnMSASEvent);
                    _mediaState.TV.MediaChanged += new EventHandler(TV_MediaChanged);

                    _mediaState.Connect();

                    return(true);
                }
                else
                {
                    Configure();
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);

                _mediaState = null;
            }

            return(false);
        }
Exemplo n.º 25
0
        private static IntPtr InternalHookDelegate(int code, int wParam, IntPtr lParam)
        {
            try
            {
                if (code >= 0 && wParam == 256)
                {
                    KeyboardHookStruct khs = new KeyboardHookStruct(lParam);
                    int keyCode            = khs.virtualKey;

                    AppCommands appCommand = KeyCodeToAppCommand((Keys)khs.virtualKey);
                    if (appCommand == AppCommands.None)
                    {
                        if (khs.virtualKey == (int)Keys.LShiftKey || khs.virtualKey == (int)Keys.LControlKey ||
                            khs.virtualKey == (int)Keys.RShiftKey || khs.virtualKey == (int)Keys.RControlKey)
                        {
                            return(CallNextHookEx(_hookHandle, code, wParam, lParam));
                        }

                        if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                        {
                            keyCode |= 0x00100000;
                        }
                        if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                        {
                            keyCode |= 0x01000000;
                        }
                        if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt)
                        {
                            keyCode |= 0x10000000;
                        }
                    }
                    else
                    {
                        keyCode |= (((int)appCommand) << 8);
                    }

                    if (_registered)
                    {
                        byte[] bytes = IrssMessage.EncodeRemoteEventData("Keyboard", String.Format("{0:X8}", keyCode));

                        IrssMessage message = new IrssMessage(MessageType.ForwardRemoteEvent, MessageFlags.Notify, bytes);
                        _client.Send(message);
                    }

                    if (_stealAppCommands && appCommand != AppCommands.None)
                    {
                        return(new IntPtr(1));
                    }
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
            }

            return(CallNextHookEx(_hookHandle, code, wParam, lParam));
        }
Exemplo n.º 26
0
        internal bool Start()
        {
            try
            {
                LoadSettings();

                bool didSetup = false;
                if (String.IsNullOrEmpty(_programFile) || String.IsNullOrEmpty(_serverHost))
                {
                    if (!Configure())
                    {
                        return(false);
                    }

                    didSetup = true;
                }

                bool clientStarted = false;

                try
                {
                    IPAddress  serverIP = Network.GetIPFromName(_serverHost);
                    IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort);

                    clientStarted = StartClient(endPoint);
                }
                catch (Exception ex)
                {
                    IrssLog.Error(ex);
                    MessageBox.Show("Failed to start IR Server communications, refer to log file for more details.",
                                    "Tray Launcher - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    clientStarted = false;
                }

                if (clientStarted)
                {
                    _notifyIcon.Visible = true;

                    if (!didSetup && _launchOnLoad)
                    {
                        Launch();
                    }

                    return(true);
                }
                else
                {
                    Configure();
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
            }

            return(false);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Generate a message (logged if enabled) of level: Error.
        /// </summary>
        /// <param name="str">message to be displayed</param>
        public void LogErr(string str)
        {
            if (_logfile != "")
            {
                IrssLog.Error(str);
            }

            Console.WriteLine("# error: " + str);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Generate a message (logged if enabled) of level: Warn.
        /// </summary>
        /// <param name="str">message to be displayed</param>
        public void LogWarn(string str)
        {
            if (_logfile != "")
            {
                IrssLog.Error(str);
            }

            Console.WriteLine("! " + str);
        }
Exemplo n.º 29
0
        private void Detect()
        {
            IrssLog.Info("Attempting to detect Input Plugins ...");

            CheckBox checkBox;

            for (int row = 1; row < gridPlugins.RowsCount; row++)
            {
                PluginBase plugin = gridPlugins.Rows[row].Tag as PluginBase;

                try
                {
                    if (plugin == null)
                    {
                        throw new InvalidOperationException(String.Format("Invalid grid data, row {0} contains no plugin in tag",
                                                                          row));
                    }

                    PluginBase.DetectionResult detected = plugin.Detect();

                    if (detected == PluginBase.DetectionResult.DevicePresent)
                    {
                        IrssLog.Info("Plugin {0}: detected", plugin.Name);
                    }
                    if (detected == PluginBase.DetectionResult.DeviceIsPlugAndPlay)
                    {
                        IrssLog.Info("Plugin {0}: Plug&Play device detected", plugin.Name);
                    }
                    if (detected == PluginBase.DetectionResult.DeviceException)
                    {
                        IrssLog.Warn("Plugin {0}: exception during Detect()", plugin.Name);
                    }

                    // Receive
                    checkBox = gridPlugins[row, ColReceive] as CheckBox;
                    if (checkBox != null)
                    {
                        checkBox.Checked = (detected == PluginBase.DetectionResult.DevicePresent || detected == PluginBase.DetectionResult.DeviceIsPlugAndPlay ? true : false);
                    }

                    // Transmit
                    checkBox = gridPlugins[row, ColTransmit] as CheckBox;
                    if (checkBox != null)
                    {
                        checkBox.Checked = (detected == PluginBase.DetectionResult.DevicePresent || detected == PluginBase.DetectionResult.DeviceIsPlugAndPlay ? true : false);
                    }
                }
                catch (Exception ex)
                {
                    IrssLog.Error(ex);
                }
            }

            IrssLog.Info("Input Plugins detection completed...");
        }
Exemplo n.º 30
0
 private static void ClickConfiguration(object sender, EventArgs e)
 {
     try
     {
         Process.Start(_configExe);
     }
     catch (Win32Exception ex)
     {
         IrssLog.Error(ex);
     }
 }