Ejemplo 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});
   }
 }
Ejemplo n.º 2
0
 public override void Initialize()
 {
   if (this._IsDisabled)
   {
     Log.Info("xPL_Connector.Initialize(): DRIVER DISABLED!");
   }
   else
   {
     this._lines[0] = string.Empty;
     this._lines[1] = string.Empty;
     Log.Info("xPL_Connector.Initialize(): called");
     this.Listener = new XplListener(this.mVendorID + "-" + this.mDeviceID, 1);
     Log.Info("xPL_Connector.Initialize(): waiting to join xPL network. (Awaiting config = {0})",
              new object[] {this.Listener.AwaitingConfiguration});
     if (this.Listener.AwaitingConfiguration)
     {
       this.Listener.ConfigItems.Add("newconf", "", xplConfigTypes.xReconf);
       this.Listener.ConfigItems.Add("interval", "", xplConfigTypes.xOption);
     }
     this.Listener.XplMessageReceived +=
       new XplListener.XplMessageReceivedEventHandler(this.Listener_XplMessageReceived);
     this.Listener.XplJoinedxPLNetwork +=
       new XplListener.XplJoinedxPLNetworkEventHandler(this.Listener_XplJoinedxPLNetwork);
     this.Listener.Listen();
     int num = 0x7530;
     while (!this.Listener.JoinedxPLNetwork)
     {
       Log.Info("xPL_Connector.Initialize(): waiting to join the xPL network");
       Thread.Sleep(100);
       num -= 100;
       if (num < 0)
       {
         break;
       }
     }
     if (!this.Listener.JoinedxPLNetwork)
     {
       Log.Info("xPL_Connector.Initialize(): Could NOT join the xPL network");
     }
     else
     {
       this._IsConnected = true;
     }
     if (this._IsConnected)
     {
       AdvancedSettings.OnSettingsChanged +=
         new AdvancedSettings.OnSettingsChangedHandler(this.AdvancedSettings_OnSettingsChanged);
       this.Clear();
     }
     this.mInstanceID = this.Listener.InstanceName;
     Log.Info("xPL_Connector.Initialize(): completed");
   }
 }
Ejemplo n.º 3
0
    private void Listener_XplMessageReceived(object sender, XplListener.XplEventArgs e)
    {
      if (e.XplMsg.Schema.msgClass.ToLowerInvariant().Equals("hbeat") && e.XplMsg.Schema.msgType.ToLowerInvariant().Equals("app"))
      {
        if (this.DoDebug)
        {
          Log.Info("xPLConnector_Listener_XplMessageReceived: Received HEARTBEAT");
        }
        this._IsConnected = true;
      }
      else if (e.XplMsg.Schema.msgClass.ToLowerInvariant().Equals("config"))
      {
        if (this.DoDebug)
        {
          Log.Info("xPLConnector_Listener_XplMessageReceived: Received CONFIG message");
        }
      }
      else if ((e.XplMsg.Source.Vendor.ToLowerInvariant().Equals(this.mVendorID.ToLowerInvariant()) &&
                e.XplMsg.Source.Device.ToLowerInvariant().Equals(this.mDeviceID.ToLowerInvariant())) &&
               e.XplMsg.Source.Instance.ToLowerInvariant().Equals(this.mInstanceID.ToLowerInvariant()))
      {
        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.ToLowerInvariant() + "." + e.XplMsg.Schema.msgType.ToLowerInvariant();
        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.ToUpperInvariant()))
                  {
                    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.ToUpperInvariant());
                    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;
                    }
                  }

                  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").ToLowerInvariant().Equals("player"))
                  {
                    this.XPL_SendPlayerDevstate("xpl-stat");
                  }
                  return;

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

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

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

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

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

              case "play":
                {
                  string path = e.XplMsg.GetParam(1, "url").ToLowerInvariant();
                  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").ToLowerInvariant();
                  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").ToLowerInvariant();
                  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").ToLowerInvariant() == "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").ToLowerInvariant();
                  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;
          }
        }
      }
    }