Esempio n. 1
0
        private void XPL_Send_Remote_Confirm_Message(XplListener.XplEventArgs e)
        {
            if (this.DoDebug)
            {
                Log.Info("XPL_Send_Remote_Confirm_Message(): PREPARING REMOTE.CONFIRM MESSAGE!");
            }
            string strMessage = string.Empty;
            string strTarget  = string.Empty;
            string param      = string.Empty;
            string str4       = string.Empty;
            string str5       = string.Empty;

            try
            {
                strTarget = e.XplMsg.GetParam(0, "source");
                param     = e.XplMsg.GetParam(1, "keys");
                str4      = e.XplMsg.GetParam(1, "device");
                str5      = e.XplMsg.GetParam(1, "zone");
                object obj2 = strMessage;
                strMessage = string.Concat(new object[] { obj2, "keys=", param, '\n' });
                if (!str4.Equals(string.Empty))
                {
                    object obj3 = strMessage;
                    strMessage = string.Concat(new object[] { obj3, "device=", str4, '\n' });
                }
                if (!str5.Equals(string.Empty))
                {
                    object obj4 = strMessage;
                    strMessage = string.Concat(new object[] { obj4, "zone=", str5, '\n' });
                }
                if (this.DoDebug)
                {
                    Log.Info("XPL_Send_Remote_Confirm_Message(): SENDING REMOTE.CONFIRM MESSAGE: {0}", new object[] { strMessage });
                }
                this.Listener.SendMessage("xpl-trig", strTarget, "remote.confirm", strMessage);
                if (this.DoDebug)
                {
                    Log.Info("XPL_Send_Remote_Confirm_Message(): SENT REMOTE.CONFIRM MESSAGE!");
                }
            }
            catch
            {
                Log.Info("XPL_Send_Remote_Confirm_Message(): CAUGHT EXCEPTION: {0}, {1}, {2}, {3}!",
                         new object[] { strTarget, param, str5, str4 });
            }
        }
Esempio n. 2
0
        private void xL_XplMessageReceived(object sender, XplListener.XplEventArgs e)
        {
            try
            {
                //maybe it should be ignored
                if ((mFilterApps.Count > 0) &&
                    (mFilterApps.ContainsKey(e.XplMsg.SourceVendor + "." + e.XplMsg.SourceDevice)))
                {
                    string lvls       = (string)mFilterApps[e.XplMsg.SourceVendor + "." + e.XplMsg.SourceDevice];
                    bool   foundKey   = false;
                    bool   foundMatch = false;
                    foreach (XplMsg.KeyValuePair kv in e.XplMsg.KeyValues)
                    {
                        if (lvls.IndexOf(kv.Key + "=") >= 0)
                        {
                            foundKey = true;
                            if (lvls.IndexOf(kv.Key + "=" + kv.Value.ToLower()) >= 0)
                            {
                                foundMatch = true;
                                break;
                            }
                        }
                    }

                    if (foundKey && !foundMatch)
                    {
                        return;
                    }
                }


                string title      = "";
                string txt        = "";
                int    level      = 0;
                int    delay      = mShowSecs;
                string othertxt   = "";
                bool   isOsdBasic = ((e.XplMsg.Type.ToLower() == "osd") && (e.XplMsg.Class.ToLower() == "basic"));

                foreach (XplMsg.KeyValuePair kv in e.XplMsg.KeyValues)
                {
                    switch (kv.Key.ToLower())
                    {
                    case "title":
                        title = kv.Value;
                        break;

                    case "type":
                        switch (kv.Value.ToLower())
                        {
                        case "err": level = 2;
                            break;

                        case "wrn": level = 1;
                            break;

                        case "inf": level = 0;
                            break;

                        default:
                            othertxt += kv.Key + "=" + kv.Value + "\n";
                            level     = 0;
                            break;
                        }
                        break;

                    case "text":
                        txt += kv.Value + "\n";
                        break;

                    case "delay":
                        if (!Int32.TryParse(kv.Value, out delay))
                        {
                            delay = mShowSecs;
                        }
                        break;

                    case "command":
                        if (!isOsdBasic)
                        {
                            othertxt += kv.Key + "=" + kv.Value + "\n";
                        }
                        break;

                    case "row":
                        if (!isOsdBasic)
                        {
                            othertxt += kv.Key + "=" + kv.Value + "\n";
                        }
                        break;

                    case "column":
                        if (!isOsdBasic)
                        {
                            othertxt += kv.Key + "=" + kv.Value + "\n";
                        }
                        break;

                    default:
                        othertxt += kv.Key + "=" + kv.Value + "\n";
                        break;
                    }
                }

                if (title.Length == 0)
                {
                    title = "xPL message (" + e.XplMsg.Class + "." + e.XplMsg.Type + ")";
                }


                if (othertxt.Length > 0)
                {
                    if (txt.Length > 0)
                    {
                        txt += "\n" + othertxt;
                    }
                    else
                    {
                        txt = othertxt;
                    }
                }

                ShowMsg(title, txt, level, delay);
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                eventLog.WriteEntry("Unable to show balloon: " + ex.Message, EventLogEntryType.Error);
            }
        }
Esempio n. 3
0
        private void Listener_XplMessageReceived(object sender, XplListener.XplEventArgs e)
        {
            if (e.XplMsg.Schema.msgClass.ToLower().Equals("hbeat") && e.XplMsg.Schema.msgType.ToLower().Equals("app"))
            {
                if (this.DoDebug)
                {
                    Log.Info("xPLConnector_Listener_XplMessageReceived: Received HEARTBEAT");
                }
                this._IsConnected = true;
            }
            else if (e.XplMsg.Schema.msgClass.ToLower().Equals("config"))
            {
                if (this.DoDebug)
                {
                    Log.Info("xPLConnector_Listener_XplMessageReceived: Received CONFIG message");
                }
            }
            else if ((e.XplMsg.Source.Vendor.ToLower().Equals(this.mVendorID.ToLower()) &&
                      e.XplMsg.Source.Device.ToLower().Equals(this.mDeviceID.ToLower())) &&
                     e.XplMsg.Source.Instance.ToLower().Equals(this.mInstanceID.ToLower()))
            {
                if (this.DoDebug)
                {
                    Log.Info("xPLConnector_Listener_XplMessageReceived: Received ECHO");
                }
            }
            else
            {
                if (this.DoDebug)
                {
                    Log.Info("xPLConnector_Listener_XplMessageReceived: {0} - {1} - {2}",
                             new object[] { e.XplMsg.Source.Vendor, e.XplMsg.Source.Device, e.XplMsg.Content });
                }
                string str   = e.XplMsg.Schema.msgClass.ToLower() + "." + e.XplMsg.Schema.msgType.ToLower();
                string str11 = str;
                if (str11 != null)
                {
                    if (!(str11 == "media.basic"))
                    {
                        if (!(str11 == "media.request"))
                        {
                            if (str11 == "remote.basic")
                            {
                                foreach (string str9 in e.XplMsg.GetParam(1, "keys").Split(new char[] { ',' }))
                                {
                                    if (this.DoDebug)
                                    {
                                        Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic \"{0}\"",
                                                 new object[] { str9 });
                                    }
                                    if (Enum.IsDefined(typeof(GUIWindow.Window), str9.ToUpper()))
                                    {
                                        if (this.DoDebug)
                                        {
                                            Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic window name",
                                                     new object[0]);
                                        }
                                        this.XPL_Send_Remote_Confirm_Message(e);
                                        int num8 = (int)Enum.Parse(typeof(GUIWindow.Window), str9.ToUpper());
                                        if (!GUIWindowManager.ActiveWindow.Equals(num8))
                                        {
                                            GUIWindowManager.SendThreadCallbackAndWait(
                                                new GUIWindowManager.Callback(this.ThreadMessageCallback), 1, num8, null);
                                            return;
                                        }
                                        break;
                                    }
                                    if (Enum.IsDefined(typeof(Keys), str9))
                                    {
                                        if (this.DoDebug)
                                        {
                                            Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic key name",
                                                     new object[0]);
                                        }
                                        this.XPL_Send_Remote_Confirm_Message(e);
                                        Key    key     = new Key(0, (int)Enum.Parse(typeof(Keys), str9));
                                        Action action3 = new Action();
                                        if (ActionTranslator.GetAction(GUIWindowManager.ActiveWindow, key, ref action3))
                                        {
                                            GUIWindowManager.OnAction(action3);
                                            return;
                                        }
                                    }
                                    foreach (string str10 in Enum.GetNames(typeof(RemoteButton)))
                                    {
                                        if (str10.ToLower().Equals(str9.ToLower()) || str9.ToLower().Equals("remote_" + str10.ToLower()))
                                        {
                                            if (this.DoDebug)
                                            {
                                                Log.Info(
                                                    "xPL_Connector.Listener_XplMessageReceived(): Received remote.basic remote key name \"{0}\"",
                                                    new object[] { str9 });
                                            }
                                            this.XPL_Send_Remote_Confirm_Message(e);
                                            if (!this.rHandler.MapAction((int)Enum.Parse(typeof(RemoteButton), str10)) && this.DoDebug)
                                            {
                                                Log.Info(
                                                    "xPL_Connector.Listener_XplMessageReceived(): COULD NOT FIRE REMOTE ACTION (isLoaded = {0})",
                                                    new object[] { this.rHandler.IsLoaded });
                                            }
                                            break;
                                        }
                                    }
                                    int result = 0;
                                    int.TryParse(str9, out result);
                                    if (result != 0)
                                    {
                                        if (this.DoDebug)
                                        {
                                            Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic raw keycode",
                                                     new object[0]);
                                        }
                                        this.XPL_Send_Remote_Confirm_Message(e);
                                        Key    key2    = new Key(0, result);
                                        Action action4 = new Action();
                                        if (ActionTranslator.GetAction(GUIWindowManager.ActiveWindow, key2, ref action4))
                                        {
                                            GUIWindowManager.OnAction(action4);
                                            return;
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            switch (e.XplMsg.GetParam(1, "request"))
                            {
                            case "devinfo":
                                this.XPL_SendDevInfo("xpl-stat");
                                return;

                            case "devstate":
                                if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player"))
                                {
                                    this.XPL_SendPlayerDevstate("xpl-stat");
                                }
                                return;

                            case "mpinfo":
                                if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player"))
                                {
                                    this.XPL_SendPlayerMediaPlayerInfo("xpl-stat");
                                    this.XPL_SendPlayerMediaPlayerInputInfo("xpl-stat");
                                }
                                return;

                            case "mptrnspt":
                                if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player"))
                                {
                                    this.XPL_SendPlayerTransportState("xpl-stat");
                                }
                                return;

                            case "mpmedia":
                                if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player"))
                                {
                                    this.XPL_SendMediaInfo("xpl-stat");
                                }
                                return;

                            case "mpconfig":
                                if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player"))
                                {
                                    this.XPL_SendPlayerMediaPlayerConfig("xpl-stat");
                                }
                                return;

                            case "mpqueue":
                                return;
                            }
                        }
                    }
                    else
                    {
                        int num;
                        switch (e.XplMsg.GetParam(1, "command").ToLower())
                        {
                        case "record":
                        case "position":
                        case "chapter":
                        case "power":
                        case "reboot":
                        case "input":
                        case "options":
                            return;

                        case "play":
                        {
                            string path = e.XplMsg.GetParam(1, "url").ToLower();
                            if (!(path.Equals(string.Empty) & g_Player.Paused))
                            {
                                if (path.Equals(g_Player.currentFileName) & g_Player.Paused)
                                {
                                    g_Player.Pause();
                                    if (this.DoDebug)
                                    {
                                        Log.Info(
                                            "xPLConnector_Listener_XplMessageReceived: Received media.basic play file command (unpause)",
                                            new object[0]);
                                        return;
                                    }
                                    return;
                                }
                                if (File.Exists(path) && !g_Player.currentFileName.Equals(path))
                                {
                                    GUIMessage message = new GUIMessage();
                                    message.Message = GUIMessage.MessageType.GUI_MSG_PLAY_FILE;
                                    message.Label   = path;
                                    GUIWindowManager.SendThreadMessage(message);
                                    if (!this.DoDebug)
                                    {
                                        return;
                                    }
                                    Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic play file command",
                                             new object[0]);
                                }
                                return;
                            }
                            g_Player.Pause();
                            if (this.DoDebug)
                            {
                                Log.Info(
                                    "xPLConnector_Listener_XplMessageReceived: Received media.basic play file command (unpause)",
                                    new object[0]);
                            }
                            return;
                        }

                        case "stop":
                        {
                            GUIMessage message2 = new GUIMessage();
                            message2.Message = GUIMessage.MessageType.GUI_MSG_STOP_FILE;
                            GUIWindowManager.SendThreadMessage(message2);
                            if (this.DoDebug)
                            {
                                Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic stop command",
                                         new object[0]);
                            }
                            return;
                        }

                        case "pause":
                            if (this.DoDebug)
                            {
                                Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic pause command",
                                         new object[0]);
                            }
                            if (!g_Player.Paused)
                            {
                                g_Player.Pause();
                            }
                            return;

                        case "forward":
                        {
                            string str4 = e.XplMsg.GetParam(1, "speed").ToLower();
                            num = 0;
                            if (!str4.Equals(string.Empty))
                            {
                                num = int.Parse(str4.Replace("x", ""));
                                break;
                            }
                            num = g_Player.Speed * 2;
                            break;
                        }

                        case "rewind":
                        {
                            string str5 = e.XplMsg.GetParam(1, "speed").ToLower();
                            int    num2 = 0;
                            if (!str5.Equals(string.Empty))
                            {
                                num2 = int.Parse(str5.Replace("x", ""));
                            }
                            else
                            {
                                num2 = Math.Abs(g_Player.Speed) * 2;
                            }
                            if (num2 > 0x20)
                            {
                                num2 = 0x20;
                            }
                            if (this.DoDebug)
                            {
                                Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic rewind ({0}x) command",
                                         new object[] { num2 });
                            }
                            g_Player.Speed = -num2;
                            return;
                        }

                        case "next":
                            Action action;
                            if (!g_Player.IsDVD)
                            {
                                action = new Action(Action.ActionType.ACTION_NEXT_ITEM, 0f, 0f);
                            }
                            else
                            {
                                action = new Action(Action.ActionType.ACTION_NEXT_CHAPTER, 0f, 0f);
                            }
                            GUIGraphicsContext.OnAction(action);
                            if (this.DoDebug)
                            {
                                Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic next command",
                                         new object[0]);
                            }
                            return;

                        case "back":
                            Action action2;
                            if (!g_Player.IsDVD)
                            {
                                action2 = new Action(Action.ActionType.ACTION_PREV_ITEM, 0f, 0f);
                            }
                            else
                            {
                                action2 = new Action(Action.ActionType.ACTION_PREV_CHAPTER, 0f, 0f);
                            }
                            GUIGraphicsContext.OnAction(action2);
                            if (this.DoDebug)
                            {
                                Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic back command",
                                         new object[0]);
                            }
                            return;

                        case "mute":
                            if (!(e.XplMsg.GetParam(1, "state").ToLower() == "on"))
                            {
                                if (this.DoDebug)
                                {
                                    Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic mute off command",
                                             new object[0]);
                                }
                                VolumeHandler.Instance.IsMuted = false;
                                return;
                            }
                            if (this.DoDebug)
                            {
                                Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic mute on command",
                                         new object[0]);
                            }
                            VolumeHandler.Instance.IsMuted = true;
                            return;

                        case "volume":
                        {
                            string str13;
                            string s = e.XplMsg.GetParam(1, "level").ToLower();
                            if (((str13 = s.Substring(0, 1)) == null) || (!(str13 == "+") && !(str13 == "-")))
                            {
                                int num7 = int.Parse(s);
                                VolumeHandler.Instance.Volume = (VolumeHandler.Instance.Maximum / 100) * num7;
                                if (this.DoDebug)
                                {
                                    Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic volume command",
                                             new object[0]);
                                }
                                return;
                            }
                            int volume = VolumeHandler.Instance.Volume;
                            int num5   = int.Parse(s) * 0x28f;
                            int num6   = volume + num5;
                            if (num6 < 0)
                            {
                                num6 = 0;
                            }
                            if (num6 > 0xffdc)
                            {
                                num6 = 0xffdc;
                            }
                            VolumeHandler.Instance.Volume = num6;
                            if (this.DoDebug)
                            {
                                Log.Info(
                                    "xPLConnector_Listener_XplMessageReceived: Received media.basic volume {0} command = orig = {1}, new = {2}, delta = {3}",
                                    new object[] { s, volume, num6, num5 });
                            }
                            return;
                        }

                        default:
                            return;
                        }
                        if (num > 0x20)
                        {
                            num = 0x20;
                        }
                        if (this.DoDebug)
                        {
                            Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic play forward ({0}x) command",
                                     new object[] { num });
                        }
                        g_Player.Speed = num;
                    }
                }
            }
        }